@@ -133,6 +133,7 @@ static void update_shader_constant_locations(ShaderBinding *binding)
133133 }
134134 }
135135 binding -> alpha_ref_loc = glGetUniformLocation (binding -> gl_program , "alphaRef" );
136+
136137 for (int i = 1 ; i < NV2A_MAX_TEXTURES ; i ++ ) {
137138 snprintf (tmp , sizeof (tmp ), "bumpMat%d" , i );
138139 binding -> bump_mat_loc [i ] = glGetUniformLocation (binding -> gl_program , tmp );
@@ -203,6 +204,16 @@ static void update_shader_constant_locations(ShaderBinding *binding)
203204 binding -> material_alpha_loc = -1 ;
204205 binding -> specular_power_loc = -1 ;
205206 }
207+
208+ for (int i = 0 ; i < 4 ; ++ i ) {
209+ snprintf (tmp , sizeof (tmp ), "colorKey[%d]" , i );
210+ binding -> color_key_loc [i ] =
211+ glGetUniformLocation (binding -> gl_program , tmp );
212+
213+ snprintf (tmp , sizeof (tmp ), "colorKeyMask[%d]" , i );
214+ binding -> color_key_mask_loc [i ] =
215+ glGetUniformLocation (binding -> gl_program , tmp );
216+ }
206217}
207218
208219static void generate_shaders (ShaderBinding * binding )
@@ -696,6 +707,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
696707 bool binding_changed )
697708{
698709 PGRAPHGLState * r = pg -> gl_renderer_state ;
710+ ShaderState * state = & binding -> state ;
699711 int i , j ;
700712
701713 /* update combiner constants */
@@ -725,7 +737,6 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
725737 glUniform1i (binding -> alpha_ref_loc , alpha_ref );
726738 }
727739
728-
729740 /* For each texture stage */
730741 for (i = 0 ; i < NV2A_MAX_TEXTURES ; i ++ ) {
731742 GLint loc ;
@@ -765,6 +776,15 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
765776 assert (r -> texture_binding [i ] != NULL );
766777 glUniform1f (loc , (float )r -> texture_binding [i ]-> scale );
767778 }
779+
780+ if (binding -> color_key_loc [i ] != -1 ) {
781+ glUniform1ui (binding -> color_key_loc [i ],
782+ pgraph_reg_r (pg , NV_PGRAPH_COLORKEYCOLOR0 + i * 4 ));
783+ }
784+ if (binding -> color_key_mask_loc [i ] != -1 ) {
785+ glUniform1ui (binding -> color_key_mask_loc [i ],
786+ state -> psh .colorkey_mask [i ]);
787+ }
768788 }
769789
770790 if (binding -> fog_color_loc != -1 ) {
@@ -794,7 +814,7 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
794814 assert (0 );
795815 }
796816
797- if (binding -> state . fixed_function ) {
817+ if (state -> fixed_function ) {
798818 /* update lighting constants */
799819 struct {
800820 uint32_t * v ;
@@ -990,7 +1010,8 @@ static bool test_shaders_dirty(PGRAPHState *pg)
9901010 CF(pg->primitive_mode, primitive_mode) \
9911011 CF(pg->surface_scale_factor, surface_scale_factor) \
9921012 CF(pg->compressed_attrs, compressed_attrs) \
993- CFA(pg->texture_matrix_enable, texture_matrix_enable)
1013+ CFA(pg->texture_matrix_enable, texture_matrix_enable) \
1014+ CR_4(NV_PGRAPH_COLORKEYCOLOR0)
9941015
9951016 #define CR_x (reg , x ) CR_x__define(reg, x)
9961017 #define CF_x (type , src , name , x ) CF_x__define(type, src, name, x)
0 commit comments