Paul Gofman : wined3d: Support zero row pitch in wined3d_texture_gl_upload_data().
Alexandre Julliard
julliard at winehq.org
Mon Sep 30 16:19:07 CDT 2019
Module: wine
Branch: master
Commit: 85c0c49af73cfee0dc46b1920b4f11acd650cea2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=85c0c49af73cfee0dc46b1920b4f11acd650cea2
Author: Paul Gofman <gofmanp at gmail.com>
Date: Fri Sep 27 00:17:20 2019 +0300
wined3d: Support zero row pitch in wined3d_texture_gl_upload_data().
Fixes Wine test failure in d3d11 test_copy_subresource_region().
The test failure could be unstable as there was read after data
end in glTexSubImage2D() called from wined3d_texture_gl_upload_data().
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3d11/tests/d3d11.c | 5 ++++-
dlls/wined3d/texture.c | 35 +++++++++++++++++++++++++----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index d58319df58..456d34470c 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -12719,10 +12719,13 @@ static void test_copy_subresource_region(void)
check_texture_color(test_context.backbuffer, 0x800000ff, 2);
memset(float_colors, 0, sizeof(float_colors));
+ for (i = 0; i < texture_desc.Width; ++i)
+ ((unsigned int *)float_colors)[i] = 0x45454545;
+
ID3D11DeviceContext1_UpdateSubresource1(context1, (ID3D11Resource *)dst_texture, 0, NULL,
float_colors, 0, 0, 0);
draw_quad(&test_context);
- check_texture_color(test_context.backbuffer, 0x00000000, 1);
+ check_texture_color(test_context.backbuffer, 0x45454545, 1);
ID3D11DeviceContext1_CopySubresourceRegion1(context1, (ID3D11Resource *)dst_texture, 0,
0, 0, 0, (ID3D11Resource *)src_texture, 0, NULL, 0);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index ff25f64043..c4ef184484 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2052,26 +2052,41 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
}
else
{
+ unsigned int y, y_count;
+
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",
target, level, dst_x, dst_y, dst_z, update_w, update_h,
update_d, format_gl->format, format_gl->type, bo.addr);
- gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_row_pitch / src_format->byte_count);
- if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
+ if (src_row_pitch)
{
- GL_EXTCALL(glTexSubImage3D(target, level, dst_x, dst_y, dst_z,
- update_w, update_h, update_d, format_gl->format, format_gl->type, bo.addr));
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_row_pitch / src_format->byte_count);
+ y_count = 1;
}
- else if (target == GL_TEXTURE_1D)
+ else
{
- gl_info->gl_ops.gl.p_glTexSubImage1D(target, level, dst_x,
- update_w, format_gl->format, format_gl->type, bo.addr);
+ y_count = update_h;
+ update_h = 1;
}
- else
+
+ for (y = 0; y < y_count; ++y)
{
- gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_x, dst_y,
- update_w, update_h, format_gl->format, format_gl->type, bo.addr);
+ 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, bo.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, bo.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, bo.addr);
+ }
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
checkGLcall("Upload texture data");
More information about the wine-cvs
mailing list