wined3d: Allow OpenGL pixel pack buffer objects to be suballocated from a larger buffer.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-11-22 18:14:42 -06:00 committed by Alexandre Julliard
parent f059a25af1
commit d7ba208569
2 changed files with 14 additions and 8 deletions

View File

@ -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);

View File

@ -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");
}