Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
So I dropped the previous first and last patches, as they weren't really needed after all, and so I got more room to send the full d3d11 state swap implementation.
Supersedes: 200145-200148
dlls/wined3d/device.c | 389 ++++++++++++++++++++++++++--------------- dlls/wined3d/texture.c | 3 +- 2 files changed, 247 insertions(+), 145 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1fd5f4b012e..44941539940 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,13 +1446,13 @@ 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); }
@@ -1464,12 +1474,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 +1574,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 +1609,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 +1646,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 +1665,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 +1685,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 +1719,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 +1730,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) @@ -1796,26 +1819,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,9 +1849,11 @@ 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, @@ -1880,6 +1908,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; unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects); @@ -1889,39 +1918,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 +1961,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 +1969,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 +1988,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 +1996,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 +2017,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 +2032,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 +2042,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 +2058,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 +2076,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 +2096,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 +2118,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 +2127,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 +2149,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 +2170,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 +2189,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 +2208,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 +2226,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 +2236,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 +2244,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 +2284,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 +2303,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 +2322,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 +2340,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 +2358,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 +2398,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 +2416,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 +2456,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 +2465,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 +2473,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 +2512,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 +2530,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 +2572,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 +2581,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 +2596,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, @@ -3557,18 +3626,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 +3648,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 +4117,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 +4130,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 +4139,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 +4156,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 +4176,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 +4205,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 +4244,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 +4280,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 +4289,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 +4509,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 +5047,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 +5059,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 +5086,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 +5096,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 +5137,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 +5146,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 +5164,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 +5176,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 +5439,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 +5473,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 +5683,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 +5693,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 +5794,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 +5816,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 +5827,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 +5952,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 +6003,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 | 187 +++++++++++++++++---------------- dlls/wined3d/texture.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 105 insertions(+), 96 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 44941539940..5aec094c854 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); @@ -1461,7 +1463,7 @@ static void wined3d_device_get_transform(const struct wined3d_device *device, { TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
- *matrix = device->state.transforms[state]; + *matrix = device->state->transforms[state]; }
/* Note lights are real special cases. Although the device caps state only @@ -1474,7 +1476,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;
@@ -1574,7 +1576,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); @@ -1599,7 +1601,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);
@@ -1646,7 +1648,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);
@@ -1657,7 +1659,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; @@ -1685,7 +1687,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);
@@ -1697,7 +1699,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);
@@ -1707,7 +1709,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); @@ -1730,7 +1732,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); @@ -1744,7 +1746,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; @@ -1764,7 +1766,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", @@ -1788,7 +1790,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);
@@ -1804,14 +1806,14 @@ void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device,
TRACE("device %p, state %p, stencil_ref %u.\n", device, state, stencil_ref);
- prev = device->state.depth_stencil_state; - if (prev == state && device->state.stencil_ref == stencil_ref) + prev = device->state->depth_stencil_state; + if (prev == state && device->state->stencil_ref == stencil_ref) return;
if (state) wined3d_depth_stencil_state_incref(state); - device->state.depth_stencil_state = state; - device->state.stencil_ref = stencil_ref; + device->state->depth_stencil_state = state; + device->state->stencil_ref = stencil_ref; wined3d_cs_emit_set_depth_stencil_state(device->cs, state, stencil_ref); if (prev) wined3d_depth_stencil_state_decref(prev); @@ -1819,7 +1821,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);
@@ -1830,7 +1832,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); @@ -1849,7 +1851,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);
@@ -1867,11 +1869,11 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device, return; }
- if (value == device->state.render_states[state]) + if (value == device->state->render_states[state]) TRACE("Application is setting the old value over, nothing to do.\n"); else { - device->state.render_states[state] = value; + device->state->render_states[state] = value; wined3d_cs_emit_set_render_state(device->cs, state, value); }
@@ -1886,7 +1888,7 @@ DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, { TRACE("device %p, state %s (%#x).\n", device, debug_d3drenderstate(state), state);
- return device->state.render_states[state]; + return device->state->render_states[state]; }
static void wined3d_device_set_sampler_state(struct wined3d_device *device, @@ -1895,20 +1897,20 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device, TRACE("device %p, sampler_idx %u, state %s, value %#x.\n", device, sampler_idx, debug_d3dsamplerstate(state), value);
- if (value == device->state.sampler_states[sampler_idx][state]) + if (value == device->state->sampler_states[sampler_idx][state]) { TRACE("Application is setting the old value over, nothing to do.\n"); return; }
- device->state.sampler_states[sampler_idx][state] = value; + device->state->sampler_states[sampler_idx][state] = value; wined3d_cs_emit_set_sampler_state(device->cs, sampler_idx, 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; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects); @@ -1936,7 +1938,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); @@ -1951,7 +1953,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); @@ -1969,7 +1971,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);
@@ -1978,7 +1980,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); @@ -1996,7 +1998,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);
@@ -2006,7 +2008,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); @@ -2032,7 +2034,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);
@@ -2048,7 +2050,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;
@@ -2096,7 +2098,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) { @@ -2118,7 +2120,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) @@ -2149,7 +2151,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) { @@ -2170,7 +2172,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", @@ -2189,7 +2191,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", @@ -2208,7 +2210,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", @@ -2226,7 +2228,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); @@ -2244,7 +2246,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);
@@ -2284,7 +2286,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", @@ -2303,7 +2305,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", @@ -2322,7 +2324,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", @@ -2340,7 +2342,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); @@ -2358,7 +2360,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);
@@ -2398,7 +2400,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); @@ -2416,7 +2418,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);
@@ -2456,7 +2458,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); @@ -2473,7 +2475,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);
@@ -2512,7 +2514,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); @@ -2530,7 +2532,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);
@@ -2572,7 +2574,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) @@ -2596,7 +2598,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) { @@ -3205,7 +3207,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; @@ -3523,7 +3525,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}; @@ -3612,13 +3614,13 @@ 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][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][state] = value;
wined3d_cs_emit_set_texture_state(device->cs, stage, state, value); } @@ -3626,7 +3628,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); @@ -4117,7 +4119,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); @@ -4156,7 +4158,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); @@ -4176,7 +4178,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);
@@ -4205,7 +4207,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); @@ -4217,7 +4219,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); @@ -4231,7 +4233,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);
@@ -4244,7 +4246,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); @@ -4256,7 +4258,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);
@@ -4266,7 +4268,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);
@@ -4289,7 +4291,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); @@ -4301,7 +4303,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);
@@ -4466,7 +4468,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;
@@ -5047,7 +5049,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); @@ -5064,7 +5066,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);
@@ -5074,7 +5076,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)) { @@ -5096,7 +5098,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;
@@ -5121,7 +5123,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; @@ -5164,7 +5166,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); @@ -5439,7 +5441,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; @@ -5794,7 +5796,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;
@@ -5952,7 +5954,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;
@@ -6003,8 +6005,14 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
+ if (!(state = heap_alloc_zero(sizeof(*state)))) + { + hr = E_OUTOFMEMORY; + goto err; + } 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))) @@ -6018,6 +6026,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;
And use them to create wined3d_device state.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/device.c | 9 ++++----- dlls/wined3d/stateblock.c | 23 +++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 3 +++ include/wine/wined3d.h | 4 ++++ 4 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5aec094c854..51f74ca1f64 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -251,7 +251,7 @@ 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); + wined3d_state_destroy(device->state); device->state = NULL; wined3d_decref(device->wined3d); device->wined3d = NULL; @@ -6005,12 +6005,11 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
- if (!(state = heap_alloc_zero(sizeof(*state)))) + if (FAILED(hr = wined3d_state_create(device, &state))) { - hr = E_OUTOFMEMORY; + ERR("Failed to create device state, hr %#x.\n", hr); goto err; } - state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state; device->max_frame_latency = 3; @@ -6026,7 +6025,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return WINED3D_OK;
err: - if (state) heap_free(state); + if (state) wined3d_state_destroy(state); for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { heap_free(device->multistate_funcs[i]); diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 46588fa4246..b6bcadaa051 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1869,6 +1869,29 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_ state_init_default(state, d3d_info); }
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state) +{ + struct wined3d_state *object; + + TRACE("device %p, state %p.\n", device, state); + + *state = NULL; + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + + *state = object; + return S_OK; +} + +void __cdecl wined3d_state_destroy(struct wined3d_state *state) +{ + TRACE("state %p.\n", state); + + state_cleanup(state); + heap_free(state); +} + static void stateblock_state_init_default(struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info) { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 44008119a8d..9d305bfc426 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -164,6 +164,9 @@ @ cdecl wined3d_device_update_texture(ptr ptr ptr) @ cdecl wined3d_device_validate_device(ptr ptr)
+@ cdecl wined3d_state_create(ptr ptr) +@ cdecl wined3d_state_destroy(ptr) + @ cdecl wined3d_output_find_closest_matching_mode(ptr ptr) @ cdecl wined3d_output_get_adapter(ptr) @ cdecl wined3d_output_get_desc(ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 96cb6fc1d86..8de7792e742 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2214,6 +2214,7 @@ struct wined3d_blend_state; struct wined3d_buffer; struct wined3d_depth_stencil_state; struct wined3d_device; +struct wined3d_state; struct wined3d_output; struct wined3d_palette; struct wined3d_query; @@ -2544,6 +2545,9 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device, struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture); HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state); +void __cdecl wined3d_state_destroy(struct wined3d_state *state); + HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output, struct wined3d_display_mode *mode); struct wined3d_adapter * __cdecl wined3d_output_get_adapter(const struct wined3d_output *output);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/device.c | 108 ++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 2 + 3 files changed, 111 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 51f74ca1f64..20935268fc4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1950,6 +1950,114 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, *rect_count = state->scissor_rect_count; }
+void CDECL wined3d_device_swap_state(struct wined3d_device *device, + struct wined3d_state *new_state, struct wined3d_state **old_state) +{ + struct wined3d_state *state = device->state; + unsigned int i, j; + + TRACE("device %p, new_state %p, old_state %p.\n", device, new_state, old_state); + + device->state = new_state; + + for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i) + wined3d_cs_emit_set_rendertarget_view(device->cs, i, new_state->fb.render_targets[i]); + + wined3d_cs_emit_set_depth_stencil_view(device->cs, new_state->fb.depth_stencil); + wined3d_cs_emit_set_vertex_declaration(device->cs, new_state->vertex_declaration); + + for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) + wined3d_cs_emit_set_stream_output(device->cs, i, new_state->stream_output[i].buffer, + new_state->stream_output[i].offset); + + for (i = 0; i < WINED3D_MAX_STREAMS; ++i) + wined3d_cs_emit_set_stream_source(device->cs, i, new_state->streams[i].buffer, + new_state->streams[i].offset, new_state->streams[i].stride); + + wined3d_cs_emit_set_index_buffer(device->cs, new_state->index_buffer, + new_state->index_format, new_state->index_offset); + + wined3d_cs_emit_set_predication(device->cs, new_state->predicate, + new_state->predicate_value); + + for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) + { + wined3d_cs_emit_set_shader(device->cs, i, new_state->shader[i]); + for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j) + wined3d_cs_emit_set_constant_buffer(device->cs, i, j, new_state->cb[i][j]); + for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j) + wined3d_cs_emit_set_sampler(device->cs, i, j, new_state->sampler[i][j]); + for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j) + wined3d_cs_emit_set_shader_resource_view(device->cs, i, j, + new_state->shader_resource_view[i][j]); + } + + for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i) + for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j) + wined3d_cs_emit_set_unordered_access_view(device->cs, i, j, + new_state->unordered_access_view[i][j], ~0); + + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_F, 0, + WINED3D_MAX_VS_CONSTS_F, new_state->vs_consts_f); + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_I, 0, + WINED3D_MAX_CONSTS_I, new_state->vs_consts_i); + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_B, 0, + WINED3D_MAX_CONSTS_B, new_state->vs_consts_b); + + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_F, 0, + WINED3D_MAX_PS_CONSTS_F, new_state->ps_consts_f); + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_I, 0, + WINED3D_MAX_CONSTS_I, new_state->ps_consts_i); + wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_B, 0, + WINED3D_MAX_CONSTS_B, new_state->ps_consts_b); + + for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) + { + wined3d_cs_emit_set_texture(device->cs, i, new_state->textures[i]); + for (j = 0; j < WINED3D_HIGHEST_SAMPLER_STATE + 1; ++j) + wined3d_cs_emit_set_sampler_state(device->cs, i, j, new_state->sampler_states[i][j]); + } + + for (i = 0; i < WINED3D_MAX_TEXTURES; ++i) + for (j = 0; j < WINED3D_HIGHEST_TEXTURE_STATE + 1; ++j) + wined3d_cs_emit_set_texture_state(device->cs, i, j, new_state->texture_states[i][j]); + + for (i = 0; i < WINED3D_HIGHEST_TRANSFORM_STATE + 1; ++i) + wined3d_cs_emit_set_transform(device->cs, i, new_state->transforms + i); + + for (i = 0; i < WINED3D_MAX_CLIP_DISTANCES; ++i) + wined3d_cs_emit_set_clip_plane(device->cs, i, new_state->clip_planes + i); + + wined3d_cs_emit_set_material(device->cs, &new_state->material); + + wined3d_cs_emit_set_viewports(device->cs, new_state->viewport_count, new_state->viewports); + wined3d_cs_emit_set_scissor_rects(device->cs, new_state->scissor_rect_count, + new_state->scissor_rects); + + for (i = 0; i < LIGHTMAP_SIZE; ++i) + { + const struct wined3d_light_info *light; + + LIST_FOR_EACH_ENTRY(light, &new_state->light_state.light_map[i], struct wined3d_light_info, entry) + { + wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); + wined3d_cs_emit_set_light_enable(device->cs, light->OriginalIndex, light->glIndex != -1); + } + } + + for (i = 0; i < WINEHIGHEST_RENDER_STATE + 1; ++i) + wined3d_cs_emit_set_render_state(device->cs, i, new_state->render_states[i]); + + wined3d_cs_emit_set_blend_state(device->cs, new_state->blend_state, &new_state->blend_factor, + new_state->sample_mask); + wined3d_cs_emit_set_depth_stencil_state(device->cs, new_state->depth_stencil_state, + new_state->stencil_ref); + wined3d_cs_emit_set_rasterizer_state(device->cs, new_state->rasterizer_state); + + if (old_state) *old_state = state; + else wined3d_state_destroy(state); +} + void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 9d305bfc426..d4d33d63256 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -160,6 +160,7 @@ @ cdecl wined3d_device_set_vs_resource_view(ptr long ptr) @ cdecl wined3d_device_set_vs_sampler(ptr long ptr) @ cdecl wined3d_device_show_cursor(ptr long) +@ cdecl wined3d_device_swap_state(ptr ptr ptr) @ cdecl wined3d_device_update_sub_resource(ptr ptr long ptr ptr long long long) @ cdecl wined3d_device_update_texture(ptr ptr ptr) @ cdecl wined3d_device_validate_device(ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 8de7792e742..b85915612f5 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2538,6 +2538,8 @@ void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device, UINT idx, struct wined3d_shader_resource_view *view); void __cdecl wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler); BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show); +void __cdecl wined3d_device_swap_state(struct wined3d_device *device, + struct wined3d_state *new_state, struct wined3d_state **old_state); void __cdecl wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int depth_pitch, unsigned int flags);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d11/d3d11_private.h | 30 ++---- dlls/d3d11/device.c | 187 ++++++++++++++++--------------------- dlls/d3d11/tests/d3d11.c | 140 +++++++++++---------------- 3 files changed, 146 insertions(+), 211 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 650b5c35871..458339a849f 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -517,34 +517,20 @@ struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDD struct d3d_query *unsafe_impl_from_ID3D11Asynchronous(ID3D11Asynchronous *iface) DECLSPEC_HIDDEN;
/* ID3DDeviceContextState */ +struct d3d_device_state_entry +{ + struct wine_rb_entry entry; + struct wined3d_device *device; + struct wined3d_state *state; +}; + struct d3d_device_context_state { ID3DDeviceContextState ID3DDeviceContextState_iface; LONG refcount, private_refcount;
struct wined3d_private_store private_store; - struct - { - ID3D11VertexShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } vs; - struct - { - ID3D11GeometryShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } gs; - struct - { - ID3D11PixelShader *shader; - ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; - ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; - ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; - } ps; - + struct wine_rb_tree devices_states; GUID emulated_interface;
struct wined3d_device *wined3d_device; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 87bdd594d81..0d20df28d20 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -88,37 +88,24 @@ static ULONG STDMETHODCALLTYPE d3d_device_context_state_AddRef(ID3DDeviceContext return refcount; }
+static void d3d_device_context_state_free_entry(struct wine_rb_entry *entry, void *context) +{ + struct d3d_device_state_entry *ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + wined3d_device_decref(ptr->device); + wined3d_state_destroy(ptr->state); + heap_free(ptr); +} + static void d3d_device_context_state_private_release(struct d3d_device_context_state *state) { ULONG refcount = InterlockedDecrement(&state->private_refcount); - unsigned int i;
TRACE("%p decreasing private refcount to %u.\n", state, refcount);
if (!refcount) { wined3d_private_store_cleanup(&state->private_store); - if (state->vs.shader) ID3D11VertexShader_Release(state->vs.shader); - if (state->gs.shader) ID3D11GeometryShader_Release(state->gs.shader); - if (state->ps.shader) ID3D11PixelShader_Release(state->ps.shader); - for (i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i) - { - if (state->vs.samplers[i]) ID3D11SamplerState_Release(state->vs.samplers[i]); - if (state->gs.samplers[i]) ID3D11SamplerState_Release(state->gs.samplers[i]); - if (state->ps.samplers[i]) ID3D11SamplerState_Release(state->ps.samplers[i]); - } - for (i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i) - { - if (state->vs.srvs[i]) ID3D11ShaderResourceView_Release(state->vs.srvs[i]); - if (state->gs.srvs[i]) ID3D11ShaderResourceView_Release(state->gs.srvs[i]); - if (state->ps.srvs[i]) ID3D11ShaderResourceView_Release(state->ps.srvs[i]); - } - for (i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i) - { - if (state->vs.cbs[i]) ID3D11Buffer_Release(state->vs.cbs[i]); - if (state->gs.cbs[i]) ID3D11Buffer_Release(state->gs.cbs[i]); - if (state->ps.cbs[i]) ID3D11Buffer_Release(state->ps.cbs[i]); - } + wine_rb_destroy(&state->devices_states, d3d_device_context_state_free_entry, NULL); wined3d_device_decref(state->wined3d_device); heap_free(state); } @@ -194,6 +181,60 @@ static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl = /* ID3DDeviceContextState methods */ };
+static int wined3d_device_compare(const void *key, const struct wine_rb_entry *entry) +{ + const struct wined3d_device *device = key; + return (char *)device - (char *)WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry)->device; +} + +static HRESULT d3d_device_context_state_get_wined3d_state(struct d3d_device_context_state *state, + struct wined3d_device *wined3d_device, struct wined3d_state **wined3d_state) +{ + struct d3d_device_state_entry *ptr; + struct wine_rb_entry *entry; + HRESULT hr = S_OK; + + *wined3d_state = NULL; + + wined3d_mutex_lock(); + if ((entry = wine_rb_get(&state->devices_states, wined3d_device))) + ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + else if ((ptr = heap_alloc(sizeof(*ptr)))) + { + wined3d_device_incref(ptr->device = wined3d_device); + wined3d_state_create(wined3d_device, &ptr->state); + } + else hr = E_OUTOFMEMORY; + wined3d_mutex_unlock(); + + if (hr == S_OK) *wined3d_state = ptr->state; + return hr; +} + +static HRESULT d3d_device_context_state_set_wined3d_state(struct d3d_device_context_state *state, + struct wined3d_device *wined3d_device, struct wined3d_state *wined3d_state) +{ + struct d3d_device_state_entry *ptr; + struct wine_rb_entry *entry; + HRESULT hr = S_OK; + + wined3d_mutex_lock(); + if ((entry = wine_rb_get(&state->devices_states, wined3d_device))) + { + ptr = WINE_RB_ENTRY_VALUE(entry, struct d3d_device_state_entry, entry); + assert(ptr->state == wined3d_state); + } + else if ((ptr = heap_alloc(sizeof(*ptr)))) + { + wined3d_device_incref(ptr->device = wined3d_device); + ptr->state = wined3d_state; + wine_rb_put(&state->devices_states, wined3d_device, &ptr->entry); + } + else hr = E_OUTOFMEMORY; + wined3d_mutex_unlock(); + return hr; +} + static void d3d_device_context_state_init(struct d3d_device_context_state *state, struct d3d_device *device, REFIID emulated_interface) { @@ -201,9 +242,7 @@ static void d3d_device_context_state_init(struct d3d_device_context_state *state state->refcount = state->private_refcount = 0;
wined3d_private_store_init(&state->private_store); - memset(&state->vs, 0, sizeof(state->vs)); - memset(&state->gs, 0, sizeof(state->gs)); - memset(&state->ps, 0, sizeof(state->ps)); + wine_rb_init(&state->devices_states, wined3d_device_compare);
state->emulated_interface = *emulated_interface; wined3d_device_incref(state->wined3d_device = device->wined3d_device); @@ -2722,73 +2761,13 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers1(ID3D iface, start_slot, buffer_count, buffers, first_constant, num_constants); }
-static void d3d11_immediate_context_capture_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state) -{ - wined3d_mutex_lock(); - - d3d11_immediate_context_VSGetShader(iface, &state->vs.shader, NULL, 0); - d3d11_immediate_context_VSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers); - d3d11_immediate_context_VSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs); - d3d11_immediate_context_VSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs); - - d3d11_immediate_context_GSGetShader(iface, &state->gs.shader, NULL, 0); - d3d11_immediate_context_GSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers); - d3d11_immediate_context_GSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs); - d3d11_immediate_context_GSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs); - - d3d11_immediate_context_PSGetShader(iface, &state->ps.shader, NULL, 0); - d3d11_immediate_context_PSGetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers); - d3d11_immediate_context_PSGetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs); - d3d11_immediate_context_PSGetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs); - - wined3d_mutex_unlock(); -} - -static void d3d11_immediate_context_restore_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state) -{ - wined3d_mutex_lock(); - - d3d11_immediate_context_VSSetShader(iface, state->vs.shader, NULL, 0); - d3d11_immediate_context_VSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers); - d3d11_immediate_context_VSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs); - d3d11_immediate_context_VSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs); - - d3d11_immediate_context_GSSetShader(iface, state->gs.shader, NULL, 0); - d3d11_immediate_context_GSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers); - d3d11_immediate_context_GSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs); - d3d11_immediate_context_GSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs); - - d3d11_immediate_context_PSSetShader(iface, state->ps.shader, NULL, 0); - d3d11_immediate_context_PSSetSamplers(iface, 0, - D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers); - d3d11_immediate_context_PSSetShaderResources(iface, 0, - D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs); - d3d11_immediate_context_PSSetConstantBuffers(iface, 0, - D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs); - - wined3d_mutex_unlock(); -} - static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface, ID3DDeviceContextState *state, ID3DDeviceContextState **prev_state) { - struct d3d_device_context_state *state_impl; + struct wined3d_state *old_wined3d_state, *new_wined3d_state; + struct d3d_device_context_state *new_impl, *old_impl; struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + HRESULT hr;
FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface, state, prev_state);
@@ -2796,24 +2775,22 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3 if (!state) return;
wined3d_mutex_lock(); - if (prev_state) - { - *prev_state = NULL; - if ((state_impl = heap_alloc(sizeof(*state_impl)))) - { - d3d_device_context_state_init(state_impl, device, &device->state->emulated_interface); - d3d11_immediate_context_capture_state(iface, state_impl); - *prev_state = &state_impl->ID3DDeviceContextState_iface; - } - } + old_impl = device->state; + new_impl = device->state = impl_from_ID3DDeviceContextState(state); + d3d_device_context_state_private_addref(new_impl);
- if ((state_impl = impl_from_ID3DDeviceContextState(state))) - { - d3d11_immediate_context_restore_state(iface, state_impl); - device->state->emulated_interface = state_impl->emulated_interface; - if (d3d_device_is_d3d10_active(device)) - FIXME("D3D10 interface emulation not fully implemented yet!\n"); - } + if (FAILED(hr = d3d_device_context_state_get_wined3d_state(new_impl, device->wined3d_device, + &new_wined3d_state))) + ERR("Failed to get new wined3d state, hr %#x.", hr); + + wined3d_device_swap_state(device->wined3d_device, new_wined3d_state, &old_wined3d_state); + d3d_device_context_state_set_wined3d_state(old_impl, device->wined3d_device, old_wined3d_state); + + if (!prev_state) d3d_device_context_state_private_release(old_impl); + else ID3DDeviceContextState_AddRef(*prev_state = &old_impl->ID3DDeviceContextState_iface); + + if (d3d_device_is_d3d10_active(device)) + FIXME("D3D10 interface emulation not fully implemented yet!\n"); wined3d_mutex_unlock(); }
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 1505b3fddbc..2eff98fe8fc 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -7083,7 +7083,7 @@ static void test_device_context_state(void) ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &previous_context_state); ok(previous_context_state != NULL, "Failed to get previous context state\n"); refcount = get_refcount(vs); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
hr = ID3DDeviceContextState_SetPrivateData(context_state, &test_guid, sizeof(constant), &constant); ok(hr == S_OK, "Failed to set private data, hr %#x.\n", hr); @@ -7093,9 +7093,9 @@ static void test_device_context_state(void) data_size = sizeof(data); memset(data, 0xa5, sizeof(data)); hr = ID3DDeviceContextState_GetPrivateData(context_state, &test_guid, &data_size, data); - todo_wine ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr); - todo_wine ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant)); - todo_wine ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n"); + ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr); + ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant)); + ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n"); ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, NULL);
context_type = ID3D11DeviceContext1_GetType(context); @@ -7142,118 +7142,96 @@ static void test_device_context_state(void)
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_HSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_HSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_hs = (ID3D11HullShader *)0xdeadbeef; ID3D11DeviceContext1_HSGetShader(context, &tmp_hs, NULL, NULL); - if (hs) todo_wine ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs); - if (tmp_hs) ID3D11HullShader_Release(tmp_hs); + if (hs) ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_HSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_DSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_DSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_ds = (ID3D11DomainShader *)0xdeadbeef; ID3D11DeviceContext1_DSGetShader(context, &tmp_ds, NULL, NULL); - if (ds) todo_wine ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds); - if (tmp_ds) ID3D11DomainShader_Release(tmp_ds); + if (ds) ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_DSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_CSGetConstantBuffers(context, 0, 1, &tmp_cb); - todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); - if (tmp_cb) ID3D11Buffer_Release(tmp_cb); + ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb); tmp_sampler = (ID3D11SamplerState *)0xdeadbeef; ID3D11DeviceContext1_CSGetSamplers(context, 0, 1, &tmp_sampler); - todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); - if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler); + ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler); tmp_cs = (ID3D11ComputeShader *)0xdeadbeef; ID3D11DeviceContext1_CSGetShader(context, &tmp_cs, NULL, NULL); - if (cs) todo_wine ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs); - if (tmp_cs) ID3D11ComputeShader_Release(tmp_cs); + if (cs) ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs); tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef; ID3D11DeviceContext1_CSGetShaderResources(context, 0, 1, &tmp_srv); - todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); - if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv); + ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv); tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef; ID3D11DeviceContext1_CSGetUnorderedAccessViews(context, 0, 1, &tmp_uav); - todo_wine ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav); - if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav); + ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
topo = 0xdeadbeef; ID3D11DeviceContext1_IAGetPrimitiveTopology(context, &topo); - todo_wine ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo); + ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo); tmp_il = (ID3D11InputLayout *)0xdeadbeef; ID3D11DeviceContext1_IAGetInputLayout(context, &tmp_il); - todo_wine ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il); - if (tmp_il) ID3D11InputLayout_Release(tmp_il); + ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il); tmp_ib = (ID3D11Buffer *)0xdeadbeef; format = 0xdeadbeef; offset = 0xdeadbeef; ID3D11DeviceContext1_IAGetIndexBuffer(context, &tmp_ib, &format, &offset); - todo_wine ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib); - if (tmp_ib) ID3D11Buffer_Release(tmp_ib); - todo_wine ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format); - todo_wine ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset); + ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib); + ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format); + ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset); tmp_vb = (ID3D11Buffer *)0xdeadbeef; stride = 0xdeadbeef; offset = 0xdeadbeef; ID3D11DeviceContext1_IAGetVertexBuffers(context, 0, 1, &tmp_vb, &stride, &offset); - todo_wine ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb); - if (tmp_vb) ID3D11Buffer_Release(tmp_vb); - todo_wine ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride); - todo_wine ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset); + ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb); + ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride); + ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
tmp_rtv = (ID3D11RenderTargetView *)0xdeadbeef; tmp_dsv = (ID3D11DepthStencilView *)0xdeadbeef; tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef; ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context, 1, &tmp_rtv, &tmp_dsv, 1, 1, &tmp_uav); - todo_wine ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv); - if (tmp_rtv) ID3D11RenderTargetView_Release(tmp_rtv); - todo_wine ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv); - if (tmp_dsv) ID3D11DepthStencilView_Release(tmp_dsv); - todo_wine ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav); - if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav); + ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv); + ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv); + ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav); tmp_bs = (ID3D11BlendState *)0xdeadbeef; memset(blend_factor, 0xcd, sizeof(blend_factor)); sample_mask = 0xdeadbeef; ID3D11DeviceContext1_OMGetBlendState(context, &tmp_bs, blend_factor, &sample_mask); - todo_wine ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs); - if (tmp_bs) ID3D11BlendState_Release(tmp_bs); - todo_wine ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)), + ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs); + ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)), "Got unexpected blend factor %f,%f,%f,%f.\n", blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]); - todo_wine ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask); + ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask); tmp_dss = (ID3D11DepthStencilState *)0xdeadbeef; stencil_ref = 0xdeadbeef; ID3D11DeviceContext1_OMGetDepthStencilState(context, &tmp_dss, &stencil_ref); - todo_wine ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss); - if (tmp_dss) ID3D11DepthStencilState_Release(tmp_dss); - todo_wine ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref); + ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss); + ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
tmp_rs = (ID3D11RasterizerState *)0xdeadbeef; ID3D11DeviceContext1_RSGetState(context, &tmp_rs); - todo_wine ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs); - if (tmp_rs) ID3D11RasterizerState_Release(tmp_rs); + ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs); memset(tmp_vp, 0xa5, sizeof(tmp_vp)); count = 2; ID3D11DeviceContext1_RSGetViewports(context, &count, tmp_vp); - todo_wine ok(count == 0, "Got unexpected viewport count %u.\n", count); + ok(count == 0, "Got unexpected viewport count %u.\n", count); memset(tmp_rect, 0xa5, sizeof(tmp_rect)); count = 2; ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect); @@ -7261,15 +7239,13 @@ static void test_device_context_state(void)
tmp_sob = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob); - todo_wine ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob); - if (tmp_sob) ID3D11Buffer_Release(tmp_sob); + ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
tmp_pred = (ID3D11Predicate *)0xdeadbeef; pred_value = 0xdeadbeef; ID3D11DeviceContext1_GetPredication(context, &tmp_pred, &pred_value); - todo_wine ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred); - if (tmp_pred) ID3D11Predicate_Release(tmp_pred); - todo_wine ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value); + ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred); + ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
/* updating the device context should also update the device context state */ hr = ID3D11Device1_CreateVertexShader(device, simple_vs, sizeof(simple_vs), NULL, &vs2); @@ -7277,14 +7253,13 @@ static void test_device_context_state(void) ID3D11DeviceContext1_VSSetShader(context, vs2, NULL, 0); ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &tmp_context_state); refcount = ID3DDeviceContextState_Release(tmp_context_state); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); - todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* context states may be used with other devices instances too */ d3d11_device2 = create_device(NULL); @@ -7305,17 +7280,16 @@ static void test_device_context_state(void) /* updating context2 vertex shader doesn't update other contexts using the same state */ ID3D11DeviceContext1_VSSetShader(context2, vs, NULL, 0); ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
ID3D11DeviceContext1_SwapDeviceContextState(context2, tmp_context_state, &context_state2); refcount = ID3DDeviceContextState_Release(tmp_context_state); ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount); refcount = ID3DDeviceContextState_Release(context_state2); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); - todo_wine ok(context_state2 == context_state, "Got unexpected state pointer.\n"); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(context_state2 == context_state, "Got unexpected state pointer.\n");
/* swapping the default state on context2 effectively clears the vertex shader */ tmp_vs = (ID3D11VertexShader *)0xdeadbeef; @@ -7333,19 +7307,17 @@ static void test_device_context_state(void) ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* even after swapping it again */ ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, NULL); tmp_vs = (ID3D11VertexShader *)0xdeadbeef; ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL); - todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); - if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs); - else refcount = 0; - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs); + refcount = ID3D11VertexShader_Release(tmp_vs); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* swapping the initial state on context2 doesn't have side effect on context either */ ID3D11DeviceContext1_SwapDeviceContextState(context2, previous_context_state, NULL); @@ -7362,10 +7334,10 @@ static void test_device_context_state(void) refcount = ID3DDeviceContextState_Release(previous_context_state); ok(!refcount, "Got refcount %u, expected 0.\n", refcount); refcount = ID3DDeviceContextState_Release(tmp_context_state); - todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); + ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount); refcount = ID3DDeviceContextState_Release(context_state); ok(!refcount, "Got refcount %u, expected 0.\n", refcount); - todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); + ok(tmp_context_state == context_state, "Got unexpected state pointer.\n"); refcount = get_refcount(vs); ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=85814
Your paranoid android.
=== w864 (32 bit report) ===
d3d11: 08c4:d3d11: unhandled exception c0000005 at 7FE95178
=== w1064v1809 (32 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.
=== w1064 (32 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.
=== w10pro64 (32 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.
=== debiant2 (32 bit Japanese:Japan report) ===
d3d11: d3d11: Timeout
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d11/device.c | 9 ++------- dlls/d3d11/tests/d3d11.c | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 0d20df28d20..0f1e65d6b77 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2199,14 +2199,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11De wined3d_device_get_scissor_rects(device->wined3d_device, &actual_count, rects); wined3d_mutex_unlock();
- if (!rects) - { - *rect_count = actual_count; - return; - } - - if (*rect_count > actual_count) + if (rects && *rect_count > actual_count) memset(&rects[actual_count], 0, (*rect_count - actual_count) * sizeof(*rects)); + *rect_count = actual_count; }
static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1 *iface, diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 2eff98fe8fc..32a9dc2e530 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -7235,7 +7235,7 @@ static void test_device_context_state(void) memset(tmp_rect, 0xa5, sizeof(tmp_rect)); count = 2; ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect); - todo_wine ok(count == 0, "Got unexpected scissor rect count %u.\n", count); + ok(count == 0, "Got unexpected scissor rect count %u.\n", count);
tmp_sob = (ID3D11Buffer *)0xdeadbeef; ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob); @@ -7514,7 +7514,7 @@ static void test_device_context_state(void) memset(tmp_rect, 0xa5, sizeof(tmp_rect)); count = 2; ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect); - todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count); + ok(count == 1, "Got scissor rect count %u, expected 1.\n", count); ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n", wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
@@ -7962,7 +7962,7 @@ static void test_device_context_state(void) memset(tmp_rect, 0xa5, sizeof(tmp_rect)); count = 2; ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect); - todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count); + ok(count == 1, "Got scissor rect count %u, expected 1.\n", count); ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n", wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=85815
Your paranoid android.
=== w2008s64 (64 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.