Commit 0e493a2d authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Store the pixel shader in the wined3d_stateblock_state structure.

parent 28b0f53f
......@@ -2534,21 +2534,28 @@ HRESULT CDECL wined3d_device_get_vs_consts_f(const struct wined3d_device *device
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
struct wined3d_shader *prev = device->update_state->shader[WINED3D_SHADER_TYPE_PIXEL];
struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_PIXEL];
TRACE("device %p, shader %p.\n", device, shader);
if (shader)
wined3d_shader_incref(shader);
if (device->update_stateblock_state->ps)
wined3d_shader_decref(device->update_stateblock_state->ps);
device->update_stateblock_state->ps = shader;
if (device->recording)
{
device->recording->changed.pixelShader = TRUE;
return;
}
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
device->update_state->shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
if (!device->recording)
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_PIXEL, shader);
device->state.shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_PIXEL, shader);
if (prev)
wined3d_shader_decref(prev);
}
......
......@@ -530,6 +530,12 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
state->vs = NULL;
wined3d_shader_decref(shader);
}
if ((shader = state->ps))
{
state->ps = NULL;
wined3d_shader_decref(shader);
}
}
void state_cleanup(struct wined3d_state *state)
......@@ -953,14 +959,13 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
stateblock->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
}
if (stateblock->changed.pixelShader && stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]
!= src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
if (stateblock->changed.pixelShader && stateblock->stateblock_state.ps != state->ps)
{
if (src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
wined3d_shader_incref(src_state->shader[WINED3D_SHADER_TYPE_PIXEL]);
if (stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL])
wined3d_shader_decref(stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]);
stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL] = src_state->shader[WINED3D_SHADER_TYPE_PIXEL];
if (state->ps)
wined3d_shader_incref(state->ps);
if (stateblock->stateblock_state.ps)
wined3d_shader_decref(stateblock->stateblock_state.ps);
stateblock->stateblock_state.ps = state->ps;
}
wined3d_state_record_lights(&stateblock->state, src_state);
......@@ -1028,7 +1033,14 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
apply_lights(device, &stateblock->state);
if (stateblock->changed.pixelShader)
wined3d_device_set_pixel_shader(device, stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]);
{
if (stateblock->stateblock_state.ps)
wined3d_shader_incref(stateblock->stateblock_state.ps);
if (state->ps)
wined3d_shader_decref(state->ps);
state->ps = stateblock->stateblock_state.ps;
wined3d_device_set_pixel_shader(device, stateblock->stateblock_state.ps);
}
/* Pixel Shader Constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
......
......@@ -2974,6 +2974,8 @@ struct wined3d_stateblock_state
struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
struct wined3d_shader *ps;
};
struct wined3d_device
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment