diff --git a/src/r_compiler/fixedfunction/drawskycodegen.cpp b/src/r_compiler/fixedfunction/drawskycodegen.cpp index f2ba148fd..f96d9fc1d 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.cpp +++ b/src/r_compiler/fixedfunction/drawskycodegen.cpp @@ -34,7 +34,8 @@ void DrawSkyCodegen::Generate(DrawSkyVariant variant, bool fourColumns, SSAValue iscale[2] = args[0][18].load(true); iscale[3] = args[0][19].load(true); textureheight0 = args[0][20].load(true); - textureheight1 = args[0][21].load(true); + SSAInt textureheight1 = args[0][21].load(true); + maxtextureheight1 = textureheight1 - 1; top_color = SSAVec4i::unpack(args[0][22].load(true)); bottom_color = SSAVec4i::unpack(args[0][23].load(true)); @@ -105,7 +106,7 @@ SSAVec4i DrawSkyCodegen::Sample(SSAInt frac, int index, DrawSkyVariant variant) } else { - SSAInt sample_index2 = SSAInt::MIN(sample_index, textureheight1); + SSAInt sample_index2 = SSAInt::MIN(sample_index, maxtextureheight1); SSAVec4i color0 = source0[index][sample_index * 4].load_vec4ub(false); SSAVec4i color1 = source1[index][sample_index2 * 4].load_vec4ub(false); return blend_alpha_blend(color0, color1); diff --git a/src/r_compiler/fixedfunction/drawskycodegen.h b/src/r_compiler/fixedfunction/drawskycodegen.h index 2b90b2a9d..a02f8dc2b 100644 --- a/src/r_compiler/fixedfunction/drawskycodegen.h +++ b/src/r_compiler/fixedfunction/drawskycodegen.h @@ -30,7 +30,7 @@ private: SSAInt texturefrac[4]; SSAInt iscale[4]; SSAInt textureheight0; - SSAInt textureheight1; + SSAInt maxtextureheight1; SSAVec4i top_color; SSAVec4i bottom_color; SSAWorkerThread thread;