Zebediah Figura : wined3d: Store the pixel shader in the wined3d_stateblock_state structure.
Alexandre Julliard
julliard at winehq.org
Mon Jan 28 16:17:02 CST 2019
Module: wine
Branch: master
Commit: 0e493a2d80d85ec07e51fd8927cb24b10cb4a6e7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0e493a2d80d85ec07e51fd8927cb24b10cb4a6e7
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Sun Jan 27 22:44:56 2019 -0600
wined3d: Store the pixel shader in the wined3d_stateblock_state structure.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/device.c | 15 +++++++++++----
dlls/wined3d/stateblock.c | 28 ++++++++++++++++++++--------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 331def2..28e113a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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);
}
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 112d8b7..2b916a9 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -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)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 52106f2..b638d87 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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
More information about the wine-cvs
mailing list