Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Some refactoring in preparation for the d3d11 state swap implementation using dynamically created wined3d_state objects.
dlls/wined3d/device.c | 66 +++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1fd5f4b012e..ad20d882cf5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1447,11 +1447,11 @@ static void wined3d_device_set_transform(struct wined3d_device *device, }
static void wined3d_device_get_transform(const struct wined3d_device *device, - enum wined3d_transform_state state, struct wined3d_matrix *matrix) + enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix) { - TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix); + TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
- *matrix = device->state.transforms[state]; + *matrix = device->state.transforms[transform_state]; }
/* Note lights are real special cases. Although the device caps state only @@ -1775,21 +1775,21 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w }
void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device, - struct wined3d_depth_stencil_state *state, unsigned int stencil_ref) + struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref) { struct wined3d_depth_stencil_state *prev;
- TRACE("device %p, state %p, stencil_ref %u.\n", device, state, stencil_ref); + TRACE("device %p, depth_stencil_state %p, stencil_ref %u.\n", device, depth_stencil_state, stencil_ref);
prev = device->state.depth_stencil_state; - if (prev == state && device->state.stencil_ref == stencil_ref) + if (prev == depth_stencil_state && device->state.stencil_ref == stencil_ref) return;
- if (state) - wined3d_depth_stencil_state_incref(state); - device->state.depth_stencil_state = state; + if (depth_stencil_state) + wined3d_depth_stencil_state_incref(depth_stencil_state); + device->state.depth_stencil_state = depth_stencil_state; device->state.stencil_ref = stencil_ref; - wined3d_cs_emit_set_depth_stencil_state(device->cs, state, stencil_ref); + wined3d_cs_emit_set_depth_stencil_state(device->cs, depth_stencil_state, stencil_ref); if (prev) wined3d_depth_stencil_state_decref(prev); } @@ -1829,52 +1829,52 @@ struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(stru }
void CDECL wined3d_device_set_render_state(struct wined3d_device *device, - enum wined3d_render_state state, DWORD value) + enum wined3d_render_state render_state, DWORD value) { - TRACE("device %p, state %s (%#x), value %#x.\n", device, debug_d3drenderstate(state), state, value); + TRACE("device %p, render_state %s (%#x), value %#x.\n", device, debug_d3drenderstate(render_state), render_state, value);
- if (state > WINEHIGHEST_RENDER_STATE) + if (render_state > WINEHIGHEST_RENDER_STATE) { - WARN("Unhandled render state %#x.\n", state); + WARN("Unhandled render state %#x.\n", render_state); return; }
- if (value == device->state.render_states[state]) + if (value == device->state.render_states[render_state]) TRACE("Application is setting the old value over, nothing to do.\n"); else { - device->state.render_states[state] = value; - wined3d_cs_emit_set_render_state(device->cs, state, value); + device->state.render_states[render_state] = value; + wined3d_cs_emit_set_render_state(device->cs, render_state, value); }
- if (state == WINED3D_RS_POINTSIZE && value == WINED3D_RESZ_CODE) + if (render_state == WINED3D_RS_POINTSIZE && value == WINED3D_RESZ_CODE) { TRACE("RESZ multisampled depth buffer resolve triggered.\n"); resolve_depth_buffer(device); } }
-DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state state) +DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state render_state) { - TRACE("device %p, state %s (%#x).\n", device, debug_d3drenderstate(state), state); + TRACE("device %p, render_state %s (%#x).\n", device, debug_d3drenderstate(render_state), render_state);
- return device->state.render_states[state]; + return device->state.render_states[render_state]; }
static void wined3d_device_set_sampler_state(struct wined3d_device *device, - UINT sampler_idx, enum wined3d_sampler_state state, DWORD value) + UINT sampler_idx, enum wined3d_sampler_state sampler_state, DWORD value) { - TRACE("device %p, sampler_idx %u, state %s, value %#x.\n", - device, sampler_idx, debug_d3dsamplerstate(state), value); + TRACE("device %p, sampler_idx %u, sampler_state %s, value %#x.\n", + device, sampler_idx, debug_d3dsamplerstate(sampler_state), value);
- if (value == device->state.sampler_states[sampler_idx][state]) + if (value == device->state.sampler_states[sampler_idx][sampler_state]) { TRACE("Application is setting the old value over, nothing to do.\n"); return; }
- device->state.sampler_states[sampler_idx][state] = value; - wined3d_cs_emit_set_sampler_state(device->cs, sampler_idx, state, value); + device->state.sampler_states[sampler_idx][sampler_state] = value; + wined3d_cs_emit_set_sampler_state(device->cs, sampler_idx, sampler_state, value); }
void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count, @@ -3529,12 +3529,12 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, }
static void wined3d_device_set_texture_stage_state(struct wined3d_device *device, - UINT stage, enum wined3d_texture_stage_state state, DWORD value) + UINT stage, enum wined3d_texture_stage_state texture_state, DWORD value) { const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
- TRACE("device %p, stage %u, state %s, value %#x.\n", - device, stage, debug_d3dtexturestate(state), value); + TRACE("device %p, stage %u, texture_state %s, value %#x.\n", + device, stage, debug_d3dtexturestate(texture_state), value);
if (stage >= d3d_info->limits.ffp_blend_stages) { @@ -3543,15 +3543,15 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device return; }
- if (value == device->state.texture_states[stage][state]) + if (value == device->state.texture_states[stage][texture_state]) { TRACE("Application is setting the old value over, nothing to do.\n"); return; }
- device->state.texture_states[stage][state] = value; + device->state.texture_states[stage][texture_state] = value;
- wined3d_cs_emit_set_texture_state(device->cs, stage, state, value); + wined3d_cs_emit_set_texture_state(device->cs, stage, texture_state, value); }
static void wined3d_device_set_texture(struct wined3d_device *device,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/device.c | 423 ++++++++++++++++++++++++++--------------- dlls/wined3d/texture.c | 3 +- 2 files changed, 269 insertions(+), 157 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ad20d882cf5..e44ca3ddb63 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1083,6 +1083,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str { static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f}; const struct wined3d_swapchain_desc *swapchain_desc; + struct wined3d_state *state = &device->state; DWORD clear_flags = 0; unsigned int i; HRESULT hr; @@ -1101,11 +1102,11 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str } device->swapchains[0] = swapchain;
- for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i) - if (device->state.fb.render_targets[i]) - wined3d_rtv_bind_count_dec(device->state.fb.render_targets[i]); + for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i) + if (state->fb.render_targets[i]) + wined3d_rtv_bind_count_dec(state->fb.render_targets[i]);
- memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets)); + memset(state->fb.render_targets, 0, sizeof(state->fb.render_targets)); if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device))) goto err_out; device->d3d_initialized = TRUE; @@ -1187,6 +1188,7 @@ static void device_free_depth_stencil_state(struct wine_rb_entry *entry, void *c
void wined3d_device_uninit_3d(struct wined3d_device *device) { + struct wined3d_state *state = &device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_texture *texture; @@ -1217,7 +1219,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device) }
wined3d_cs_emit_reset_state(device->cs); - state_cleanup(&device->state); + state_cleanup(state); for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i) { wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); @@ -1237,11 +1239,11 @@ void wined3d_device_uninit_3d(struct wined3d_device *device) device->adapter->adapter_ops->adapter_uninit_3d(device); device->d3d_initialized = FALSE;
- if ((view = device->state.fb.depth_stencil)) + if ((view = state->fb.depth_stencil)) { TRACE("Releasing depth/stencil view %p.\n", view);
- device->state.fb.depth_stencil = NULL; + state->fb.depth_stencil = NULL; wined3d_rendertarget_view_decref(view); }
@@ -1261,8 +1263,8 @@ void wined3d_device_uninit_3d(struct wined3d_device *device) heap_free(device->swapchains); device->swapchains = NULL;
- memset(&device->state, 0, sizeof(device->state)); - state_init(&device->state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + memset(state, 0, sizeof(*state)); + state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); }
/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw @@ -1298,6 +1300,7 @@ UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer, UINT offset) { + struct wined3d_state *state = &device->state; struct wined3d_stream_output *stream; struct wined3d_buffer *prev_buffer;
@@ -1309,7 +1312,7 @@ void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT return; }
- stream = &device->state.stream_output[idx]; + stream = &state->stream_output[idx]; prev_buffer = stream->buffer;
if (buffer) @@ -1324,6 +1327,8 @@ void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_device *device, UINT idx, UINT *offset) { + struct wined3d_state *state = &device->state; + TRACE("device %p, idx %u, offset %p.\n", device, idx, offset);
if (idx >= WINED3D_MAX_STREAM_OUTPUT_BUFFERS) @@ -1333,13 +1338,14 @@ struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_de }
if (offset) - *offset = device->state.stream_output[idx].offset; - return device->state.stream_output[idx].buffer; + *offset = state->stream_output[idx].offset; + return state->stream_output[idx].buffer; }
HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride) { + struct wined3d_state *state = &device->state; struct wined3d_stream_state *stream; struct wined3d_buffer *prev_buffer;
@@ -1357,7 +1363,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI return WINED3DERR_INVALIDCALL; }
- stream = &device->state.streams[stream_idx]; + stream = &state->streams[stream_idx]; prev_buffer = stream->buffer;
if (prev_buffer == buffer @@ -1383,6 +1389,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride) { + const struct wined3d_state *state = &device->state; const struct wined3d_stream_state *stream;
TRACE("device %p, stream_idx %u, buffer %p, offset %p, stride %p.\n", @@ -1394,7 +1401,7 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi return WINED3DERR_INVALIDCALL; }
- stream = &device->state.streams[stream_idx]; + stream = &state->streams[stream_idx]; *buffer = stream->buffer; if (offset) *offset = stream->offset; @@ -1405,12 +1412,13 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi
static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider) { + struct wined3d_state *state = &device->state; struct wined3d_stream_state *stream; UINT old_flags, old_freq;
TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider);
- stream = &device->state.streams[stream_idx]; + stream = &state->streams[stream_idx]; old_flags = stream->flags; old_freq = stream->frequency;
@@ -1423,6 +1431,8 @@ static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, static void wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix) { + struct wined3d_state *state = &device->state; + TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(d3dts), matrix); TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14); @@ -1436,22 +1446,24 @@ static void wined3d_device_set_transform(struct wined3d_device *device, * tend towards setting the same matrix repeatedly for some reason. * * From here on we assume that the new matrix is different, wherever it matters. */ - if (!memcmp(&device->state.transforms[d3dts], matrix, sizeof(*matrix))) + if (!memcmp(&state->transforms[d3dts], matrix, sizeof(*matrix))) { TRACE("The application is setting the same matrix over again.\n"); return; }
- device->state.transforms[d3dts] = *matrix; + state->transforms[d3dts] = *matrix; wined3d_cs_emit_set_transform(device->cs, d3dts, matrix); }
static void wined3d_device_get_transform(const struct wined3d_device *device, enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
- *matrix = device->state.transforms[transform_state]; + *matrix = state->transforms[transform_state]; }
/* Note lights are real special cases. Although the device caps state only @@ -1464,12 +1476,13 @@ static void wined3d_device_get_transform(const struct wined3d_device *device, static void wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const struct wined3d_light *light) { + struct wined3d_state *state = &device->state; struct wined3d_light_info *object = NULL; float rho;
TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
- if (FAILED(wined3d_light_state_set_light(&device->state.light_state, light_idx, light, &object))) + if (FAILED(wined3d_light_state_set_light(&state->light_state, light_idx, light, &object))) return;
/* Initialize the object. */ @@ -1563,30 +1576,33 @@ static void wined3d_device_set_light(struct wined3d_device *device,
static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable) { + struct wined3d_state *state = &device->state; struct wined3d_light_info *light_info;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
/* Special case - enabling an undefined light creates one with a strict set of parameters. */ - if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx))) + if (!(light_info = wined3d_light_state_get_light(&state->light_state, light_idx))) { TRACE("Light enabled requested but light not defined, so defining one!\n"); wined3d_device_set_light(device, light_idx, &WINED3D_default_light);
- if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx))) + if (!(light_info = wined3d_light_state_get_light(&state->light_state, light_idx))) { FIXME("Adding default lights has failed dismally\n"); return; } }
- wined3d_light_state_enable_light(&device->state.light_state, &device->adapter->d3d_info, light_info, enable); + wined3d_light_state_enable_light(&state->light_state, &device->adapter->d3d_info, light_info, enable); wined3d_cs_emit_set_light_enable(device->cs, light_idx, enable); }
static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane) { + struct wined3d_state *state = &device->state; + TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
if (plane_idx >= device->adapter->d3d_info.limits.max_clip_distances) @@ -1595,13 +1611,13 @@ static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device, return WINED3DERR_INVALIDCALL; }
- if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane))) + if (!memcmp(&state->clip_planes[plane_idx], plane, sizeof(*plane))) { TRACE("Application is setting old values over, nothing to do.\n"); return WINED3D_OK; }
- device->state.clip_planes[plane_idx] = *plane; + state->clip_planes[plane_idx] = *plane;
wined3d_cs_emit_set_clip_plane(device->cs, plane_idx, plane);
@@ -1632,15 +1648,18 @@ HRESULT CDECL wined3d_device_get_clip_status(const struct wined3d_device *device
static void wined3d_device_set_material(struct wined3d_device *device, const struct wined3d_material *material) { + struct wined3d_state *state = &device->state; + TRACE("device %p, material %p.\n", device, material);
- device->state.material = *material; + state->material = *material; wined3d_cs_emit_set_material(device->cs, material); }
void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset) { + struct wined3d_state *state = &device->state; enum wined3d_format_id prev_format; struct wined3d_buffer *prev_buffer; unsigned int prev_offset; @@ -1648,18 +1667,18 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, TRACE("device %p, buffer %p, format %s, offset %u.\n", device, buffer, debug_d3dformat(format_id), offset);
- prev_buffer = device->state.index_buffer; - prev_format = device->state.index_format; - prev_offset = device->state.index_offset; + prev_buffer = state->index_buffer; + prev_format = state->index_format; + prev_offset = state->index_offset;
if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset) return;
if (buffer) wined3d_buffer_incref(buffer); - device->state.index_buffer = buffer; - device->state.index_format = format_id; - device->state.index_offset = offset; + state->index_buffer = buffer; + state->index_format = format_id; + state->index_offset = offset; wined3d_cs_emit_set_index_buffer(device->cs, buffer, format_id, offset); if (prev_buffer) wined3d_buffer_decref(prev_buffer); @@ -1668,24 +1687,29 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device, enum wined3d_format_id *format, unsigned int *offset) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, format %p, offset %p.\n", device, format, offset);
- *format = device->state.index_format; + *format = state->index_format; if (offset) - *offset = device->state.index_offset; - return device->state.index_buffer; + *offset = state->index_offset; + return state->index_buffer; }
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index) { + struct wined3d_state *state = &device->state; + TRACE("device %p, base_index %d.\n", device, base_index);
- device->state.base_vertex_index = base_index; + state->base_vertex_index = base_index; }
void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned int viewport_count, const struct wined3d_viewport *viewports) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, viewport_count %u, viewports %p.\n", device, viewport_count, viewports); @@ -1697,10 +1721,10 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned }
if (viewport_count) - memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports)); + memcpy(state->viewports, viewports, viewport_count * sizeof(*viewports)); else - memset(device->state.viewports, 0, sizeof(device->state.viewports)); - device->state.viewport_count = viewport_count; + memset(state->viewports, 0, sizeof(state->viewports)); + state->viewport_count = viewport_count;
wined3d_cs_emit_set_viewports(device->cs, viewport_count, viewports); } @@ -1708,15 +1732,16 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count, struct wined3d_viewport *viewports) { + const struct wined3d_state *state = &device->state; unsigned int count;
TRACE("device %p, viewport_count %p, viewports %p.\n", device, viewport_count, viewports);
- count = viewport_count ? min(*viewport_count, device->state.viewport_count) : 1; + count = viewport_count ? min(*viewport_count, state->viewport_count) : 1; if (count && viewports) - memcpy(viewports, device->state.viewports, count * sizeof(*viewports)); + memcpy(viewports, state->viewports, count * sizeof(*viewports)); if (viewport_count) - *viewport_count = device->state.viewport_count; + *viewport_count = state->viewport_count; }
static void resolve_depth_buffer(struct wined3d_device *device) @@ -1777,18 +1802,19 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref) { + struct wined3d_state *state = &device->state; struct wined3d_depth_stencil_state *prev;
TRACE("device %p, depth_stencil_state %p, stencil_ref %u.\n", device, depth_stencil_state, stencil_ref);
- prev = device->state.depth_stencil_state; - if (prev == depth_stencil_state && device->state.stencil_ref == stencil_ref) + prev = state->depth_stencil_state; + if (prev == depth_stencil_state && state->stencil_ref == stencil_ref) return;
if (depth_stencil_state) wined3d_depth_stencil_state_incref(depth_stencil_state); - device->state.depth_stencil_state = depth_stencil_state; - device->state.stencil_ref = stencil_ref; + state->depth_stencil_state = depth_stencil_state; + state->stencil_ref = stencil_ref; wined3d_cs_emit_set_depth_stencil_state(device->cs, depth_stencil_state, stencil_ref); if (prev) wined3d_depth_stencil_state_decref(prev); @@ -1796,26 +1822,29 @@ void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device,
struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_state(const struct wined3d_device *device, unsigned int *stencil_ref) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, stencil_ref %p.\n", device, stencil_ref);
- *stencil_ref = device->state.stencil_ref; - return device->state.depth_stencil_state; + *stencil_ref = state->stencil_ref; + return state->depth_stencil_state; }
void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device, struct wined3d_rasterizer_state *rasterizer_state) { + struct wined3d_state *state = &device->state; struct wined3d_rasterizer_state *prev;
TRACE("device %p, rasterizer_state %p.\n", device, rasterizer_state);
- prev = device->state.rasterizer_state; + prev = state->rasterizer_state; if (prev == rasterizer_state) return;
if (rasterizer_state) wined3d_rasterizer_state_incref(rasterizer_state); - device->state.rasterizer_state = rasterizer_state; + state->rasterizer_state = rasterizer_state; wined3d_cs_emit_set_rasterizer_state(device->cs, rasterizer_state); if (prev) wined3d_rasterizer_state_decref(prev); @@ -1823,14 +1852,18 @@ void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device,
struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(struct wined3d_device *device) { + struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.rasterizer_state; + return state->rasterizer_state; }
void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state render_state, DWORD value) { + struct wined3d_state *state = &device->state; + TRACE("device %p, render_state %s (%#x), value %#x.\n", device, debug_d3drenderstate(render_state), render_state, value);
if (render_state > WINEHIGHEST_RENDER_STATE) @@ -1839,11 +1872,11 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device, return; }
- if (value == device->state.render_states[render_state]) + if (value == state->render_states[render_state]) TRACE("Application is setting the old value over, nothing to do.\n"); else { - device->state.render_states[render_state] = value; + state->render_states[render_state] = value; wined3d_cs_emit_set_render_state(device->cs, render_state, value); }
@@ -1856,30 +1889,35 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state render_state) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, render_state %s (%#x).\n", device, debug_d3drenderstate(render_state), render_state);
- return device->state.render_states[render_state]; + return state->render_states[render_state]; }
static void wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state sampler_state, DWORD value) { + struct wined3d_state *state = &device->state; + TRACE("device %p, sampler_idx %u, sampler_state %s, value %#x.\n", device, sampler_idx, debug_d3dsamplerstate(sampler_state), value);
- if (value == device->state.sampler_states[sampler_idx][sampler_state]) + if (value == state->sampler_states[sampler_idx][sampler_state]) { TRACE("Application is setting the old value over, nothing to do.\n"); return; }
- device->state.sampler_states[sampler_idx][sampler_state] = value; + state->sampler_states[sampler_idx][sampler_state] = value; wined3d_cs_emit_set_sampler_state(device->cs, sampler_idx, sampler_state, value); }
void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count, const RECT *rects) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects); @@ -1889,39 +1927,41 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i])); }
- if (device->state.scissor_rect_count == rect_count - && !memcmp(device->state.scissor_rects, rects, rect_count * sizeof(*rects))) + if (state->scissor_rect_count == rect_count + && !memcmp(state->scissor_rects, rects, rect_count * sizeof(*rects))) { TRACE("App is setting the old scissor rectangles over, nothing to do.\n"); return; }
if (rect_count) - memcpy(device->state.scissor_rects, rects, rect_count * sizeof(*rects)); + memcpy(state->scissor_rects, rects, rect_count * sizeof(*rects)); else - memset(device->state.scissor_rects, 0, sizeof(device->state.scissor_rects)); - device->state.scissor_rect_count = rect_count; + memset(state->scissor_rects, 0, sizeof(state->scissor_rects)); + state->scissor_rect_count = rect_count;
wined3d_cs_emit_set_scissor_rects(device->cs, rect_count, rects); }
void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count, RECT *rects) { + const struct wined3d_state *state = &device->state; unsigned int count;
TRACE("device %p, rect_count %p, rects %p.\n", device, rect_count, rects);
- count = rect_count ? min(*rect_count, device->state.scissor_rect_count) : 1; + count = rect_count ? min(*rect_count, state->scissor_rect_count) : 1; if (count && rects) - memcpy(rects, device->state.scissor_rects, count * sizeof(*rects)); + memcpy(rects, state->scissor_rects, count * sizeof(*rects)); if (rect_count) - *rect_count = device->state.scissor_rect_count; + *rect_count = state->scissor_rect_count; }
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { - struct wined3d_vertex_declaration *prev = device->state.vertex_declaration; + struct wined3d_state *state = &device->state; + struct wined3d_vertex_declaration *prev = state->vertex_declaration;
TRACE("device %p, declaration %p.\n", device, declaration);
@@ -1930,7 +1970,7 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
if (declaration) wined3d_vertex_declaration_incref(declaration); - device->state.vertex_declaration = declaration; + state->vertex_declaration = declaration; wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); if (prev) wined3d_vertex_declaration_decref(prev); @@ -1938,14 +1978,17 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.vertex_declaration; + return state->vertex_declaration; }
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_VERTEX]; + struct wined3d_state *state = &device->state; + struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_VERTEX];
TRACE("device %p, shader %p.\n", device, shader);
@@ -1954,7 +1997,7 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_VERTEX] = shader; + state->shader[WINED3D_SHADER_TYPE_VERTEX] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_VERTEX, shader); if (prev) wined3d_shader_decref(prev); @@ -1962,14 +2005,17 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_VERTEX]; + return state->shader[WINED3D_SHADER_TYPE_VERTEX]; }
void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer) { + struct wined3d_state *state = &device->state; struct wined3d_buffer *prev;
TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer); @@ -1980,13 +2026,13 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, return; }
- prev = device->state.cb[type][idx]; + prev = state->cb[type][idx]; if (buffer == prev) return;
if (buffer) wined3d_buffer_incref(buffer); - device->state.cb[type][idx] = buffer; + state->cb[type][idx] = buffer; wined3d_cs_emit_set_constant_buffer(device->cs, type, idx, buffer); if (prev) wined3d_buffer_decref(prev); @@ -1995,6 +2041,8 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, shader_type %#x, idx %u.\n", device, shader_type, idx);
if (idx >= MAX_CONSTANT_BUFFERS) @@ -2003,12 +2051,13 @@ struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wi return NULL; }
- return device->state.cb[shader_type][idx]; + return state->cb[shader_type][idx]; }
static void wined3d_device_set_shader_resource_view(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view) { + struct wined3d_state *state = &device->state; const struct wined3d_rendertarget_view *dsv; struct wined3d_shader_resource_view *prev;
@@ -2018,12 +2067,12 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic return; }
- prev = device->state.shader_resource_view[type][idx]; + prev = state->shader_resource_view[type][idx]; if (view == prev) return;
if (view && (wined3d_is_srv_rtv_bound(view) - || ((dsv = device->state.fb.depth_stencil) + || ((dsv = state->fb.depth_stencil) && dsv->resource == view->resource && wined3d_dsv_srv_conflict(dsv, view->format)))) { WARN("Application is trying to bind resource which is attached as render target.\n"); @@ -2036,7 +2085,7 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic wined3d_srv_bind_count_inc(view); }
- device->state.shader_resource_view[type][idx] = view; + state->shader_resource_view[type][idx] = view; wined3d_cs_emit_set_shader_resource_view(device->cs, type, idx, view); if (prev) { @@ -2056,13 +2105,15 @@ void CDECL wined3d_device_set_vs_resource_view(struct wined3d_device *device, static struct wined3d_shader_resource_view *wined3d_device_get_shader_resource_view( const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { + const struct wined3d_state *state = &device->state; + if (idx >= MAX_SHADER_RESOURCE_VIEWS) { WARN("Invalid view index %u.\n", idx); return NULL; }
- return device->state.shader_resource_view[shader_type][idx]; + return state->shader_resource_view[shader_type][idx]; }
struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view(const struct wined3d_device *device, @@ -2076,6 +2127,7 @@ struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view( static void wined3d_device_set_sampler(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler) { + struct wined3d_state *state = &device->state; struct wined3d_sampler *prev;
if (idx >= MAX_SAMPLER_OBJECTS) @@ -2084,13 +2136,13 @@ static void wined3d_device_set_sampler(struct wined3d_device *device, return; }
- prev = device->state.sampler[type][idx]; + prev = state->sampler[type][idx]; if (sampler == prev) return;
if (sampler) wined3d_sampler_incref(sampler); - device->state.sampler[type][idx] = sampler; + state->sampler[type][idx] = sampler; wined3d_cs_emit_set_sampler(device->cs, type, idx, sampler); if (prev) wined3d_sampler_decref(prev); @@ -2106,13 +2158,15 @@ void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx static struct wined3d_sampler *wined3d_device_get_sampler(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { + const struct wined3d_state *state = &device->state; + if (idx >= MAX_SAMPLER_OBJECTS) { WARN("Invalid sampler index %u.\n", idx); return NULL; }
- return device->state.sampler[shader_type][idx]; + return state->sampler[shader_type][idx]; }
struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3d_device *device, UINT idx) @@ -2125,12 +2179,13 @@ struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3 static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_b[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->vs_consts_b[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2143,12 +2198,13 @@ static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_i[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->vs_consts_i[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2161,12 +2217,13 @@ static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, static void wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.vs_consts_f[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->vs_consts_f[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2178,7 +2235,8 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_PIXEL]; + struct wined3d_state *state = &device->state; + struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_PIXEL];
TRACE("device %p, shader %p.\n", device, shader);
@@ -2187,7 +2245,7 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_PIXEL] = shader; + state->shader[WINED3D_SHADER_TYPE_PIXEL] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_PIXEL, shader); if (prev) wined3d_shader_decref(prev); @@ -2195,9 +2253,11 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_PIXEL]; + return state->shader[WINED3D_SHADER_TYPE_PIXEL]; }
void CDECL wined3d_device_set_ps_resource_view(struct wined3d_device *device, @@ -2233,12 +2293,13 @@ struct wined3d_sampler * CDECL wined3d_device_get_ps_sampler(const struct wined3 static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_b[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->ps_consts_b[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2251,12 +2312,13 @@ static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_i[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->ps_consts_i[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2269,12 +2331,13 @@ static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, static void wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { + struct wined3d_state *state = &device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
- memcpy(&device->state.ps_consts_f[start_idx], constants, count * sizeof(*constants)); + memcpy(&state->ps_consts_f[start_idx], constants, count * sizeof(*constants)); if (TRACE_ON(d3d)) { for (i = 0; i < count; ++i) @@ -2286,16 +2349,17 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader) { + struct wined3d_state *state = &device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_HULL]; + prev = state->shader[WINED3D_SHADER_TYPE_HULL]; if (shader == prev) return; if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_HULL] = shader; + state->shader[WINED3D_SHADER_TYPE_HULL] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_HULL, shader); if (prev) wined3d_shader_decref(prev); @@ -2303,9 +2367,11 @@ void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_HULL]; + return state->shader[WINED3D_SHADER_TYPE_HULL]; }
void CDECL wined3d_device_set_hs_resource_view(struct wined3d_device *device, @@ -2341,16 +2407,17 @@ struct wined3d_sampler * CDECL wined3d_device_get_hs_sampler(const struct wined3
void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader) { + struct wined3d_state *state = &device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_DOMAIN]; + prev = state->shader[WINED3D_SHADER_TYPE_DOMAIN]; if (shader == prev) return; if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_DOMAIN] = shader; + state->shader[WINED3D_SHADER_TYPE_DOMAIN] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_DOMAIN, shader); if (prev) wined3d_shader_decref(prev); @@ -2358,9 +2425,11 @@ void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_DOMAIN]; + return state->shader[WINED3D_SHADER_TYPE_DOMAIN]; }
void CDECL wined3d_device_set_ds_resource_view(struct wined3d_device *device, @@ -2396,7 +2465,8 @@ struct wined3d_sampler * CDECL wined3d_device_get_ds_sampler(const struct wined3
void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_shader *prev = device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY]; + struct wined3d_state *state = &device->state; + struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
TRACE("device %p, shader %p.\n", device, shader);
@@ -2404,7 +2474,7 @@ void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, str return; if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader; + state->shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_GEOMETRY, shader); if (prev) wined3d_shader_decref(prev); @@ -2412,9 +2482,11 @@ void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, str
struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY]; + return state->shader[WINED3D_SHADER_TYPE_GEOMETRY]; }
void CDECL wined3d_device_set_gs_resource_view(struct wined3d_device *device, @@ -2449,16 +2521,17 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader) { + struct wined3d_state *state = &device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader);
- prev = device->state.shader[WINED3D_SHADER_TYPE_COMPUTE]; + prev = state->shader[WINED3D_SHADER_TYPE_COMPUTE]; if (shader == prev) return; if (shader) wined3d_shader_incref(shader); - device->state.shader[WINED3D_SHADER_TYPE_COMPUTE] = shader; + state->shader[WINED3D_SHADER_TYPE_COMPUTE] = shader; wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_COMPUTE, shader); if (prev) wined3d_shader_decref(prev); @@ -2466,9 +2539,11 @@ void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, stru
struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.shader[WINED3D_SHADER_TYPE_COMPUTE]; + return state->shader[WINED3D_SHADER_TYPE_COMPUTE]; }
void CDECL wined3d_device_set_cs_resource_view(struct wined3d_device *device, @@ -2506,6 +2581,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav, unsigned int initial_count) { + struct wined3d_state *state = &device->state; struct wined3d_unordered_access_view *prev;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS) @@ -2514,13 +2590,13 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev return; }
- prev = device->state.unordered_access_view[pipeline][idx]; + prev = state->unordered_access_view[pipeline][idx]; if (uav == prev && initial_count == ~0u) return;
if (uav) wined3d_unordered_access_view_incref(uav); - device->state.unordered_access_view[pipeline][idx] = uav; + state->unordered_access_view[pipeline][idx] = uav; wined3d_cs_emit_set_unordered_access_view(device->cs, pipeline, idx, uav, initial_count); if (prev) wined3d_unordered_access_view_decref(prev); @@ -2529,13 +2605,15 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev static struct wined3d_unordered_access_view *wined3d_device_get_pipeline_unordered_access_view( const struct wined3d_device *device, enum wined3d_pipeline pipeline, unsigned int idx) { + const struct wined3d_state *state = &device->state; + if (idx >= MAX_UNORDERED_ACCESS_VIEWS) { WARN("Invalid UAV index %u.\n", idx); return NULL; }
- return device->state.unordered_access_view[pipeline][idx]; + return state->unordered_access_view[pipeline][idx]; }
void CDECL wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx, @@ -3531,6 +3609,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, static void wined3d_device_set_texture_stage_state(struct wined3d_device *device, UINT stage, enum wined3d_texture_stage_state texture_state, DWORD value) { + struct wined3d_state *state = &device->state; const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, stage %u, texture_state %s, value %#x.\n", @@ -3543,13 +3622,13 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device return; }
- if (value == device->state.texture_states[stage][texture_state]) + if (value == state->texture_states[stage][texture_state]) { TRACE("Application is setting the old value over, nothing to do.\n"); return; }
- device->state.texture_states[stage][texture_state] = value; + state->texture_states[stage][texture_state] = value;
wined3d_cs_emit_set_texture_state(device->cs, stage, texture_state, value); } @@ -3557,18 +3636,19 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device static void wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture) { + struct wined3d_state *state = &device->state; struct wined3d_texture *prev;
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
/* Windows accepts overflowing this array... we do not. */ - if (stage >= ARRAY_SIZE(device->state.textures)) + if (stage >= ARRAY_SIZE(state->textures)) { WARN("Ignoring invalid stage %u.\n", stage); return; }
- prev = device->state.textures[stage]; + prev = state->textures[stage]; TRACE("Previous texture %p.\n", prev);
if (texture == prev) @@ -3578,7 +3658,7 @@ static void wined3d_device_set_texture(struct wined3d_device *device, }
TRACE("Setting new texture to %p.\n", texture); - device->state.textures[stage] = texture; + state->textures[stage] = texture;
if (texture) wined3d_texture_incref(texture); @@ -4047,6 +4127,8 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device) HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { + struct wined3d_state *state = &device->state; + TRACE("device %p, rect_count %u, rects %p, flags %#x, color %s, depth %.8e, stencil %u.\n", device, rect_count, rects, flags, debug_color(color), depth, stencil);
@@ -4058,7 +4140,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL)) { - struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil; + struct wined3d_rendertarget_view *ds = state->fb.depth_stencil; if (!ds) { WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n"); @@ -4067,8 +4149,8 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou } else if (flags & WINED3DCLEAR_TARGET) { - if (ds->width < device->state.fb.render_targets[0]->width - || ds->height < device->state.fb.render_targets[0]->height) + if (ds->width < state->fb.render_targets[0]->width + || ds->height < state->fb.render_targets[0]->height) { WARN("Silently ignoring depth and target clear with mismatching sizes\n"); return WINED3D_OK; @@ -4084,18 +4166,19 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou void CDECL wined3d_device_set_predication(struct wined3d_device *device, struct wined3d_query *predicate, BOOL value) { + struct wined3d_state *state = &device->state; struct wined3d_query *prev;
TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value);
- prev = device->state.predicate; + prev = state->predicate; if (predicate) { FIXME("Predicated rendering not implemented.\n"); wined3d_query_incref(predicate); } - device->state.predicate = predicate; - device->state.predicate_value = value; + state->predicate = predicate; + state->predicate_value = value; wined3d_cs_emit_set_predication(device->cs, predicate, value); if (prev) wined3d_query_decref(prev); @@ -4103,11 +4186,13 @@ void CDECL wined3d_device_set_predication(struct wined3d_device *device,
struct wined3d_query * CDECL wined3d_device_get_predication(struct wined3d_device *device, BOOL *value) { + struct wined3d_state *state = &device->state; + TRACE("device %p, value %p.\n", device, value);
if (value) - *value = device->state.predicate_value; - return device->state.predicate; + *value = state->predicate_value; + return state->predicate; }
void CDECL wined3d_device_dispatch_compute(struct wined3d_device *device, @@ -4130,32 +4215,38 @@ void CDECL wined3d_device_dispatch_compute_indirect(struct wined3d_device *devic void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count) { + struct wined3d_state *state = &device->state; + TRACE("device %p, primitive_type %s, patch_vertex_count %u.\n", device, debug_d3dprimitivetype(primitive_type), patch_vertex_count);
- device->state.primitive_type = primitive_type; - device->state.patch_vertex_count = patch_vertex_count; + state->primitive_type = primitive_type; + state->patch_vertex_count = patch_vertex_count; }
void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device, enum wined3d_primitive_type *primitive_type, unsigned int *patch_vertex_count) { + const struct wined3d_state *state = &device->state; + TRACE("device %p, primitive_type %p, patch_vertex_count %p.\n", device, primitive_type, patch_vertex_count);
- *primitive_type = device->state.primitive_type; + *primitive_type = state->primitive_type; if (patch_vertex_count) - *patch_vertex_count = device->state.patch_vertex_count; + *patch_vertex_count = state->patch_vertex_count;
TRACE("Returning %s.\n", debug_d3dprimitivetype(*primitive_type)); }
HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count) { + struct wined3d_state *state = &device->state; + TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, - device->state.patch_vertex_count, 0, start_vertex, vertex_count, 0, 0, false); + wined3d_cs_emit_draw(device->cs, state->primitive_type, + state->patch_vertex_count, 0, start_vertex, vertex_count, 0, 0, false);
return WINED3D_OK; } @@ -4163,27 +4254,33 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device, UINT start_vertex, UINT vertex_count, UINT start_instance, UINT instance_count) { + struct wined3d_state *state = &device->state; + TRACE("device %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n", device, start_vertex, vertex_count, start_instance, instance_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count, + wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count, 0, start_vertex, vertex_count, start_instance, instance_count, false); }
void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { + struct wined3d_state *state = &device->state; + TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
- wined3d_cs_emit_draw_indirect(device->cs, device->state.primitive_type, - device->state.patch_vertex_count, buffer, offset, false); + wined3d_cs_emit_draw_indirect(device->cs, state->primitive_type, + state->patch_vertex_count, buffer, offset, false); }
HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count) { + struct wined3d_state *state = &device->state; + TRACE("device %p, start_idx %u, index_count %u.\n", device, start_idx, index_count);
- if (!device->state.index_buffer) + if (!state->index_buffer) { /* D3D9 returns D3DERR_INVALIDCALL when DrawIndexedPrimitive is called * without an index buffer set. (The first time at least...) @@ -4193,8 +4290,8 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic return WINED3DERR_INVALIDCALL; }
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count, - device->state.base_vertex_index, start_idx, index_count, 0, 0, true); + wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count, + state->base_vertex_index, start_idx, index_count, 0, 0, true);
return WINED3D_OK; } @@ -4202,20 +4299,24 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device *device, UINT start_idx, UINT index_count, UINT start_instance, UINT instance_count) { + struct wined3d_state *state = &device->state; + TRACE("device %p, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n", device, start_idx, index_count, start_instance, instance_count);
- wined3d_cs_emit_draw(device->cs, device->state.primitive_type, device->state.patch_vertex_count, - device->state.base_vertex_index, start_idx, index_count, start_instance, instance_count, true); + wined3d_cs_emit_draw(device->cs, state->primitive_type, state->patch_vertex_count, + state->base_vertex_index, start_idx, index_count, start_instance, instance_count, true); }
void CDECL wined3d_device_draw_indexed_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { + struct wined3d_state *state = &device->state; + TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
- wined3d_cs_emit_draw_indirect(device->cs, device->state.primitive_type, - device->state.patch_vertex_count, buffer, offset, true); + wined3d_cs_emit_draw_indirect(device->cs, state->primitive_type, + state->patch_vertex_count, buffer, offset, true); }
HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device, @@ -4418,8 +4519,8 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device if (wined3d_state_uses_depth_buffer(state) || (state->depth_stencil_state && state->depth_stencil_state->desc.stencil)) { - struct wined3d_rendertarget_view *rt = device->state.fb.render_targets[0]; - struct wined3d_rendertarget_view *ds = device->state.fb.depth_stencil; + struct wined3d_rendertarget_view *rt = state->fb.render_targets[0]; + struct wined3d_rendertarget_view *ds = state->fb.depth_stencil;
if (ds && rt && (ds->width < rt->width || ds->height < rt->height)) { @@ -4956,6 +5057,7 @@ void CDECL wined3d_device_clear_unordered_access_view_uint(struct wined3d_device struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device, unsigned int view_idx) { + const struct wined3d_state *state = &device->state; unsigned int max_rt_count;
TRACE("device %p, view_idx %u.\n", device, view_idx); @@ -4967,19 +5069,23 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(co return NULL; }
- return device->state.fb.render_targets[view_idx]; + return state->fb.render_targets[view_idx]; }
struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(const struct wined3d_device *device) { + const struct wined3d_state *state = &device->state; + TRACE("device %p.\n", device);
- return device->state.fb.depth_stencil; + return state->fb.depth_stencil; }
static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, const struct wined3d_rendertarget_view *view, BOOL dsv) { + struct wined3d_state *state = &device->state; + if (view && wined3d_is_rtv_srv_bound(view)) { const struct wined3d_resource *resource = view->resource; @@ -4990,7 +5096,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device,
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j) - if ((srv = device->state.shader_resource_view[i][j]) && srv->resource == resource + if ((srv = state->shader_resource_view[i][j]) && srv->resource == resource && ((!dsv && wined3d_is_srv_rtv_bound(srv)) || (dsv && wined3d_dsv_srv_conflict(view, srv->format)))) wined3d_device_set_shader_resource_view(device, i, j, NULL); @@ -5000,6 +5106,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device, unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport) { + struct wined3d_state *state = &device->state; struct wined3d_rendertarget_view *prev; unsigned int max_rt_count;
@@ -5040,7 +5147,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device wined3d_cs_emit_set_scissor_rects(device->cs, 1, state->scissor_rects); }
- prev = device->state.fb.render_targets[view_idx]; + prev = state->fb.render_targets[view_idx]; if (view == prev) return WINED3D_OK;
@@ -5049,7 +5156,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device wined3d_rendertarget_view_incref(view); wined3d_rtv_bind_count_inc(view); } - device->state.fb.render_targets[view_idx] = view; + state->fb.render_targets[view_idx] = view; wined3d_cs_emit_set_rendertarget_view(device->cs, view_idx, view); /* Release after the assignment, to prevent device_resource_released() * from seeing the surface as still in use. */ @@ -5067,6 +5174,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device, struct wined3d_rendertarget_view *view) { + struct wined3d_state *state = &device->state; struct wined3d_rendertarget_view *prev;
TRACE("device %p, view %p.\n", device, view); @@ -5078,14 +5186,14 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic return WINED3DERR_INVALIDCALL; }
- prev = device->state.fb.depth_stencil; + prev = state->fb.depth_stencil; if (prev == view) { TRACE("Trying to do a NOP SetRenderTarget operation.\n"); return WINED3D_OK; }
- if ((device->state.fb.depth_stencil = view)) + if ((state->fb.depth_stencil = view)) wined3d_rendertarget_view_incref(view); wined3d_cs_emit_set_depth_stencil_view(device->cs, view); if (prev) @@ -5341,6 +5449,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; struct wined3d_swapchain_state *swapchain_state; struct wined3d_swapchain_desc *current_desc; + struct wined3d_state *state = &device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_swapchain *swapchain; @@ -5374,7 +5483,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, wined3d_texture_decref(device->cursor_texture); device->cursor_texture = NULL; } - state_unbind_resources(&device->state); + state_unbind_resources(state); }
for (i = 0; i < d3d_info->limits.max_rt_count; ++i) @@ -5584,7 +5693,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, { TRACE("Resetting state.\n"); wined3d_cs_emit_reset_state(device->cs); - state_cleanup(&device->state); + state_cleanup(state);
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry) { @@ -5594,8 +5703,8 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->adapter->adapter_ops->adapter_uninit_3d(device);
- memset(&device->state, 0, sizeof(device->state)); - state_init(&device->state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + memset(state, 0, sizeof(*state)); + state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device_init_swapchain_state(device, swapchain); if (wined3d_settings.logo) @@ -5695,18 +5804,19 @@ static void device_resource_remove(struct wined3d_device *device, struct wined3d void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) { enum wined3d_resource_type type = resource->type; + struct wined3d_state *state = &device->state; struct wined3d_rendertarget_view *rtv; unsigned int i;
TRACE("device %p, resource %p, type %s.\n", device, resource, debug_d3dresourcetype(type));
- for (i = 0; i < ARRAY_SIZE(device->state.fb.render_targets); ++i) + for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i) { - if ((rtv = device->state.fb.render_targets[i]) && rtv->resource == resource) + if ((rtv = state->fb.render_targets[i]) && rtv->resource == resource) ERR("Resource %p is still in use as render target %u.\n", resource, i); }
- if ((rtv = device->state.fb.depth_stencil) && rtv->resource == resource) + if ((rtv = state->fb.depth_stencil) && rtv->resource == resource) ERR("Resource %p is still in use as depth/stencil buffer.\n", resource);
switch (type) @@ -5716,10 +5826,10 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso case WINED3D_RTYPE_TEXTURE_3D: for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) { - if (&device->state.textures[i]->resource == resource) + if (&state->textures[i]->resource == resource) { ERR("Texture resource %p is still in use, stage %u.\n", resource, i); - device->state.textures[i] = NULL; + state->textures[i] = NULL; } } break; @@ -5727,17 +5837,17 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso case WINED3D_RTYPE_BUFFER: for (i = 0; i < WINED3D_MAX_STREAMS; ++i) { - if (&device->state.streams[i].buffer->resource == resource) + if (&state->streams[i].buffer->resource == resource) { ERR("Buffer resource %p is still in use, stream %u.\n", resource, i); - device->state.streams[i].buffer = NULL; + state->streams[i].buffer = NULL; } }
- if (&device->state.index_buffer->resource == resource) + if (&state->index_buffer->resource == resource) { ERR("Buffer resource %p is still in use as index buffer.\n", resource); - device->state.index_buffer = NULL; + state->index_buffer = NULL; } break;
@@ -5852,6 +5962,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx]; const struct wined3d_fragment_pipe_ops *fragment_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline; + struct wined3d_state *state = &device->state; unsigned int i; HRESULT hr;
@@ -5902,14 +6013,14 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
- state_init(&device->state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->max_frame_latency = 3;
if (!(device->cs = wined3d_cs_create(device))) { WARN("Failed to create command stream.\n"); - state_cleanup(&device->state); + state_cleanup(state); hr = E_FAIL; goto err; } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index f4f929db2ca..40b25c6f229 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1602,6 +1602,7 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) if (texture->lod != lod) { struct wined3d_device *device = resource->device; + struct wined3d_state *state = &device->state;
wined3d_resource_wait_idle(resource); texture->lod = lod; @@ -1610,7 +1611,7 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) wined3d_texture_gl(texture)->texture_srgb.base_level = ~0u; if (resource->bind_count) wined3d_cs_emit_set_sampler_state(device->cs, texture->sampler, WINED3D_SAMP_MAX_MIP_LEVEL, - device->state.sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]); + state->sampler_states[texture->sampler][WINED3D_SAMP_MAX_MIP_LEVEL]); }
return old;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/cs.c | 10 +- dlls/wined3d/device.c | 176 +++++++++++++++++---------------- dlls/wined3d/texture.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 100 insertions(+), 90 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 0385b8f4693..4ee3d97b7fc 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -677,7 +677,7 @@ static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data) void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; const struct wined3d_viewport *vp = &state->viewports[0]; struct wined3d_rendertarget_view *view; struct wined3d_cs_clear *op; @@ -886,7 +886,7 @@ static void acquire_compute_pipeline_resources(const struct wined3d_state *state void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -904,7 +904,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs, struct wined3d_buffer *buffer, unsigned int offset) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -1045,7 +1045,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, enum wined3d_primitive_type pri unsigned int index_count, unsigned int start_instance, unsigned int instance_count, bool indexed) { const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info; - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -1069,7 +1069,7 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, enum wined3d_primitive unsigned int patch_vertex_count, struct wined3d_buffer *buffer, unsigned int offset, bool indexed) { const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info; - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e44ca3ddb63..865d7f83098 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -251,6 +251,8 @@ void wined3d_device_cleanup(struct wined3d_device *device) wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL); wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
+ heap_free(device->state); + device->state = NULL; wined3d_decref(device->wined3d); device->wined3d = NULL; } @@ -1083,7 +1085,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str { static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f}; const struct wined3d_swapchain_desc *swapchain_desc; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; DWORD clear_flags = 0; unsigned int i; HRESULT hr; @@ -1188,7 +1190,7 @@ static void device_free_depth_stencil_state(struct wine_rb_entry *entry, void *c
void wined3d_device_uninit_3d(struct wined3d_device *device) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_texture *texture; @@ -1300,7 +1302,7 @@ UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer, UINT offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_output *stream; struct wined3d_buffer *prev_buffer;
@@ -1327,7 +1329,7 @@ void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_device *device, UINT idx, UINT *offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, idx %u, offset %p.\n", device, idx, offset);
@@ -1345,7 +1347,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_de HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_state *stream; struct wined3d_buffer *prev_buffer;
@@ -1389,7 +1391,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; const struct wined3d_stream_state *stream;
TRACE("device %p, stream_idx %u, buffer %p, offset %p, stride %p.\n", @@ -1412,7 +1414,7 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi
static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_state *stream; UINT old_flags, old_freq;
@@ -1431,7 +1433,7 @@ static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, static void wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(d3dts), matrix); @@ -1459,7 +1461,7 @@ static void wined3d_device_set_transform(struct wined3d_device *device, static void wined3d_device_get_transform(const struct wined3d_device *device, enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
@@ -1476,7 +1478,7 @@ static void wined3d_device_get_transform(const struct wined3d_device *device, static void wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const struct wined3d_light *light) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_light_info *object = NULL; float rho;
@@ -1576,7 +1578,7 @@ static void wined3d_device_set_light(struct wined3d_device *device,
static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_light_info *light_info;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable); @@ -1601,7 +1603,7 @@ static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
@@ -1648,7 +1650,7 @@ HRESULT CDECL wined3d_device_get_clip_status(const struct wined3d_device *device
static void wined3d_device_set_material(struct wined3d_device *device, const struct wined3d_material *material) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, material %p.\n", device, material);
@@ -1659,7 +1661,7 @@ static void wined3d_device_set_material(struct wined3d_device *device, const str void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; enum wined3d_format_id prev_format; struct wined3d_buffer *prev_buffer; unsigned int prev_offset; @@ -1687,7 +1689,7 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device, enum wined3d_format_id *format, unsigned int *offset) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, format %p, offset %p.\n", device, format, offset);
@@ -1699,7 +1701,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, base_index %d.\n", device, base_index);
@@ -1709,7 +1711,7 @@ void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, I void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned int viewport_count, const struct wined3d_viewport *viewports) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, viewport_count %u, viewports %p.\n", device, viewport_count, viewports); @@ -1732,7 +1734,7 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count, struct wined3d_viewport *viewports) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int count;
TRACE("device %p, viewport_count %p, viewports %p.\n", device, viewport_count, viewports); @@ -1746,7 +1748,7 @@ void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, uns
static void resolve_depth_buffer(struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *src_view; struct wined3d_resource *dst_resource; struct wined3d_texture *dst_texture; @@ -1766,7 +1768,7 @@ static void resolve_depth_buffer(struct wined3d_device *device) void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_blend_state *prev;
TRACE("device %p, blend_state %p, blend_factor %s, sample_mask %#x.\n", @@ -1790,7 +1792,7 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct wined3d_device *device, struct wined3d_color *blend_factor, unsigned int *sample_mask) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, blend_factor %p, sample_mask %p.\n", device, blend_factor, sample_mask);
@@ -1802,7 +1804,7 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_depth_stencil_state *prev;
TRACE("device %p, depth_stencil_state %p, stencil_ref %u.\n", device, depth_stencil_state, stencil_ref); @@ -1822,7 +1824,7 @@ void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device,
struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_state(const struct wined3d_device *device, unsigned int *stencil_ref) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, stencil_ref %p.\n", device, stencil_ref);
@@ -1833,7 +1835,7 @@ struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_stat void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device, struct wined3d_rasterizer_state *rasterizer_state) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rasterizer_state *prev;
TRACE("device %p, rasterizer_state %p.\n", device, rasterizer_state); @@ -1852,7 +1854,7 @@ void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device,
struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(struct wined3d_device *device) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -1862,7 +1864,7 @@ struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(stru void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state render_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, render_state %s (%#x), value %#x.\n", device, debug_d3drenderstate(render_state), render_state, value);
@@ -1889,7 +1891,7 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state render_state) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, render_state %s (%#x).\n", device, debug_d3drenderstate(render_state), render_state);
@@ -1899,7 +1901,7 @@ DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, static void wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state sampler_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, sampler_idx %u, sampler_state %s, value %#x.\n", device, sampler_idx, debug_d3dsamplerstate(sampler_state), value); @@ -1917,7 +1919,7 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device, void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count, const RECT *rects) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects); @@ -1945,7 +1947,7 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig
void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count, RECT *rects) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int count;
TRACE("device %p, rect_count %p, rects %p.\n", device, rect_count, rects); @@ -1960,7 +1962,7 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_vertex_declaration *prev = state->vertex_declaration;
TRACE("device %p, declaration %p.\n", device, declaration); @@ -1978,7 +1980,7 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -1987,7 +1989,7 @@ struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_VERTEX];
TRACE("device %p, shader %p.\n", device, shader); @@ -2005,7 +2007,7 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2015,7 +2017,7 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_buffer *prev;
TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer); @@ -2041,7 +2043,7 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, shader_type %#x, idx %u.\n", device, shader_type, idx);
@@ -2057,7 +2059,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wi static void wined3d_device_set_shader_resource_view(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; const struct wined3d_rendertarget_view *dsv; struct wined3d_shader_resource_view *prev;
@@ -2105,7 +2107,7 @@ void CDECL wined3d_device_set_vs_resource_view(struct wined3d_device *device, static struct wined3d_shader_resource_view *wined3d_device_get_shader_resource_view( const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_SHADER_RESOURCE_VIEWS) { @@ -2127,7 +2129,7 @@ struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view( static void wined3d_device_set_sampler(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_sampler *prev;
if (idx >= MAX_SAMPLER_OBJECTS) @@ -2158,7 +2160,7 @@ void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx static struct wined3d_sampler *wined3d_device_get_sampler(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_SAMPLER_OBJECTS) { @@ -2179,7 +2181,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3 static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2198,7 +2200,7 @@ static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2217,7 +2219,7 @@ static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, static void wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2235,7 +2237,7 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_PIXEL];
TRACE("device %p, shader %p.\n", device, shader); @@ -2253,7 +2255,7 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2293,7 +2295,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_ps_sampler(const struct wined3 static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2312,7 +2314,7 @@ static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2331,7 +2333,7 @@ static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, static void wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2349,7 +2351,7 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2367,7 +2369,7 @@ void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2407,7 +2409,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_hs_sampler(const struct wined3
void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2425,7 +2427,7 @@ void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2465,7 +2467,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_ds_sampler(const struct wined3
void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
TRACE("device %p, shader %p.\n", device, shader); @@ -2482,7 +2484,7 @@ void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, str
struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2521,7 +2523,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2539,7 +2541,7 @@ void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, stru
struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2581,7 +2583,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav, unsigned int initial_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_unordered_access_view *prev;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS) @@ -2605,7 +2607,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev static struct wined3d_unordered_access_view *wined3d_device_get_pipeline_unordered_access_view( const struct wined3d_device *device, enum wined3d_pipeline pipeline, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS) { @@ -3214,7 +3216,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO enum wined3d_material_color_source diffuse_source, specular_source, ambient_source, emissive_source; const struct wined3d_color *material_specular_state_colour; struct wined3d_matrix mat, proj_mat, view_mat, world_mat; - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; const struct wined3d_format *output_colour_format; static const struct wined3d_color black; struct wined3d_map_desc map_desc; @@ -3532,7 +3534,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer, const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_info stream_info; struct wined3d_resource *resource; struct wined3d_box box = {0}; @@ -3609,7 +3611,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, static void wined3d_device_set_texture_stage_state(struct wined3d_device *device, UINT stage, enum wined3d_texture_stage_state texture_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, stage %u, texture_state %s, value %#x.\n", @@ -3636,7 +3638,7 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device static void wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_texture *prev;
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture); @@ -4127,7 +4129,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device) HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, rect_count %u, rects %p, flags %#x, color %s, depth %.8e, stencil %u.\n", device, rect_count, rects, flags, debug_color(color), depth, stencil); @@ -4166,7 +4168,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou void CDECL wined3d_device_set_predication(struct wined3d_device *device, struct wined3d_query *predicate, BOOL value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_query *prev;
TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value); @@ -4186,7 +4188,7 @@ void CDECL wined3d_device_set_predication(struct wined3d_device *device,
struct wined3d_query * CDECL wined3d_device_get_predication(struct wined3d_device *device, BOOL *value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, value %p.\n", device, value);
@@ -4215,7 +4217,7 @@ void CDECL wined3d_device_dispatch_compute_indirect(struct wined3d_device *devic void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, primitive_type %s, patch_vertex_count %u.\n", device, debug_d3dprimitivetype(primitive_type), patch_vertex_count); @@ -4227,7 +4229,7 @@ void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device, enum wined3d_primitive_type *primitive_type, unsigned int *patch_vertex_count) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, primitive_type %p, patch_vertex_count %p.\n", device, primitive_type, patch_vertex_count); @@ -4241,7 +4243,7 @@ void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device
HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
@@ -4254,7 +4256,7 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device, UINT start_vertex, UINT vertex_count, UINT start_instance, UINT instance_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n", device, start_vertex, vertex_count, start_instance, instance_count); @@ -4266,7 +4268,7 @@ void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
@@ -4276,7 +4278,7 @@ void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_devic
HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_idx %u, index_count %u.\n", device, start_idx, index_count);
@@ -4299,7 +4301,7 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device *device, UINT start_idx, UINT index_count, UINT start_instance, UINT instance_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n", device, start_idx, index_count, start_instance, instance_count); @@ -4311,7 +4313,7 @@ void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device void CDECL wined3d_device_draw_indexed_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
@@ -4476,7 +4478,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; struct wined3d_texture *texture; DWORD i;
@@ -5057,7 +5059,7 @@ void CDECL wined3d_device_clear_unordered_access_view_uint(struct wined3d_device struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device, unsigned int view_idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int max_rt_count;
TRACE("device %p, view_idx %u.\n", device, view_idx); @@ -5074,7 +5076,7 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(co
struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -5084,7 +5086,7 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(c static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, const struct wined3d_rendertarget_view *view, BOOL dsv) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
if (view && wined3d_is_rtv_srv_bound(view)) { @@ -5106,7 +5108,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device, unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *prev; unsigned int max_rt_count;
@@ -5131,7 +5133,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device * primary stateblock. */ if (!view_idx && set_viewport) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
state->viewports[0].x = 0; state->viewports[0].y = 0; @@ -5174,7 +5176,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device, struct wined3d_rendertarget_view *view) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *prev;
TRACE("device %p, view %p.\n", device, view); @@ -5449,7 +5451,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; struct wined3d_swapchain_state *swapchain_state; struct wined3d_swapchain_desc *current_desc; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_swapchain *swapchain; @@ -5804,7 +5806,7 @@ static void device_resource_remove(struct wined3d_device *device, struct wined3d void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) { enum wined3d_resource_type type = resource->type; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *rtv; unsigned int i;
@@ -5962,7 +5964,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx]; const struct wined3d_fragment_pipe_ops *fragment_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline; - struct wined3d_state *state = &device->state; + struct wined3d_state *state; unsigned int i; HRESULT hr;
@@ -6013,8 +6015,15 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
+ if (!(state = heap_alloc(sizeof(*state)))) + { + hr = E_OUTOFMEMORY; + goto err; + } + memset(state, 0, sizeof(*state)); state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ device->state = state; device->max_frame_latency = 3;
if (!(device->cs = wined3d_cs_create(device))) @@ -6028,6 +6037,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return WINED3D_OK;
err: + if (state) heap_free(state); for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { heap_free(device->multistate_funcs[i]); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 40b25c6f229..42316b4d85f 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1602,7 +1602,7 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) if (texture->lod != lod) { struct wined3d_device *device = resource->device; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
wined3d_resource_wait_idle(resource); texture->lod = lod; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2a75ab5d43d..56d3ef8fea2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3776,7 +3776,7 @@ struct wined3d_device
enum wined3d_feature_level feature_level;
- struct wined3d_state state; + struct wined3d_state *state;
/* Internal use fields */ struct wined3d_device_creation_parameters create_parms;
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -6013,8 +6015,15 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
- if (!(state = heap_alloc(sizeof(*state))))
- {
hr = E_OUTOFMEMORY;
goto err;
- }
- memset(state, 0, sizeof(*state));
That should probably use heap_alloc_zero().
On 2/18/21 3:06 PM, Henri Verbeet wrote:
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -6013,8 +6015,15 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
- if (!(state = heap_alloc(sizeof(*state))))
- {
hr = E_OUTOFMEMORY;
goto err;
- }
- memset(state, 0, sizeof(*state));
That should probably use heap_alloc_zero().
Yeah, it was initially like that, then I thought the next change replacing memset + state_init with state_reset would also be apply there.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/cs.c | 5 ++--- dlls/wined3d/device.c | 9 +++------ dlls/wined3d/stateblock.c | 8 +++++++- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 4ee3d97b7fc..66288014f30 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2074,8 +2074,7 @@ static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data) struct wined3d_adapter *adapter = cs->device->adapter;
state_cleanup(&cs->state); - memset(&cs->state, 0, sizeof(cs->state)); - state_init(&cs->state, &adapter->d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); + state_reset(&cs->state, &adapter->d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); }
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) @@ -2973,7 +2972,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) cs->device = device; cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
- state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); + state_reset(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
cs->data_size = WINED3D_INITIAL_CS_SIZE; if (!(cs->data = heap_alloc(cs->data_size))) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 865d7f83098..6a9eee152a3 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1265,8 +1265,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device) heap_free(device->swapchains); device->swapchains = NULL;
- memset(state, 0, sizeof(*state)); - state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); }
/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw @@ -5705,8 +5704,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->adapter->adapter_ops->adapter_uninit_3d(device);
- memset(state, 0, sizeof(*state)); - state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device_init_swapchain_state(device, swapchain); if (wined3d_settings.logo) @@ -6020,8 +6018,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined hr = E_OUTOFMEMORY; goto err; } - memset(state, 0, sizeof(*state)); - state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state; device->max_frame_latency = 3; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 46588fa4246..b23301a4758 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1854,7 +1854,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d state->streams[i].frequency = 1; }
-void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +static void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) { unsigned int i;
@@ -1869,6 +1869,12 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_ state_init_default(state, d3d_info); }
+void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +{ + memset(&state->flags, 0, sizeof(struct wined3d_state) - FIELD_OFFSET(struct wined3d_state, flags)); + state_init(state, d3d_info, flags); +} + static void stateblock_state_init_default(struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 56d3ef8fea2..fe735c6e228 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4641,7 +4641,7 @@ HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD l const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN; -void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN; +void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN; void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
enum wined3d_cs_queue_id
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -2973,7 +2972,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) cs->device = device; cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
- state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
- state_reset(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
I think reset and initialisation are conceptually different, and this is clearly an initialisation. More, there's no need for the memset() that state_reset() does here, since "cs" was allocated with heap_alloc_zero().
@@ -6020,8 +6018,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined hr = E_OUTOFMEMORY; goto err; }
- memset(state, 0, sizeof(*state));
- state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
- state_reset(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
Likewise.
+void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +{
- memset(&state->flags, 0, sizeof(struct wined3d_state) - FIELD_OFFSET(struct wined3d_state, flags));
- state_init(state, d3d_info, flags);
+}
Do we expect to ever change the flags on state_reset()? The "flags" parameter seems redundant. The memset() effectively clears the entire structure, except if we were to ever move the "flags" field to a different place in the structure. Any reason to not simply use "memset(state, 0, sizeof(*state));"?
On 2/18/21 3:06 PM, Henri Verbeet wrote:
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -2973,7 +2972,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) cs->device = device; cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
- state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
- state_reset(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
I think reset and initialisation are conceptually different, and this is clearly an initialisation. More, there's no need for the memset() that state_reset() does here, since "cs" was allocated with heap_alloc_zero().
@@ -6020,8 +6018,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined hr = E_OUTOFMEMORY; goto err; }
- memset(state, 0, sizeof(*state));
- state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
- state_reset(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
Likewise.
+void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +{
- memset(&state->flags, 0, sizeof(struct wined3d_state) - FIELD_OFFSET(struct wined3d_state, flags));
- state_init(state, d3d_info, flags);
+}
Do we expect to ever change the flags on state_reset()? The "flags" parameter seems redundant. The memset() effectively clears the entire structure, except if we were to ever move the "flags" field to a different place in the structure. Any reason to not simply use "memset(state, 0, sizeof(*state));"?
So I wanted to avoid adding a new helper, but would having both state_init and state_reset make more sense?
On Thu, 18 Feb 2021 at 15:14, Rémi Bernon rbernon@codeweavers.com wrote:
On 2/18/21 3:06 PM, Henri Verbeet wrote:
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
+void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +{
- memset(&state->flags, 0, sizeof(struct wined3d_state) - FIELD_OFFSET(struct wined3d_state, flags));
- state_init(state, d3d_info, flags);
+}
Do we expect to ever change the flags on state_reset()? The "flags" parameter seems redundant. The memset() effectively clears the entire structure, except if we were to ever move the "flags" field to a different place in the structure. Any reason to not simply use "memset(state, 0, sizeof(*state));"?
So I wanted to avoid adding a new helper, but would having both state_init and state_reset make more sense?
I think so, yes.
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
static void wined3d_device_get_transform(const struct wined3d_device *device,
enum wined3d_transform_state state, struct wined3d_matrix *matrix)
enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix)
{
- TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
- TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
- *matrix = device->state.transforms[state];
- *matrix = device->state.transforms[transform_state];
}
That seems a bit gratuitous. In most of the cases you're changing here, there are very few actual uses of "device->state". E.g., in the code above, you may just as well simply do
- *matrix = device->state.transforms[state]; + *matrix = device->state->transforms[state];
in patch 3/4, and skip the changes in patches 1/2 and 2/2.
On 2/18/21 3:06 PM, Henri Verbeet wrote:
On Thu, 18 Feb 2021 at 13:31, Rémi Bernon rbernon@codeweavers.com wrote:
static void wined3d_device_get_transform(const struct wined3d_device *device,
enum wined3d_transform_state state, struct wined3d_matrix *matrix)
{enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix)
- TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
- TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
- *matrix = device->state.transforms[state];
- *matrix = device->state.transforms[transform_state]; }
That seems a bit gratuitous. In most of the cases you're changing here, there are very few actual uses of "device->state". E.g., in the code above, you may just as well simply do
- *matrix = device->state.transforms[state];
- *matrix = device->state->transforms[state];
in patch 3/4, and skip the changes in patches 1/2 and 2/2.
Sure, it just felt more natural to setup a common pattern for all the functions, so that the changes in the later patches are obviously trivial.