Skip to content

Commit

Permalink
Manually revert "Remove LM flag from vshader too" (#16718)
Browse files Browse the repository at this point in the history
Reverts #16718

Though maybe we can keep this one? Let's see.
  • Loading branch information
hrydgard committed May 9, 2023
1 parent 38c4c48 commit 0babac5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ static u32 sceMpegAvcInitYCbCr(u32 mpeg, int mode, int width, int height, u32 yc
return -1;
}

ERROR_LOG(ME, "UNIMPL sceMpegAvcInitYCbCr(%08x, %i, %i, %i, %08x)", mpeg, mode, width, height, ycbcr_addr);
WARN_LOG_ONCE(sceMpegAvcInitYCbCr, ME, "UNIMPL sceMpegAvcInitYCbCr(%08x, %i, %i, %i, %08x)", mpeg, mode, width, height, ycbcr_addr);
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions GPU/Common/ShaderId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void ComputeVertexShaderID(VShaderID *id_out, VertexDecoder *vertexDecoder, bool
!isModeThrough && gstate_c.submitType == SubmitType::DRAW; // neither hw nor sw spline/bezier. See #11692

VShaderID id;
id.SetBit(VS_BIT_LMODE, lmode);
id.SetBit(VS_BIT_IS_THROUGH, isModeThrough);
id.SetBit(VS_BIT_HAS_COLOR, vtypeHasColor);
id.SetBit(VS_BIT_VERTEX_RANGE_CULLING, vertexRangeCulling);
Expand Down Expand Up @@ -130,7 +131,6 @@ void ComputeVertexShaderID(VShaderID *id_out, VertexDecoder *vertexDecoder, bool
// doShadeMapping is stored as UVGenMode, and light type doesn't matter for shade mapping.
id.SetBit(VS_BIT_LIGHTING_ENABLE);
if (gstate_c.Use(GPU_USE_LIGHT_UBERSHADER)) {
lmode = false; // handled dynamically.
id.SetBit(VS_BIT_LIGHT_UBERSHADER);
} else {
id.SetBits(VS_BIT_MATERIAL_UPDATE, 3, gstate.getMaterialUpdate());
Expand Down Expand Up @@ -162,7 +162,6 @@ void ComputeVertexShaderID(VShaderID *id_out, VertexDecoder *vertexDecoder, bool
}
}

id.SetBit(VS_BIT_LMODE, lmode);
id.SetBit(VS_BIT_FLATSHADE, doFlatShading);

// These two bits cannot be combined, otherwise havoc occurs. We get reports that indicate this happened somehow... "ERROR: 0:14: 'u_proj' : undeclared identifier"
Expand Down
2 changes: 0 additions & 2 deletions GPU/Common/ShaderUniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ uint32_t PackLightControlBits() {

// Material update is 3 bits.
lightControl |= gstate.getMaterialUpdate() << 20;
// LMODE is 1 bit.
lightControl |= gstate.isUsingSecondaryColor() << 23;
return lightControl;
}

Expand Down
23 changes: 6 additions & 17 deletions GPU/Common/VertexShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,24 +1158,13 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
WRITE(p, " %sv_color0 = lightSum0;\n", compat.vsOutPrefix);
WRITE(p, " %sv_color1 = splat3(0.0);\n", compat.vsOutPrefix);
} else {
if (lightUberShader) {
p.C(" bool lmode = (u_lightControl & (0x1u << 0x17u)) != 0x0u;\n");
p.C(" if (lmode) {\n");
p.F(" %sv_color0 = lightSum0;\n", compat.vsOutPrefix);
p.F(" %sv_color1 = clamp(lightSum1, 0.0, 1.0);\n", compat.vsOutPrefix);
p.C(" } else {\n");
p.F(" %sv_color0 = clamp(lightSum0 + vec4(lightSum1, 0.0), 0.0, 1.0);\n", compat.vsOutPrefix);
p.F(" %sv_color1 = splat3(0.0);\n", compat.vsOutPrefix);
p.C(" }");
if (lmode) {
WRITE(p, " %sv_color0 = lightSum0;\n", compat.vsOutPrefix);
// v_color1 only exists when lmode = 1.
WRITE(p, " %sv_color1 = clamp(lightSum1, 0.0, 1.0);\n", compat.vsOutPrefix);
} else {
if (lmode) {
WRITE(p, " %sv_color0 = lightSum0;\n", compat.vsOutPrefix);
// v_color1 only exists when lmode = 1.
WRITE(p, " %sv_color1 = clamp(lightSum1, 0.0, 1.0);\n", compat.vsOutPrefix);
} else {
WRITE(p, " %sv_color0 = clamp(lightSum0 + vec4(lightSum1, 0.0), 0.0, 1.0);\n", compat.vsOutPrefix);
WRITE(p, " %sv_color1 = splat3(0.0);\n", compat.vsOutPrefix);
}
WRITE(p, " %sv_color0 = clamp(lightSum0 + vec4(lightSum1, 0.0), 0.0, 1.0);\n", compat.vsOutPrefix);
WRITE(p, " %sv_color1 = splat3(0.0);\n", compat.vsOutPrefix);
}
}
} else {
Expand Down
6 changes: 2 additions & 4 deletions GPU/GPUCommonHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const CommonCommandTableEntry commonCommandTable[] = {
{ GE_CMD_LIGHTTYPE3, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_LIGHT3 },
{ GE_CMD_MATERIALUPDATE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE },

// These change vertex shaders (in non uber shader mode) so need flushing.
{ GE_CMD_LIGHTMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE },
// These change all shaders so need flushing.
{ GE_CMD_LIGHTMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE },

{ GE_CMD_TEXFILTER, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS },
{ GE_CMD_TEXWRAP, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE },
Expand Down Expand Up @@ -460,11 +460,9 @@ void GPUCommonHW::UpdateCmdInfo() {
if (gstate_c.Use(GPU_USE_LIGHT_UBERSHADER)) {
cmdInfo_[GE_CMD_MATERIALUPDATE].RemoveDirty(DIRTY_VERTEXSHADER_STATE);
cmdInfo_[GE_CMD_MATERIALUPDATE].AddDirty(DIRTY_LIGHT_CONTROL);
cmdInfo_[GE_CMD_LIGHTMODE].AddDirty(DIRTY_LIGHT_CONTROL);
} else {
cmdInfo_[GE_CMD_MATERIALUPDATE].RemoveDirty(DIRTY_LIGHT_CONTROL);
cmdInfo_[GE_CMD_MATERIALUPDATE].AddDirty(DIRTY_VERTEXSHADER_STATE);
cmdInfo_[GE_CMD_LIGHTMODE].RemoveDirty(DIRTY_LIGHT_CONTROL);
}
}

Expand Down

0 comments on commit 0babac5

Please sign in to comment.