[PATCH 3/6] wined3d: Allow OpenGL pixel pack buffer objects to be suballocated from a larger buffer.
Zebediah Figura
zfigura at codeweavers.com
Fri Nov 19 17:23:46 CST 2021
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/wined3d/surface.c | 5 ++++-
dlls/wined3d/texture.c | 15 +++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 79dc0bd06b6..9168e8cc9f8 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -419,10 +419,12 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
unsigned int restore_idx;
BYTE *row, *top, *bottom;
BOOL src_is_upside_down;
+ uint8_t *offset;
unsigned int i;
BYTE *mem;
wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
+ offset = data.addr;
restore_texture = context->current_rt.texture;
restore_idx = context->current_rt.sub_resource_idx;
@@ -471,6 +473,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(data.buffer_object)->id));
checkGLcall("glBindBuffer");
+ offset += data.buffer_object->buffer_offset;
}
level = sub_resource_idx % texture->level_count;
@@ -484,7 +487,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
width = wined3d_texture_get_level_width(texture, level);
height = wined3d_texture_get_level_height(texture, level);
gl_info->gl_ops.gl.p_glReadPixels(0, 0, width, height,
- format_gl->format, format_gl->type, data.addr);
+ format_gl->format, format_gl->type, offset);
checkGLcall("glReadPixels");
/* Reset previous pixel store pack state */
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index d164819a10a..f6f30919c70 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2690,7 +2690,7 @@ static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, bo->id));
checkGLcall("glBindBuffer");
- mem = data->addr;
+ mem = (uint8_t *)data->addr + bo->b.buffer_offset;
}
else
{
@@ -2793,7 +2793,8 @@ static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, bo->id));
checkGLcall("glBindBuffer");
- GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, (GLintptr)data->addr, sub_resource->size, src_data));
+ GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER,
+ (GLintptr)data->addr + bo->b.buffer_offset, sub_resource->size, src_data));
checkGLcall("glBufferSubData");
}
else
@@ -2824,6 +2825,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
unsigned int src_level, src_width, src_height, src_depth;
unsigned int src_row_pitch, src_slice_pitch;
const struct wined3d_format_gl *format_gl;
+ uint8_t *offset = dst_bo_addr->addr;
struct wined3d_bo *dst_bo;
BOOL srgb = FALSE;
GLenum target;
@@ -2903,22 +2905,23 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(dst_bo)->id));
checkGLcall("glBindBuffer");
+ offset += dst_bo->buffer_offset;
}
if (src_texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- src_texture, src_sub_resource_idx, src_level, format_gl->format, format_gl->type, dst_bo_addr->addr);
+ src_texture, src_sub_resource_idx, src_level, format_gl->format, format_gl->type, offset);
- GL_EXTCALL(glGetCompressedTexImage(target, src_level, dst_bo_addr->addr));
+ GL_EXTCALL(glGetCompressedTexImage(target, src_level, offset));
checkGLcall("glGetCompressedTexImage");
}
else
{
TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- src_texture, src_sub_resource_idx, src_level, format_gl->format, format_gl->type, dst_bo_addr->addr);
+ src_texture, src_sub_resource_idx, src_level, format_gl->format, format_gl->type, offset);
- gl_info->gl_ops.gl.p_glGetTexImage(target, src_level, format_gl->format, format_gl->type, dst_bo_addr->addr);
+ gl_info->gl_ops.gl.p_glGetTexImage(target, src_level, format_gl->format, format_gl->type, offset);
checkGLcall("glGetTexImage");
}
--
2.33.0
More information about the wine-devel
mailing list