Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v2: - change helpers' names; - use uint32_t instead of long.
dlls/wined3d/device.c | 12 +++++++++++- dlls/wined3d/wined3d_private.h | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 7fef322e3d0..ac2748a141f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1060,6 +1060,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; DWORD clear_flags = 0; + unsigned int i; HRESULT hr;
TRACE("device %p, swapchain %p.\n", device, swapchain); @@ -1096,6 +1097,10 @@ 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]); + memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets)); if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device))) goto err_out; @@ -4873,13 +4878,19 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device return WINED3D_OK;
if (view) + { wined3d_rendertarget_view_incref(view); + wined3d_rtv_bind_count_inc(view); + } device->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. */ if (prev) + { + wined3d_rtv_bind_count_dec(prev); wined3d_rendertarget_view_decref(prev); + }
wined3d_unbind_srv_for_rtv(device, view, FALSE);
@@ -4912,7 +4923,6 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic wined3d_cs_emit_set_depth_stencil_view(device->cs, view); if (prev) wined3d_rendertarget_view_decref(prev); - wined3d_unbind_srv_for_rtv(device, view, TRUE);
return WINED3D_OK; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 048c16663f4..b828e45046c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3953,7 +3953,8 @@ struct wined3d_resource { LONG ref; LONG bind_count; - LONG srv_bind_count_device; + uint32_t srv_bind_count_device; + uint32_t rtv_bind_count_device; LONG map_count; LONG access_count; struct wined3d_device *device; @@ -5999,23 +6000,24 @@ static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_vi static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_state *state, const struct wined3d_resource *resource, const struct wined3d_format *srv_format) { - struct wined3d_rendertarget_view * const *rts = &state->fb.render_targets[0]; const struct wined3d_rendertarget_view *dsv; - unsigned int i;
if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL) && (dsv = state->fb.depth_stencil) && dsv->resource == resource && wined3d_dsv_srv_conflict(dsv, srv_format)) return TRUE;
- if (!(resource->bind_flags & WINED3D_BIND_RENDER_TARGET)) - return FALSE; + return resource->rtv_bind_count_device; +}
- for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i) - if (rts[i] && rts[i]->resource == resource) - return TRUE; +static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv) +{ + ++rtv->resource->rtv_bind_count_device; +}
- return FALSE; +static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv) +{ + --rtv->resource->rtv_bind_count_device; }
static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/wined3d/context.c | 3 ++- dlls/wined3d/device.c | 5 ++++- dlls/wined3d/wined3d_private.h | 13 ------------- 3 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 3a263e1f6bd..08c6e27922c 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -347,7 +347,8 @@ static void context_preload_texture(struct wined3d_context *context, if (!(texture = state->textures[idx])) return;
- if (wined3d_resource_check_fbo_attached(state, &texture->resource, NULL)) + if (texture->resource.rtv_bind_count_device || (state->fb.depth_stencil + && state->fb.depth_stencil->resource == &texture->resource)) context->uses_fbo_attached_resources = 1;
wined3d_texture_load(texture, context, is_srgb_enabled(state->sampler_states[idx])); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ac2748a141f..ff74cab70e9 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1952,6 +1952,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) { + const struct wined3d_rendertarget_view *dsv; struct wined3d_shader_resource_view *prev;
if (idx >= MAX_SHADER_RESOURCE_VIEWS) @@ -1964,7 +1965,9 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic if (view == prev) return;
- if (view && wined3d_resource_check_fbo_attached(&device->state, view->resource, view->format)) + if (view && (view->resource->rtv_bind_count_device + || ((dsv = device->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"); view = NULL; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b828e45046c..0f880778d3c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5997,19 +5997,6 @@ static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_vi || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL)); }
-static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_state *state, - const struct wined3d_resource *resource, const struct wined3d_format *srv_format) -{ - const struct wined3d_rendertarget_view *dsv; - - if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL) - && (dsv = state->fb.depth_stencil) && dsv->resource == resource - && wined3d_dsv_srv_conflict(dsv, srv_format)) - return TRUE; - - return resource->rtv_bind_count_device; -} - static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv) { ++rtv->resource->rtv_bind_count_device;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v2: - change helpers' names; - use bool instead of BOOL; - use a separate structure for per-subresource counts; - try harder to avoid crawling through per-subresource counts.
dlls/d3d11/tests/d3d11.c | 70 ++++++++++++-- dlls/wined3d/device.c | 11 ++- dlls/wined3d/resource.c | 1 + dlls/wined3d/stateblock.c | 2 +- dlls/wined3d/wined3d_private.h | 169 ++++++++++++++++++++++++++++++++- 5 files changed, 238 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 67d843ae9e5..afdb3a085c7 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -29453,12 +29453,13 @@ static void test_desktop_window(void)
static void test_sample_attached_rtv(void) { - ID3D11ShaderResourceView *srv, *srv_test, *srv_ds; + ID3D11ShaderResourceView *srv, *srv2, *srv_test, *srv_ds; + D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc, srvds_desc; ID3D11Texture2D *texture, *texture2, *dstexture; - D3D11_SHADER_RESOURCE_VIEW_DESC srvds_desc; + ID3D11RenderTargetView *rtv, *rtv2, *rtvs[2]; D3D11_DEPTH_STENCIL_VIEW_DESC dsview_desc; struct d3d11_test_context test_context; - ID3D11RenderTargetView *rtv, *rtvs[2]; + D3D11_RENDER_TARGET_VIEW_DESC rtv_desc; D3D11_TEXTURE2D_DESC texture_desc; D3D_FEATURE_LEVEL feature_level; D3D11_SAMPLER_DESC sampler_desc; @@ -29472,6 +29473,7 @@ static void test_sample_attached_rtv(void) ID3D11Device *device; unsigned int x, y; unsigned int i; + D3D11_BOX box; DWORD color; HRESULT hr;
@@ -29574,7 +29576,7 @@ static void test_sample_attached_rtv(void)
texture_desc.Width = 64; texture_desc.Height = 64; - texture_desc.MipLevels = 1; + texture_desc.MipLevels = 2; texture_desc.ArraySize = 1; texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -29598,7 +29600,15 @@ static void test_sample_attached_rtv(void)
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
- hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture2, NULL, &rtv); + memset(&rtv_desc, 0, sizeof(rtv_desc)); + rtv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + rtv_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + U(rtv_desc).Texture2D.MipSlice = 0; + + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture2, &rtv_desc, &rtv); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + U(rtv_desc).Texture2D.MipSlice = 1; + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture2, &rtv_desc, &rtv2); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
rtvs[0] = test_context.backbuffer_rtv; @@ -29606,12 +29616,20 @@ static void test_sample_attached_rtv(void)
ID3D11DeviceContext_OMSetRenderTargets(context, 2, rtvs, NULL);
- hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srv); + memset(&srv_desc, 0, sizeof(srv_desc)); + srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + U(srv_desc).Texture2D.MipLevels = 1; + + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, &srv_desc, &srv); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv);
draw_quad(&test_context);
+ set_box(&box, 0, 0, 0, 320, 240, 1); + ID3D11DeviceContext_CopySubresourceRegion(context, (ID3D11Resource *)texture2, 1, 0, 0, 0, (ID3D11Resource *)texture2, 0, &box); + get_texture_readback(texture2, 0, &rb); for (y = 0; y < 4; ++y) { @@ -29623,12 +29641,29 @@ static void test_sample_attached_rtv(void) } } release_resource_readback(&rb); + get_texture_readback(texture2, 1, &rb); + for (y = 0; y < 4; ++y) + { + for (x = 0; x < 4; ++x) + { + color = get_readback_color(&rb, 40 + x * 80, 30 + y * 60, 0); + ok(compare_color(color, 0x40404040, 2), + "Got unexpected color 0x%08x at (%u, %u).\n", color, x, y); + } + } + release_resource_readback(&rb);
ID3D11ShaderResourceView_Release(srv); + ID3D11DeviceContext_OMSetRenderTargets(context, 2, rtvs, NULL);
ID3D11DeviceContext_ClearRenderTargetView(context, rtv, red);
- hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture2, NULL, &srv); + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture2, &srv_desc, &srv); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + + U(srv_desc).Texture2D.MostDetailedMip = 1; + U(srv_desc).Texture2D.MipLevels = 1; + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture2, &srv_desc, &srv2); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
memset(&blend_desc, 0, sizeof(blend_desc)); @@ -29705,6 +29740,25 @@ static void test_sample_attached_rtv(void) ID3D11DeviceContext_PSGetShaderResources(context, 0, 1, &srv_test); ok(!srv_test, "Unexpected SRV %p.\n", srv_test);
+ ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv2); + ID3D11DeviceContext_OMSetRenderTargets(context, 2, rtvs, NULL); + ID3D11DeviceContext_PSGetShaderResources(context, 0, 1, &srv_test); + ok(!!srv_test, "Unexpected SRV %p.\n", srv_test); + ID3D11ShaderResourceView_Release(srv_test); + + draw_quad(&test_context); + get_texture_readback(test_context.backbuffer, 0, &rb); + for (y = 0; y < 4; ++y) + { + for (x = 0; x < 4; ++x) + { + color = get_readback_color(&rb, 80 + x * 160, 60 + y * 120, 0); + ok(compare_color(color, 0x80808080, 2), + "Got unexpected color 0x%08x at (%u, %u).\n", color, x, y); + } + } + release_resource_readback(&rb); + texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL; memset(&dsview_desc, 0, sizeof(dsview_desc)); dsview_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; @@ -29762,7 +29816,9 @@ static void test_sample_attached_rtv(void)
ID3D11DeviceContext_OMSetRenderTargets(context, 2, rtvs, NULL);
+ ID3D11RenderTargetView_Release(rtv2); ID3D11RenderTargetView_Release(rtv); + ID3D11ShaderResourceView_Release(srv2); ID3D11ShaderResourceView_Release(srv); ID3D11SamplerState_Release(sampler); ID3D11PixelShader_Release(ps); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ff74cab70e9..a2ce76ab9dc 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1965,7 +1965,7 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic if (view == prev) return;
- if (view && (view->resource->rtv_bind_count_device + if (view && (wined3d_is_srv_rtv_bound(view) || ((dsv = device->state.fb.depth_stencil) && dsv->resource == view->resource && wined3d_dsv_srv_conflict(dsv, view->format)))) { @@ -1976,14 +1976,14 @@ static void wined3d_device_set_shader_resource_view(struct wined3d_device *devic if (view) { wined3d_shader_resource_view_incref(view); - ++view->resource->srv_bind_count_device; + wined3d_srv_bind_count_inc(view); }
device->state.shader_resource_view[type][idx] = view; wined3d_cs_emit_set_shader_resource_view(device->cs, type, idx, view); if (prev) { - --prev->resource->srv_bind_count_device; + wined3d_srv_bind_count_dec(prev); wined3d_shader_resource_view_decref(prev); } } @@ -4817,7 +4817,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) { - if (view && view->resource->srv_bind_count_device) + if (view && wined3d_is_rtv_srv_bound(view)) { const struct wined3d_resource *resource = view->resource; const struct wined3d_shader_resource_view *srv; @@ -4828,7 +4828,8 @@ 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 - && (!dsv || wined3d_dsv_srv_conflict(view, srv->format))) + && ((!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); } } diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 15e4a45ea59..c8d5fecf9d9 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -233,6 +233,7 @@ static void wined3d_resource_destroy_object(void *object) { struct wined3d_resource *resource = object;
+ heap_free(resource->sub_resource_bind_counts_device); wined3d_resource_free_sysmem(resource); context_resource_released(resource->device, resource); wined3d_resource_release(resource); diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index e7deb2464db..5ff9f3cc3f8 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -450,7 +450,7 @@ void state_unbind_resources(struct wined3d_state *state) if ((srv = state->shader_resource_view[i][j])) { state->shader_resource_view[i][j] = NULL; - --srv->resource->srv_bind_count_device; + wined3d_srv_bind_count_dec(srv); wined3d_shader_resource_view_decref(srv); } } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0f880778d3c..de6cd82ecf6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3949,6 +3949,9 @@ struct wined3d_resource_ops HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx); };
+#define WINED3D_SUB_RESOURCES_BIND_SRV 1 +#define WINED3D_SUB_RESOURCES_BIND_RTV 2 + struct wined3d_resource { LONG ref; @@ -3981,6 +3984,14 @@ struct wined3d_resource const struct wined3d_resource_ops *resource_ops;
struct list resource_list_entry; + + struct + { + uint32_t srv; + uint32_t rtv; + } + *sub_resource_bind_counts_device; + uint32_t sub_resource_bind_flags; };
static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource) @@ -5997,14 +6008,168 @@ static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_vi || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL)); }
+static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view *srv) +{ + struct wined3d_texture *texture; + + if (srv->resource->type == WINED3D_RTYPE_BUFFER) + return TRUE; + + if (srv->desc.u.texture.layer_idx || srv->desc.u.texture.level_idx) + return FALSE; + + texture = texture_from_resource(srv->resource); + return srv->desc.u.texture.level_count == texture->level_count + && srv->desc.u.texture.layer_count == texture->layer_count; +} + +static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view *rtv) +{ + struct wined3d_texture *texture; + + if (rtv->resource->type == WINED3D_RTYPE_BUFFER) + return TRUE; + + if (rtv->sub_resource_idx) + return FALSE; + + texture = texture_from_resource(rtv->resource); + return texture->level_count == 1 && rtv->layer_count == texture->layer_count; +} + +static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv) +{ + struct wined3d_resource *resource = srv->resource; + struct wined3d_texture *texture; + unsigned int level, layer; + + ++resource->srv_bind_count_device; + + if (wined3d_srv_all_subresources(srv)) + return; + + texture = texture_from_resource(resource); + + if (!resource->sub_resource_bind_counts_device + && !(resource->sub_resource_bind_counts_device = heap_alloc_zero(texture->level_count + * texture->layer_count * sizeof(*resource->sub_resource_bind_counts_device)))) + return; + + for (layer = 0; layer < srv->desc.u.texture.layer_count; ++layer) + for (level = 0; level < srv->desc.u.texture.level_count; ++level) + ++resource->sub_resource_bind_counts_device[(layer + srv->desc.u.texture.layer_idx) + * texture->level_count + srv->desc.u.texture.level_idx + level].srv; + + resource->sub_resource_bind_flags |= WINED3D_SUB_RESOURCES_BIND_SRV; +} + +static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv) +{ + struct wined3d_resource *resource = srv->resource; + unsigned int level, layer, count; + struct wined3d_texture *texture; + + --resource->srv_bind_count_device; + + if (wined3d_srv_all_subresources(srv)) + return; + + texture = texture_from_resource(resource); + + count = 0; + for (layer = 0; layer < srv->desc.u.texture.layer_count; ++layer) + for (level = 0; level < srv->desc.u.texture.level_count; ++level) + count += --resource->sub_resource_bind_counts_device[(layer + srv->desc.u.texture.layer_idx) + * texture->level_count + srv->desc.u.texture.level_idx + level].srv; + + if (!count) + resource->sub_resource_bind_flags &= ~WINED3D_SUB_RESOURCES_BIND_SRV; +} + static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv) { - ++rtv->resource->rtv_bind_count_device; + struct wined3d_resource *resource = rtv->resource; + struct wined3d_texture *texture; + unsigned int layer; + + ++resource->rtv_bind_count_device; + + if (wined3d_rtv_all_subresources(rtv)) + return; + + texture = texture_from_resource(resource); + + if (!resource->sub_resource_bind_counts_device + && !(resource->sub_resource_bind_counts_device = heap_alloc_zero(texture->level_count + * texture->layer_count * sizeof(*resource->sub_resource_bind_counts_device)))) + return; + + for (layer = 0; layer < rtv->layer_count; ++layer) + ++resource->sub_resource_bind_counts_device[rtv->sub_resource_idx + layer * texture->level_count].rtv; + + resource->sub_resource_bind_flags |= WINED3D_SUB_RESOURCES_BIND_RTV; }
static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv) { - --rtv->resource->rtv_bind_count_device; + struct wined3d_resource *resource = rtv->resource; + struct wined3d_texture *texture; + unsigned int layer, count; + + --resource->rtv_bind_count_device; + + if (wined3d_rtv_all_subresources(rtv)) + return; + + texture = texture_from_resource(rtv->resource); + + count = 0; + for (layer = 0; layer < rtv->layer_count; ++layer) + count += --resource->sub_resource_bind_counts_device[rtv->sub_resource_idx + + layer * texture->level_count].rtv; + + if (!count) + resource->sub_resource_bind_flags &= ~WINED3D_SUB_RESOURCES_BIND_RTV; +} + +static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_shader_resource_view *srv) +{ + struct wined3d_resource *resource = srv->resource; + struct wined3d_texture *texture; + unsigned int level, layer; + + if (!resource->rtv_bind_count_device || !(resource->sub_resource_bind_flags & WINED3D_SUB_RESOURCES_BIND_RTV) + || wined3d_srv_all_subresources(srv)) + return resource->rtv_bind_count_device; + + texture = texture_from_resource(resource); + + for (layer = 0; layer < srv->desc.u.texture.layer_count; ++layer) + for (level = 0; level < srv->desc.u.texture.level_count; ++level) + if (resource->sub_resource_bind_counts_device[(layer + srv->desc.u.texture.layer_idx) + * texture->level_count + srv->desc.u.texture.level_idx + level].rtv) + return TRUE; + + return FALSE; +} + +static inline bool wined3d_is_rtv_srv_bound(const struct wined3d_rendertarget_view *rtv) +{ + struct wined3d_resource *resource = rtv->resource; + struct wined3d_texture *texture; + unsigned int layer; + + if (!resource->srv_bind_count_device || !(resource->sub_resource_bind_flags & WINED3D_SUB_RESOURCES_BIND_SRV) + || wined3d_rtv_all_subresources(rtv)) + return resource->srv_bind_count_device; + + texture = texture_from_resource(resource); + + for (layer = 0; layer < rtv->layer_count; ++layer) + if (resource->sub_resource_bind_counts_device[rtv->sub_resource_idx + layer * texture->level_count].srv) + return TRUE; + + return FALSE; }
static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
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=79265
Your paranoid android.
=== w10pro64 (32 bit report) ===
d3d11: d3d11.c:5804: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5805: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5806: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5809: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5810: Test failed: Got unexpected CPrimitives count: 0. d3d11.c:5651: Test failed: Got unexpected query result 0x0000000000000000.
=== w10pro64_ar (32 bit report) ===
d3d11: d3d11.c:5804: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5805: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5806: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5809: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5810: Test failed: Got unexpected CPrimitives count: 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com