[PATCH 4/4] wined3d: Don't store PBO pointers in allocatedMemory.
Stefan Dösinger
stefan at codeweavers.com
Mon Nov 25 16:41:13 CST 2013
---
dlls/wined3d/surface.c | 31 +++++++++++++++++--------------
dlls/wined3d/wined3d_private.h | 2 +-
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index dcb8ebf..8ec238a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -767,9 +767,10 @@ 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;
+ BYTE *ret;
TRACE("surface %p, rect %s, flags %#x.\n",
surface, wine_dbgstr_rect(rect), flags);
@@ -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
@@ -817,6 +813,12 @@ static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD
context_release(context);
}
+ else
+ {
+ ret = surface->resource.allocatedMemory;
+ }
+
+ return ret;
}
static void surface_unmap(struct wined3d_surface *surface)
@@ -842,8 +844,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 +1473,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)
@@ -3194,6 +3196,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);
@@ -3232,7 +3235,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;
@@ -3242,7 +3245,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;
@@ -3254,13 +3257,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);
};
--
1.8.3.2
More information about the wine-patches
mailing list