From 8bdbe37c91b9c642ab2a3f4cbe265a9455870366 Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 17 May 2014 00:24:18 +0200 Subject: [PATCH 1/3] TexCache: Wipe pal hash --- Source/Core/VideoCommon/TextureCacheBase.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index e3eb6a00fa..d84d90fc61 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -33,7 +33,6 @@ public: u32 addr; u32 size_in_bytes; u64 hash; - //u32 pal_hash; u32 format; enum TexCacheEntryType type; @@ -64,10 +63,9 @@ public: virtual_height = _virtual_height; } - void SetHashes(u64 _hash/*, u32 _pal_hash*/) + void SetHashes(u64 _hash) { hash = _hash; - //pal_hash = _pal_hash; } From 614d058db14f4a282e27a8c21402f45cfaa5be88 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 19 May 2014 22:35:53 +0200 Subject: [PATCH 2/3] TexCache: don't load tex level 0 on creation This reverts an optimization which isn't worth imo. Every texture uploads have to alloc vram and a staging buffer, so there is no need to do both in the same call. --- Source/Core/VideoBackends/D3D/TextureCache.cpp | 11 +---------- Source/Core/VideoBackends/OGL/TextureCache.cpp | 5 +---- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 +++----- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index af1267c1de..1ae2c38d77 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -87,24 +87,18 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, { D3D11_USAGE usage = D3D11_USAGE_DEFAULT; D3D11_CPU_ACCESS_FLAG cpu_access = (D3D11_CPU_ACCESS_FLAG)0; - D3D11_SUBRESOURCE_DATA srdata, *data = nullptr; if (tex_levels == 1) { usage = D3D11_USAGE_DYNAMIC; cpu_access = D3D11_CPU_ACCESS_WRITE; - - srdata.pSysMem = TextureCache::temp; - srdata.SysMemPitch = 4 * expanded_width; - - data = &srdata; } const D3D11_TEXTURE2D_DESC texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8G8B8A8_UNORM, width, height, 1, tex_levels, D3D11_BIND_SHADER_RESOURCE, usage, cpu_access); ID3D11Texture2D *pTexture; - const HRESULT hr = D3D::device->CreateTexture2D(&texdesc, data, &pTexture); + const HRESULT hr = D3D::device->CreateTexture2D(&texdesc, nullptr, &pTexture); CHECK(SUCCEEDED(hr), "Create texture of the TextureCache"); TCacheEntry* const entry = new TCacheEntry(new D3DTexture2D(pTexture, D3D11_BIND_SHADER_RESOURCE)); @@ -116,9 +110,6 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, SAFE_RELEASE(pTexture); - if (tex_levels != 1) - entry->Load(width, height, expanded_width, 0); - return entry; } diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 4199604cd0..0cea0d556a 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -175,10 +175,7 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, glBindTexture(GL_TEXTURE_2D_ARRAY, entry.texture); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, tex_levels - 1); - entry.Load(width, height, expanded_width, 0); - - // This isn't needed as Load() also reset the stage in the end - //TextureCache::SetStage(); + TextureCache::SetStage(); return &entry; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 143a26cbd1..a539f561a3 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -481,16 +481,14 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage, GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true); } - else - { - // load texture (CreateTexture also loads level 0) - entry->Load(width, height, expandedWidth, 0); - } entry->SetGeneralParameters(address, texture_size, full_format, entry->num_mipmaps, entry->num_layers); entry->SetDimensions(nativeW, nativeH, width, height); entry->hash = tex_hash; + // load texture + entry->Load(width, height, expandedWidth, 0); + if (entry->IsEfbCopy() && !g_ActiveConfig.bCopyEFBToTexture) entry->type = TCET_EC_DYNAMIC; else From 38f42da55aa49d438fda123ccd7c7126e23714f4 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 5 Nov 2014 22:09:39 +0100 Subject: [PATCH 3/3] TexCache: remove expanded_width This variable isn't use any more. --- Source/Core/VideoBackends/D3D/TextureCache.cpp | 3 +-- Source/Core/VideoBackends/D3D/TextureCache.h | 2 +- Source/Core/VideoBackends/OGL/TextureCache.cpp | 3 +-- Source/Core/VideoBackends/OGL/TextureCache.h | 2 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 2 +- Source/Core/VideoCommon/TextureCacheBase.h | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index 1ae2c38d77..5664fb5be1 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -81,8 +81,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage); } -TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, - unsigned int height, unsigned int expanded_width, +TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels, PC_TexFormat pcfmt) { D3D11_USAGE usage = D3D11_USAGE_DEFAULT; diff --git a/Source/Core/VideoBackends/D3D/TextureCache.h b/Source/Core/VideoBackends/D3D/TextureCache.h index 79cd8145a8..3845165ad5 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.h +++ b/Source/Core/VideoBackends/D3D/TextureCache.h @@ -39,7 +39,7 @@ private: }; TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) override; + unsigned int tex_levels, PC_TexFormat pcfmt) override; TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override; u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;}; diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 0cea0d556a..cf044b6362 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -108,8 +108,7 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l return SaveTexture(filename, GL_TEXTURE_2D_ARRAY, texture, virtual_width, virtual_height, level); } -TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, - unsigned int height, unsigned int expanded_width, +TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels, PC_TexFormat pcfmt) { int gl_format = 0, diff --git a/Source/Core/VideoBackends/OGL/TextureCache.h b/Source/Core/VideoBackends/OGL/TextureCache.h index f8d181e8e1..c2001d4bca 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.h +++ b/Source/Core/VideoBackends/OGL/TextureCache.h @@ -54,7 +54,7 @@ private: ~TextureCache(); TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) override; + unsigned int tex_levels, PC_TexFormat pcfmt) override; TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index a539f561a3..ce9b724b8f 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -466,7 +466,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage, // create the entry/texture if (nullptr == entry) { - textures[texID] = entry = g_texture_cache->CreateTexture(width, height, expandedWidth, texLevels, pcfmt); + textures[texID] = entry = g_texture_cache->CreateTexture(width, height, texLevels, pcfmt); // Sometimes, we can get around recreating a texture if only the number of mip levels changes // e.g. if our texture cache entry got too many mipmap levels we can limit the number of used levels by setting the appropriate render states diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index d84d90fc61..0b8cf48918 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -98,7 +98,7 @@ public: static bool Find(u32 start_address, u64 hash); virtual TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) = 0; + unsigned int tex_levels, PC_TexFormat pcfmt) = 0; virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) = 0; virtual void CompileShaders() = 0; // currently only implemented by OGL