Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PixelShaderGen: fix OOB indirect texcoord indices #8296

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Expand Up @@ -794,16 +794,14 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host
unsigned int texcoord = uid_data->GetTevindirefCoord(i);
unsigned int texmap = uid_data->GetTevindirefMap(i);

if (texcoord < uid_data->genMode_numtexgens)
{
out.SetConstantsUsed(C_INDTEXSCALE + i / 2, C_INDTEXSCALE + i / 2);
out.Write("\ttempcoord = fixpoint_uv%d >> " I_INDTEXSCALE "[%d].%s;\n", texcoord, i / 2,
(i & 1) ? "zw" : "xy");
}
else
{
out.Write("\ttempcoord = int2(0, 0);\n");
}
// TODO: are out-of-range values set to zero or clamped?
// TODO: same thing probably with direct texcoord indices?
if (texcoord >= uid_data->genMode_numtexgens)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What shall happen if uid_data->genMode_numtexgens == 0 ?

texcoord = 0;

out.SetConstantsUsed(C_INDTEXSCALE + i / 2, C_INDTEXSCALE + i / 2);
out.Write("\ttempcoord = fixpoint_uv%d >> " I_INDTEXSCALE "[%d].%s;\n", texcoord, i / 2,
(i & 1) ? "zw" : "xy");

out.Write("\tint3 iindtex%d = ", i);
SampleTexture(out, "float2(tempcoord)", "abg", texmap, stereo, ApiType);
Expand Down