[PATCH 2/3] wined3d: Handle partial updates to 3D textures in wined3d_texture_gl_upload_bo().
Jan Sikorski
jsikorski at codeweavers.com
Wed Mar 10 08:10:44 CST 2021
Signed-off-by: Jan Sikorski <jsikorski at codeweavers.com>
---
dlls/wined3d/texture.c | 56 ++++++++++++++++++++++++++++--------------
1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index a4148b166f2..09f2fd766c5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2137,7 +2137,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
}
static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format, GLenum target,
- unsigned int level, unsigned int src_row_pitch, unsigned int dst_x, unsigned int dst_y,
+ unsigned int level, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_x, unsigned int dst_y,
unsigned int dst_z, unsigned int update_w, unsigned int update_h, unsigned int update_d,
const BYTE *addr, BOOL srgb, struct wined3d_texture *dst_texture,
const struct wined3d_gl_info *gl_info)
@@ -2213,7 +2213,9 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format
}
else
{
- unsigned int y, y_count;
+ unsigned int slice_to_row_pitch = src_slice_pitch / src_row_pitch;
+ unsigned int y, y_count, z, z_count;
+ const BYTE *upload_addr;
TRACE("Uploading data, target %#x, level %u, x %u, y %u, z %u, "
"w %u, h %u, d %u, format %#x, type %#x, addr %p.\n",
@@ -2231,25 +2233,43 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format
update_h = 1;
}
- for (y = 0; y < y_count; ++y)
+ if (src_slice_pitch && slice_to_row_pitch * src_row_pitch == src_slice_pitch)
{
- if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
- {
- GL_EXTCALL(glTexSubImage3D(target, level, dst_x, dst_y + y, dst_z,
- update_w, update_h, update_d, format_gl->format, format_gl->type, addr));
- }
- else if (target == GL_TEXTURE_1D)
- {
- gl_info->gl_ops.gl.p_glTexSubImage1D(target, level, dst_x,
- update_w, format_gl->format, format_gl->type, addr);
- }
- else
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, slice_to_row_pitch);
+ z_count = 1;
+ }
+ else
+ {
+ z_count = update_d;
+ update_d = 1;
+ }
+
+ for (z = 0; z < z_count; ++z)
+ {
+ for (y = 0; y < y_count; ++y)
{
- gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_x, dst_y + y,
- update_w, update_h, format_gl->format, format_gl->type, addr);
+ upload_addr = addr;
+ if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
+ {
+ GL_EXTCALL(glTexSubImage3D(target, level, dst_x, dst_y + y, dst_z + z,
+ update_w, update_h, update_d, format_gl->format, format_gl->type, upload_addr));
+ }
+ else if (target == GL_TEXTURE_1D)
+ {
+ gl_info->gl_ops.gl.p_glTexSubImage1D(target, level, dst_x,
+ update_w, format_gl->format, format_gl->type, upload_addr);
+ }
+ else
+ {
+ gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_x, dst_y + y,
+ update_w, update_h, format_gl->format, format_gl->type, upload_addr);
+ }
+ upload_addr += src_row_pitch;
}
+ addr += src_slice_pitch;
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
checkGLcall("Upload texture data");
}
}
@@ -2462,7 +2482,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
src_format->upload(src_mem, converted_mem, src_row_pitch, src_slice_pitch,
dst_row_pitch, dst_slice_pitch, update_w, update_h, 1);
- wined3d_texture_gl_upload_bo(src_format, target, level, dst_row_pitch, dst_x, dst_y,
+ wined3d_texture_gl_upload_bo(src_format, target, level, dst_row_pitch, dst_slice_pitch, dst_x, dst_y,
dst_z + z, update_w, update_h, 1, converted_mem, srgb, dst_texture, gl_info);
}
@@ -2477,7 +2497,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
checkGLcall("glBindBuffer");
}
- wined3d_texture_gl_upload_bo(src_format, target, level, src_row_pitch, dst_x, dst_y,
+ wined3d_texture_gl_upload_bo(src_format, target, level, src_row_pitch, src_slice_pitch, dst_x, dst_y,
dst_z, update_w, update_h, update_d, bo.addr, srgb, dst_texture, gl_info);
if (bo.buffer_object)
--
2.30.1
More information about the wine-devel
mailing list