Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 169 ++++++++++++--------------------- dlls/wined3d/cs.c | 53 ++++++----- dlls/wined3d/device.c | 71 ++++++++------ dlls/wined3d/wined3d.spec | 2 +- dlls/wined3d/wined3d_private.h | 6 +- include/wine/wined3d.h | 5 +- 6 files changed, 141 insertions(+), 165 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 0ba195b73eb..bfb21b59839 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -578,6 +578,32 @@ static void d3d11_device_context_set_constant_buffers(ID3D11DeviceContext1 *ifac wined3d_mutex_unlock(); }
+static void d3d11_device_context_set_shader_resource_views(ID3D11DeviceContext1 *iface, enum wined3d_shader_type type, + unsigned int start_slot, unsigned int count, ID3D11ShaderResourceView *const *views) +{ + struct wined3d_shader_resource_view *wined3d_views[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; + struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); + unsigned int i; + + if (count > ARRAY_SIZE(wined3d_views)) + { + WARN("View count %u exceeds limit; ignoring call.\n", count); + return; + } + + for (i = 0; i < count; ++i) + { + struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); + + wined3d_views[i] = view ? view->wined3d_view : NULL; + } + + wined3d_mutex_lock(); + wined3d_device_context_set_shader_resource_views(context->wined3d_context, + type, start_slot, count, wined3d_views); + wined3d_mutex_unlock(); +} + static void STDMETHODCALLTYPE d3d11_device_context_GetDevice(ID3D11DeviceContext1 *iface, ID3D11Device **device) { struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); @@ -631,21 +657,10 @@ static void STDMETHODCALLTYPE d3d11_device_context_VSSetConstantBuffers(ID3D11De static void STDMETHODCALLTYPE d3d11_device_context_PSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_PIXEL, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_PSSetShader(ID3D11DeviceContext1 *iface, @@ -913,20 +928,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_IASetPrimitiveTopology(ID3D11 static void STDMETHODCALLTYPE d3d11_device_context_VSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_VERTEX, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_VSSetSamplers(ID3D11DeviceContext1 *iface, @@ -1025,20 +1029,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_SetPredication(ID3D11DeviceCo static void STDMETHODCALLTYPE d3d11_device_context_GSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_GEOMETRY, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_GSSetSamplers(ID3D11DeviceContext1 *iface, @@ -1543,21 +1536,10 @@ static void STDMETHODCALLTYPE d3d11_device_context_ExecuteCommandList(ID3D11Devi static void STDMETHODCALLTYPE d3d11_device_context_HSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_HULL, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_HULL, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_HSSetShader(ID3D11DeviceContext1 *iface, @@ -1611,21 +1593,10 @@ static void STDMETHODCALLTYPE d3d11_device_context_HSSetConstantBuffers(ID3D11De static void STDMETHODCALLTYPE d3d11_device_context_DSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_DOMAIN, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_DOMAIN, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_DSSetShader(ID3D11DeviceContext1 *iface, @@ -1679,21 +1650,10 @@ static void STDMETHODCALLTYPE d3d11_device_context_DSSetConstantBuffers(ID3D11De static void STDMETHODCALLTYPE d3d11_device_context_CSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D11ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(context->wined3d_context, WINED3D_SHADER_TYPE_COMPUTE, - start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d11_device_context_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_COMPUTE, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d11_device_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1 *iface, @@ -4589,6 +4549,32 @@ static void d3d10_device_set_constant_buffers(ID3D10Device1 *iface, enum wined3d wined3d_mutex_unlock(); }
+static void d3d10_device_set_shader_resource_views(ID3D10Device1 *iface, enum wined3d_shader_type type, + unsigned int start_slot, unsigned int count, ID3D10ShaderResourceView *const *views) +{ + struct wined3d_shader_resource_view *wined3d_views[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; + struct d3d_device *device = impl_from_ID3D10Device(iface); + unsigned int i; + + if (count > ARRAY_SIZE(wined3d_views)) + { + WARN("View count %u exceeds limit; ignoring call.\n", count); + return; + } + + for (i = 0; i < count; ++i) + { + struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]); + + wined3d_views[i] = view ? view->wined3d_view : NULL; + } + + wined3d_mutex_lock(); + wined3d_device_context_set_shader_resource_views(device->immediate_context.wined3d_context, + type, start_slot, count, wined3d_views); + wined3d_mutex_unlock(); +} + static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) { @@ -4602,21 +4588,10 @@ static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *i static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface, UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(device->immediate_context.wined3d_context, - WINED3D_SHADER_TYPE_PIXEL, start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d10_device_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface, @@ -4826,21 +4801,10 @@ static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface, UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(device->immediate_context.wined3d_context, - WINED3D_SHADER_TYPE_VERTEX, start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d10_device_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface, @@ -4880,21 +4844,10 @@ static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface, UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
- wined3d_mutex_lock(); - for (i = 0; i < view_count; ++i) - { - struct d3d_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]); - - wined3d_device_context_set_shader_resource_view(device->immediate_context.wined3d_context, - WINED3D_SHADER_TYPE_GEOMETRY, start_slot + i, view ? view->wined3d_view : NULL); - } - wined3d_mutex_unlock(); + d3d10_device_set_shader_resource_views(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, view_count, views); }
static void STDMETHODCALLTYPE d3d10_device_GSSetSamplers(ID3D10Device1 *iface, diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 712a20696a4..12d3c99e909 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -118,7 +118,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_CONSTANT_BUFFERS, WINED3D_CS_OP_SET_TEXTURE, - WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW, + WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS, WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW, WINED3D_CS_OP_SET_SAMPLER, WINED3D_CS_OP_SET_SHADER, @@ -307,12 +307,13 @@ struct wined3d_cs_set_color_key struct wined3d_color_key color_key; };
-struct wined3d_cs_set_shader_resource_view +struct wined3d_cs_set_shader_resource_views { enum wined3d_cs_op opcode; enum wined3d_shader_type type; - UINT view_idx; - struct wined3d_shader_resource_view *view; + unsigned int start_idx; + unsigned int count; + struct wined3d_shader_resource_view *views[1]; };
struct wined3d_cs_set_unordered_access_view @@ -606,7 +607,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op) 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); - WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW); + 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_SAMPLER); WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER); @@ -1665,18 +1666,23 @@ void wined3d_device_context_emit_set_texture(struct wined3d_device_context *cont wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
-static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_set_shader_resource_views(struct wined3d_cs *cs, const void *data) { - const struct wined3d_cs_set_shader_resource_view *op = data; - struct wined3d_shader_resource_view *prev; + const struct wined3d_cs_set_shader_resource_views *op = data; + unsigned int i;
- prev = cs->state.shader_resource_view[op->type][op->view_idx]; - cs->state.shader_resource_view[op->type][op->view_idx] = op->view; + for (i = 0; i < op->count; ++i) + { + struct wined3d_shader_resource_view *prev = cs->state.shader_resource_view[op->type][op->start_idx + i]; + struct wined3d_shader_resource_view *view = op->views[i];
- if (op->view) - InterlockedIncrement(&op->view->resource->bind_count); - if (prev) - InterlockedDecrement(&prev->resource->bind_count); + cs->state.shader_resource_view[op->type][op->start_idx + i] = view; + + if (view) + InterlockedIncrement(&view->resource->bind_count); + if (prev) + InterlockedDecrement(&prev->resource->bind_count); + }
if (op->type != WINED3D_SHADER_TYPE_COMPUTE) device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); @@ -1684,16 +1690,19 @@ static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, cons device_invalidate_state(cs->c.device, STATE_COMPUTE_SHADER_RESOURCE_BINDING); }
-void wined3d_device_context_emit_set_shader_resource_view(struct wined3d_device_context *context, - enum wined3d_shader_type type, unsigned int view_idx, struct wined3d_shader_resource_view *view) +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) { - struct wined3d_cs_set_shader_resource_view *op; + struct wined3d_cs_set_shader_resource_views *op;
- op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW; + op = wined3d_device_context_require_space(context, + offsetof(struct wined3d_cs_set_shader_resource_views, views[count]), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS; op->type = type; - op->view_idx = view_idx; - op->view = view; + op->start_idx = start_idx; + op->count = count; + memcpy(op->views, views, count * sizeof(*views));
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); } @@ -2922,7 +2931,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* 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, - /* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW */ wined3d_cs_exec_set_shader_resource_view, + /* 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_SAMPLER */ wined3d_cs_exec_set_sampler, /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index f0aa9fbd250..a90c55bb6d6 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1701,10 +1701,8 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte { wined3d_device_context_emit_set_sampler(context, i, j, state->sampler[i][j]); } - for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j) - { - wined3d_device_context_emit_set_shader_resource_view(context, i, j, state->shader_resource_view[i][j]); - } + wined3d_device_context_emit_set_shader_resource_views(context, i, 0, + MAX_SHADER_RESOURCE_VIEWS, state->shader_resource_view[i]); }
for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i) @@ -1980,45 +1978,58 @@ void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_contex wined3d_device_context_emit_set_scissor_rects(context, rect_count, rects); }
-void CDECL wined3d_device_context_set_shader_resource_view(struct wined3d_device_context *context, - enum wined3d_shader_type type, unsigned int idx, struct wined3d_shader_resource_view *view) +void CDECL wined3d_device_context_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 *const views) { + struct wined3d_shader_resource_view *real_views[MAX_SHADER_RESOURCE_VIEWS]; struct wined3d_state *state = context->state; - const struct wined3d_rendertarget_view *dsv; - struct wined3d_shader_resource_view *prev; + const struct wined3d_rendertarget_view *dsv = state->fb.depth_stencil; + unsigned int i;
- TRACE("context %p, type %#x, idx %u, view %p.\n", context, type, idx, view); + TRACE("context %p, type %#x, start_idx %u, count %u, views %p.\n", context, type, start_idx, count, views);
- if (idx >= MAX_SHADER_RESOURCE_VIEWS) + if (start_idx + count > MAX_SHADER_RESOURCE_VIEWS) { - WARN("Invalid view index %u.\n", idx); + WARN("Invalid view index %u, count %u.\n", start_idx, count); return; }
- prev = state->shader_resource_view[type][idx]; - if (view == prev) + if (!memcmp(views, &state->shader_resource_view[type][start_idx], count * sizeof(*views))) return;
- if (view && (wined3d_is_srv_rtv_bound(state, view) - || ((dsv = state->fb.depth_stencil) - && dsv->resource == view->resource && wined3d_dsv_srv_conflict(dsv, view->format)))) + memcpy(real_views, views, count * sizeof(*views)); + + for (i = 0; i < count; ++i) { - WARN("Application is trying to bind resource which is attached as render target.\n"); - view = NULL; + struct wined3d_shader_resource_view *view = real_views[i]; + + if (view && (wined3d_is_srv_rtv_bound(state, view) + || (dsv && 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"); + real_views[i] = NULL; + } }
- if (view) + wined3d_device_context_emit_set_shader_resource_views(context, type, start_idx, count, real_views); + for (i = 0; i < count; ++i) { - wined3d_shader_resource_view_incref(view); - wined3d_srv_bind_count_inc(view); - } + struct wined3d_shader_resource_view *prev = state->shader_resource_view[type][start_idx + i]; + struct wined3d_shader_resource_view *view = real_views[i];
- state->shader_resource_view[type][idx] = view; - wined3d_device_context_emit_set_shader_resource_view(context, type, idx, view); - if (prev) - { - wined3d_srv_bind_count_dec(prev); - wined3d_shader_resource_view_decref(prev); + if (view) + { + wined3d_shader_resource_view_incref(view); + wined3d_srv_bind_count_inc(view); + } + + state->shader_resource_view[type][start_idx + i] = view; + if (prev) + { + wined3d_srv_bind_count_dec(prev); + wined3d_shader_resource_view_decref(prev); + } } }
@@ -2098,8 +2109,10 @@ static void wined3d_device_context_unbind_srv_for_rtv(struct wined3d_device_cont && ((!dsv && wined3d_is_srv_rtv_bound(state, srv)) || (dsv && wined3d_dsv_srv_conflict(view, srv->format)))) { + static struct wined3d_shader_resource_view *const null_srv; + WARN("Application sets bound resource as render target.\n"); - wined3d_device_context_set_shader_resource_view(context, i, j, NULL); + wined3d_device_context_set_shader_resource_views(context, i, j, 1, &null_srv); } } } diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 3f22af60689..2c61996be6d 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -133,7 +133,7 @@ @ cdecl wined3d_device_context_set_sampler(ptr long long ptr) @ cdecl wined3d_device_context_set_scissor_rects(ptr long ptr) @ cdecl wined3d_device_context_set_shader(ptr long ptr) -@ cdecl wined3d_device_context_set_shader_resource_view(ptr long 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_source(ptr long ptr long long) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index afdea25ded9..ff10b1362f9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4821,9 +4821,9 @@ void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader) DECLSPEC_HIDDEN; -void wined3d_device_context_emit_set_shader_resource_view(struct wined3d_device_context *context, - enum wined3d_shader_type type, unsigned int view_idx, - struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN; +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_source(struct wined3d_device_context *context, unsigned int stream_idx, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 2e01d27ed68..7272a40287e 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2517,8 +2517,9 @@ void __cdecl wined3d_device_context_set_scissor_rects(struct wined3d_device_cont const RECT *rects); void __cdecl wined3d_device_context_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader); -void __cdecl wined3d_device_context_set_shader_resource_view(struct wined3d_device_context *context, - enum wined3d_shader_type type, unsigned int idx, struct wined3d_shader_resource_view *view); +void __cdecl wined3d_device_context_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); 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);