Zebediah Figura : wined3d: Allow OpenGL pixel pack buffer objects to be suballocated from a larger buffer.
Alexandre Julliard
julliard at winehq.org
Tue Nov 23 16:03:29 CST 2021
Module: wine
Branch: master
Commit: d7ba2085697b41c00e94701569074c6c03e30a14
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d7ba2085697b41c00e94701569074c6c03e30a14
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Mon Nov 22 18:14:42 2021 -0600
wined3d: Allow OpenGL pixel pack buffer objects to be suballocated from a larger buffer.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/surface.c | 7 +++++--
dlls/wined3d/texture.c | 15 +++++++++------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9c6f5e18c28..060ac84b8b7 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -420,9 +420,11 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
BYTE *row, *top, *bottom;
BOOL src_is_upside_down;
BYTE *mem = NULL;
+ uint8_t *offset;
unsigned int i;
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 */
@@ -504,7 +507,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
mem = GL_EXTCALL(glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE));
checkGLcall("glMapBuffer");
}
- mem += (uintptr_t)data.addr;
+ mem += (uintptr_t)offset;
top = mem;
bottom = mem + row_pitch * (height - 1);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 072092e73be..1ab50a27596 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2693,7 +2693,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
{
@@ -2796,7 +2796,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
@@ -2827,6 +2828,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;
@@ -2906,22 +2908,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");
}
More information about the wine-cvs
mailing list