[PATCH 5/6] wined3d: Pass a struct wined3d_bo_address to read_from_framebuffer.
Stefan Dösinger
stefan at codeweavers.com
Tue Nov 26 17:26:40 CST 2013
---
dlls/wined3d/surface.c | 54 +++++++++++++++++++++-----------------------------
1 file changed, 23 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 0c211af..ae6cdaf 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3669,7 +3669,8 @@ HRESULT CDECL wined3d_surface_flip(struct wined3d_surface *surface, struct wined
}
/* Read the framebuffer back into the surface */
-static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, UINT pitch)
+static void read_from_framebuffer(struct wined3d_surface *surface,
+ const struct wined3d_bo_address *data, UINT pitch)
{
struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info;
@@ -3720,7 +3721,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
/* In case of P8 render targets the index is stored in the alpha component */
fmt = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
- mem = dest;
+ mem = data->addr;
bpp = surface->resource.format->byte_count;
}
else
@@ -3749,21 +3750,18 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
break;
default:
- mem = dest;
+ mem = data->addr;
fmt = surface->resource.format->glFormat;
type = surface->resource.format->glType;
bpp = surface->resource.format->byte_count;
}
- if (surface->flags & SFLAG_PBO)
+ if (data->buffer_object)
{
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, surface->pbo));
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, data->buffer_object));
checkGLcall("glBindBufferARB");
if (mem)
- {
ERR("mem not null for pbo -- unexpected\n");
- mem = NULL;
- }
}
/* Save old pixel store pack state */
@@ -3795,23 +3793,14 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_SKIP_ROWS, skipRow);
checkGLcall("glPixelStorei");
- if (surface->flags & SFLAG_PBO)
+ if (data->buffer_object && !srcIsUpsideDown)
{
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
- checkGLcall("glBindBufferARB");
-
/* Check if we need to flip the image. If we need to flip use glMapBufferARB
* to get a pointer to it and perform the flipping in software. This is a lot
* faster than calling glReadPixels for each line. In case we want more speed
* we should rerender it flipped in a FBO and read the data back from the FBO. */
- if (!srcIsUpsideDown)
- {
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
- checkGLcall("glBindBufferARB");
-
- mem = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
- checkGLcall("glMapBufferARB");
- }
+ mem = GL_EXTCALL(glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB));
+ checkGLcall("glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB)");
}
/* TODO: Merge this with the palettization loop below for P8 targets */
@@ -3842,15 +3831,19 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
bottom -= pitch;
}
HeapFree(GetProcessHeap(), 0, row);
+ }
- /* Unmap the temp PBO buffer */
- if (surface->flags & SFLAG_PBO)
- {
- GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
- }
+ if (data->buffer_object)
+ {
+ if (!srcIsUpsideDown)
+ GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB));
+
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
+ checkGLcall("glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)");
}
+ context_release(context);
+
/* For P8 textures we need to perform an inverse palette lookup. This is
* done by searching for a palette index which matches the RGB value.
* Note this isn't guaranteed to work when there are multiple entries for
@@ -3888,7 +3881,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
&& *green == pal[c].peGreen
&& *blue == pal[c].peBlue)
{
- *((BYTE *) dest + y * width + x) = c;
+ *((BYTE *)data->addr + y * width + x) = c;
break;
}
}
@@ -3896,8 +3889,6 @@ static void read_from_framebuffer(struct wined3d_surface *surface, void *dest, U
}
HeapFree(GetProcessHeap(), 0, mem);
}
-
- context_release(context);
}
/* Read the framebuffer contents into a texture. Note that this function
@@ -5105,8 +5096,9 @@ static void surface_load_sysmem(struct wined3d_surface *surface,
if (surface->flags & SFLAG_INDRAWABLE)
{
- read_from_framebuffer(surface, surface->resource.allocatedMemory,
- wined3d_surface_get_pitch(surface));
+ struct wined3d_bo_address data;
+ surface_get_memory(surface, &data);
+ read_from_framebuffer(surface, &data, wined3d_surface_get_pitch(surface));
return;
}
--
1.8.3.2
More information about the wine-patches
mailing list