mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 22:41:18 +12:00
Latte: Small refactor and clean up for texture size code
This commit is contained in:
parent
0993658c82
commit
dd7cb74cd2
13 changed files with 64 additions and 110 deletions
|
@ -206,14 +206,10 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u
|
|||
|
||||
bool isDepthSampler = shaderContext->textureUsesDepthCompare[textureIndex];
|
||||
// look for already existing texture
|
||||
LatteTextureView* textureView;
|
||||
if (isDepthSampler == false)
|
||||
textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim);
|
||||
else
|
||||
textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, true);
|
||||
if (textureView == nullptr)
|
||||
LatteTextureView* textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, isDepthSampler);
|
||||
if (!textureView)
|
||||
{
|
||||
// create new mapping
|
||||
// view not found, create a new mapping which will also create a new texture if necessary
|
||||
textureView = LatteTexture_CreateMapping(physAddr, physMipAddr, width, height, depth, pitch, tileMode, swizzle, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, dim, isDepthSampler);
|
||||
if (textureView == nullptr)
|
||||
continue;
|
||||
|
@ -273,9 +269,7 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u
|
|||
// check for changes
|
||||
if (LatteTC_HasTextureChanged(textureView->baseTexture) || swizzleChanged)
|
||||
{
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
debug_printf("Reload texture 0x%08x res %dx%d memRange %08x-%08x SwizzleChange: %s\n", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height, textureView->baseTexture->texDataPtrLow, textureView->baseTexture->texDataPtrHigh, swizzleChanged ? "yes" : "no");
|
||||
#endif
|
||||
// update swizzle / changed mip address
|
||||
if (swizzleChanged)
|
||||
{
|
||||
|
@ -338,44 +332,6 @@ void LatteTexture_updateTextures()
|
|||
LatteTexture_updateTexturesForStage(geometryShader, LATTE_CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS);
|
||||
}
|
||||
|
||||
// returns the width, height, depth of the texture
|
||||
void LatteTexture_getSize(LatteTexture* texture, sint32* width, sint32* height, sint32* depth, sint32 mipLevel)
|
||||
{
|
||||
*width = texture->width;
|
||||
*height = texture->height;
|
||||
if (depth != NULL)
|
||||
*depth = texture->depth;
|
||||
// handle mip level
|
||||
*width = std::max(1, *width >> mipLevel);
|
||||
*height = std::max(1, *height >> mipLevel);
|
||||
if(texture->Is3DTexture() && depth)
|
||||
*depth = std::max(1, *depth >> mipLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the internally used width/height/depth of the texture
|
||||
* Usually this is the width/height/depth specified by the game,
|
||||
* unless the texture resolution was redefined via graphic pack texture rules
|
||||
*/
|
||||
void LatteTexture_getEffectiveSize(LatteTexture* texture, sint32* effectiveWidth, sint32* effectiveHeight, sint32* effectiveDepth, sint32 mipLevel)
|
||||
{
|
||||
*effectiveWidth = texture->width;
|
||||
*effectiveHeight = texture->height;
|
||||
if( effectiveDepth != NULL )
|
||||
*effectiveDepth = texture->depth;
|
||||
if( texture->overwriteInfo.hasResolutionOverwrite )
|
||||
{
|
||||
*effectiveWidth = texture->overwriteInfo.width;
|
||||
*effectiveHeight = texture->overwriteInfo.height;
|
||||
if( effectiveDepth != NULL )
|
||||
*effectiveDepth = texture->overwriteInfo.depth;
|
||||
}
|
||||
// handle mipLevel
|
||||
// todo: Mip-mapped 3D textures decrease in depth also?
|
||||
*effectiveWidth = std::max(1, *effectiveWidth >> mipLevel);
|
||||
*effectiveHeight = std::max(1, *effectiveHeight >> mipLevel);
|
||||
}
|
||||
|
||||
sint32 LatteTexture_getEffectiveWidth(LatteTexture* texture)
|
||||
{
|
||||
if (texture->overwriteInfo.hasResolutionOverwrite)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue