wined3d: Unbind stateblock resources in wined3d_device_uninit_3d().
This commit is contained in:
parent
5b17ba887b
commit
3f455832a3
|
@ -1427,6 +1427,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
|
||||||
if (device->logo_surface)
|
if (device->logo_surface)
|
||||||
wined3d_surface_decref(device->logo_surface);
|
wined3d_surface_decref(device->logo_surface);
|
||||||
|
|
||||||
|
stateblock_unbind_resources(device->stateBlock);
|
||||||
|
|
||||||
/* Unload resources */
|
/* Unload resources */
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
|
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
|
||||||
{
|
{
|
||||||
|
@ -5412,20 +5414,12 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
||||||
struct wined3d_display_mode mode;
|
struct wined3d_display_mode mode;
|
||||||
BOOL DisplayModeChanged = FALSE;
|
BOOL DisplayModeChanged = FALSE;
|
||||||
BOOL update_desc = FALSE;
|
BOOL update_desc = FALSE;
|
||||||
unsigned int i;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("device %p, swapchain_desc %p.\n", device, swapchain_desc);
|
TRACE("device %p, swapchain_desc %p.\n", device, swapchain_desc);
|
||||||
|
|
||||||
wined3d_device_set_index_buffer(device, NULL, WINED3DFMT_UNKNOWN);
|
stateblock_unbind_resources(device->stateBlock);
|
||||||
for (i = 0; i < MAX_STREAMS; ++i)
|
|
||||||
{
|
|
||||||
wined3d_device_set_stream_source(device, i, NULL, 0, 0);
|
|
||||||
}
|
|
||||||
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
|
|
||||||
{
|
|
||||||
wined3d_device_set_texture(device, i, NULL);
|
|
||||||
}
|
|
||||||
if (device->onscreen_depth_stencil)
|
if (device->onscreen_depth_stencil)
|
||||||
{
|
{
|
||||||
wined3d_surface_decref(device->onscreen_depth_stencil);
|
wined3d_surface_decref(device->onscreen_depth_stencil);
|
||||||
|
|
|
@ -466,6 +466,58 @@ ULONG CDECL wined3d_stateblock_incref(struct wined3d_stateblock *stateblock)
|
||||||
return refcount;
|
return refcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stateblock_unbind_resources(struct wined3d_stateblock *stateblock)
|
||||||
|
{
|
||||||
|
struct wined3d_state *state = &stateblock->state;
|
||||||
|
struct wined3d_vertex_declaration *decl;
|
||||||
|
struct wined3d_texture *texture;
|
||||||
|
struct wined3d_buffer *buffer;
|
||||||
|
struct wined3d_shader *shader;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if ((decl = state->vertex_declaration))
|
||||||
|
{
|
||||||
|
state->vertex_declaration = NULL;
|
||||||
|
wined3d_vertex_declaration_decref(decl);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
|
||||||
|
{
|
||||||
|
if ((texture = state->textures[i]))
|
||||||
|
{
|
||||||
|
state->textures[i] = NULL;
|
||||||
|
wined3d_texture_decref(texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_STREAMS; ++i)
|
||||||
|
{
|
||||||
|
if ((buffer = state->streams[i].buffer))
|
||||||
|
{
|
||||||
|
state->streams[i].buffer = NULL;
|
||||||
|
wined3d_buffer_decref(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((buffer = state->index_buffer))
|
||||||
|
{
|
||||||
|
state->index_buffer = NULL;
|
||||||
|
wined3d_buffer_decref(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((shader = state->vertex_shader))
|
||||||
|
{
|
||||||
|
state->vertex_shader = NULL;
|
||||||
|
wined3d_shader_decref(shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((shader = state->pixel_shader))
|
||||||
|
{
|
||||||
|
state->pixel_shader = NULL;
|
||||||
|
wined3d_shader_decref(shader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
|
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
|
||||||
{
|
{
|
||||||
ULONG refcount = InterlockedDecrement(&stateblock->ref);
|
ULONG refcount = InterlockedDecrement(&stateblock->ref);
|
||||||
|
@ -474,46 +526,9 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
|
||||||
|
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
{
|
{
|
||||||
struct wined3d_buffer *buffer;
|
|
||||||
int counter;
|
int counter;
|
||||||
|
|
||||||
if (stateblock->state.vertex_declaration)
|
stateblock_unbind_resources(stateblock);
|
||||||
wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
|
|
||||||
|
|
||||||
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
|
|
||||||
{
|
|
||||||
struct wined3d_texture *texture = stateblock->state.textures[counter];
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
stateblock->state.textures[counter] = NULL;
|
|
||||||
wined3d_texture_decref(texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (counter = 0; counter < MAX_STREAMS; ++counter)
|
|
||||||
{
|
|
||||||
buffer = stateblock->state.streams[counter].buffer;
|
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
stateblock->state.streams[counter].buffer = NULL;
|
|
||||||
if (wined3d_buffer_decref(buffer))
|
|
||||||
{
|
|
||||||
WARN("Buffer %p still referenced by stateblock, stream %u.\n", buffer, counter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = stateblock->state.index_buffer;
|
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
stateblock->state.index_buffer = NULL;
|
|
||||||
wined3d_buffer_decref(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stateblock->state.vertex_shader)
|
|
||||||
wined3d_shader_decref(stateblock->state.vertex_shader);
|
|
||||||
if (stateblock->state.pixel_shader)
|
|
||||||
wined3d_shader_decref(stateblock->state.pixel_shader);
|
|
||||||
|
|
||||||
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
|
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2331,6 +2331,7 @@ struct wined3d_stateblock
|
||||||
|
|
||||||
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
|
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
|
||||||
void stateblock_init_default_state(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
|
void stateblock_init_default_state(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
|
||||||
|
void stateblock_unbind_resources(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* Direct3D terminology with little modifications. We do not have an issued state
|
/* Direct3D terminology with little modifications. We do not have an issued state
|
||||||
* because only the driver knows about it, but we have a created state because d3d
|
* because only the driver knows about it, but we have a created state because d3d
|
||||||
|
|
Loading…
Reference in New Issue