Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/texture.c | 72 ++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 752b6b4cf9b..22bd8cc34b7 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2137,10 +2137,10 @@ 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 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) + 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) { const struct wined3d_format_gl *format_gl = wined3d_format_gl(src_format);
@@ -2213,17 +2213,19 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format } else { - unsigned int y, y_count; + unsigned int y, y_count, z, z_count; + bool unpacking_rows = false;
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, addr);
- if (src_row_pitch) + if (src_row_pitch && !(src_row_pitch % src_format->byte_count)) { gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_row_pitch / src_format->byte_count); y_count = 1; + unpacking_rows = true; } else { @@ -2231,25 +2233,47 @@ 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 && unpacking_rows && !(src_slice_pitch % src_row_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, src_slice_pitch / src_row_pitch); + z_count = 1; + } + else if (src_slice_pitch && !unpacking_rows && !(src_slice_pitch % (update_w * src_format->byte_count))) + { + gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, + src_slice_pitch / (update_w * src_format->byte_count)); + 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); + const BYTE *upload_addr = &addr[z * src_slice_pitch + y * src_row_pitch]; + 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); + } } } 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,8 +2486,8 @@ 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, - dst_z + z, update_w, update_h, 1, converted_mem, srgb, dst_texture, gl_info); + 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); }
wined3d_context_gl_unmap_bo_address(context_gl, &bo, 0, NULL); @@ -2477,8 +2501,8 @@ 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, - dst_z, update_w, update_h, update_d, bo.addr, srgb, dst_texture, gl_info); + 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) {
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/texture.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 22bd8cc34b7..4db62b198eb 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2169,43 +2169,44 @@ static void wined3d_texture_gl_upload_bo(const struct wined3d_format *src_format GL_EXTCALL(glCompressedTexSubImage1D(target, level, dst_x, update_w, internal, dst_row_pitch, addr)); } - else if (dst_row_pitch == src_row_pitch) + else { - if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D) + unsigned int row, y, slice, slice_count = 1, row_count = 1; + + /* glCompressedTexSubImage2D() ignores pixel store state, so we + * can't use the unpack row length like for glTexSubImage2D. */ + if (dst_row_pitch != src_row_pitch) { - GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, dst_y, dst_z, - update_w, update_h, update_d, internal, dst_slice_pitch * update_d, addr)); + row_count = (update_h + src_format->block_height - 1) / src_format->block_height; + update_h = src_format->block_height; + wined3d_format_calculate_pitch(src_format, 1, update_w, update_h, + &dst_row_pitch, &dst_slice_pitch); } - else + + if (dst_slice_pitch != src_slice_pitch) { - GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, dst_y, - update_w, update_h, internal, dst_slice_pitch, addr)); + slice_count = update_d; + update_d = 1; } - } - else - { - unsigned int row_count = (update_h + src_format->block_height - 1) / src_format->block_height; - unsigned int row, y, z;
- /* glCompressedTexSubImage2D() ignores pixel store state, so we - * can't use the unpack row length like for glTexSubImage2D. */ - for (z = dst_z; z < dst_z + update_d; ++z) + for (slice = 0; slice < slice_count; ++slice) { for (row = 0, y = dst_y; row < row_count; ++row) { + const BYTE *upload_addr = &addr[slice * src_slice_pitch + row * src_row_pitch]; + if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D) { - GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, y, z, - update_w, src_format->block_height, 1, internal, dst_row_pitch, addr)); + GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, y, dst_z + slice, update_w, + update_h, update_d, internal, update_d * dst_slice_pitch, upload_addr)); } else { - GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, y, - update_w, src_format->block_height, internal, dst_row_pitch, addr)); + GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, y, update_w, + update_h, internal, dst_slice_pitch, upload_addr)); }
y += src_format->block_height; - addr += src_row_pitch; } } }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 167 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 38a0afc3fee..f6ba0b16748 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -13713,12 +13713,14 @@ static void test_update_subresource(void) { struct d3d11_test_context test_context; D3D11_SUBRESOURCE_DATA resource_data; + D3D11_TEXTURE3D_DESC texture_desc_3d; D3D11_TEXTURE2D_DESC texture_desc; ID3D11SamplerState *sampler_state; ID3D11ShaderResourceView *ps_srv; D3D11_SAMPLER_DESC sampler_desc; ID3D11DeviceContext *context; struct resource_readback rb; + ID3D11Texture3D *texture_3d; ID3D11Texture2D *texture; ID3D11PixelShader *ps; ID3D11Device *device; @@ -13753,8 +13755,41 @@ static void test_update_subresource(void) 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e, }; + static const DWORD ps_code_3d[] = + { +#if 0 + Texture3D t; + SamplerState s; + + float4 main(float4 position : SV_POSITION) : SV_Target + { + float3 p1, p2; + p2.x = p1.x = position.x / 640.0f; + p2.y = p1.y = position.y / 480.0f; + p1.z = 0.25; + p2.z = 0.75; + return 0.5 * (t.Sample(s, p1) + t.Sample(s, p2)); + } +#endif + 0x43425844, 0x4d466d63, 0xa3d10db1, 0xd6534470, 0x16d738ef, 0x00000001, 0x000001ec, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000150, 0x00000040, + 0x00000054, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555, + 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, + 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3e800000, + 0x09000045, 0x001000f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x0a000038, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, + 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f400000, + 0x09000045, 0x001000f2, 0x00000001, 0x00100246, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, + 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, + 0x3f000000, 0x3f000000, 0x0100003e, + }; static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f}; - static const DWORD initial_data[16] = {0}; + static const DWORD initial_data[32] = {0}; static const DWORD bitmap_data[] = { 0xff0000ff, 0xff00ffff, 0xff00ff00, 0xffffff00, @@ -13769,6 +13804,25 @@ static void test_update_subresource(void) 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000, 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000, }; + static const DWORD bc7_data[] = + { + 0x3a7b944b, 0x982a5800, 0x9cab4983, 0xc6a09579, + 0x5f7f2bfe, 0xa95d98f2, 0x3bfb4c03, 0x8be16a41, + 0x8362e6c0, 0x358ed7a2, 0xec3e130b, 0x86cebc86, + 0xf045be66, 0x7a16507f, 0xfe9ccc9f, 0x3f103e16, + 0x84d466c5, 0xfaf5cb5a, 0x9b9e1859, 0x384589b0, + 0x9268b4b8, 0x212b3643, 0x813f853a, 0x4a2bd7c2, + 0x1809f3e0, 0xf646d5ef, 0x40e80679, 0x05791fe5, + 0x6604e7e5, 0x5c28b55d, 0x1ef211f5, 0x632d47f6, + }; + static const DWORD bc7_expected_colors[] = + { + 0xc1752752, 0xc39859a9, 0xff79c08e, 0xff63bf6c, + 0xbf7d2756, 0xb89f3d40, 0xffda3a77, 0xffd08099, + 0x415f1f37, 0x43671d3f, 0xffc64758, 0xff57a194, + 0x405a2032, 0x39422619, 0xff749b76, 0xffabb879, + }; + static const DWORD expected_colors_3d[] = { 0xffff8000, 0xffff8080, 0x80008000, 0xff8080ff };
if (!init_test_context(&test_context, NULL)) return; @@ -13876,10 +13930,117 @@ static void test_update_subresource(void) } release_resource_readback(&rb);
- ID3D11PixelShader_Release(ps); - ID3D11SamplerState_Release(sampler_state); ID3D11ShaderResourceView_Release(ps_srv); ID3D11Texture2D_Release(texture); + ID3D11PixelShader_Release(ps); + + hr = ID3D11Device_CreatePixelShader(device, ps_code_3d, sizeof(ps_code_3d), NULL, &ps); + ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); + + texture_desc_3d.Width = 2; + texture_desc_3d.Height = 2; + texture_desc_3d.Depth = 2; + texture_desc_3d.MipLevels = 1; + texture_desc_3d.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texture_desc_3d.Usage = D3D11_USAGE_DEFAULT; + texture_desc_3d.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texture_desc_3d.CPUAccessFlags = 0; + texture_desc_3d.MiscFlags = 0; + + resource_data.SysMemPitch = texture_desc_3d.Width * sizeof(*initial_data); + resource_data.SysMemSlicePitch = texture_desc_3d.Width * texture_desc_3d.Height * sizeof(*initial_data); + + hr = ID3D11Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d); + ok(SUCCEEDED(hr), "Failed to create 3d texture, hr %#x.\n", hr); + + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture_3d, NULL, &ps_srv); + ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); + + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &ps_srv); + + set_box(&box, 0, 0, 0, 1, 2, 1); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data, 8, 16); + set_box(&box, 0, 0, 0, 1, 1, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data + 4, 16, 32); + set_box(&box, 1, 0, 0, 2, 1, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data + 8, 4, 0); + set_box(&box, 0, 0, 1, 2, 1, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data + 2, 4, 5); + set_box(&box, 0, 0, 1, 2, 1, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data + 3, 12, 0); + set_box(&box, 1, 1, 0, 2, 2, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bitmap_data, 0, 32); + + draw_quad(&test_context); + get_texture_readback(test_context.backbuffer, 0, &rb); + for (i = 0; i < 2; ++i) + { + for (j = 0; j < 2; ++j) + { + color = get_readback_color(&rb, 160 + j * 320, 120 + i * 240, 0); + ok(compare_color(color, expected_colors_3d[j + i * 2], 1), + "Got color 0x%08x at (%u, %u), expected 0x%08x.\n", + color, j, i, expected_colors_3d[j + i * 2]); + } + } + release_resource_readback(&rb); + ID3D11ShaderResourceView_Release(ps_srv); + ID3D11Texture3D_Release(texture_3d); + + texture_desc_3d.Width = 8; + texture_desc_3d.Height = 8; + texture_desc_3d.Depth = 2; + texture_desc_3d.Format = DXGI_FORMAT_BC7_UNORM; + + resource_data.SysMemPitch = 32; + resource_data.SysMemSlicePitch = 64; + + hr = ID3D11Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d); + if (FAILED(hr)) + { + skip("Failed to create BC7 3d texture, hr %#x.\n", hr); + } + else + { + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture_3d, NULL, &ps_srv); + ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); + + ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &ps_srv); + ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red); + + set_box(&box, 0, 0, 0, 8, 8, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data, 32, 64); + set_box(&box, 0, 0, 1, 8, 8, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data, 16, 0); + set_box(&box, 0, 0, 0, 4, 4, 1); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data + 8, 0, 0); + set_box(&box, 4, 4, 0, 8, 8, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data + 16, 0, 16); + set_box(&box, 0, 4, 1, 8, 8, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data + 1, 4, 32); + set_box(&box, 4, 0, 0, 8, 4, 2); + ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)texture_3d, 0, &box, bc7_data + 2, 0, 1); + + draw_quad(&test_context); + get_texture_readback(test_context.backbuffer, 0, &rb); + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 4; ++j) + { + color = get_readback_color(&rb, 70 + j * 160, 50 + i * 120, 0); + ok(compare_color(color, bc7_expected_colors[j + i * 4], 1), + "Got color 0x%08x at (%u, %u), expected 0x%08x.\n", + color, j, i, bc7_expected_colors[j + i * 4]); + } + } + release_resource_readback(&rb); + ID3D11ShaderResourceView_Release(ps_srv); + ID3D11Texture3D_Release(texture_3d); + } + + ID3D11PixelShader_Release(ps); + ID3D11SamplerState_Release(sampler_state); release_test_context(&test_context); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=87779
Your paranoid android.
=== w2008s64 (32 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.
=== w1064v1809 (32 bit report) ===
d3d11: d3d11.c:5811: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5812: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5813: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5816: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5817: Test failed: Got unexpected CPrimitives count: 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/d3d10core/tests/d3d10core.c | 165 ++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c index 2d836d4e7ac..95956fdcc7f 100644 --- a/dlls/d3d10core/tests/d3d10core.c +++ b/dlls/d3d10core/tests/d3d10core.c @@ -9531,11 +9531,13 @@ static void test_update_subresource(void) { struct d3d10core_test_context test_context; D3D10_SUBRESOURCE_DATA resource_data; + D3D10_TEXTURE3D_DESC texture_desc_3d; D3D10_TEXTURE2D_DESC texture_desc; ID3D10SamplerState *sampler_state; ID3D10ShaderResourceView *ps_srv; D3D10_SAMPLER_DESC sampler_desc; struct resource_readback rb; + ID3D10Texture3D *texture_3d; ID3D10Texture2D *texture; ID3D10PixelShader *ps; ID3D10Device *device; @@ -9570,6 +9572,39 @@ static void test_update_subresource(void) 0x3b088889, 0x00000000, 0x00000000, 0x09000045, 0x001020f2, 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e, }; + static const DWORD ps_code_3d[] = + { +#if 0 + Texture3D t; + SamplerState s; + + float4 main(float4 position : SV_POSITION) : SV_Target + { + float3 p1, p2; + p2.x = p1.x = position.x / 640.0f; + p2.y = p1.y = position.y / 480.0f; + p1.z = 0.25; + p2.z = 0.75; + return 0.5 * (t.Sample(s, p1) + t.Sample(s, p2)); + } +#endif + 0x43425844, 0x4d466d63, 0xa3d10db1, 0xd6534470, 0x16d738ef, 0x00000001, 0x000001ec, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000150, 0x00000040, + 0x00000054, 0x0300005a, 0x00106000, 0x00000000, 0x04002858, 0x00107000, 0x00000000, 0x00005555, + 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, + 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3e800000, + 0x09000045, 0x001000f2, 0x00000000, 0x00100246, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x0a000038, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, + 0x3b088889, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f400000, + 0x09000045, 0x001000f2, 0x00000001, 0x00100246, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, + 0x0a000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, + 0x3f000000, 0x3f000000, 0x0100003e, + }; static const float red[] = {1.0f, 0.0f, 0.0f, 0.5f}; static const DWORD initial_data[16] = {0}; static const DWORD bitmap_data[] = @@ -9586,6 +9621,25 @@ static void test_update_subresource(void) 0xffffff00, 0xffff0000, 0xffff00ff, 0x00000000, 0xff000000, 0xff7f7f7f, 0xffffffff, 0x00000000, }; + static const DWORD bc7_data[] = + { + 0x3a7b944b, 0x982a5800, 0x9cab4983, 0xc6a09579, + 0x5f7f2bfe, 0xa95d98f2, 0x3bfb4c03, 0x8be16a41, + 0x8362e6c0, 0x358ed7a2, 0xec3e130b, 0x86cebc86, + 0xf045be66, 0x7a16507f, 0xfe9ccc9f, 0x3f103e16, + 0x84d466c5, 0xfaf5cb5a, 0x9b9e1859, 0x384589b0, + 0x9268b4b8, 0x212b3643, 0x813f853a, 0x4a2bd7c2, + 0x1809f3e0, 0xf646d5ef, 0x40e80679, 0x05791fe5, + 0x6604e7e5, 0x5c28b55d, 0x1ef211f5, 0x632d47f6, + }; + static const DWORD bc7_expected_colors[] = + { + 0xc1752752, 0xc39859a9, 0xff79c08e, 0xff63bf6c, + 0xbf7d2756, 0xb89f3d40, 0xffda3a77, 0xffd08099, + 0x415f1f37, 0x43671d3f, 0xffc64758, 0xff57a194, + 0x405a2032, 0x39422619, 0xff749b76, 0xffabb879, + }; + static const DWORD expected_colors_3d[] = { 0xffff8000, 0xffff8080, 0x80008000, 0xff8080ff };
if (!init_test_context(&test_context)) return; @@ -9692,10 +9746,117 @@ static void test_update_subresource(void) } release_resource_readback(&rb);
- ID3D10PixelShader_Release(ps); - ID3D10SamplerState_Release(sampler_state); ID3D10ShaderResourceView_Release(ps_srv); ID3D10Texture2D_Release(texture); + ID3D10PixelShader_Release(ps); + + hr = ID3D10Device_CreatePixelShader(device, ps_code_3d, sizeof(ps_code_3d), &ps); + ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); + + texture_desc_3d.Width = 2; + texture_desc_3d.Height = 2; + texture_desc_3d.Depth = 2; + texture_desc_3d.MipLevels = 1; + texture_desc_3d.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texture_desc_3d.Usage = D3D11_USAGE_DEFAULT; + texture_desc_3d.BindFlags = D3D11_BIND_SHADER_RESOURCE; + texture_desc_3d.CPUAccessFlags = 0; + texture_desc_3d.MiscFlags = 0; + + resource_data.SysMemPitch = texture_desc_3d.Width * sizeof(*initial_data); + resource_data.SysMemSlicePitch = texture_desc_3d.Width * texture_desc_3d.Height * sizeof(*initial_data); + + hr = ID3D10Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d); + ok(SUCCEEDED(hr), "Failed to create 3d texture, hr %#x.\n", hr); + + hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture_3d, NULL, &ps_srv); + ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); + + ID3D10Device_PSSetShader(device, ps); + ID3D10Device_PSSetShaderResources(device, 0, 1, &ps_srv); + + set_box(&box, 0, 0, 0, 1, 2, 1); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data, 8, 16); + set_box(&box, 0, 0, 0, 1, 1, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data + 4, 16, 32); + set_box(&box, 1, 0, 0, 2, 1, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data + 8, 4, 0); + set_box(&box, 0, 0, 1, 2, 1, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data + 2, 4, 5); + set_box(&box, 0, 0, 1, 2, 1, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data + 3, 12, 0); + set_box(&box, 1, 1, 0, 2, 2, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bitmap_data, 0, 32); + + draw_quad(&test_context); + get_texture_readback(test_context.backbuffer, 0, &rb); + for (i = 0; i < 2; ++i) + { + for (j = 0; j < 2; ++j) + { + color = get_readback_color(&rb, 160 + j * 320, 120 + i * 240); + ok(compare_color(color, expected_colors_3d[j + i * 2], 1), + "Got color 0x%08x at (%u, %u), expected 0x%08x.\n", + color, j, i, expected_colors_3d[j + i * 2]); + } + } + release_resource_readback(&rb); + ID3D10ShaderResourceView_Release(ps_srv); + ID3D10Texture3D_Release(texture_3d); + + texture_desc_3d.Width = 8; + texture_desc_3d.Height = 8; + texture_desc_3d.Depth = 2; + texture_desc_3d.Format = DXGI_FORMAT_BC7_UNORM; + + resource_data.SysMemPitch = 32; + resource_data.SysMemSlicePitch = 64; + + hr = ID3D10Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d); + if (FAILED(hr)) + { + skip("Failed to create BC7 3d texture, hr %#x.\n", hr); + } + else + { + hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture_3d, NULL, &ps_srv); + ok(SUCCEEDED(hr), "Failed to create shader resource view, hr %#x.\n", hr); + + ID3D10Device_PSSetShaderResources(device, 0, 1, &ps_srv); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, red); + + set_box(&box, 0, 0, 0, 8, 8, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data, 32, 64); + set_box(&box, 0, 0, 1, 8, 8, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data, 16, 0); + set_box(&box, 0, 0, 0, 4, 4, 1); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data + 8, 0, 0); + set_box(&box, 4, 4, 0, 8, 8, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data + 16, 0, 16); + set_box(&box, 0, 4, 1, 8, 8, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data + 1, 4, 32); + set_box(&box, 4, 0, 0, 8, 4, 2); + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)texture_3d, 0, &box, bc7_data + 2, 0, 1); + + draw_quad(&test_context); + get_texture_readback(test_context.backbuffer, 0, &rb); + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 4; ++j) + { + color = get_readback_color(&rb, 70 + j * 160, 50 + i * 120); + ok(compare_color(color, bc7_expected_colors[j + i * 4], 1), + "Got color 0x%08x at (%u, %u), expected 0x%08x.\n", + color, j, i, bc7_expected_colors[j + i * 4]); + } + } + release_resource_readback(&rb); + ID3D10ShaderResourceView_Release(ps_srv); + ID3D10Texture3D_Release(texture_3d); + } + + ID3D10PixelShader_Release(ps); + ID3D10SamplerState_Release(sampler_state); release_test_context(&test_context); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=87780
Your paranoid android.
=== w10pro64 (32 bit report) ===
d3d10core: d3d10core.c:4766: Test failed: Got unexpected IAVertices count: 0. d3d10core.c:4767: Test failed: Got unexpected IAPrimitives count: 0. d3d10core.c:4768: Test failed: Got unexpected VSInvocations count: 0. d3d10core.c:4771: Test failed: Got unexpected CInvocations count: 0. d3d10core.c:4772: Test failed: Got unexpected CPrimitives count: 0.
On Fri, 26 Mar 2021 at 14:22, Jan Sikorski jsikorski@codeweavers.com wrote:
- texture_desc_3d.Width = 2;
- texture_desc_3d.Height = 2;
- texture_desc_3d.Depth = 2;
- texture_desc_3d.MipLevels = 1;
- texture_desc_3d.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- texture_desc_3d.Usage = D3D11_USAGE_DEFAULT;
- texture_desc_3d.BindFlags = D3D11_BIND_SHADER_RESOURCE;
- texture_desc_3d.CPUAccessFlags = 0;
- texture_desc_3d.MiscFlags = 0;
D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE.
- hr = ID3D10Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d);
- if (FAILED(hr))
- {
skip("Failed to create BC7 3d texture, hr %#x.\n", hr);
- }
Does that pass anywhere? BC7 is supposed to be a feature level 11.0+ feature.
On 26 Mar 2021, at 19:20, Henri Verbeet hverbeet@gmail.com wrote:
On Fri, 26 Mar 2021 at 14:22, Jan Sikorski jsikorski@codeweavers.com wrote:
- texture_desc_3d.Width = 2;
- texture_desc_3d.Height = 2;
- texture_desc_3d.Depth = 2;
- texture_desc_3d.MipLevels = 1;
- texture_desc_3d.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- texture_desc_3d.Usage = D3D11_USAGE_DEFAULT;
- texture_desc_3d.BindFlags = D3D11_BIND_SHADER_RESOURCE;
- texture_desc_3d.CPUAccessFlags = 0;
- texture_desc_3d.MiscFlags = 0;
D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE.
- hr = ID3D10Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d);
- if (FAILED(hr))
- {
skip("Failed to create BC7 3d texture, hr %#x.\n", hr);
- }
Does that pass anywhere? BC7 is supposed to be a feature level 11.0+ feature.
Oops, you’re right, I rushed that part. Looks like there’s no D3D10 compressed format that we support in 3D without decompressing. We could skip it altogether or maybe do an array of 2D, say, BC4 textures instead? (I don’t know if UpdateSubresource can write to multiple layers though..)
On Mon, 29 Mar 2021 at 10:27, Jan Sikorski jsikorski@codeweavers.com wrote:
On 26 Mar 2021, at 19:20, Henri Verbeet hverbeet@gmail.com wrote: On Fri, 26 Mar 2021 at 14:22, Jan Sikorski jsikorski@codeweavers.com wrote:
- texture_desc_3d.Width = 2;
- texture_desc_3d.Height = 2;
- texture_desc_3d.Depth = 2;
- texture_desc_3d.MipLevels = 1;
- texture_desc_3d.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- texture_desc_3d.Usage = D3D11_USAGE_DEFAULT;
- texture_desc_3d.BindFlags = D3D11_BIND_SHADER_RESOURCE;
- texture_desc_3d.CPUAccessFlags = 0;
- texture_desc_3d.MiscFlags = 0;
D3D10_USAGE_DEFAULT, D3D10_BIND_SHADER_RESOURCE.
- hr = ID3D10Device_CreateTexture3D(device, &texture_desc_3d, &resource_data, &texture_3d);
- if (FAILED(hr))
- {
skip("Failed to create BC7 3d texture, hr %#x.\n", hr);
- }
Does that pass anywhere? BC7 is supposed to be a feature level 11.0+ feature.
Oops, you’re right, I rushed that part. Looks like there’s no D3D10 compressed format that we support in 3D without decompressing. We could skip it altogether or maybe do an array of 2D, say, BC4 textures instead? (I don’t know if UpdateSubresource can write to multiple layers though..)
Skipping should be fine, but it might not be bad to test the upload decompression paths either.