Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Don't load level 0 twice for 1-level textures in DX11." and f…
…ix it properly.

All backend TextureCaches now load level 0 in CreateTexture.

This reverts commit 294cb16.
  • Loading branch information
jordan-woyak committed Feb 20, 2013
1 parent 294cb16 commit 6e6d8af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
15 changes: 10 additions & 5 deletions Source/Core/VideoCommon/Src/TextureCacheBase.cpp
Expand Up @@ -481,15 +481,20 @@ 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->SetDimensions(nativeW, nativeH, width, height);
entry->hash = tex_hash;
if (entry->IsEfbCopy() && !g_ActiveConfig.bCopyEFBToTexture) entry->type = TCET_EC_DYNAMIC;
else entry->type = TCET_NORMAL;

// load texture
entry->Load(width, height, expandedWidth, 0);

if (entry->IsEfbCopy() && !g_ActiveConfig.bCopyEFBToTexture)
entry->type = TCET_EC_DYNAMIC;
else
entry->type = TCET_NORMAL;

if (g_ActiveConfig.bDumpTextures && !using_custom_texture)
DumpTexture(entry, 0);
Expand Down
9 changes: 7 additions & 2 deletions Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp
Expand Up @@ -70,19 +70,24 @@ 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 = NULL;

// This is just an optimization apparently?
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, NULL, &pTexture);
const HRESULT hr = D3D::device->CreateTexture2D(&texdesc, data, &pTexture);
CHECK(SUCCEEDED(hr), "Create texture of the TextureCache");

TCacheEntry* const entry = new TCacheEntry(new D3DTexture2D(pTexture, D3D11_BIND_SHADER_RESOURCE));
Expand Down
2 changes: 2 additions & 0 deletions Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp
Expand Up @@ -226,6 +226,8 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, u
TCacheEntry* entry = new TCacheEntry(D3D::CreateTexture2D(temp, width, height, expanded_width, d3d_fmt, swap_r_b, tex_levels));
entry->swap_r_b = swap_r_b;
entry->d3d_fmt = d3d_fmt;

entry->Load(width, height, expanded_width, 0);

return entry;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
Expand Up @@ -178,6 +178,8 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width,
entry.pcfmt = pcfmt;

entry.bHaveMipMaps = tex_levels != 1;

entry.Load(width, height, expanded_width, 0);

return &entry;
}
Expand Down

0 comments on commit 6e6d8af

Please sign in to comment.