Henri Verbeet : wined3d: Introduce wined3d_texture_get_gl_buffer().

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 24 11:04:00 CDT 2016


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Mar 23 17:58:23 2016 +0100

wined3d: Introduce wined3d_texture_get_gl_buffer().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/context.c         |  2 +-
 dlls/wined3d/surface.c         | 44 ++++++------------------------------------
 dlls/wined3d/texture.c         | 32 ++++++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |  2 +-
 4 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 0d6ba69..d28ebd3 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -337,7 +337,7 @@ static inline DWORD context_generate_rt_mask(GLenum buffer)
 
 static inline DWORD context_generate_rt_mask_from_surface(const struct wined3d_surface *target)
 {
-    return (1u << 31) | surface_get_gl_buffer(target);
+    return (1u << 31) | wined3d_texture_get_gl_buffer(target->container);
 }
 
 static inline void context_set_fbo_key_for_surface(const struct wined3d_context *context,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index b86cb72..ceea4fe 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -698,7 +698,7 @@ static void surface_blt_fbo(const struct wined3d_device *device,
     if (src_location == WINED3D_LOCATION_DRAWABLE)
     {
         TRACE("Source surface %p is onscreen.\n", src_surface);
-        buffer = surface_get_gl_buffer(src_surface);
+        buffer = wined3d_texture_get_gl_buffer(src_surface->container);
         surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
     }
     else
@@ -715,7 +715,7 @@ static void surface_blt_fbo(const struct wined3d_device *device,
     if (dst_location == WINED3D_LOCATION_DRAWABLE)
     {
         TRACE("Destination surface %p is onscreen.\n", dst_surface);
-        buffer = surface_get_gl_buffer(dst_surface);
+        buffer = wined3d_texture_get_gl_buffer(dst_surface->container);
         surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
     }
     else
@@ -1444,38 +1444,6 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const
     checkGLcall("set_compatible_renderbuffer");
 }
 
-GLenum surface_get_gl_buffer(const struct wined3d_surface *surface)
-{
-    const struct wined3d_swapchain *swapchain = surface->container->swapchain;
-
-    TRACE("surface %p.\n", surface);
-
-    if (!swapchain)
-    {
-        ERR("Surface %p is not on a swapchain.\n", surface);
-        return GL_NONE;
-    }
-
-    if (swapchain->back_buffers && swapchain->back_buffers[0] == surface->container)
-    {
-        if (swapchain->render_to_fbo)
-        {
-            TRACE("Returning GL_COLOR_ATTACHMENT0\n");
-            return GL_COLOR_ATTACHMENT0;
-        }
-        TRACE("Returning GL_BACK\n");
-        return GL_BACK;
-    }
-    else if (surface->container == swapchain->front_buffer)
-    {
-        TRACE("Returning GL_FRONT\n");
-        return GL_FRONT;
-    }
-
-    FIXME("Higher back buffer, returning GL_BACK\n");
-    return GL_BACK;
-}
-
 /* Context activation is done by the caller. */
 void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb)
 {
@@ -1913,7 +1881,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
     else
     {
         /* Onscreen surfaces are always part of a swapchain */
-        GLenum buffer = surface_get_gl_buffer(surface);
+        GLenum buffer = wined3d_texture_get_gl_buffer(texture);
         TRACE("Mapping %#x buffer.\n", buffer);
         gl_info->gl_ops.gl.p_glReadBuffer(buffer);
         checkGLcall("glReadBuffer");
@@ -2016,7 +1984,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct
     if (wined3d_resource_is_offscreen(&texture->resource))
         gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context));
     else
-        gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(surface));
+        gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(texture));
     checkGLcall("glReadBuffer");
 
     gl_info->gl_ops.gl.p_glCopyTexSubImage2D(surface->texture_target, surface->texture_level,
@@ -2127,7 +2095,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
     }
     else
     {
-        gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(src_surface));
+        gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
     }
     checkGLcall("glReadBuffer");
 
@@ -2291,7 +2259,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
     }
     else
     {
-        gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(src_surface));
+        gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
     }
 
     /* TODO: Only back up the part that will be overwritten */
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 2687bf1..feb6919 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -37,6 +37,38 @@ BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct
             && !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
 }
 
+GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
+{
+    const struct wined3d_swapchain *swapchain = texture->swapchain;
+
+    TRACE("texture %p.\n", texture);
+
+    if (!swapchain)
+    {
+        ERR("Texture %p is not part of a swapchain.\n", texture);
+        return GL_NONE;
+    }
+
+    if (swapchain->back_buffers && swapchain->back_buffers[0] == texture)
+    {
+        if (swapchain->render_to_fbo)
+        {
+            TRACE("Returning GL_COLOR_ATTACHMENT0.\n");
+            return GL_COLOR_ATTACHMENT0;
+        }
+        TRACE("Returning GL_BACK.\n");
+        return GL_BACK;
+    }
+    else if (texture == swapchain->front_buffer)
+    {
+        TRACE("Returning GL_FRONT.\n");
+        return GL_FRONT;
+    }
+
+    FIXME("Higher back buffer, returning GL_BACK.\n");
+    return GL_BACK;
+}
+
 static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
         UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
         struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c638c45..a9d2a96 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2453,6 +2453,7 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
         struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
 BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
         unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
+GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
 struct wined3d_resource *wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
         UINT sub_resource_idx) DECLSPEC_HIDDEN;
 void wined3d_texture_load(struct wined3d_texture *texture,
@@ -2605,7 +2606,6 @@ void wined3d_surface_cleanup(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
 HRESULT surface_color_fill(struct wined3d_surface *s,
         const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN;
 HRESULT surface_create_dib_section(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
-GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HIDDEN;
 void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context,
         unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
 HRESULT wined3d_surface_init(struct wined3d_surface *surface,




More information about the wine-cvs mailing list