mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 07:45:33 +01:00
TextureCache: Renaming some variables
OGL: Fix a possible bug at texture dumping OGL: Add a TODO about a possible bug
This commit is contained in:
parent
04a7e33f0b
commit
c5008fe9de
@ -266,7 +266,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (((entry->isRenderTarget || entry->isDynamic) && hash_value == entry->hash && address == entry->addr)
|
if (((entry->isRenderTarget || entry->isDynamic) && hash_value == entry->hash && address == entry->addr)
|
||||||
|| ((address == entry->addr) && (hash_value == entry->hash) && full_format == entry->format && entry->mipLevels == maxlevel))
|
|| ((address == entry->addr) && (hash_value == entry->hash) && full_format == entry->format && entry->num_mipmaps == maxlevel))
|
||||||
{
|
{
|
||||||
entry->isDynamic = false;
|
entry->isDynamic = false;
|
||||||
goto return_entry;
|
goto return_entry;
|
||||||
@ -279,8 +279,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
|||||||
texture_is_dynamic = (entry->isRenderTarget || entry->isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
|
texture_is_dynamic = (entry->isRenderTarget || entry->isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
|
||||||
|
|
||||||
if (!entry->isRenderTarget &&
|
if (!entry->isRenderTarget &&
|
||||||
((!entry->isDynamic && width == entry->realW && height == entry->realH && full_format == entry->format && entry->mipLevels == maxlevel)
|
((!entry->isDynamic && width == entry->native_width && height == entry->native_height && full_format == entry->format && entry->num_mipmaps == maxlevel)
|
||||||
|| (entry->isDynamic && entry->realW == width && entry->realH == height)))
|
|| (entry->isDynamic && entry->native_width == width && entry->native_height == height)))
|
||||||
{
|
{
|
||||||
// reuse the texture
|
// reuse the texture
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
|||||||
// Sometimes, we can get around recreating a texture if only the number of mip levels gets changes
|
// Sometimes, we can get around recreating a texture if only the number of mip levels gets 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
|
// 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
|
||||||
// Thus, we don't update this member for every Load, but just whenever the texture gets recreated
|
// Thus, we don't update this member for every Load, but just whenever the texture gets recreated
|
||||||
entry->mipLevels = maxlevel;
|
entry->num_mipmaps = maxlevel;
|
||||||
|
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
||||||
}
|
}
|
||||||
@ -341,11 +341,11 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
|||||||
entry->format = full_format;
|
entry->format = full_format;
|
||||||
entry->size_in_bytes = texture_size;
|
entry->size_in_bytes = texture_size;
|
||||||
|
|
||||||
entry->virtualW = width;
|
entry->native_width = nativeW;
|
||||||
entry->virtualH = height;
|
entry->native_height = nativeH;
|
||||||
|
|
||||||
entry->realW = nativeW;
|
entry->virtual_width = width;
|
||||||
entry->realH = nativeH;
|
entry->virtual_height = height;
|
||||||
|
|
||||||
entry->isRenderTarget = false;
|
entry->isRenderTarget = false;
|
||||||
entry->isNonPow2 = false;
|
entry->isNonPow2 = false;
|
||||||
@ -633,8 +633,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
|
|||||||
TCacheEntryBase *entry = textures[dstAddr];
|
TCacheEntryBase *entry = textures[dstAddr];
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
if ((entry->isRenderTarget && entry->virtualW == scaled_tex_w && entry->virtualH == scaled_tex_h)
|
if ((entry->isRenderTarget && entry->virtual_width == scaled_tex_w && entry->virtual_height == scaled_tex_h)
|
||||||
|| (entry->isDynamic && entry->realW == tex_w && entry->realH == tex_h))
|
|| (entry->isDynamic && entry->native_width == tex_w && entry->native_height == tex_h))
|
||||||
{
|
{
|
||||||
texture_is_dynamic = entry->isDynamic;
|
texture_is_dynamic = entry->isDynamic;
|
||||||
}
|
}
|
||||||
@ -660,14 +660,14 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
|
|||||||
entry->addr = dstAddr;
|
entry->addr = dstAddr;
|
||||||
entry->hash = 0;
|
entry->hash = 0;
|
||||||
|
|
||||||
entry->realW = tex_w;
|
entry->native_width = tex_w;
|
||||||
entry->realH = tex_h;
|
entry->native_height = tex_h;
|
||||||
|
|
||||||
entry->virtualW = scaled_tex_w;
|
entry->virtual_width = scaled_tex_w;
|
||||||
entry->virtualH = scaled_tex_h;
|
entry->virtual_height = scaled_tex_h;
|
||||||
|
|
||||||
entry->format = dstFormat;
|
entry->format = dstFormat;
|
||||||
entry->mipLevels = 0;
|
entry->num_mipmaps = 0;
|
||||||
|
|
||||||
entry->isRenderTarget = true;
|
entry->isRenderTarget = true;
|
||||||
entry->isNonPow2 = true;
|
entry->isNonPow2 = true;
|
||||||
|
@ -16,29 +16,31 @@ class TextureCache
|
|||||||
public:
|
public:
|
||||||
struct TCacheEntryBase
|
struct TCacheEntryBase
|
||||||
{
|
{
|
||||||
// TODO: organize
|
// common members
|
||||||
u32 addr;
|
u32 addr;
|
||||||
u32 size_in_bytes;
|
u32 size_in_bytes;
|
||||||
u64 hash;
|
u64 hash;
|
||||||
//u32 paletteHash;
|
//u32 pal_hash;
|
||||||
u32 oldpixel;
|
|
||||||
u32 format;
|
u32 format;
|
||||||
|
|
||||||
int frameCount;
|
|
||||||
|
|
||||||
unsigned int realW, realH; // Texture dimensions from the GameCube's point of view
|
//bool is_preloaded;
|
||||||
unsigned int virtualW, virtualH; // Texture dimensions from OUR point of view
|
|
||||||
// Real and virtual dimensions are usually the same, but may be
|
|
||||||
// different if e.g. we use high-res textures. Then, realW,realH will
|
|
||||||
// be the dimensions of the original GameCube texture and
|
|
||||||
// virtualW,virtualH will be the dimensions of the high-res texture.
|
|
||||||
|
|
||||||
unsigned int mipLevels;
|
unsigned int num_mipmaps;
|
||||||
|
unsigned int native_width, native_height; // Texture dimensions from the GameCube's point of view
|
||||||
|
unsigned int virtual_width, virtual_height; // Texture dimensions from OUR point of view - for hires textures or scaled EFB copies
|
||||||
|
|
||||||
|
|
||||||
|
// EFB copies
|
||||||
bool isRenderTarget; // copied from EFB
|
bool isRenderTarget; // copied from EFB
|
||||||
bool isDynamic; // Used for hybrid EFB copies to enable checks for CPU modifications
|
bool isDynamic; // Used for hybrid EFB copies to enable checks for CPU modifications
|
||||||
|
|
||||||
|
// deprecated members
|
||||||
|
u32 oldpixel;
|
||||||
|
int frameCount;
|
||||||
bool isNonPow2; // doesn't seem to be used anywhere
|
bool isNonPow2; // doesn't seem to be used anywhere
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TCacheEntryBase()
|
//TCacheEntryBase()
|
||||||
//{
|
//{
|
||||||
// // TODO: remove these
|
// // TODO: remove these
|
||||||
|
@ -107,7 +107,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||||||
g_renderer->ResetAPIState();
|
g_renderer->ResetAPIState();
|
||||||
|
|
||||||
// stretch picture with increased internal resolution
|
// stretch picture with increased internal resolution
|
||||||
const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)virtualW, (float)virtualH);
|
const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)virtual_width, (float)virtual_height);
|
||||||
D3D::context->RSSetViewports(1, &vp);
|
D3D::context->RSSetViewports(1, &vp);
|
||||||
|
|
||||||
// set transformation
|
// set transformation
|
||||||
|
@ -233,7 +233,7 @@ void VertexManager::vFlush()
|
|||||||
if (tentry)
|
if (tentry)
|
||||||
{
|
{
|
||||||
// 0s are probably for no manual wrapping needed.
|
// 0s are probably for no manual wrapping needed.
|
||||||
PixelShaderManager::SetTexDims(i, tentry->realW, tentry->realH, 0, 0);
|
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ERROR_LOG(VIDEO, "error loading texture");
|
ERROR_LOG(VIDEO, "error loading texture");
|
||||||
|
@ -90,15 +90,15 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||||||
// Stretch picture with increased internal resolution
|
// Stretch picture with increased internal resolution
|
||||||
vp.X = 0;
|
vp.X = 0;
|
||||||
vp.Y = 0;
|
vp.Y = 0;
|
||||||
vp.Width = virtualW;
|
vp.Width = virtual_width;
|
||||||
vp.Height = virtualH;
|
vp.Height = virtual_height;
|
||||||
vp.MinZ = 0.0f;
|
vp.MinZ = 0.0f;
|
||||||
vp.MaxZ = 1.0f;
|
vp.MaxZ = 1.0f;
|
||||||
D3D::dev->SetViewport(&vp);
|
D3D::dev->SetViewport(&vp);
|
||||||
RECT destrect;
|
RECT destrect;
|
||||||
destrect.bottom = virtualH;
|
destrect.bottom = virtual_height;
|
||||||
destrect.left = 0;
|
destrect.left = 0;
|
||||||
destrect.right = virtualW;
|
destrect.right = virtual_width;
|
||||||
destrect.top = 0;
|
destrect.top = 0;
|
||||||
|
|
||||||
PixelShaderManager::SetColorMatrix(colmat); // set transformation
|
PixelShaderManager::SetColorMatrix(colmat); // set transformation
|
||||||
@ -133,7 +133,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||||||
|
|
||||||
D3D::drawShadedTexQuad(read_texture, &sourcerect,
|
D3D::drawShadedTexQuad(read_texture, &sourcerect,
|
||||||
Renderer::GetTargetWidth(), Renderer::GetTargetHeight(),
|
Renderer::GetTargetWidth(), Renderer::GetTargetHeight(),
|
||||||
virtualW, virtualH,
|
virtual_width, virtual_height,
|
||||||
// TODO: why is D3DFMT_D24X8 singled out here? why not D3DFMT_D24X4S4/D24S8/D24FS8/D32/D16/D15S1 too, or none of them?
|
// TODO: why is D3DFMT_D24X8 singled out here? why not D3DFMT_D24X4S4/D24S8/D24FS8/D32/D16/D15S1 too, or none of them?
|
||||||
PixelShaderCache::GetDepthMatrixProgram(SSAAMode, (srcFormat == PIXELFMT_Z24) && bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8),
|
PixelShaderCache::GetDepthMatrixProgram(SSAAMode, (srcFormat == PIXELFMT_Z24) && bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8),
|
||||||
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
|
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
|
||||||
|
@ -142,7 +142,7 @@ void VertexManager::vFlush()
|
|||||||
if (tentry)
|
if (tentry)
|
||||||
{
|
{
|
||||||
// 0s are probably for no manual wrapping needed.
|
// 0s are probably for no manual wrapping needed.
|
||||||
PixelShaderManager::SetTexDims(i, tentry->realW, tentry->realH, 0, 0);
|
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ERROR_LOG(VIDEO, "error loading texture");
|
ERROR_LOG(VIDEO, "error loading texture");
|
||||||
|
@ -124,7 +124,7 @@ bool TextureCache::TCacheEntry::Save(const char filename[])
|
|||||||
std::string tga_filename(filename);
|
std::string tga_filename(filename);
|
||||||
tga_filename.replace(tga_filename.size() - 3, 3, "tga");
|
tga_filename.replace(tga_filename.size() - 3, 3, "tga");
|
||||||
|
|
||||||
return SaveTexture(tga_filename.c_str(), GL_TEXTURE_2D, texture, realW, realH);
|
return SaveTexture(tga_filename.c_str(), GL_TEXTURE_2D, texture, virtual_width, virtual_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width,
|
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width,
|
||||||
@ -294,7 +294,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||||||
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
||||||
|
|
||||||
glViewport(0, 0, virtualW, virtualH);
|
glViewport(0, 0, virtual_width, virtual_height);
|
||||||
|
|
||||||
PixelShaderCache::SetCurrentShader((srcFormat == PIXELFMT_Z24) ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram());
|
PixelShaderCache::SetCurrentShader((srcFormat == PIXELFMT_Z24) ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram());
|
||||||
PixelShaderManager::SetColorMatrix(colmat); // set transformation
|
PixelShaderManager::SetColorMatrix(colmat); // set transformation
|
||||||
@ -337,7 +337,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
|
|||||||
{
|
{
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
SaveTexture(StringFromFormat("%sefb_frame_%i.tga", File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
|
SaveTexture(StringFromFormat("%sefb_frame_%i.tga", File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
|
||||||
count++).c_str(), GL_TEXTURE_2D, texture, realW, realH);
|
count++).c_str(), GL_TEXTURE_2D, texture, virtual_width, virtual_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void VertexManager::vFlush()
|
|||||||
if (tentry)
|
if (tentry)
|
||||||
{
|
{
|
||||||
// 0s are probably for no manual wrapping needed.
|
// 0s are probably for no manual wrapping needed.
|
||||||
PixelShaderManager::SetTexDims(i, tentry->realW, tentry->realH, 0, 0);
|
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
|
||||||
|
|
||||||
if (g_ActiveConfig.iLog & CONF_SAVETEXTURES)
|
if (g_ActiveConfig.iLog & CONF_SAVETEXTURES)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user