Henri Verbeet : wined3d: Never pass a surface to wined3d_resource_is_offscreen().

Alexandre Julliard julliard at wine.codeweavers.com
Fri Sep 19 13:18:31 CDT 2014


Module: wine
Branch: master
Commit: 4f2110b0ce758822f549c5a730938739e1b5a79e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4f2110b0ce758822f549c5a730938739e1b5a79e

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Sep 19 10:41:48 2014 +0200

wined3d: Never pass a surface to wined3d_resource_is_offscreen().

---

 dlls/wined3d/arb_program_shader.c |  4 ++--
 dlls/wined3d/context.c            |  4 ++--
 dlls/wined3d/resource.c           |  3 ---
 dlls/wined3d/surface.c            | 20 ++++++++++----------
 4 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 4a61cc8..52b9d9d 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7645,7 +7645,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
     if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
             && (src_surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_DRAWABLE))
             == WINED3D_LOCATION_DRAWABLE
-            && !wined3d_resource_is_offscreen(&src_surface->resource))
+            && !wined3d_resource_is_offscreen(&src_surface->container->resource))
     {
         /* Without FBO blits transferring from the drawable to the texture is
          * expensive, because we have to flip the data in sysmem. Since we can
@@ -7662,7 +7662,7 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
 
     context_apply_blit_state(context, device);
 
-    if (!wined3d_resource_is_offscreen(&dst_surface->resource))
+    if (!wined3d_resource_is_offscreen(&dst_surface->container->resource))
         surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
 
     arbfp_blit_set(device->blit_priv, context, src_surface);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 693267e..b83ec78 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1590,7 +1590,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
     ret->current_rt = target;
     ret->tid = GetCurrentThreadId();
 
-    ret->render_offscreen = wined3d_resource_is_offscreen(&target->resource);
+    ret->render_offscreen = wined3d_resource_is_offscreen(&target->container->resource);
     ret->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
     ret->valid = 1;
 
@@ -3043,7 +3043,7 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d
 {
     BOOL old_render_offscreen = context->render_offscreen, render_offscreen;
 
-    render_offscreen = wined3d_resource_is_offscreen(&target->resource);
+    render_offscreen = wined3d_resource_is_offscreen(&target->container->resource);
     if (context->current_rt == target && render_offscreen == old_render_offscreen) return;
 
     /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 772ce10..d40af56 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -305,9 +305,6 @@ BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
 {
     struct wined3d_swapchain *swapchain;
 
-    if (resource->type == WINED3D_RTYPE_SURFACE)
-        resource = &surface_from_resource(resource)->container->resource;
-
     /* Only texture resources can be onscreen. */
     if (resource->type != WINED3D_RTYPE_TEXTURE)
         return TRUE;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 04ef3f0..9603e21 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1511,7 +1511,7 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
         if (srgb)
             internal = format->glGammaInternal;
         else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET
-                && wined3d_resource_is_offscreen(&surface->resource))
+                && wined3d_resource_is_offscreen(&surface->container->resource))
             internal = format->rtInternal;
         else
             internal = format->glInternal;
@@ -1856,7 +1856,7 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
     if (srgb)
         internal = format->glGammaInternal;
     else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET
-            && wined3d_resource_is_offscreen(&surface->resource))
+            && wined3d_resource_is_offscreen(&surface->container->resource))
         internal = format->rtInternal;
     else
         internal = format->glInternal;
@@ -3047,7 +3047,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
      * There is no need to keep track of the current read buffer or reset it, every part of the code
      * that reads sets the read buffer as desired.
      */
-    if (wined3d_resource_is_offscreen(&surface->resource))
+    if (wined3d_resource_is_offscreen(&surface->container->resource))
     {
         /* Mapping the primary render target which is not on a swapchain.
          * Read from the back buffer. */
@@ -3146,7 +3146,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb)
 
     TRACE("Reading back offscreen render target %p.\n", surface);
 
-    if (wined3d_resource_is_offscreen(&surface->resource))
+    if (wined3d_resource_is_offscreen(&surface->container->resource))
         gl_info->gl_ops.gl.p_glReadBuffer(device->offscreenBuffer);
     else
         gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(surface));
@@ -3513,7 +3513,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
 
     /* Bind the target texture */
     context_bind_texture(context, dst_surface->container->target, dst_surface->container->texture_rgb.name);
-    if (wined3d_resource_is_offscreen(&src_surface->resource))
+    if (wined3d_resource_is_offscreen(&src_surface->container->resource))
     {
         TRACE("Reading from an offscreen target\n");
         upsidedown = !upsidedown;
@@ -3619,7 +3619,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
     context_apply_blit_state(context, device);
     wined3d_texture_load(dst_surface->container, context, FALSE);
 
-    src_offscreen = wined3d_resource_is_offscreen(&src_surface->resource);
+    src_offscreen = wined3d_resource_is_offscreen(&src_surface->container->resource);
     noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
     if (!noBackBufferBackup && !src_surface->container->texture_rgb.name)
     {
@@ -3919,7 +3919,7 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
     /* Activate the destination context, set it up for blitting */
     context_apply_blit_state(context, device);
 
-    if (!wined3d_resource_is_offscreen(&dst_surface->resource))
+    if (!wined3d_resource_is_offscreen(&dst_surface->container->resource))
         surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
 
     device->blitter->set_shader(device->blit_priv, context, src_surface);
@@ -4522,7 +4522,7 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface,
     RECT r;
 
     if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
-            && wined3d_resource_is_offscreen(&surface->resource))
+            && wined3d_resource_is_offscreen(&surface->container->resource))
     {
         ERR("Trying to load offscreen surface into WINED3D_LOCATION_DRAWABLE.\n");
         return WINED3DERR_INVALIDCALL;
@@ -4550,7 +4550,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
     BYTE *mem = NULL;
 
     if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
-            && wined3d_resource_is_offscreen(&surface->resource)
+            && wined3d_resource_is_offscreen(&surface->container->resource)
             && (surface->locations & WINED3D_LOCATION_DRAWABLE))
     {
         surface_load_fb_texture(surface, srgb);
@@ -5856,7 +5856,7 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
 
                     if (SUCCEEDED(surface_upload_from_surface(dst_surface, &dst_point, src_surface, &src_rect)))
                     {
-                        if (!wined3d_resource_is_offscreen(&dst_surface->resource))
+                        if (!wined3d_resource_is_offscreen(&dst_surface->container->resource))
                             surface_load_location(dst_surface, dst_surface->container->resource.draw_binding);
                         return WINED3D_OK;
                     }




More information about the wine-cvs mailing list