mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-02 05:54:18 +01:00
fix: support buffer data & fix: depth
This commit is contained in:
parent
f01130022a
commit
0cb83d4668
@ -615,7 +615,8 @@ LatteDecompilerShader* LatteShader_CreateShaderFromDecompilerOutput(LatteDecompi
|
|||||||
LatteDecompilerShader* shader = decompilerOutput.shader;
|
LatteDecompilerShader* shader = decompilerOutput.shader;
|
||||||
shader->baseHash = baseHash;
|
shader->baseHash = baseHash;
|
||||||
// copy resource mapping
|
// copy resource mapping
|
||||||
if(g_renderer->GetType() == RendererAPI::Vulkan)
|
// HACK
|
||||||
|
if (g_renderer->GetType() != RendererAPI::OpenGL)
|
||||||
shader->resourceMapping = decompilerOutput.resourceMappingVK;
|
shader->resourceMapping = decompilerOutput.resourceMappingVK;
|
||||||
else
|
else
|
||||||
shader->resourceMapping = decompilerOutput.resourceMappingGL;
|
shader->resourceMapping = decompilerOutput.resourceMappingGL;
|
||||||
@ -626,7 +627,8 @@ LatteDecompilerShader* LatteShader_CreateShaderFromDecompilerOutput(LatteDecompi
|
|||||||
shader->hasStreamoutBufferWrite = decompilerOutput.streamoutBufferWriteMask.any();
|
shader->hasStreamoutBufferWrite = decompilerOutput.streamoutBufferWriteMask.any();
|
||||||
// copy uniform offsets
|
// copy uniform offsets
|
||||||
// for OpenGL these are retrieved in _prepareSeparableUniforms()
|
// for OpenGL these are retrieved in _prepareSeparableUniforms()
|
||||||
if (g_renderer->GetType() == RendererAPI::Vulkan)
|
// HACK
|
||||||
|
if (g_renderer->GetType() != RendererAPI::OpenGL)
|
||||||
{
|
{
|
||||||
shader->uniform.loc_remapped = decompilerOutput.uniformOffsetsVK.offset_remapped;
|
shader->uniform.loc_remapped = decompilerOutput.uniformOffsetsVK.offset_remapped;
|
||||||
shader->uniform.loc_uniformRegister = decompilerOutput.uniformOffsetsVK.offset_uniformRegister;
|
shader->uniform.loc_uniformRegister = decompilerOutput.uniformOffsetsVK.offset_uniformRegister;
|
||||||
|
@ -1531,7 +1531,7 @@ static void _emitALUOP2InstructionCode(LatteDecompilerShaderContext* shaderConte
|
|||||||
debugBreakpoint();
|
debugBreakpoint();
|
||||||
_emitOperandInputCode(shaderContext, aluInstruction, 1, LATTE_DECOMPILER_DTYPE_SIGNED_INT);
|
_emitOperandInputCode(shaderContext, aluInstruction, 1, LATTE_DECOMPILER_DTYPE_SIGNED_INT);
|
||||||
src->add(")");
|
src->add(")");
|
||||||
src->add(") discard;");
|
src->add(") discard_fragment();");
|
||||||
src->add(_CRLF);
|
src->add(_CRLF);
|
||||||
}
|
}
|
||||||
else if( aluInstruction->opcode == ALU_OP2_INST_KILLGT ||
|
else if( aluInstruction->opcode == ALU_OP2_INST_KILLGT ||
|
||||||
@ -1551,7 +1551,7 @@ static void _emitALUOP2InstructionCode(LatteDecompilerShaderContext* shaderConte
|
|||||||
debugBreakpoint();
|
debugBreakpoint();
|
||||||
_emitOperandInputCode(shaderContext, aluInstruction, 1, LATTE_DECOMPILER_DTYPE_FLOAT);
|
_emitOperandInputCode(shaderContext, aluInstruction, 1, LATTE_DECOMPILER_DTYPE_FLOAT);
|
||||||
src->add(")");
|
src->add(")");
|
||||||
src->add(") discard;");
|
src->add(") discard_fragment();");
|
||||||
src->add(_CRLF);
|
src->add(_CRLF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3136,7 +3136,7 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
|||||||
if( pixelColorOutputIndex == 0 && alphaTestEnable && alphaTestFunc == Latte::E_COMPAREFUNC::NEVER )
|
if( pixelColorOutputIndex == 0 && alphaTestEnable && alphaTestFunc == Latte::E_COMPAREFUNC::NEVER )
|
||||||
{
|
{
|
||||||
// never pass alpha test
|
// never pass alpha test
|
||||||
src->add("discard;" _CRLF);
|
src->add("discard_fragment();" _CRLF);
|
||||||
}
|
}
|
||||||
else if( pixelColorOutputIndex == 0 && alphaTestEnable && alphaTestFunc != Latte::E_COMPAREFUNC::ALWAYS)
|
else if( pixelColorOutputIndex == 0 && alphaTestEnable && alphaTestFunc != Latte::E_COMPAREFUNC::ALWAYS)
|
||||||
{
|
{
|
||||||
@ -3166,7 +3166,7 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
src->add(" supportBuffer.alphaTestRef");
|
src->add(" supportBuffer.alphaTestRef");
|
||||||
src->add(") == false) discard;" _CRLF);
|
src->add(") == false) discard_fragment();" _CRLF);
|
||||||
}
|
}
|
||||||
// pixel color output
|
// pixel color output
|
||||||
src->addFmt("out.passPixelColor{} = ", pixelColorOutputIndex);
|
src->addFmt("out.passPixelColor{} = ", pixelColorOutputIndex);
|
||||||
@ -4067,14 +4067,21 @@ void LatteDecompiler_emitMSLShader(LatteDecompilerShaderContext* shaderContext,
|
|||||||
}
|
}
|
||||||
for(auto& cfInstruction : shaderContext->cfInstructions)
|
for(auto& cfInstruction : shaderContext->cfInstructions)
|
||||||
LatteDecompiler_emitClauseCodeMSL(shaderContext, &cfInstruction, false);
|
LatteDecompiler_emitClauseCodeMSL(shaderContext, &cfInstruction, false);
|
||||||
if( shader->shaderType == LatteConst::ShaderType::Geometry )
|
//if(shader->shaderType == LatteConst::ShaderType::Geometry)
|
||||||
src->add("EndPrimitive();" _CRLF);
|
// src->add("EndPrimitive();" _CRLF);
|
||||||
// vertex shader should write renderstate point size at the end if required but not modified by shader
|
// vertex shader should write renderstate point size at the end if required but not modified by shader
|
||||||
if (shaderContext->analyzer.outputPointSize && shaderContext->analyzer.writesPointSize == false)
|
if (shaderContext->analyzer.outputPointSize && shaderContext->analyzer.writesPointSize == false)
|
||||||
{
|
{
|
||||||
if (shader->shaderType == LatteConst::ShaderType::Vertex && shaderContext->options->usesGeometryShader == false)
|
if (shader->shaderType == LatteConst::ShaderType::Vertex && shaderContext->options->usesGeometryShader == false)
|
||||||
src->add("out.pointSize = supportBuffer.pointSize;" _CRLF);
|
src->add("out.pointSize = supportBuffer.pointSize;" _CRLF);
|
||||||
}
|
}
|
||||||
|
// HACK: this should be handled outside of the shader, because clipping currently wouldn't work
|
||||||
|
if (shader->shaderType == LatteConst::ShaderType::Vertex)
|
||||||
|
{
|
||||||
|
// Convert depth from the range of [-1, 1] to [0, 1]
|
||||||
|
src->add("out.position /= out.position.w;" _CRLF);
|
||||||
|
src->add("out.position.z = out.position.z * 0.5 + 0.5;" _CRLF);
|
||||||
|
}
|
||||||
// return
|
// return
|
||||||
src->add("return out;" _CRLF);
|
src->add("return out;" _CRLF);
|
||||||
// end of shader main
|
// end of shader main
|
||||||
|
Loading…
Reference in New Issue
Block a user