Commit 1b8ccaab authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wined3d: Track resource binding as render target.

parent 8b4e07d5
...@@ -1060,6 +1060,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str ...@@ -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}; static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f};
const struct wined3d_swapchain_desc *swapchain_desc; const struct wined3d_swapchain_desc *swapchain_desc;
DWORD clear_flags = 0; DWORD clear_flags = 0;
unsigned int i;
HRESULT hr; HRESULT hr;
TRACE("device %p, swapchain %p.\n", device, swapchain); TRACE("device %p, swapchain %p.\n", device, swapchain);
...@@ -1096,6 +1097,10 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str ...@@ -1096,6 +1097,10 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str
} }
device->swapchains[0] = swapchain; 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)); memset(device->state.fb.render_targets, 0, sizeof(device->state.fb.render_targets));
if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device))) if (FAILED(hr = device->adapter->adapter_ops->adapter_init_3d(device)))
goto err_out; goto err_out;
...@@ -4849,13 +4854,19 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device ...@@ -4849,13 +4854,19 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device
return WINED3D_OK; return WINED3D_OK;
if (view) if (view)
{
wined3d_rendertarget_view_incref(view); wined3d_rendertarget_view_incref(view);
wined3d_rtv_bind_count_inc(view);
}
device->state.fb.render_targets[view_idx] = view; device->state.fb.render_targets[view_idx] = view;
wined3d_cs_emit_set_rendertarget_view(device->cs, view_idx, view); wined3d_cs_emit_set_rendertarget_view(device->cs, view_idx, view);
/* Release after the assignment, to prevent device_resource_released() /* Release after the assignment, to prevent device_resource_released()
* from seeing the surface as still in use. */ * from seeing the surface as still in use. */
if (prev) if (prev)
{
wined3d_rtv_bind_count_dec(prev);
wined3d_rendertarget_view_decref(prev); wined3d_rendertarget_view_decref(prev);
}
wined3d_unbind_srv_for_rtv(device, view, FALSE); wined3d_unbind_srv_for_rtv(device, view, FALSE);
...@@ -4888,7 +4899,6 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic ...@@ -4888,7 +4899,6 @@ HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *devic
wined3d_cs_emit_set_depth_stencil_view(device->cs, view); wined3d_cs_emit_set_depth_stencil_view(device->cs, view);
if (prev) if (prev)
wined3d_rendertarget_view_decref(prev); wined3d_rendertarget_view_decref(prev);
wined3d_unbind_srv_for_rtv(device, view, TRUE); wined3d_unbind_srv_for_rtv(device, view, TRUE);
return WINED3D_OK; return WINED3D_OK;
......
...@@ -3936,7 +3936,8 @@ struct wined3d_resource ...@@ -3936,7 +3936,8 @@ struct wined3d_resource
{ {
LONG ref; LONG ref;
LONG bind_count; LONG bind_count;
LONG srv_bind_count_device; uint32_t srv_bind_count_device;
uint32_t rtv_bind_count_device;
LONG map_count; LONG map_count;
LONG access_count; LONG access_count;
struct wined3d_device *device; struct wined3d_device *device;
...@@ -5975,23 +5976,24 @@ static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_vi ...@@ -5975,23 +5976,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, 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_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; const struct wined3d_rendertarget_view *dsv;
unsigned int i;
if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL) if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
&& (dsv = state->fb.depth_stencil) && dsv->resource == resource && (dsv = state->fb.depth_stencil) && dsv->resource == resource
&& wined3d_dsv_srv_conflict(dsv, srv_format)) && wined3d_dsv_srv_conflict(dsv, srv_format))
return TRUE; return TRUE;
if (!(resource->bind_flags & WINED3D_BIND_RENDER_TARGET)) return resource->rtv_bind_count_device;
return FALSE; }
for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i) static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv)
if (rts[i] && rts[i]->resource == resource) {
return TRUE; ++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) static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment