mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
implement calculate texture lod
This commit is contained in:
parent
7eb8508db4
commit
927c52e268
@ -2690,16 +2690,16 @@ static void _emitTEXGetCompTexLodCode(LatteDecompilerShaderContext* shaderContex
|
|||||||
{
|
{
|
||||||
// 3 coordinates
|
// 3 coordinates
|
||||||
if(shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT)
|
if(shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT)
|
||||||
src->addFmt("float4(textureQueryLod(tex{}, {}.{}{}{}),0.0,0.0)", texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]], resultElemTable[texInstruction->textureFetch.srcSel[2]]);
|
src->addFmt("float4(textureCalculateLod(tex{}, samplr{}, {}.{}{}{}),0.0,0.0)", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]], resultElemTable[texInstruction->textureFetch.srcSel[2]]);
|
||||||
else
|
else
|
||||||
src->addFmt("float4(textureQueryLod(tex{}, bitCast<float>({}.{}{}{})),0.0,0.0)", texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]], resultElemTable[texInstruction->textureFetch.srcSel[2]]);
|
src->addFmt("float4(textureCalculateLod(tex{}, samplr{}, bitCast<float>({}.{}{}{})),0.0,0.0)", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]], resultElemTable[texInstruction->textureFetch.srcSel[2]]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT)
|
if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT)
|
||||||
src->addFmt("float4(textureQueryLod(tex{}, {}.{}{}),0.0,0.0)", texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]]);
|
src->addFmt("float4(textureCalculateLod(tex{}, samplr{}, {}.{}{}),0.0,0.0)", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]]);
|
||||||
else
|
else
|
||||||
src->addFmt("float4(textureQueryLod(tex{}, bitCast<float>({}.{}{})),0.0,0.0)", texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]]);
|
src->addFmt("float4(textureCalculateLod(tex{}, samplr{}, bitCast<float>({}.{}{})),0.0,0.0)", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex, _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[texInstruction->textureFetch.srcSel[0]], resultElemTable[texInstruction->textureFetch.srcSel[1]]);
|
||||||
debugBreakpoint();
|
debugBreakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3734,7 +3734,6 @@ void LatteDecompiler_emitHelperFunctions(LatteDecompilerShaderContext* shaderCon
|
|||||||
|
|
||||||
// Sample compare emulate
|
// Sample compare emulate
|
||||||
// TODO: only add when needed
|
// TODO: only add when needed
|
||||||
|
|
||||||
// TODO: lod_options overload
|
// TODO: lod_options overload
|
||||||
// TODO: when the sampler has linear min mag filter, use gather and filter manually
|
// TODO: when the sampler has linear min mag filter, use gather and filter manually
|
||||||
// TODO: offset?
|
// TODO: offset?
|
||||||
@ -3745,6 +3744,15 @@ void LatteDecompiler_emitHelperFunctions(LatteDecompilerShaderContext* shaderCon
|
|||||||
"}\r\n"
|
"}\r\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Texture calculate lod
|
||||||
|
// TODO: only add when needed
|
||||||
|
fCStr_shaderSource->add(""
|
||||||
|
"template<typename TextureT, typename CoordT>\r\n"
|
||||||
|
"float2 textureCalculateLod(TextureT tex, sampler samplr, CoordT coord) {\r\n"
|
||||||
|
"float lod = tex.calculate_unclamped_lod(samplr, coord);\r\n"
|
||||||
|
"return float2(floor(lod), fract(lod));\r\n"
|
||||||
|
"}\r\n");
|
||||||
|
|
||||||
// clamp
|
// clamp
|
||||||
fCStr_shaderSource->add(""
|
fCStr_shaderSource->add(""
|
||||||
"int clampFI32(int v)\r\n"
|
"int clampFI32(int v)\r\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user