1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fixes in CombinerProgramBuilder

This commit is contained in:
Sergey Lipskiy 2017-01-11 19:23:44 +07:00
parent fa3e7a0584
commit a39bdd2ad3

View File

@ -1612,28 +1612,30 @@ public:
/*---------------ShaderPartsEnd-------------*/ /*---------------ShaderPartsEnd-------------*/
u32 g_cycleType = G_CYC_1CYCLE;
static static
bool needClampColor() { bool needClampColor() {
return gDP.otherMode.cycleType <= G_CYC_2CYCLE; return g_cycleType <= G_CYC_2CYCLE;
} }
static static
bool combinedColorC(const gDPCombine & _combine) { bool combinedColorC(const gDPCombine & _combine) {
if (gDP.otherMode.cycleType != G_CYC_2CYCLE) if (g_cycleType != G_CYC_2CYCLE)
return false; return false;
return _combine.mRGB1 == G_CCMUX_COMBINED; return _combine.mRGB1 == G_CCMUX_COMBINED;
} }
static static
bool combinedAlphaC(const gDPCombine & _combine) { bool combinedAlphaC(const gDPCombine & _combine) {
if (gDP.otherMode.cycleType != G_CYC_2CYCLE) if (g_cycleType != G_CYC_2CYCLE)
return false; return false;
return _combine.mA1 == G_ACMUX_COMBINED; return _combine.mA1 == G_ACMUX_COMBINED;
} }
static static
bool combinedColorABD(const gDPCombine & _combine) { bool combinedColorABD(const gDPCombine & _combine) {
if (gDP.otherMode.cycleType != G_CYC_2CYCLE) if (g_cycleType != G_CYC_2CYCLE)
return false; return false;
if (_combine.aRGB1 == G_CCMUX_COMBINED) if (_combine.aRGB1 == G_CCMUX_COMBINED)
return true; return true;
@ -1644,7 +1646,7 @@ bool combinedColorABD(const gDPCombine & _combine) {
static static
bool combinedAlphaABD(const gDPCombine & _combine) { bool combinedAlphaABD(const gDPCombine & _combine) {
if (gDP.otherMode.cycleType != G_CYC_2CYCLE) if (g_cycleType != G_CYC_2CYCLE)
return false; return false;
if (_combine.aA1 == G_ACMUX_COMBINED) if (_combine.aA1 == G_ACMUX_COMBINED)
return true; return true;
@ -1660,7 +1662,7 @@ int CombinerProgramBuilder::compileCombiner(const CombinerKey & _key, Combiner &
std::stringstream ssShader; std::stringstream ssShader;
if (gDP.otherMode.cycleType != G_CYC_2CYCLE) { if (g_cycleType != G_CYC_2CYCLE) {
_correctFirstStageParams(_alpha.stage[0]); _correctFirstStageParams(_alpha.stage[0]);
_correctFirstStageParams(_color.stage[0]); _correctFirstStageParams(_color.stage[0]);
} }
@ -1682,7 +1684,7 @@ int CombinerProgramBuilder::compileCombiner(const CombinerKey & _key, Combiner &
else if (combinedColorABD(combine)) else if (combinedColorABD(combine))
m_signExtendColorABD->write(ssShader); m_signExtendColorABD->write(ssShader);
if (gDP.otherMode.cycleType == G_CYC_2CYCLE) { if (g_cycleType == G_CYC_2CYCLE) {
ssShader << " combined_color = vec4(color1, alpha1);" << std::endl; ssShader << " combined_color = vec4(color1, alpha1);" << std::endl;
if (_alpha.numStages == 2) { if (_alpha.numStages == 2) {
@ -1716,12 +1718,13 @@ int CombinerProgramBuilder::compileCombiner(const CombinerKey & _key, Combiner &
else else
ssShader << " lowp vec4 clampedColor = clamp(cmbRes, 0.0, 1.0);" << std::endl; ssShader << " lowp vec4 clampedColor = clamp(cmbRes, 0.0, 1.0);" << std::endl;
m_callDither->write(ssShader); if (g_cycleType <= G_CYC_2CYCLE)
m_callDither->write(ssShader);
if (config.generalEmulation.enableLegacyBlending == 0) { if (config.generalEmulation.enableLegacyBlending == 0) {
if (gDP.otherMode.cycleType <= G_CYC_2CYCLE) if (g_cycleType <= G_CYC_2CYCLE)
m_blender1->write(ssShader); m_blender1->write(ssShader);
if (gDP.otherMode.cycleType == G_CYC_2CYCLE) if (g_cycleType == G_CYC_2CYCLE)
m_blender2->write(ssShader); m_blender2->write(ssShader);
ssShader << " fragColor = clampedColor;" << std::endl; ssShader << " fragColor = clampedColor;" << std::endl;
@ -1739,6 +1742,8 @@ graphics::CombinerProgram * CombinerProgramBuilder::buildCombinerProgram(Combine
Combiner & _alpha, Combiner & _alpha,
const CombinerKey & _key) const CombinerKey & _key)
{ {
g_cycleType = _key.getCycleType();
std::string strCombiner; std::string strCombiner;
CombinerInputs combinerInputs(compileCombiner(_key, _color, _alpha, strCombiner)); CombinerInputs combinerInputs(compileCombiner(_key, _color, _alpha, strCombiner));
@ -1758,11 +1763,12 @@ graphics::CombinerProgram * CombinerProgramBuilder::buildCombinerProgram(Combine
if (bUseTextures) { if (bUseTextures) {
m_fragmentGlobalVariablesTex->write(ssShader); m_fragmentGlobalVariablesTex->write(ssShader);
if (gDP.otherMode.cycleType == G_CYC_2CYCLE && config.generalEmulation.enableLegacyBlending == 0) if (g_cycleType == G_CYC_2CYCLE && config.generalEmulation.enableLegacyBlending == 0)
ssShader << "uniform lowp ivec4 uBlendMux2;" << std::endl << "uniform lowp int uForceBlendCycle2;" << std::endl; ssShader << "uniform lowp ivec4 uBlendMux2;" << std::endl << "uniform lowp int uForceBlendCycle2;" << std::endl;
if (g_cycleType <= G_CYC_2CYCLE)
m_fragmentHeaderDither->write(ssShader);
m_fragmentHeaderNoise->write(ssShader); m_fragmentHeaderNoise->write(ssShader);
m_fragmentHeaderDither->write(ssShader);
m_fragmentHeaderWriteDepth->write(ssShader); m_fragmentHeaderWriteDepth->write(ssShader);
m_fragmentHeaderDepthCompare->write(ssShader); m_fragmentHeaderDepthCompare->write(ssShader);
m_fragmentHeaderReadMSTex->write(ssShader); m_fragmentHeaderReadMSTex->write(ssShader);
@ -1773,11 +1779,12 @@ graphics::CombinerProgram * CombinerProgramBuilder::buildCombinerProgram(Combine
} else { } else {
m_fragmentGlobalVariablesNotex->write(ssShader); m_fragmentGlobalVariablesNotex->write(ssShader);
if (gDP.otherMode.cycleType == G_CYC_2CYCLE && config.generalEmulation.enableLegacyBlending == 0) if (g_cycleType == G_CYC_2CYCLE && config.generalEmulation.enableLegacyBlending == 0)
ssShader << "uniform lowp ivec4 uBlendMux2;" << std::endl << "uniform lowp int uForceBlendCycle2;" << std::endl; ssShader << "uniform lowp ivec4 uBlendMux2;" << std::endl << "uniform lowp int uForceBlendCycle2;" << std::endl;
if (g_cycleType <= G_CYC_2CYCLE)
m_fragmentHeaderDither->write(ssShader);
m_fragmentHeaderNoise->write(ssShader); m_fragmentHeaderNoise->write(ssShader);
m_fragmentHeaderDither->write(ssShader);
m_fragmentHeaderWriteDepth->write(ssShader); m_fragmentHeaderWriteDepth->write(ssShader);
m_fragmentHeaderDepthCompare->write(ssShader); m_fragmentHeaderDepthCompare->write(ssShader);
} }
@ -1786,12 +1793,13 @@ graphics::CombinerProgram * CombinerProgramBuilder::buildCombinerProgram(Combine
m_fragmentHeaderCalcLight->write(ssShader); m_fragmentHeaderCalcLight->write(ssShader);
/* Write body */ /* Write body */
if (gDP.otherMode.cycleType == G_CYC_2CYCLE) if (g_cycleType == G_CYC_2CYCLE)
m_fragmentMain2Cycle->write(ssShader); m_fragmentMain2Cycle->write(ssShader);
else else
m_fragmentMain->write(ssShader); m_fragmentMain->write(ssShader);
m_fragmentBlendMux->write(ssShader); if (g_cycleType <= G_CYC_2CYCLE)
m_fragmentBlendMux->write(ssShader);
if (bUseLod) { if (bUseLod) {
m_fragmentReadTexMipmap->write(ssShader); m_fragmentReadTexMipmap->write(ssShader);
@ -1830,7 +1838,8 @@ graphics::CombinerProgram * CombinerProgramBuilder::buildCombinerProgram(Combine
m_shaderNoise->write(ssShader); m_shaderNoise->write(ssShader);
m_shaderDither->write(ssShader); if (g_cycleType <= G_CYC_2CYCLE)
m_shaderDither->write(ssShader);
m_shaderWriteDepth->write(ssShader); m_shaderWriteDepth->write(ssShader);