Commit aee3c0fa authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Introduce a separate function for cleaning up a wined3d_state structure.

parent 4e755d26
......@@ -588,6 +588,27 @@ void state_unbind_resources(struct wined3d_state *state)
}
}
static void state_cleanup(struct wined3d_state *state)
{
unsigned int counter;
state_unbind_resources(state);
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
{
struct list *e1, *e2;
LIST_FOR_EACH_SAFE(e1, e2, &state->light_map[counter])
{
struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry);
list_remove(&light->entry);
HeapFree(GetProcessHeap(), 0, light);
}
}
HeapFree(GetProcessHeap(), 0, state->vs_consts_f);
HeapFree(GetProcessHeap(), 0, state->ps_consts_f);
}
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
{
ULONG refcount = InterlockedDecrement(&stateblock->ref);
......@@ -596,24 +617,9 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
if (!refcount)
{
int counter;
state_unbind_resources(&stateblock->state);
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
{
struct list *e1, *e2;
LIST_FOR_EACH_SAFE(e1, e2, &stateblock->state.light_map[counter])
{
struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry);
list_remove(&light->entry);
HeapFree(GetProcessHeap(), 0, light);
}
}
state_cleanup(&stateblock->state);
HeapFree(GetProcessHeap(), 0, stateblock->state.vs_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->state.ps_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->contained_ps_consts_f);
......
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