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 <davyaxel0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22583>
This commit is contained in:
Axel Davy 2023-04-13 19:44:04 +02:00 committed by Marge Bot
parent 9923a31945
commit 80d1da14f0
3 changed files with 5 additions and 5 deletions

View file

@ -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),

View file

@ -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;

View file

@ -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,