[PATCH 3/5] wined3d: Get rid of the "container" field from struct wined3d_surface.
Henri Verbeet
hverbeet at codeweavers.com
Wed Mar 14 03:09:14 CDT 2018
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/cs.c | 12 +++++-------
dlls/wined3d/device.c | 25 +++++++++++++++++--------
dlls/wined3d/swapchain.c | 20 ++++++++++----------
dlls/wined3d/texture.c | 1 -
dlls/wined3d/wined3d_private.h | 15 ---------------
5 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 480717c06a5..0db2daa4893 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1011,16 +1011,14 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
struct wined3d_device *device = cs->device;
struct wined3d_rendertarget_view *prev;
- if ((prev = cs->state.fb->depth_stencil))
+ if ((prev = cs->state.fb->depth_stencil) && prev->resource->type != WINED3D_RTYPE_BUFFER)
{
- struct wined3d_surface *prev_surface = wined3d_rendertarget_view_get_surface(prev);
+ struct wined3d_texture *prev_texture = texture_from_resource(prev->resource);
- if (prev_surface && (device->swapchains[0]->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
- || prev_surface->container->flags & WINED3D_TEXTURE_DISCARD))
- {
- wined3d_texture_validate_location(prev_surface->container,
+ if (device->swapchains[0]->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
+ || prev_texture->flags & WINED3D_TEXTURE_DISCARD)
+ wined3d_texture_validate_location(prev_texture,
prev->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
- }
}
cs->fb.depth_stencil = op->view;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 92dfa0ccf93..c5517f5fcde 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -226,11 +226,11 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
float depth, DWORD stencil)
{
struct wined3d_rendertarget_view *rtv = rt_count ? fb->render_targets[0] : NULL;
- struct wined3d_surface *target = rtv ? wined3d_rendertarget_view_get_surface(rtv) : NULL;
struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
- struct wined3d_surface *depth_stencil = dsv ? wined3d_rendertarget_view_get_surface(dsv) : NULL;
const struct wined3d_state *state = &device->cs->state;
+ struct wined3d_texture *depth_stencil = NULL;
const struct wined3d_gl_info *gl_info;
+ struct wined3d_texture *target = NULL;
UINT drawable_width, drawable_height;
struct wined3d_color corrected_color;
struct wined3d_context *context;
@@ -238,10 +238,19 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
BOOL render_offscreen;
unsigned int i;
- if (target)
- context = context_acquire(device, target->container, rtv->sub_resource_idx);
+ if (rtv && rtv->resource->type != WINED3D_RTYPE_BUFFER)
+ {
+ target = texture_from_resource(rtv->resource);
+ context = context_acquire(device, target, rtv->sub_resource_idx);
+ }
else
+ {
context = context_acquire(device, NULL, 0);
+ }
+
+ if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
+ depth_stencil = texture_from_resource(dsv->resource);
+
if (!context->valid)
{
context_release(context);
@@ -281,11 +290,11 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
}
else
{
- unsigned int ds_level = dsv->sub_resource_idx % depth_stencil->container->level_count;
+ unsigned int ds_level = dsv->sub_resource_idx % depth_stencil->level_count;
render_offscreen = TRUE;
- drawable_width = wined3d_texture_get_level_pow2_width(depth_stencil->container, ds_level);
- drawable_height = wined3d_texture_get_level_pow2_height(depth_stencil->container, ds_level);
+ drawable_width = wined3d_texture_get_level_pow2_width(depth_stencil, ds_level);
+ drawable_height = wined3d_texture_get_level_pow2_height(depth_stencil, ds_level);
}
if (depth_stencil)
@@ -449,7 +458,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
}
if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET
- && target->container->swapchain && target->container->swapchain->front_buffer == target->container))
+ && target->swapchain && target->swapchain->front_buffer == target))
gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
context_release(context);
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 4542f291f43..36d84f6182a 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -385,6 +385,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
{
struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
const struct wined3d_fb_state *fb = &swapchain->device->cs->fb;
+ struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
const struct wined3d_gl_info *gl_info;
struct wined3d_texture *logo_texture;
struct wined3d_context *context;
@@ -509,14 +510,13 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
wined3d_texture_validate_location(swapchain->back_buffers[swapchain->desc.backbuffer_count - 1],
0, WINED3D_LOCATION_DISCARDED);
- if (fb->depth_stencil)
+ if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
{
- struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(fb->depth_stencil);
+ struct wined3d_texture *ds = texture_from_resource(dsv->resource);
- if (ds && (swapchain->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
- || ds->container->flags & WINED3D_TEXTURE_DISCARD))
- wined3d_texture_validate_location(ds->container,
- fb->depth_stencil->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
+ if ((swapchain->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
+ || ds->flags & WINED3D_TEXTURE_DISCARD))
+ wined3d_texture_validate_location(ds, dsv->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
}
context_release(context);
@@ -553,7 +553,7 @@ static void swapchain_gdi_frontbuffer_updated(struct wined3d_swapchain *swapchai
if (swapchain->palette)
wined3d_palette_apply_to_dc(swapchain->palette, front->dc);
- if (front->container->resource.map_count)
+ if (swapchain->front_buffer->resource.map_count)
ERR("Trying to blit a mapped surface.\n");
TRACE("Copying surface %p to screen.\n", front);
@@ -595,15 +595,15 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain,
/* Flip the surface data. */
dc = front->dc;
bitmap = front->bitmap;
- data = front->container->resource.heap_memory;
+ data = swapchain->front_buffer->resource.heap_memory;
front->dc = back->dc;
front->bitmap = back->bitmap;
- front->container->resource.heap_memory = back->container->resource.heap_memory;
+ swapchain->front_buffer->resource.heap_memory = swapchain->back_buffers[0]->resource.heap_memory;
back->dc = dc;
back->bitmap = bitmap;
- back->container->resource.heap_memory = data;
+ swapchain->back_buffers[0]->resource.heap_memory = data;
/* FPS support */
if (TRACE_ON(fps))
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 6abc7e71770..fc5c6747862 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2365,7 +2365,6 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
struct wined3d_surface *surface;
surface = &surfaces[idx];
- surface->container = texture;
sub_resource = &texture->sub_resources[idx];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3a404e01674..7da2da4f5c8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3337,8 +3337,6 @@ struct fbo_entry
struct wined3d_surface
{
- struct wined3d_texture *container;
-
/* For GetDC */
HBITMAP bitmap;
HDC dc;
@@ -3716,19 +3714,6 @@ struct wined3d_rendertarget_view
struct wined3d_view_desc desc;
};
-static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
- const struct wined3d_rendertarget_view *view)
-{
- struct wined3d_texture *texture;
-
- if (!view || view->resource->type != WINED3D_RTYPE_TEXTURE_2D)
- return NULL;
-
- texture = texture_from_resource(view->resource);
-
- return texture->sub_resources[view->sub_resource_idx].u.surface;
-}
-
void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
--
2.11.0
More information about the wine-devel
mailing list