=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Don' t store PBO pointers in allocatedMemory.

Alexandre Julliard julliard at winehq.org
Wed Nov 27 14:50:06 CST 2013


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Wed Nov 27 00:26:36 2013 +0100

wined3d: Don't store PBO pointers in allocatedMemory.

---

 dlls/wined3d/surface.c         |   28 ++++++++++++++--------------
 dlls/wined3d/wined3d_private.h |    2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index bea4ce4..ac168dd 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -767,7 +767,7 @@ static void surface_realize_palette(struct wined3d_surface *surface)
         surface_load_location(surface, surface->draw_binding);
 }
 
-static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
+static BYTE *surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
 {
     struct wined3d_device *device = surface->resource.device;
 
@@ -793,6 +793,7 @@ static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD
 
     if (surface->flags & SFLAG_PBO)
     {
+        BYTE *ret;
         const struct wined3d_gl_info *gl_info;
         struct wined3d_context *context;
 
@@ -802,12 +803,7 @@ static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD
         GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
         checkGLcall("glBindBufferARB");
 
-        /* This shouldn't happen but could occur if some other function
-         * didn't handle the PBO properly. */
-        if (surface->resource.allocatedMemory)
-            ERR("The surface already has PBO memory allocated.\n");
-
-        surface->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
+        ret = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
         checkGLcall("glMapBufferARB");
 
         /* Make sure the PBO isn't set anymore in order not to break non-PBO
@@ -816,7 +812,10 @@ static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD
         checkGLcall("glBindBufferARB");
 
         context_release(context);
+        return ret;
     }
+
+    return surface->resource.allocatedMemory;
 }
 
 static void surface_unmap(struct wined3d_surface *surface)
@@ -842,8 +841,6 @@ static void surface_unmap(struct wined3d_surface *surface)
         GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
         checkGLcall("glUnmapBufferARB");
         context_release(context);
-
-        surface->resource.allocatedMemory = NULL;
     }
 
     TRACE("dirtyfied %u.\n", surface->flags & (SFLAG_INDRAWABLE | SFLAG_INTEXTURE) ? 0 : 1);
@@ -1473,10 +1470,12 @@ static void gdi_surface_realize_palette(struct wined3d_surface *surface)
         x11_copy_to_screen(surface->swapchain, NULL);
 }
 
-static void gdi_surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
+static BYTE *gdi_surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
 {
     TRACE("surface %p, rect %s, flags %#x.\n",
             surface, wine_dbgstr_rect(rect), flags);
+
+    return surface->resource.allocatedMemory;
 }
 
 static void gdi_surface_unmap(struct wined3d_surface *surface)
@@ -3195,6 +3194,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
         struct wined3d_map_desc *map_desc, const RECT *rect, DWORD flags)
 {
     const struct wined3d_format *format = surface->resource.format;
+    BYTE *base_memory;
 
     TRACE("surface %p, map_desc %p, rect %s, flags %#x.\n",
             surface, map_desc, wine_dbgstr_rect(rect), flags);
@@ -3233,7 +3233,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
         }
     }
 
-    surface->surface_ops->surface_map(surface, rect, flags);
+    base_memory = surface->surface_ops->surface_map(surface, rect, flags);
 
     if (format->flags & WINED3DFMT_FLAG_BROKEN_PITCH)
         map_desc->row_pitch = surface->resource.width * format->byte_count;
@@ -3243,7 +3243,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
 
     if (!rect)
     {
-        map_desc->data = surface->resource.allocatedMemory;
+        map_desc->data = base_memory;
         surface->lockedRect.left = 0;
         surface->lockedRect.top = 0;
         surface->lockedRect.right = surface->resource.width;
@@ -3255,13 +3255,13 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
         {
             /* Compressed textures are block based, so calculate the offset of
              * the block that contains the top-left pixel of the locked rectangle. */
-            map_desc->data = surface->resource.allocatedMemory
+            map_desc->data = base_memory
                     + ((rect->top / format->block_height) * map_desc->row_pitch)
                     + ((rect->left / format->block_width) * format->block_byte_count);
         }
         else
         {
-            map_desc->data = surface->resource.allocatedMemory
+            map_desc->data = base_memory
                     + (map_desc->row_pitch * rect->top)
                     + (rect->left * format->byte_count);
         }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5b5d01a..cb685e2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2169,7 +2169,7 @@ struct wined3d_surface_ops
 {
     HRESULT (*surface_private_setup)(struct wined3d_surface *surface);
     void (*surface_realize_palette)(struct wined3d_surface *surface);
-    void (*surface_map)(struct wined3d_surface *surface, const RECT *rect, DWORD flags);
+    BYTE *(*surface_map)(struct wined3d_surface *surface, const RECT *rect, DWORD flags);
     void (*surface_unmap)(struct wined3d_surface *surface);
 };
 




More information about the wine-cvs mailing list