Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3d8/device.c | 5 ++--- dlls/d3d9/device.c | 4 ++-- dlls/ddraw/device.c | 4 ++-- dlls/ddraw/viewport.c | 8 ++++---- dlls/wined3d/device.c | 6 +++--- dlls/wined3d/palette.c | 2 +- dlls/wined3d/stateblock.c | 6 ++---- dlls/wined3d/view.c | 9 +++------ include/wine/wined3d.h | 11 +++++++++++ 9 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index b14e6679763..c0fa38e090a 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3071,7 +3071,7 @@ static HRESULT WINAPI d3d8_device_GetVertexShaderConstant(IDirect3DDevice8 *ifac if (!constants) return D3DERR_INVALIDCALL;
- if (start_idx >= device->vs_uniform_count || count > device->vs_uniform_count - start_idx) + if (!wined3d_bound_range(start_idx, count, device->vs_uniform_count)) { WARN("Trying to access %u constants, but d3d8 only supports %u.\n", start_idx + count, device->vs_uniform_count); @@ -3375,8 +3375,7 @@ static HRESULT WINAPI d3d8_device_GetPixelShaderConstant(IDirect3DDevice8 *iface
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
- if (!constants || start_idx >= D3D8_MAX_PIXEL_SHADER_CONSTANTF - || count > D3D8_MAX_PIXEL_SHADER_CONSTANTF - start_idx) + if (!constants || !wined3d_bound_range(start_idx, count, D3D8_MAX_PIXEL_SHADER_CONSTANTF)) return WINED3DERR_INVALIDCALL;
wined3d_mutex_lock(); diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 932d6d2d814..c8b906a981f 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3684,7 +3684,7 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantF(IDirect3DDevice9Ex *i if (!constants) return D3DERR_INVALIDCALL;
- if (start_idx >= device->vs_uniform_count || count > device->vs_uniform_count - start_idx) + if (!wined3d_bound_range(start_idx, count, device->vs_uniform_count)) { WARN("Trying to access %u constants, but d3d9 only supports %u\n", start_idx + count, device->vs_uniform_count); @@ -4033,7 +4033,7 @@ static HRESULT WINAPI d3d9_device_GetPixelShaderConstantF(IDirect3DDevice9Ex *if
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
- if (!constants || start_idx >= WINED3D_MAX_PS_CONSTS_F || count > WINED3D_MAX_PS_CONSTS_F - start_idx) + if (!constants || !wined3d_bound_range(start_idx, count, WINED3D_MAX_PS_CONSTS_F)) return WINED3DERR_INVALIDCALL;
wined3d_mutex_lock(); diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index e9070cfbda6..b66ae7698c8 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -5373,8 +5373,8 @@ static HRESULT d3d_device7_SetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *vi surface = wined3d_rendertarget_view_get_sub_resource_parent(rtv); wined3d_texture_get_sub_resource_desc(surface->wined3d_texture, surface->sub_resource_idx, &rt_desc);
- if (viewport->dwX > rt_desc.width || viewport->dwWidth > rt_desc.width - viewport->dwX - || viewport->dwY > rt_desc.height || viewport->dwHeight > rt_desc.height - viewport->dwY) + if (!wined3d_bound_range(viewport->dwX, viewport->dwWidth, rt_desc.width) + || !wined3d_bound_range(viewport->dwY, viewport->dwHeight, rt_desc.height)) { WARN("Invalid viewport, returning E_INVALIDARG.\n"); wined3d_mutex_unlock(); diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index ada3f1757b7..13a6a147083 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -414,8 +414,8 @@ static HRESULT WINAPI d3d_viewport_SetViewport(IDirect3DViewport3 *iface, D3DVIE surface = wined3d_rendertarget_view_get_sub_resource_parent(rtv); wined3d_texture_get_sub_resource_desc(surface->wined3d_texture, surface->sub_resource_idx, &rt_desc);
- if (vp->dwX > rt_desc.width || vp->dwWidth > rt_desc.width - vp->dwX - || vp->dwY > rt_desc.height || vp->dwHeight > rt_desc.height - vp->dwY) + if (!wined3d_bound_range(vp->dwX, vp->dwWidth, rt_desc.width) + || !wined3d_bound_range(vp->dwY, vp->dwHeight, rt_desc.height)) { WARN("Invalid viewport, returning DDERR_INVALIDPARAMS.\n"); wined3d_mutex_unlock(); @@ -1043,8 +1043,8 @@ static HRESULT WINAPI d3d_viewport_SetViewport2(IDirect3DViewport3 *iface, D3DVI surface = wined3d_rendertarget_view_get_sub_resource_parent(rtv); wined3d_texture_get_sub_resource_desc(surface->wined3d_texture, surface->sub_resource_idx, &rt_desc);
- if (vp->dwX > rt_desc.width || vp->dwWidth > rt_desc.width - vp->dwX - || vp->dwY > rt_desc.height || vp->dwHeight > rt_desc.height - vp->dwY) + if (!wined3d_bound_range(vp->dwX, vp->dwWidth, rt_desc.width) + || !wined3d_bound_range(vp->dwY, vp->dwHeight, rt_desc.height)) { WARN("Invalid viewport, returning DDERR_INVALIDPARAMS.\n"); wined3d_mutex_unlock(); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 175a3b7ed0b..e9d4d0a0677 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1837,7 +1837,7 @@ void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_con
TRACE("context %p, type %#x, start_idx %u, count %u, buffers %p.\n", context, type, start_idx, count, buffers);
- if (start_idx >= MAX_CONSTANT_BUFFERS || count > MAX_CONSTANT_BUFFERS - start_idx) + if (!wined3d_bound_range(start_idx, count, MAX_CONSTANT_BUFFERS)) { WARN("Invalid constant buffer index %u, count %u.\n", start_idx, count); return; @@ -1988,7 +1988,7 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic
TRACE("context %p, type %#x, start_idx %u, count %u, views %p.\n", context, type, start_idx, count, views);
- if (start_idx >= MAX_SHADER_RESOURCE_VIEWS || count > MAX_SHADER_RESOURCE_VIEWS - start_idx) + if (!wined3d_bound_range(start_idx, count, MAX_SHADER_RESOURCE_VIEWS)) { WARN("Invalid view index %u, count %u.\n", start_idx, count); return; @@ -2040,7 +2040,7 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co
TRACE("context %p, type %#x, start_idx %u, count %u, samplers %p.\n", context, type, start_idx, count, samplers);
- if (start_idx >= MAX_SAMPLER_OBJECTS || count > MAX_SAMPLER_OBJECTS - start_idx) + if (!wined3d_bound_range(start_idx, count, MAX_SAMPLER_OBJECTS)) { WARN("Invalid sampler index %u, count %u.\n", start_idx, count); return; diff --git a/dlls/wined3d/palette.c b/dlls/wined3d/palette.c index 615fb00905f..85105d1f8de 100644 --- a/dlls/wined3d/palette.c +++ b/dlls/wined3d/palette.c @@ -61,7 +61,7 @@ HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette,
if (flags) return WINED3DERR_INVALIDCALL; /* unchecked */ - if (start > palette->size || count > palette->size - start) + if (!wined3d_bound_range(start, count, palette->size)) return WINED3DERR_INVALIDCALL;
if (palette->flags & WINED3D_PALETTE_8BIT_ENTRIES) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 1f1ba262336..4cf30941d62 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1204,8 +1204,7 @@ HRESULT CDECL wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *stat TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
- if (!constants || start_idx >= d3d_info->limits.vs_uniform_count - || count > d3d_info->limits.vs_uniform_count - start_idx) + if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.vs_uniform_count)) return WINED3DERR_INVALIDCALL;
memcpy(&stateblock->stateblock_state.vs_consts_f[start_idx], constants, count * sizeof(*constants)); @@ -1273,8 +1272,7 @@ HRESULT CDECL wined3d_stateblock_set_ps_consts_f(struct wined3d_stateblock *stat TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
- if (!constants || start_idx >= d3d_info->limits.ps_uniform_count - || count > d3d_info->limits.ps_uniform_count - start_idx) + if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.ps_uniform_count)) return WINED3DERR_INVALIDCALL;
memcpy(&stateblock->stateblock_state.ps_consts_f[start_idx], constants, count * sizeof(*constants)); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 03d6a4d17b5..55742fb06b6 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -132,8 +132,7 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_ return NULL;
buffer_size = buffer->resource.size / element_size; - if (desc->u.buffer.start_idx >= buffer_size - || desc->u.buffer.count > buffer_size - desc->u.buffer.start_idx) + if (!wined3d_bound_range(desc->u.buffer.start_idx, desc->u.buffer.count, buffer_size)) return NULL; } else @@ -156,11 +155,9 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
if (!desc->u.texture.level_count || (mip_slice && desc->u.texture.level_count != 1) - || desc->u.texture.level_idx >= texture->level_count - || desc->u.texture.level_count > texture->level_count - desc->u.texture.level_idx + || !wined3d_bound_range(desc->u.texture.level_idx, desc->u.texture.level_count, texture->level_count) || !desc->u.texture.layer_count - || desc->u.texture.layer_idx >= depth_or_layer_count - || desc->u.texture.layer_count > depth_or_layer_count - desc->u.texture.layer_idx) + || !wined3d_bound_range(desc->u.texture.layer_idx, desc->u.texture.layer_count, depth_or_layer_count)) return NULL; }
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 80a636edc9f..10253cab87d 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2927,6 +2927,17 @@ static inline int wined3d_bit_scan(unsigned int *x) return bit_offset; }
+static inline bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit) +{ +#if defined(__GNUC__) && __GNUC__ >= 5 + unsigned int sum; + + return !__builtin_add_overflow(start, count, &sum) && sum <= limit; +#else + return start <= limit && count <= limit - start; +#endif +} + static inline void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back) {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3d11/device.c | 67 ++++++++++++++++++-------------- dlls/wined3d/cs.c | 70 +++++++++++++++++++++------------- dlls/wined3d/device.c | 45 +++++++++++----------- dlls/wined3d/wined3d.spec | 2 +- dlls/wined3d/wined3d_private.h | 6 +-- include/wine/wined3d.h | 6 +-- 6 files changed, 111 insertions(+), 85 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index ec2447b3c4e..93df97e59ae 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -1087,20 +1087,17 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargets(ID3D11Devi }
static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews( - ID3D11DeviceContext1 *iface, UINT render_target_view_count, - ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view, - UINT unordered_access_view_start_slot, UINT unordered_access_view_count, - ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts) + ID3D11DeviceContext1 *iface, UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views, + ID3D11DepthStencilView *depth_stencil_view, UINT uav_start_idx, UINT uav_count, + ID3D11UnorderedAccessView *const *uavs, const UINT *initial_counts) { struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); unsigned int i;
TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, " - "unordered_access_view_start_slot %u, unordered_access_view_count %u, unordered_access_views %p, " - "initial_counts %p.\n", + "uav_start_idx %u, uav_count %u, uavs %p, initial_counts %p.\n", iface, render_target_view_count, render_target_views, depth_stencil_view, - unordered_access_view_start_slot, unordered_access_view_count, unordered_access_views, - initial_counts); + uav_start_idx, uav_count, uavs, initial_counts);
if (render_target_view_count != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL) { @@ -1108,28 +1105,31 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargetsAndUnordere depth_stencil_view); }
- if (unordered_access_view_count != D3D11_KEEP_UNORDERED_ACCESS_VIEWS) + if (uav_count != D3D11_KEEP_UNORDERED_ACCESS_VIEWS) { - wined3d_mutex_lock(); - for (i = 0; i < unordered_access_view_start_slot; ++i) - { - wined3d_device_context_set_unordered_access_view(context->wined3d_context, - WINED3D_PIPELINE_GRAPHICS, i, NULL, ~0u); - } - for (i = 0; i < unordered_access_view_count; ++i) - { - struct d3d11_unordered_access_view *view - = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views[i]); + struct wined3d_unordered_access_view *wined3d_views[D3D11_PS_CS_UAV_REGISTER_COUNT] = {0}; + unsigned int wined3d_initial_counts[D3D11_PS_CS_UAV_REGISTER_COUNT];
- wined3d_device_context_set_unordered_access_view(context->wined3d_context, - WINED3D_PIPELINE_GRAPHICS, unordered_access_view_start_slot + i, - view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u); - } - for (; unordered_access_view_start_slot + i < D3D11_PS_CS_UAV_REGISTER_COUNT; ++i) + if (!wined3d_bound_range(uav_start_idx, uav_count, ARRAY_SIZE(wined3d_views))) { - wined3d_device_context_set_unordered_access_view(context->wined3d_context, - WINED3D_PIPELINE_GRAPHICS, unordered_access_view_start_slot + i, NULL, ~0u); + WARN("View count %u exceeds limit; ignoring call.\n", uav_count); + return; } + + memset(wined3d_initial_counts, 0xff, sizeof(wined3d_initial_counts)); + + for (i = 0; i < uav_count; ++i) + { + struct d3d11_unordered_access_view *view = + unsafe_impl_from_ID3D11UnorderedAccessView(uavs[i]); + + wined3d_views[uav_start_idx + i] = view ? view->wined3d_view : NULL; + wined3d_initial_counts[uav_start_idx + i] = initial_counts ? initial_counts[i] : ~0u; + } + + wined3d_mutex_lock(); + wined3d_device_context_set_unordered_access_views(context->wined3d_context, WINED3D_PIPELINE_GRAPHICS, + 0, ARRAY_SIZE(wined3d_views), wined3d_views, wined3d_initial_counts); wined3d_mutex_unlock(); } } @@ -1651,19 +1651,28 @@ static void STDMETHODCALLTYPE d3d11_device_context_CSSetUnorderedAccessViews(ID3 UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts) { struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); + struct wined3d_unordered_access_view *wined3d_views[D3D11_PS_CS_UAV_REGISTER_COUNT]; unsigned int i;
TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n", iface, start_slot, view_count, views, initial_counts);
- wined3d_mutex_lock(); + if (view_count > ARRAY_SIZE(wined3d_views)) + { + WARN("View count %u exceeds limit; ignoring call.\n", view_count); + return; + } + for (i = 0; i < view_count; ++i) { struct d3d11_unordered_access_view *view = unsafe_impl_from_ID3D11UnorderedAccessView(views[i]);
- wined3d_device_context_set_unordered_access_view(context->wined3d_context, WINED3D_PIPELINE_COMPUTE, - start_slot + i, view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u); + wined3d_views[i] = view ? view->wined3d_view : NULL; } + + wined3d_mutex_lock(); + wined3d_device_context_set_unordered_access_views(context->wined3d_context, WINED3D_PIPELINE_COMPUTE, + start_slot, view_count, wined3d_views, initial_counts); wined3d_mutex_unlock(); }
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 1deafc2d4c3..f7e5009df46 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -123,7 +123,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_CONSTANT_BUFFERS, WINED3D_CS_OP_SET_TEXTURE, WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS, - WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW, + WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS, WINED3D_CS_OP_SET_SAMPLERS, WINED3D_CS_OP_SET_SHADER, WINED3D_CS_OP_SET_BLEND_STATE, @@ -319,13 +319,17 @@ struct wined3d_cs_set_shader_resource_views struct wined3d_shader_resource_view *views[1]; };
-struct wined3d_cs_set_unordered_access_view +struct wined3d_cs_set_unordered_access_views { enum wined3d_cs_op opcode; enum wined3d_pipeline pipeline; - unsigned int view_idx; - struct wined3d_unordered_access_view *view; - unsigned int initial_count; + unsigned int start_idx; + unsigned int count; + struct + { + struct wined3d_unordered_access_view *view; + unsigned int initial_count; + } uavs[1]; };
struct wined3d_cs_set_samplers @@ -604,7 +608,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) WINED3D_TO_STR(WINED3D_CS_OP_SET_CONSTANT_BUFFERS); WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE); WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS); - WINED3D_TO_STR(WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW); + WINED3D_TO_STR(WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS); WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLERS); WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER); WINED3D_TO_STR(WINED3D_CS_OP_SET_BLEND_STATE); @@ -1702,37 +1706,49 @@ void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
-static void wined3d_cs_exec_set_unordered_access_view(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_set_unordered_access_views(struct wined3d_cs *cs, const void *data) { - const struct wined3d_cs_set_unordered_access_view *op = data; - struct wined3d_unordered_access_view *prev; + const struct wined3d_cs_set_unordered_access_views *op = data; + unsigned int i;
- prev = cs->state.unordered_access_view[op->pipeline][op->view_idx]; - cs->state.unordered_access_view[op->pipeline][op->view_idx] = op->view; + for (i = 0; i < op->count; ++i) + { + struct wined3d_unordered_access_view *prev = cs->state.unordered_access_view[op->pipeline][op->start_idx + i]; + struct wined3d_unordered_access_view *view = op->uavs[i].view; + unsigned int initial_count = op->uavs[i].initial_count;
- if (op->view) - InterlockedIncrement(&op->view->resource->bind_count); - if (prev) - InterlockedDecrement(&prev->resource->bind_count); + cs->state.unordered_access_view[op->pipeline][op->start_idx + i] = view;
- if (op->view && op->initial_count != ~0u) - wined3d_unordered_access_view_set_counter(op->view, op->initial_count); + if (view) + InterlockedIncrement(&view->resource->bind_count); + if (prev) + InterlockedDecrement(&prev->resource->bind_count); + + if (view && initial_count != ~0u) + wined3d_unordered_access_view_set_counter(view, initial_count); + }
device_invalidate_state(cs->c.device, STATE_UNORDERED_ACCESS_VIEW_BINDING(op->pipeline)); }
-void wined3d_device_context_emit_set_unordered_access_view(struct wined3d_device_context *context, - enum wined3d_pipeline pipeline, unsigned int view_idx, struct wined3d_unordered_access_view *view, - unsigned int initial_count) +void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context *context, + enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, + struct wined3d_unordered_access_view *const *views, const unsigned int *initial_counts) { - struct wined3d_cs_set_unordered_access_view *op; + struct wined3d_cs_set_unordered_access_views *op; + unsigned int i;
- op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW; + op = wined3d_device_context_require_space(context, + offsetof(struct wined3d_cs_set_unordered_access_views, uavs[count]), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS; op->pipeline = pipeline; - op->view_idx = view_idx; - op->view = view; - op->initial_count = initial_count; + op->start_idx = start_idx; + op->count = count; + for (i = 0; i < count; ++i) + { + op->uavs[i].view = views[i]; + op->uavs[i].initial_count = initial_counts ? initial_counts[i] : ~0u; + }
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); } @@ -2917,7 +2933,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_CONSTANT_BUFFERS */ wined3d_cs_exec_set_constant_buffers, /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, /* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS */ wined3d_cs_exec_set_shader_resource_views, - /* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_set_unordered_access_view, + /* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEWS */ wined3d_cs_exec_set_unordered_access_views, /* WINED3D_CS_OP_SET_SAMPLERS */ wined3d_cs_exec_set_samplers, /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, /* WINED3D_CS_OP_SET_BLEND_STATE */ wined3d_cs_exec_set_blend_state, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e9d4d0a0677..bb37f6aff51 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1703,13 +1703,8 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte }
for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i) - { - for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j) - { - wined3d_device_context_emit_set_unordered_access_view(context, i, j, - state->unordered_access_view[i][j], ~0); - } - } + wined3d_device_context_emit_set_unordered_access_views(context, i, 0, MAX_UNORDERED_ACCESS_VIEWS, + state->unordered_access_view[i], NULL);
wined3d_device_context_push_constants(context, WINED3D_PUSH_CONSTANTS_VS_F, 0, WINED3D_MAX_VS_CONSTS_F, state->vs_consts_f); @@ -2063,31 +2058,37 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co } }
-void CDECL wined3d_device_context_set_unordered_access_view(struct wined3d_device_context *context, - enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav, - unsigned int initial_count) +void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context, + enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, + struct wined3d_unordered_access_view *const *uavs, const unsigned int *initial_counts) { struct wined3d_state *state = context->state; - struct wined3d_unordered_access_view *prev; + unsigned int i;
- TRACE("context %p, pipeline %#x, idx %u, uav %p, initial_count %u.\n", context, pipeline, idx, uav, initial_count); + TRACE("context %p, pipeline %#x, start_idx %u, count %u, uavs %p, initial_counts %p.\n", + context, pipeline, start_idx, count, uavs, initial_counts);
- if (idx >= MAX_UNORDERED_ACCESS_VIEWS) + if (!wined3d_bound_range(start_idx, count, MAX_UNORDERED_ACCESS_VIEWS)) { - WARN("Invalid UAV index %u.\n", idx); + WARN("Invalid UAV index %u, count %u.\n", start_idx, count); return; }
- prev = state->unordered_access_view[pipeline][idx]; - if (uav == prev && initial_count == ~0u) + if (!memcmp(uavs, &state->unordered_access_view[pipeline][start_idx], count * sizeof(*uavs)) && !initial_counts) return;
- if (uav) - wined3d_unordered_access_view_incref(uav); - state->unordered_access_view[pipeline][idx] = uav; - wined3d_device_context_emit_set_unordered_access_view(context, pipeline, idx, uav, initial_count); - if (prev) - wined3d_unordered_access_view_decref(prev); + wined3d_device_context_emit_set_unordered_access_views(context, pipeline, start_idx, count, uavs, initial_counts); + for (i = 0; i < count; ++i) + { + struct wined3d_unordered_access_view *prev = state->unordered_access_view[pipeline][start_idx + i]; + struct wined3d_unordered_access_view *uav = uavs[i]; + + if (uav) + wined3d_unordered_access_view_incref(uav); + state->unordered_access_view[pipeline][start_idx + i] = uav; + if (prev) + wined3d_unordered_access_view_decref(prev); + } }
static void wined3d_device_context_unbind_srv_for_rtv(struct wined3d_device_context *context, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 4d4f34f8d6a..13c8b218b65 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -138,7 +138,7 @@ @ cdecl wined3d_device_context_set_state(ptr ptr) @ cdecl wined3d_device_context_set_stream_output(ptr long ptr long) @ cdecl wined3d_device_context_set_stream_source(ptr long ptr long long) -@ cdecl wined3d_device_context_set_unordered_access_view(ptr long long ptr long) +@ cdecl wined3d_device_context_set_unordered_access_views(ptr long long long ptr ptr) @ cdecl wined3d_device_context_set_vertex_declaration(ptr ptr) @ cdecl wined3d_device_context_set_viewports(ptr long ptr) @ cdecl wined3d_device_context_unmap(ptr ptr long) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 91fb681a691..36fdf56a73c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4856,9 +4856,9 @@ void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context enum wined3d_texture_stage_state state, unsigned int value) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_transform(struct wined3d_device_context *context, enum wined3d_transform_state state, const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN; -void wined3d_device_context_emit_set_unordered_access_view(struct wined3d_device_context *context, - enum wined3d_pipeline pipeline, unsigned int view_idx, struct wined3d_unordered_access_view *view, - unsigned int initial_count) DECLSPEC_HIDDEN; +void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context *context, + enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, + struct wined3d_unordered_access_view *const *views, const unsigned int *initial_count) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 10253cab87d..21b9e01efd0 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2527,9 +2527,9 @@ void __cdecl wined3d_device_context_set_stream_output(struct wined3d_device_cont struct wined3d_buffer *buffer, unsigned int offset); HRESULT __cdecl wined3d_device_context_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx, struct wined3d_buffer *buffer, unsigned int offset, unsigned int stride); -void __cdecl wined3d_device_context_set_unordered_access_view(struct wined3d_device_context *context, - enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav, - unsigned int initial_count); +void __cdecl wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context, + enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count, + struct wined3d_unordered_access_view *const *uavs, const unsigned int *initial_counts); void __cdecl wined3d_device_context_set_vertex_declaration(struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration); void __cdecl wined3d_device_context_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3d11/device.c | 35 +++++++++++------------- dlls/wined3d/cs.c | 49 ++++++++++++++++------------------ dlls/wined3d/device.c | 40 +++++++++++---------------- dlls/wined3d/wined3d.spec | 2 +- dlls/wined3d/wined3d_private.h | 10 ++----- include/wine/wined3d.h | 10 +++++-- 6 files changed, 65 insertions(+), 81 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 93df97e59ae..635173371db 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -1181,24 +1181,22 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetDepthStencilState(ID3D11 static void STDMETHODCALLTYPE d3d11_device_context_SOSetTargets(ID3D11DeviceContext1 *iface, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *offsets) { + struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS] = {0}; struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int count, i; + unsigned int i;
TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets);
- count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT); - wined3d_mutex_lock(); - for (i = 0; i < count; ++i) + for (i = 0; i < buffer_count; ++i) { struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
- wined3d_device_context_set_stream_output(context->wined3d_context, i, - buffer ? buffer->wined3d_buffer : NULL, offsets ? offsets[i] : 0); - } - for (; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i) - { - wined3d_device_context_set_stream_output(context->wined3d_context, i, NULL, 0); + outputs[i].buffer = buffer ? buffer->wined3d_buffer : NULL; + outputs[i].offset = offsets ? offsets[i] : 0; } + + wined3d_mutex_lock(); + wined3d_device_context_set_stream_outputs(context->wined3d_context, outputs); wined3d_mutex_unlock(); }
@@ -4909,25 +4907,22 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface, UINT target_count, ID3D10Buffer *const *targets, const UINT *offsets) { + struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS] = {0}; struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int count, i; + unsigned int i;
TRACE("iface %p, target_count %u, targets %p, offsets %p.\n", iface, target_count, targets, offsets);
- count = min(target_count, D3D10_SO_BUFFER_SLOT_COUNT); - wined3d_mutex_lock(); - for (i = 0; i < count; ++i) + for (i = 0; i < target_count; ++i) { struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(targets[i]);
- wined3d_device_context_set_stream_output(device->immediate_context.wined3d_context, i, - buffer ? buffer->wined3d_buffer : NULL, offsets[i]); + outputs[i].buffer = buffer ? buffer->wined3d_buffer : NULL; + outputs[i].offset = offsets ? offsets[i] : 0; }
- for (i = count; i < D3D10_SO_BUFFER_SLOT_COUNT; ++i) - { - wined3d_device_context_set_stream_output(device->immediate_context.wined3d_context, i, NULL, 0); - } + wined3d_mutex_lock(); + wined3d_device_context_set_stream_outputs(device->immediate_context.wined3d_context, outputs); wined3d_mutex_unlock(); }
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index f7e5009df46..49b4f529554 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -118,7 +118,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_VERTEX_DECLARATION, WINED3D_CS_OP_SET_STREAM_SOURCE, WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ, - WINED3D_CS_OP_SET_STREAM_OUTPUT, + WINED3D_CS_OP_SET_STREAM_OUTPUTS, WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_CONSTANT_BUFFERS, WINED3D_CS_OP_SET_TEXTURE, @@ -269,12 +269,10 @@ struct wined3d_cs_set_stream_source_freq UINT flags; };
-struct wined3d_cs_set_stream_output +struct wined3d_cs_set_stream_outputs { enum wined3d_cs_op opcode; - UINT stream_idx; - struct wined3d_buffer *buffer; - UINT offset; + struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]; };
struct wined3d_cs_set_index_buffer @@ -603,7 +601,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) WINED3D_TO_STR(WINED3D_CS_OP_SET_VERTEX_DECLARATION); WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCE); WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ); - WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_OUTPUT); + WINED3D_TO_STR(WINED3D_CS_OP_SET_STREAM_OUTPUTS); WINED3D_TO_STR(WINED3D_CS_OP_SET_INDEX_BUFFER); WINED3D_TO_STR(WINED3D_CS_OP_SET_CONSTANT_BUFFERS); WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE); @@ -1471,35 +1469,34 @@ void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_i wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT); }
-static void wined3d_cs_exec_set_stream_output(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_set_stream_outputs(struct wined3d_cs *cs, const void *data) { - const struct wined3d_cs_set_stream_output *op = data; - struct wined3d_stream_output *stream; - struct wined3d_buffer *prev; + const struct wined3d_cs_set_stream_outputs *op = data; + unsigned int i;
- stream = &cs->state.stream_output[op->stream_idx]; - prev = stream->buffer; - stream->buffer = op->buffer; - stream->offset = op->offset; + for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) + { + struct wined3d_buffer *prev = cs->state.stream_output[i].buffer; + struct wined3d_buffer *buffer = op->outputs[i].buffer;
- if (op->buffer) - InterlockedIncrement(&op->buffer->resource.bind_count); - if (prev) - InterlockedDecrement(&prev->resource.bind_count); + if (buffer) + InterlockedIncrement(&buffer->resource.bind_count); + if (prev) + InterlockedDecrement(&prev->resource.bind_count); + }
+ memcpy(cs->state.stream_output, op->outputs, sizeof(op->outputs)); device_invalidate_state(cs->c.device, STATE_STREAM_OUTPUT); }
-void wined3d_device_context_emit_set_stream_output(struct wined3d_device_context *context, unsigned int stream_idx, - struct wined3d_buffer *buffer, unsigned int offset) +void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context, + const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) { - struct wined3d_cs_set_stream_output *op; + struct wined3d_cs_set_stream_outputs *op;
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUT; - op->stream_idx = stream_idx; - op->buffer = buffer; - op->offset = offset; + op->opcode = WINED3D_CS_OP_SET_STREAM_OUTPUTS; + memcpy(op->outputs, outputs, sizeof(op->outputs));
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); } @@ -2928,7 +2925,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, /* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq, - /* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output, + /* WINED3D_CS_OP_SET_STREAM_OUTPUTS */ wined3d_cs_exec_set_stream_outputs, /* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, /* WINED3D_CS_OP_SET_CONSTANT_BUFFERS */ wined3d_cs_exec_set_constant_buffers, /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index bb37f6aff51..7a78a271aa1 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1676,11 +1676,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte wined3d_device_context_emit_set_depth_stencil_view(context, state->fb.depth_stencil); wined3d_device_context_emit_set_vertex_declaration(context, state->vertex_declaration);
- for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) - { - wined3d_device_context_emit_set_stream_output(context, i, - state->stream_output[i].buffer, state->stream_output[i].offset); - } + wined3d_device_context_emit_set_stream_outputs(context, state->stream_output);
for (i = 0; i < WINED3D_MAX_STREAMS; ++i) { @@ -2334,30 +2330,26 @@ void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_c wined3d_vertex_declaration_decref(prev); }
-void CDECL wined3d_device_context_set_stream_output(struct wined3d_device_context *context, unsigned int idx, - struct wined3d_buffer *buffer, unsigned int offset) +void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_context *context, + const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) { - struct wined3d_stream_output *stream; - struct wined3d_buffer *prev_buffer; + struct wined3d_state *state = context->state; + unsigned int i;
- TRACE("context %p, idx %u, buffer %p, offset %u.\n", context, idx, buffer, offset); + TRACE("context %p, outputs %p.\n", context, outputs);
- if (idx >= WINED3D_MAX_STREAM_OUTPUT_BUFFERS) + wined3d_device_context_emit_set_stream_outputs(context, outputs); + for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) { - WARN("Invalid stream output %u.\n", idx); - return; + struct wined3d_buffer *prev_buffer = state->stream_output[i].buffer; + struct wined3d_buffer *buffer = outputs[i].buffer; + + if (buffer) + wined3d_buffer_incref(buffer); + state->stream_output[i] = outputs[i]; + if (prev_buffer) + wined3d_buffer_decref(prev_buffer); } - - stream = &context->state->stream_output[idx]; - prev_buffer = stream->buffer; - - if (buffer) - wined3d_buffer_incref(buffer); - stream->buffer = buffer; - stream->offset = offset; - wined3d_device_context_emit_set_stream_output(context, idx, buffer, offset); - if (prev_buffer) - wined3d_buffer_decref(prev_buffer); }
void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, unsigned int start_vertex, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 13c8b218b65..ccd941af7a7 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -136,7 +136,7 @@ @ cdecl wined3d_device_context_set_shader(ptr long ptr) @ cdecl wined3d_device_context_set_shader_resource_views(ptr long long long ptr) @ cdecl wined3d_device_context_set_state(ptr ptr) -@ cdecl wined3d_device_context_set_stream_output(ptr long ptr long) +@ cdecl wined3d_device_context_set_stream_outputs(ptr ptr) @ cdecl wined3d_device_context_set_stream_source(ptr long ptr long long) @ cdecl wined3d_device_context_set_unordered_access_views(ptr long long long ptr ptr) @ cdecl wined3d_device_context_set_vertex_declaration(ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 36fdf56a73c..2708d5c7f32 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3660,12 +3660,6 @@ struct wined3d_rasterizer_state struct wine_rb_entry entry; };
-struct wined3d_stream_output -{ - struct wined3d_buffer *buffer; - UINT offset; -}; - #define LIGHTMAP_SIZE 43 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
@@ -4846,8 +4840,8 @@ void wined3d_device_context_emit_set_shader(struct wined3d_device_context *conte void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_shader_resource_view *const *views) DECLSPEC_HIDDEN; -void wined3d_device_context_emit_set_stream_output(struct wined3d_device_context *context, unsigned int stream_idx, - struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN; +void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context, + const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx, struct wined3d_buffer *buffer, unsigned int offset, unsigned int stride) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 21b9e01efd0..1369fffddf3 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2212,6 +2212,12 @@ struct wined3d_stateblock_state struct wined3d_light_state *light_state; };
+struct wined3d_stream_output +{ + struct wined3d_buffer *buffer; + unsigned int offset; +}; + struct wined3d_parent_ops { void (__stdcall *wined3d_object_destroyed)(void *parent); @@ -2523,8 +2529,8 @@ void __cdecl wined3d_device_context_set_shader_resource_views(struct wined3d_dev enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_shader_resource_view *const *views); void __cdecl wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state); -void __cdecl wined3d_device_context_set_stream_output(struct wined3d_device_context *context, unsigned int idx, - struct wined3d_buffer *buffer, unsigned int offset); +void __cdecl wined3d_device_context_set_stream_outputs(struct wined3d_device_context *context, + const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]); HRESULT __cdecl wined3d_device_context_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx, struct wined3d_buffer *buffer, unsigned int offset, unsigned int stride); void __cdecl wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context,
On Wed, 7 Jul 2021 at 03:44, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -1181,24 +1181,22 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetDepthStencilState(ID3D11 static void STDMETHODCALLTYPE d3d11_device_context_SOSetTargets(ID3D11DeviceContext1 *iface, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *offsets) {
- struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS] = {0}; struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface);
- unsigned int count, i;
unsigned int i;
TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets);
- count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT);
- wined3d_mutex_lock();
- for (i = 0; i < count; ++i)
- for (i = 0; i < buffer_count; ++i) { struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
wined3d_device_context_set_stream_output(context->wined3d_context, i,
buffer ? buffer->wined3d_buffer : NULL, offsets ? offsets[i] : 0);
- }
- for (; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i)
- {
wined3d_device_context_set_stream_output(context->wined3d_context, i, NULL, 0);
outputs[i].buffer = buffer ? buffer->wined3d_buffer : NULL;
}outputs[i].offset = offsets ? offsets[i] : 0;
- wined3d_mutex_lock();
- wined3d_device_context_set_stream_outputs(context->wined3d_context, outputs); wined3d_mutex_unlock();
}
Getting rid of the "count = min(buffer_count, D3D11_SO_BUFFER_SLOT_COUNT);" is a change in behaviour. It may be correct, but it doesn't belong in this patch.