Skip to content

Commit

Permalink
wined3d: Destroy the push constant buffers on device reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elizabeth Figura authored and julliard committed Jul 12, 2024
1 parent 551a3e6 commit a5535ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dlls/wined3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
13 changes: 10 additions & 3 deletions dlls/wined3d/stateblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a5535ae

Please sign in to comment.