Module: wine Branch: master Commit: a5535aea042674417935a2239f1242a9a3306cdd URL: https://gitlab.winehq.org/wine/wine/-/commit/a5535aea042674417935a2239f1242a...
Author: Elizabeth Figura zfigura@codeweavers.com Date: Sun Jun 9 12:50:30 2024 -0500
wined3d: Destroy the push constant buffers on device reset.
---
dlls/wined3d/device.c | 6 ++++++ dlls/wined3d/stateblock.c | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index acc70256462..e445679ec2f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5020,6 +5020,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, wined3d_texture_decref(device->cursor_texture); device->cursor_texture = NULL; } + for (unsigned int i = 0; i < ARRAY_SIZE(device->push_constants); ++i) + { + if (device->push_constants[i]) + wined3d_buffer_decref(device->push_constants[i]); + device->push_constants[i] = NULL; + } state_unbind_resources(state); }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 28aa2a46f08..104affe6e56 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -2193,6 +2193,14 @@ static void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state
}
+/* FFP push constant buffers do not have a "default" state on the CS side. + * We need to explicitly invalidate them when initializing the context or + * resetting. */ +static void wined3d_stateblock_invalidate_push_constants(struct wined3d_stateblock *stateblock) +{ + stateblock->changed.ffp_ps_constants = 1; +} + static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, struct wined3d_device *device, enum wined3d_stateblock_type type) { @@ -2207,9 +2215,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const stru stateblock->changed.store_stream_offset = 1; list_init(&stateblock->changed.changed_lights);
- /* FFP push constant buffers need to be set if used; the backend does not - * have a default state for them. */ - stateblock->changed.ffp_ps_constants = 1; + wined3d_stateblock_invalidate_push_constants(stateblock);
if (type == WINED3D_SBT_RECORDED || type == WINED3D_SBT_PRIMARY) return WINED3D_OK; @@ -2286,6 +2292,7 @@ void CDECL wined3d_stateblock_reset(struct wined3d_stateblock *stateblock) memset(&stateblock->stateblock_state, 0, sizeof(stateblock->stateblock_state)); stateblock->stateblock_state.light_state = &stateblock->light_state; wined3d_stateblock_state_init(&stateblock->stateblock_state, stateblock->device, WINED3D_STATE_INIT_DEFAULT); + wined3d_stateblock_invalidate_push_constants(stateblock); }
static void wined3d_device_set_base_vertex_index(struct wined3d_device *device, int base_index)