mirror of https://github.com/xemu-project/xemu.git
nv2a: Clear entire PSH struct before hashing
This commit is contained in:
parent
a88b4cf9f5
commit
afed1a4835
|
@ -3292,54 +3292,54 @@ static void pgraph_bind_shaders(PGRAPHState *pg)
|
||||||
|
|
||||||
ShaderBinding* old_binding = pg->shader_binding;
|
ShaderBinding* old_binding = pg->shader_binding;
|
||||||
|
|
||||||
ShaderState state = {
|
ShaderState state;
|
||||||
.psh = (PshState){
|
memset(&state, 0, sizeof(ShaderState));
|
||||||
/* register combier stuff */
|
|
||||||
.window_clip_exclusive = pg->regs[NV_PGRAPH_SETUPRASTER]
|
|
||||||
& NV_PGRAPH_SETUPRASTER_WINDOWCLIPTYPE,
|
|
||||||
.combiner_control = pg->regs[NV_PGRAPH_COMBINECTL],
|
|
||||||
.shader_stage_program = pg->regs[NV_PGRAPH_SHADERPROG],
|
|
||||||
.other_stage_input = pg->regs[NV_PGRAPH_SHADERCTL],
|
|
||||||
.final_inputs_0 = pg->regs[NV_PGRAPH_COMBINESPECFOG0],
|
|
||||||
.final_inputs_1 = pg->regs[NV_PGRAPH_COMBINESPECFOG1],
|
|
||||||
|
|
||||||
.alpha_test = pg->regs[NV_PGRAPH_CONTROL_0]
|
/* register combier stuff */
|
||||||
& NV_PGRAPH_CONTROL_0_ALPHATESTENABLE,
|
state.psh.window_clip_exclusive = pg->regs[NV_PGRAPH_SETUPRASTER]
|
||||||
.alpha_func = (enum PshAlphaFunc)GET_MASK(pg->regs[NV_PGRAPH_CONTROL_0],
|
& NV_PGRAPH_SETUPRASTER_WINDOWCLIPTYPE;
|
||||||
NV_PGRAPH_CONTROL_0_ALPHAFUNC),
|
state.psh.combiner_control = pg->regs[NV_PGRAPH_COMBINECTL];
|
||||||
},
|
state.psh.shader_stage_program = pg->regs[NV_PGRAPH_SHADERPROG];
|
||||||
|
state.psh.other_stage_input = pg->regs[NV_PGRAPH_SHADERCTL];
|
||||||
|
state.psh.final_inputs_0 = pg->regs[NV_PGRAPH_COMBINESPECFOG0];
|
||||||
|
state.psh.final_inputs_1 = pg->regs[NV_PGRAPH_COMBINESPECFOG1];
|
||||||
|
|
||||||
|
state.psh.alpha_test = pg->regs[NV_PGRAPH_CONTROL_0]
|
||||||
|
& NV_PGRAPH_CONTROL_0_ALPHATESTENABLE;
|
||||||
|
state.psh.alpha_func = (enum PshAlphaFunc)GET_MASK(pg->regs[NV_PGRAPH_CONTROL_0],
|
||||||
|
NV_PGRAPH_CONTROL_0_ALPHAFUNC);
|
||||||
|
|
||||||
|
state.fixed_function = fixed_function;
|
||||||
|
|
||||||
/* fixed function stuff */
|
/* fixed function stuff */
|
||||||
.skinning = (enum VshSkinning)GET_MASK(pg->regs[NV_PGRAPH_CSV0_D],
|
if (fixed_function) {
|
||||||
NV_PGRAPH_CSV0_D_SKIN),
|
state.skinning = (enum VshSkinning)GET_MASK(pg->regs[NV_PGRAPH_CSV0_D],
|
||||||
.lighting = GET_MASK(pg->regs[NV_PGRAPH_CSV0_C],
|
NV_PGRAPH_CSV0_D_SKIN);
|
||||||
NV_PGRAPH_CSV0_C_LIGHTING),
|
state.lighting = GET_MASK(pg->regs[NV_PGRAPH_CSV0_C],
|
||||||
.normalization = pg->regs[NV_PGRAPH_CSV0_C]
|
NV_PGRAPH_CSV0_C_LIGHTING);
|
||||||
& NV_PGRAPH_CSV0_C_NORMALIZATION_ENABLE,
|
state.normalization = pg->regs[NV_PGRAPH_CSV0_C]
|
||||||
|
& NV_PGRAPH_CSV0_C_NORMALIZATION_ENABLE;
|
||||||
|
|
||||||
/* color material */
|
/* color material */
|
||||||
.emission_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_EMISSION),
|
state.emission_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_EMISSION);
|
||||||
.ambient_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_AMBIENT),
|
state.ambient_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_AMBIENT);
|
||||||
.diffuse_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_DIFFUSE),
|
state.diffuse_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_DIFFUSE);
|
||||||
.specular_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_SPECULAR),
|
state.specular_src = (enum MaterialColorSource)GET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_SPECULAR);
|
||||||
|
}
|
||||||
.fixed_function = fixed_function,
|
|
||||||
|
|
||||||
/* vertex program stuff */
|
/* vertex program stuff */
|
||||||
.vertex_program = vertex_program,
|
state.vertex_program = vertex_program,
|
||||||
.z_perspective = pg->regs[NV_PGRAPH_CONTROL_0]
|
state.z_perspective = pg->regs[NV_PGRAPH_CONTROL_0]
|
||||||
& NV_PGRAPH_CONTROL_0_Z_PERSPECTIVE_ENABLE,
|
& NV_PGRAPH_CONTROL_0_Z_PERSPECTIVE_ENABLE;
|
||||||
|
|
||||||
/* geometry shader stuff */
|
/* geometry shader stuff */
|
||||||
.primitive_mode = (enum ShaderPrimitiveMode)pg->primitive_mode,
|
state.primitive_mode = (enum ShaderPrimitiveMode)pg->primitive_mode;
|
||||||
.polygon_front_mode = (enum ShaderPolygonMode)GET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER],
|
state.polygon_front_mode = (enum ShaderPolygonMode)GET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER],
|
||||||
NV_PGRAPH_SETUPRASTER_FRONTFACEMODE),
|
NV_PGRAPH_SETUPRASTER_FRONTFACEMODE);
|
||||||
.polygon_back_mode = (enum ShaderPolygonMode)GET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER],
|
state.polygon_back_mode = (enum ShaderPolygonMode)GET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER],
|
||||||
NV_PGRAPH_SETUPRASTER_BACKFACEMODE),
|
NV_PGRAPH_SETUPRASTER_BACKFACEMODE);
|
||||||
};
|
|
||||||
|
|
||||||
state.program_length = 0;
|
state.program_length = 0;
|
||||||
memset(state.program_data, 0, sizeof(state.program_data));
|
|
||||||
|
|
||||||
if (vertex_program) {
|
if (vertex_program) {
|
||||||
// copy in vertex program tokens
|
// copy in vertex program tokens
|
||||||
|
@ -3437,12 +3437,6 @@ static void pgraph_bind_shaders(PGRAPHState *pg)
|
||||||
last_y = y;
|
last_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: We should memset(state, 0x00, sizeof(state)) instead */
|
|
||||||
memset(state.psh.rgb_inputs, 0, sizeof(state.psh.rgb_inputs));
|
|
||||||
memset(state.psh.rgb_outputs, 0, sizeof(state.psh.rgb_outputs));
|
|
||||||
memset(state.psh.alpha_inputs, 0, sizeof(state.psh.alpha_inputs));
|
|
||||||
memset(state.psh.alpha_outputs, 0, sizeof(state.psh.alpha_outputs));
|
|
||||||
|
|
||||||
/* Copy content of enabled combiner stages */
|
/* Copy content of enabled combiner stages */
|
||||||
int num_stages = pg->regs[NV_PGRAPH_COMBINECTL] & 0xFF;
|
int num_stages = pg->regs[NV_PGRAPH_COMBINECTL] & 0xFF;
|
||||||
for (i = 0; i < num_stages; i++) {
|
for (i = 0; i < num_stages; i++) {
|
||||||
|
|
Loading…
Reference in New Issue