Skip to content

Commit 3f52f3a

Browse files
committed
fix: cubemap sampling
1 parent 0c73ff8 commit 3f52f3a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitMSL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,11 +2357,10 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
23572357
{
23582358
debugBreakpoint();
23592359
}
2360-
src->add("float4(");
23612360
src->addFmt("redcCUBEReverse({},", _getTexGPRAccess(shaderContext, texInstruction->srcGpr, LATTE_DECOMPILER_DTYPE_FLOAT, texInstruction->textureFetch.srcSel[0], texInstruction->textureFetch.srcSel[1], -1, -1, tempBuffer0));
23622361
_emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 2, LATTE_DECOMPILER_DTYPE_SIGNED_INT);
23632362
src->addFmt(")");
2364-
src->addFmt(",cubeMapArrayIndex{})", texInstruction->textureFetch.textureIndex); // cubemap index
2363+
src->addFmt(", uint(cubeMapArrayIndex{})", texInstruction->textureFetch.textureIndex); // cubemap index
23652364
}
23662365
else if (texDim == Latte::E_DIM::DIM_1D)
23672366
{
@@ -2411,7 +2410,7 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
24112410
src->addFmt("redcCUBEReverse({},", _getTexGPRAccess(shaderContext, texInstruction->srcGpr, LATTE_DECOMPILER_DTYPE_FLOAT, texInstruction->textureFetch.srcSel[0], texInstruction->textureFetch.srcSel[1], -1, -1, tempBuffer0));
24122411
_emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 2, LATTE_DECOMPILER_DTYPE_SIGNED_INT);
24132412
src->add(")");
2414-
src->addFmt(", cubeMapArrayIndex{}", texInstruction->textureFetch.textureIndex); // cubemap index
2413+
src->addFmt(", uint(cubeMapArrayIndex{})", texInstruction->textureFetch.textureIndex); // cubemap index
24152414
}
24162415
else if( texDim == Latte::E_DIM::DIM_1D )
24172416
{

src/Cafe/HW/Latte/Renderer/Metal/LatteTextureMtl.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "Cafe/HW/Latte/Renderer/Metal/LatteTextureViewMtl.h"
33
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
44
#include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h"
5+
#include "Common/precompiled.h"
56

67
LatteTextureMtl::LatteTextureMtl(class MetalRenderer* mtlRenderer, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle,
78
Latte::E_HWTILEMODE tileMode, bool isDepth)
@@ -42,13 +43,9 @@ LatteTextureMtl::LatteTextureMtl(class MetalRenderer* mtlRenderer, Latte::E_DIM
4243
textureType = MTL::TextureType3D;
4344
break;
4445
case Latte::E_DIM::DIM_CUBEMAP:
45-
if (effectiveBaseDepth % 6 != 0)
46-
debug_printf("cubemaps must have an array length multiple of 6, length: %u\n", effectiveBaseDepth);
46+
cemu_assert_debug(effectiveBaseDepth % 6 == 0 && "cubemaps must have an array length multiple of 6");
4747

48-
if (effectiveBaseDepth <= 6)
49-
textureType = MTL::TextureTypeCube;
50-
else
51-
textureType = MTL::TextureTypeCubeArray;
48+
textureType = MTL::TextureTypeCubeArray;
5249
break;
5350
default:
5451
cemu_assert_unimplemented();

src/Cafe/HW/Latte/Renderer/Metal/LatteTextureViewMtl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ MTL::Texture* LatteTextureViewMtl::CreateSwizzledView(uint32 gpuSamplerSwizzle)
9191
textureType = MTL::TextureType3D;
9292
break;
9393
case Latte::E_DIM::DIM_CUBEMAP:
94-
textureType = MTL::TextureTypeCube; // TODO: check this
94+
cemu_assert_debug(this->numSlice % 6 == 0 && "cubemaps must have an array length multiple of 6");
95+
96+
textureType = MTL::TextureTypeCubeArray;
9597
break;
9698
default:
9799
cemu_assert_unimplemented();

0 commit comments

Comments
 (0)