nv2a: Remove colorkey_mask from PshState

It's a uniform, so we don't want it to be part of the PSH setup state,
which used as the shader cache key.
This commit is contained in:
Matt Borgerson
2025-06-28 00:08:45 -07:00
committed by mborgerson
parent 634577c753
commit 3ad4eb3101
5 changed files with 18 additions and 7 deletions

View File

@ -783,7 +783,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
} }
if (binding->color_key_mask_loc[i] != -1) { if (binding->color_key_mask_loc[i] != -1) {
glUniform1ui(binding->color_key_mask_loc[i], glUniform1ui(binding->color_key_mask_loc[i],
state->psh.colorkey_mask[i]); pgraph_get_color_key_mask_for_texture(pg, i));
} }
} }

View File

@ -70,7 +70,6 @@ typedef struct PshState {
bool compare_mode[4][4]; bool compare_mode[4][4];
bool alphakill[4]; bool alphakill[4];
int colorkey_mode[4]; int colorkey_mode[4];
uint32_t colorkey_mask[4];
enum ConvolutionFilter conv_tex[4]; enum ConvolutionFilter conv_tex[4];
bool tex_x8y24[4]; bool tex_x8y24[4];
int dim_tex[4]; int dim_tex[4];

View File

@ -41,6 +41,14 @@ static uint32_t get_colorkey_mask(unsigned int color_format)
} }
} }
uint32_t pgraph_get_color_key_mask_for_texture(PGRAPHState *pg, int i)
{
assert(i < NV2A_MAX_TEXTURES);
uint32_t fmt = pgraph_reg_r(pg, NV_PGRAPH_TEXFMT0 + i*4);
unsigned int color_format = GET_MASK(fmt, NV_PGRAPH_TEXFMT0_COLOR);
return get_colorkey_mask(color_format);
}
ShaderState pgraph_get_shader_state(PGRAPHState *pg) ShaderState pgraph_get_shader_state(PGRAPHState *pg)
{ {
bool vertex_program = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CSV0_D), bool vertex_program = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CSV0_D),
@ -246,7 +254,6 @@ ShaderState pgraph_get_shader_state(PGRAPHState *pg)
state.psh.rect_tex[i] = f.linear; state.psh.rect_tex[i] = f.linear;
state.psh.tex_x8y24[i] = color_format == NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_X8_Y24_FIXED || state.psh.tex_x8y24[i] = color_format == NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_X8_Y24_FIXED ||
color_format == NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_X8_Y24_FLOAT; color_format == NV097_SET_TEXTURE_FORMAT_COLOR_LU_IMAGE_DEPTH_X8_Y24_FLOAT;
state.psh.colorkey_mask[i] = get_colorkey_mask(color_format);
uint32_t border_source = uint32_t border_source =
GET_MASK(tex_fmt, NV_PGRAPH_TEXFMT0_BORDER_SOURCE); GET_MASK(tex_fmt, NV_PGRAPH_TEXFMT0_BORDER_SOURCE);

View File

@ -112,5 +112,6 @@ typedef struct ShaderState {
typedef struct PGRAPHState PGRAPHState; typedef struct PGRAPHState PGRAPHState;
ShaderState pgraph_get_shader_state(PGRAPHState *pg); ShaderState pgraph_get_shader_state(PGRAPHState *pg);
uint32_t pgraph_get_color_key_mask_for_texture(PGRAPHState *pg, int i);
#endif #endif

View File

@ -506,10 +506,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
uniform1uiv(&binding->fragment->uniforms, binding->color_key_loc, 4, uniform1uiv(&binding->fragment->uniforms, binding->color_key_loc, 4,
color_key_colors); color_key_colors);
} }
if (binding->color_key_mask_loc != -1) { uint32_t color_key_mask[4] = { 0 };
uniform1uiv(&binding->fragment->uniforms, binding->color_key_mask_loc,
4, state->psh.colorkey_mask);
}
/* For each texture stage */ /* For each texture stage */
for (int i = 0; i < NV2A_MAX_TEXTURES; i++) { for (int i = 0; i < NV2A_MAX_TEXTURES; i++) {
@ -557,6 +554,13 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
} }
uniform1f(&binding->fragment->uniforms, loc, scale); uniform1f(&binding->fragment->uniforms, loc, scale);
} }
color_key_mask[i] = pgraph_get_color_key_mask_for_texture(pg, i);
}
if (binding->color_key_mask_loc != -1) {
uniform1uiv(&binding->fragment->uniforms, binding->color_key_mask_loc,
4, color_key_mask);
} }
if (binding->fog_color_loc != -1) { if (binding->fog_color_loc != -1) {