mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
fix: texture swizzle
This commit is contained in:
parent
0a7f30c6a4
commit
5fc45407db
@ -2334,7 +2334,7 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
|
||||
// shadow sampler
|
||||
if (texDim == Latte::E_DIM::DIM_2D_ARRAY)
|
||||
{
|
||||
// 3 coords + compare value (as float4)
|
||||
// 3 coords + compare value
|
||||
src->add("float3(");
|
||||
_emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 0, LATTE_DECOMPILER_DTYPE_FLOAT);
|
||||
src->add(", ");
|
||||
@ -2442,7 +2442,8 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
|
||||
}
|
||||
else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
|
||||
{
|
||||
src->add(",0.0");
|
||||
// TODO: correct?
|
||||
src->add(", level(0.0)");
|
||||
}
|
||||
}
|
||||
// gradient parameters
|
||||
|
@ -27,12 +27,12 @@ MTL::Texture* LatteTextureViewMtl::GetSwizzledView(uint32 gpuSamplerSwizzle)
|
||||
// Mask out
|
||||
gpuSamplerSwizzle &= 0x0FFF0000;
|
||||
|
||||
// RGBA swizzle == no swizzle
|
||||
if (gpuSamplerSwizzle == RGBA_SWIZZLE)
|
||||
{
|
||||
return m_baseTexture->GetTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// First, try to find a view in the cache
|
||||
|
||||
// Fast cache
|
||||
@ -63,7 +63,6 @@ MTL::Texture* LatteTextureViewMtl::GetSwizzledView(uint32 gpuSamplerSwizzle)
|
||||
it->second = texture;
|
||||
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
MTL::Texture* LatteTextureViewMtl::CreateSwizzledView(uint32 gpuSamplerSwizzle)
|
||||
@ -117,10 +116,14 @@ MTL::Texture* LatteTextureViewMtl::CreateSwizzledView(uint32 gpuSamplerSwizzle)
|
||||
layerCount = this->numSlice;
|
||||
}
|
||||
|
||||
// TODO: swizzle
|
||||
MTL::TextureSwizzleChannels swizzle;
|
||||
swizzle.red = GetMtlTextureSwizzle(compSelR);
|
||||
swizzle.green = GetMtlTextureSwizzle(compSelG);
|
||||
swizzle.blue = GetMtlTextureSwizzle(compSelB);
|
||||
swizzle.alpha = GetMtlTextureSwizzle(compSelA);
|
||||
|
||||
auto formatInfo = GetMtlPixelFormatInfo(format, m_baseTexture->IsDepth());
|
||||
MTL::Texture* texture = m_baseTexture->GetTexture()->newTextureView(formatInfo.pixelFormat, textureType, NS::Range::Make(baseLevel, levelCount), NS::Range::Make(baseLayer, layerCount));
|
||||
MTL::Texture* texture = m_baseTexture->GetTexture()->newTextureView(formatInfo.pixelFormat, textureType, NS::Range::Make(baseLevel, levelCount), NS::Range::Make(baseLayer, layerCount), swizzle);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define RGBA_SWIZZLE 0x06880000
|
||||
#define INVALID_SWIZZLE 0xFFFFFFFF
|
||||
|
||||
// TODO: test the swizzle
|
||||
class LatteTextureViewMtl : public LatteTextureView
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user