From 80d1da14f047f7ac4e4a28e9640d600b823df1cc Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Thu, 13 Apr 2023 19:44:04 +0200 Subject: [PATCH] frontend/nine: fix fog key overflow FOGTABLEMODE is 2 bits. It could thus overwrite the part of the ps key reserved for centroid interpolation. Fix the size of FOGTABLEMODE and the key Signed-off-by: Axel Davy Part-of: --- src/gallium/frontends/nine/nine_limits.h | 4 ++-- src/gallium/frontends/nine/pixelshader9.c | 2 +- src/gallium/frontends/nine/pixelshader9.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/nine/nine_limits.h b/src/gallium/frontends/nine/nine_limits.h index b5090daa11d..f94b7c93dcb 100644 --- a/src/gallium/frontends/nine/nine_limits.h +++ b/src/gallium/frontends/nine/nine_limits.h @@ -90,7 +90,7 @@ render_state_limits_table[D3DRS_BLENDOPALPHA + 1] = { __BOOLEAN_RS(FOGENABLE), __BOOLEAN_RS(SPECULARENABLE), __NO_LIMIT_RS(FOGCOLOR), - __MASK_RS(FOGTABLEMODE, 0x00000007), + __MASK_RS(FOGTABLEMODE, 0x00000003), __NO_LIMIT_RS(FOGSTART), /* a bit more complex than that, lets ignore */ __NO_LIMIT_RS(FOGEND), __NO_LIMIT_RS(FOGDENSITY), /* actually should be between 0.0 and 1.0 */ @@ -115,7 +115,7 @@ render_state_limits_table[D3DRS_BLENDOPALPHA + 1] = { __BOOLEAN_RS(CLIPPING), __BOOLEAN_RS(LIGHTING), __NO_LIMIT_RS(AMBIENT), - __MASK_RS(FOGVERTEXMODE, 0x00000007), + __MASK_RS(FOGVERTEXMODE, 0x00000003), __BOOLEAN_RS(COLORVERTEX), __BOOLEAN_RS(LOCALVIEWER), __BOOLEAN_RS(NORMALIZENORMALS), diff --git a/src/gallium/frontends/nine/pixelshader9.c b/src/gallium/frontends/nine/pixelshader9.c index c5fe93c077f..8df27a99c98 100644 --- a/src/gallium/frontends/nine/pixelshader9.c +++ b/src/gallium/frontends/nine/pixelshader9.c @@ -211,7 +211,7 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This, } info.fog_enable = device->context.rs[D3DRS_FOGENABLE]; info.fog_mode = device->context.rs[D3DRS_FOGTABLEMODE]; - info.force_color_in_centroid = (key >> 22) & 1; + info.force_color_in_centroid = (key >> 23) & 1; info.add_constants_defs.c_combination = nine_shader_constant_combination_get(This->c_combinations, (key >> 24) & 0xff); info.add_constants_defs.int_const_added = &This->int_slots_used; diff --git a/src/gallium/frontends/nine/pixelshader9.h b/src/gallium/frontends/nine/pixelshader9.h index 1cf5a553856..dd5e1edcf99 100644 --- a/src/gallium/frontends/nine/pixelshader9.h +++ b/src/gallium/frontends/nine/pixelshader9.h @@ -113,12 +113,12 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps, if (ps->byte_code.version < 0x30) { key |= ((uint64_t)context->rs[D3DRS_FOGENABLE]) << 20; - key |= ((uint64_t)context->rs[D3DRS_FOGTABLEMODE]) << 21; + key |= ((uint64_t)context->rs[D3DRS_FOGTABLEMODE]) << 21; /* 2 bits */ } /* centroid interpolation automatically used for color ps inputs */ if (context->rt[0]->base.info.nr_samples) - key |= ((uint64_t)1) << 22; + key |= ((uint64_t)1) << 23; if ((ps->const_int_slots > 0 || ps->const_bool_slots > 0) && context->inline_constants) key |= ((uint64_t)nine_shader_constant_combination_key(&ps->c_combinations,