Commit 8a7744b0 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Call state_init_default() from state_init() when the appropriate flag is set.

parent bc0f990b
......@@ -224,13 +224,13 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
return NULL;
}
if (FAILED(state_init(&cs->state, &cs->fb, &device->adapter->d3d_info, WINED3D_STATE_NO_REF)))
if (FAILED(state_init(&cs->state, &cs->fb, gl_info, &device->adapter->d3d_info,
WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT)))
{
HeapFree(GetProcessHeap(), 0, cs->fb.render_targets);
HeapFree(GetProcessHeap(), 0, cs);
return NULL;
}
state_init_default(&cs->state, gl_info);
cs->ops = &wined3d_cs_st_ops;
cs->device = device;
......
......@@ -4705,9 +4705,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
if (device->d3d_initialized)
delete_opengl_contexts(device, swapchain);
if (FAILED(hr = state_init(&device->state, &device->fb, &device->adapter->d3d_info, 0)))
if (FAILED(hr = state_init(&device->state, &device->fb, &device->adapter->gl_info,
&device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT)))
ERR("Failed to initialize device state, hr %#x.\n", hr);
state_init_default(&device->state, &device->adapter->gl_info);
device->update_state = &device->state;
device_init_swapchain_state(device, swapchain);
......@@ -4969,12 +4969,12 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
device->blitter = adapter->blitter;
if (FAILED(hr = state_init(&device->state, &device->fb, &adapter->d3d_info, 0)))
if (FAILED(hr = state_init(&device->state, &device->fb, &adapter->gl_info,
&adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT)))
{
ERR("Failed to initialize device state, hr %#x.\n", hr);
goto err;
}
state_init_default(&device->state, &adapter->gl_info);
device->update_state = &device->state;
if (!(device->cs = wined3d_cs_create(device)))
......
......@@ -599,33 +599,6 @@ void state_cleanup(struct wined3d_state *state)
HeapFree(GetProcessHeap(), 0, state->ps_consts_f);
}
HRESULT state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
const struct wined3d_d3d_info *d3d_info, DWORD flags)
{
unsigned int i;
state->flags = flags;
state->fb = fb;
for (i = 0; i < LIGHTMAP_SIZE; i++)
{
list_init(&state->light_map[i]);
}
if (!(state->vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
4 * sizeof(float) * d3d_info->limits.vs_uniform_count)))
return E_OUTOFMEMORY;
if (!(state->ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
4 * sizeof(float) * d3d_info->limits.ps_uniform_count)))
{
HeapFree(GetProcessHeap(), 0, state->vs_consts_f);
return E_OUTOFMEMORY;
}
return WINED3D_OK;
}
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
{
ULONG refcount = InterlockedDecrement(&stateblock->ref);
......@@ -1173,7 +1146,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
TRACE("Applied stateblock %p.\n", stateblock);
}
void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
static void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
{
union
{
......@@ -1379,6 +1352,37 @@ void state_init_default(struct wined3d_state *state, const struct wined3d_gl_inf
}
}
HRESULT state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
DWORD flags)
{
unsigned int i;
state->flags = flags;
state->fb = fb;
for (i = 0; i < LIGHTMAP_SIZE; i++)
{
list_init(&state->light_map[i]);
}
if (!(state->vs_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
4 * sizeof(float) * d3d_info->limits.vs_uniform_count)))
return E_OUTOFMEMORY;
if (!(state->ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
4 * sizeof(float) * d3d_info->limits.ps_uniform_count)))
{
HeapFree(GetProcessHeap(), 0, state->vs_consts_f);
return E_OUTOFMEMORY;
}
if (flags & WINED3D_STATE_INIT_DEFAULT)
state_init_default(state, gl_info);
return WINED3D_OK;
}
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
struct wined3d_device *device, enum wined3d_stateblock_type type)
{
......@@ -1388,7 +1392,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
stateblock->ref = 1;
stateblock->device = device;
if (FAILED(hr = state_init(&stateblock->state, NULL, d3d_info, 0)))
if (FAILED(hr = state_init(&stateblock->state, NULL, &device->adapter->gl_info, d3d_info, 0)))
return hr;
if (FAILED(hr = stateblock_allocate_shader_constants(stateblock)))
......
......@@ -1805,6 +1805,7 @@ struct wined3d_stream_state
};
#define WINED3D_STATE_NO_REF 0x00000001
#define WINED3D_STATE_INIT_DEFAULT 0x00000002
struct wined3d_state
{
......@@ -2454,8 +2455,8 @@ void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DEC
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
HRESULT state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN;
void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
DWORD flags) DECLSPEC_HIDDEN;
void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
struct wined3d_cs_ops
......
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