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
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;
......@@ -4849,13 +4854,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);
......@@ -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);
if (prev)
wined3d_rendertarget_view_decref(prev);
wined3d_unbind_srv_for_rtv(device, view, TRUE);
return WINED3D_OK;
......
......@@ -3936,7 +3936,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;
......@@ -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,
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)
......
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