For shader_glsl_generate_sm4_output_setup().
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/shader.c | 65 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 23 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index b757d930da88..68d99543a3d0 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -992,6 +992,40 @@ static void wined3d_insert_interpolation_mode(DWORD *packed_interpolation_mode, register_idx * WINED3D_PACKED_INTERPOLATION_BIT_COUNT, WINED3D_PACKED_INTERPOLATION_BIT_COUNT, mode); }
+static HRESULT shader_scan_output_signature(struct wined3d_shader *shader) +{ + const struct wined3d_shader_signature *output_signature = &shader->output_signature; + struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps; + unsigned int i; + HRESULT hr; + + for (i = 0; i < output_signature->element_count; ++i) + { + const struct wined3d_shader_signature_element *e = &output_signature->elements[i]; + unsigned int mask; + + reg_maps->output_registers |= 1u << e->register_idx; + if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE) + { + if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask))) + return hr; + reg_maps->clip_distance_mask |= mask; + } + else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE) + { + if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask))) + return hr; + reg_maps->cull_distance_mask |= mask; + } + else if (e->sysval_semantic == WINED3D_SV_VIEWPORT_ARRAY_INDEX) + { + reg_maps->viewport_array = 1; + } + } + + return WINED3D_OK; +} + /* Note that this does not count the loop register as an address register. */ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe, struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature *input_signature, @@ -1789,29 +1823,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
if (output_signature->elements) { - for (i = 0; i < output_signature->element_count; ++i) - { - const struct wined3d_shader_signature_element *e = &output_signature->elements[i]; - unsigned int mask; - - reg_maps->output_registers |= 1u << e->register_idx; - if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE) - { - if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask))) - return hr; - reg_maps->clip_distance_mask |= mask; - } - else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE) - { - if (FAILED(hr = shader_calculate_clip_or_cull_distance_mask(e, &mask))) - return hr; - reg_maps->cull_distance_mask |= mask; - } - else if (e->sysval_semantic == WINED3D_SV_VIEWPORT_ARRAY_INDEX) - { - reg_maps->viewport_array = 1; - } - } + if (FAILED(hr = shader_scan_output_signature(shader))) + return hr; } else if (reg_maps->output_registers) { @@ -3701,6 +3714,12 @@ static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device shader->reg_maps.shader_version.major = 4; shader->reg_maps.shader_version.minor = 0; shader_set_limits(shader); + + if (FAILED(hr = shader_scan_output_signature(shader))) + { + shader_cleanup(shader); + return hr; + } }
shader->load_local_constsF = shader->lconst_inf_or_nan;
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/shader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 68d99543a3d0..c8939459d0eb 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1027,12 +1027,14 @@ static HRESULT shader_scan_output_signature(struct wined3d_shader *shader) }
/* Note that this does not count the loop register as an address register. */ -static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe, - struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature *input_signature, - struct wined3d_shader_signature *output_signature, DWORD constf_size) +static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD constf_size) { struct wined3d_shader_signature_element input_signature_elements[max(MAX_ATTRIBS, MAX_REG_INPUT)]; struct wined3d_shader_signature_element output_signature_elements[MAX_REG_OUTPUT]; + struct wined3d_shader_signature *output_signature = &shader->output_signature; + struct wined3d_shader_signature *input_signature = &shader->input_signature; + struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps; + const struct wined3d_shader_frontend *fe = shader->frontend; unsigned int cur_loop_depth = 0, max_loop_depth = 0; struct wined3d_shader_version shader_version; struct wined3d_shader_phase *phase = NULL; @@ -3292,11 +3294,11 @@ const struct wined3d_shader_backend_ops none_shader_backend = static HRESULT shader_set_function(struct wined3d_shader *shader, DWORD float_const_count, enum wined3d_shader_type type, unsigned int max_version) { + const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info; struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps; const struct wined3d_shader_frontend *fe; - HRESULT hr; unsigned int backend_version; - const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info; + HRESULT hr;
TRACE("shader %p, float_const_count %u, type %#x, max_version %u.\n", shader, float_const_count, type, max_version); @@ -3314,8 +3316,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, DWORD float_co shader_trace_init(fe, shader->frontend_data);
/* Second pass: figure out which registers are used, what the semantics are, etc. */ - if (FAILED(hr = shader_get_registers_used(shader, fe, reg_maps, &shader->input_signature, - &shader->output_signature, float_const_count))) + if (FAILED(hr = shader_get_registers_used(shader, float_const_count))) return hr;
if (reg_maps->shader_version.type != type)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10core/tests/device.c | 175 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index ba0a914e7eec..d3e359e019e5 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -14523,6 +14523,180 @@ static void test_stream_output_resume(void) release_test_context(&test_context); }
+static void test_stream_output_vs(void) +{ + struct d3d10core_test_context test_context; + ID3D10InputLayout *input_layout; + ID3D10Buffer *vb, *so_buffer; + struct resource_readback rb; + ID3D10GeometryShader *gs; + ID3D10VertexShader *vs; + ID3D10Device *device; + const float *result; + unsigned int offset; + unsigned int i, j; + HRESULT hr; + + static const DWORD vs_code[] = + { +#if 0 + struct vertex + { + float4 position : POSITION; + float4 color0 : COLOR0; + float4 color1 : COLOR1; + }; + + vertex main(in vertex i) + { + return i; + } +#endif + 0x43425844, 0xa67e993e, 0x1632c139, 0x02a7725f, 0xfb0221cd, 0x00000001, 0x00000194, 0x00000003, + 0x0000002c, 0x00000094, 0x000000fc, 0x4e475349, 0x00000060, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002, + 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x00000060, 0x00000003, + 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000059, + 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000059, 0x00000001, 0x00000000, + 0x00000003, 0x00000002, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x52444853, + 0x00000090, 0x00010040, 0x00000024, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, + 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, + 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, + 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, + 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, 0x0100003e, + }; + static const D3D10_INPUT_ELEMENT_DESC layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 32, D3D10_INPUT_PER_VERTEX_DATA, 0}, + }; + static const D3D10_SO_DECLARATION_ENTRY all_so_decl[] = + { + {"POSITION", 0, 0, 4, 0}, + {"COLOR", 0, 0, 4, 0}, + {"COLOR", 1, 0, 4, 0}, + }; + static const D3D10_SO_DECLARATION_ENTRY position_so_decl[] = + { + {"POSITION", 0, 0, 4, 0}, + }; + static const D3D10_SO_DECLARATION_ENTRY color_so_decl[] = + { + {"COLOR", 1, 0, 2, 0}, + }; + static const struct + { + struct vec4 position; + struct vec4 color0; + struct vec4 color1; + } + vb_data[] = + { + {{-1.0f, -1.0f, 0.0f, 1.0f}, {1.0f, 2.0f, 3.0f, 4.0f}, {5.0f, 6.0f, 7.0f, 8.0f}}, + {{-1.0f, 1.0f, 0.0f, 1.0f}, {9.0f, 1.1f, 1.2f, 1.3f}, {1.4f, 1.5f, 1.6f, 1.7f}}, + {{ 1.0f, -1.0f, 0.0f, 1.0f}, {1.8f, 1.9f, 2.0f, 2.1f}, {2.2f, 2.3f, 2.4f, 2.5f}}, + {{ 1.0f, 1.0f, 0.0f, 1.0f}, {2.5f, 2.6f, 2.7f, 2.8f}, {2.9f, 3.0f, 3.1f, 3.2f}}, + }; + static const unsigned int vb_stride[] = {sizeof(*vb_data)}; + static const float expected_data[] = + { + -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, + -1.0f, 1.0f, 0.0f, 1.0f, 9.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, + 1.0f, -1.0f, 0.0f, 1.0f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f, + 1.0f, 1.0f, 0.0f, 1.0f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f, 3.1f, 3.2f, + }; + static const float expected_data2[] = + { + -1.0f, -1.0f, 0.0f, 1.0f, + -1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, -1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 0.0f, 1.0f, + }; + static const float expected_data3[] = + { + 5.0f, 6.0f, + 1.4f, 1.5f, + 2.2f, 2.3f, + 2.9f, 3.0f, + }; + static const struct + { + const D3D10_SO_DECLARATION_ENTRY *so_declaration; + unsigned int so_entry_count; + unsigned int so_stride; + const float *expected_data; + unsigned int expected_data_size; + BOOL todo; + } + tests[] = + { + {all_so_decl, ARRAY_SIZE(all_so_decl), 48, expected_data, ARRAY_SIZE(expected_data)}, + {position_so_decl, ARRAY_SIZE(position_so_decl), 16, expected_data2, ARRAY_SIZE(expected_data2)}, + {color_so_decl, ARRAY_SIZE(color_so_decl), 8, expected_data3, ARRAY_SIZE(expected_data3), TRUE}, + }; + + if (!init_test_context(&test_context)) + return; + + device = test_context.device; + + vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(vb_data), vb_data); + + hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), + vs_code, sizeof(vs_code), &input_layout); + ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + + hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs); + ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); + + so_buffer = create_buffer(device, D3D10_BIND_STREAM_OUTPUT, 1024, NULL); + + ID3D10Device_IASetInputLayout(device, input_layout); + offset = 0; + ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, vb_stride, &offset); + ID3D10Device_VSSetShader(device, vs); + + ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_POINTLIST); + + gs = NULL; + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + if (gs) + ID3D10GeometryShader_Release(gs); + + hr = ID3D10Device_CreateGeometryShaderWithStreamOutput(device, vs_code, sizeof(vs_code), + tests[i].so_declaration, tests[i].so_entry_count, tests[i].so_stride, &gs); + ok(hr == S_OK, "Failed to create geometry shader with stream output, hr %#x.\n", hr); + ID3D10Device_GSSetShader(device, gs); + + offset = 0; + ID3D10Device_SOSetTargets(device, 1, &so_buffer, &offset); + + ID3D10Device_Draw(device, 4, 0); + + get_buffer_readback(so_buffer, &rb); + result = rb.map_desc.pData; + for (j = 0; j < tests[i].expected_data_size; ++j) + { + float expected_value = tests[i].expected_data[j]; + todo_wine_if(tests[i].todo) + ok(compare_float(result[j], expected_value, 2), + "Test %u: Got %.8e, expected %.8e at %u.\n", + i, result[j], expected_value, j); + } + release_resource_readback(&rb); + } + + ID3D10Buffer_Release(vb); + ID3D10Buffer_Release(so_buffer); + ID3D10VertexShader_Release(vs); + ID3D10GeometryShader_Release(gs); + ID3D10InputLayout_Release(input_layout); + release_test_context(&test_context); +} + static void test_depth_bias(void) { struct vec3 vertices[] = @@ -16488,6 +16662,7 @@ START_TEST(device) test_geometry_shader(); test_stream_output(); test_stream_output_resume(); + test_stream_output_vs(); test_depth_bias(); test_format_compatibility(); test_clip_distance();
Hi,
While running your changed tests on Windows, 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=38023
Your paranoid android.
=== wvistau64 (64 bit device) === device.c:4453: Test failed: Got unexpected IAVertices count: 0. device.c:4454: Test failed: Got unexpected IAPrimitives count: 0. device.c:4455: Test failed: Got unexpected VSInvocations count: 0. device.c:4458: Test failed: Got unexpected CInvocations count: 0. device.c:4459: Test failed: Got unexpected CPrimitives count: 0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/cs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index b0572ab47c20..dc07f52723de 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -986,8 +986,7 @@ void wined3d_cs_emit_set_viewports(struct wined3d_cs *cs, unsigned int viewport_ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_set_viewports, viewports[viewport_count]), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_SET_VIEWPORTS; - if (viewport_count) - memcpy(op->viewports, viewports, viewport_count * sizeof(*viewports)); + memcpy(op->viewports, viewports, viewport_count * sizeof(*viewports)); op->viewport_count = viewport_count;
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); @@ -1012,8 +1011,7 @@ void wined3d_cs_emit_set_scissor_rects(struct wined3d_cs *cs, unsigned int rect_ op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_set_scissor_rects, rects[rect_count]), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_SET_SCISSOR_RECTS; - if (rect_count) - memcpy(op->rects, rects, rect_count * sizeof(*rects)); + memcpy(op->rects, rects, rect_count * sizeof(*rects)); op->rect_count = rect_count;
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
Extracted from patch 144562.
--- dlls/d3d11/tests/d3d11.c | 112 ++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 83 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 82790932b149..4f6664d918ca 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -629,6 +629,21 @@ static void check_uav_desc_(unsigned int line, const D3D11_UNORDERED_ACCESS_VIEW } }
+static void set_viewport(ID3D11DeviceContext *context, float x, float y, + float width, float height, float min_depth, float max_depth) +{ + D3D11_VIEWPORT vp; + + vp.TopLeftX = x; + vp.TopLeftY = y; + vp.Width = width; + vp.Height = height; + vp.MinDepth = min_depth; + vp.MaxDepth = max_depth; + + ID3D11DeviceContext_RSSetViewports(context, 1, &vp); +} + #define create_buffer(a, b, c, d) create_buffer_(__LINE__, a, b, 0, c, d) #define create_buffer_misc(a, b, c, d, e) create_buffer_(__LINE__, a, b, c, d, e) static ID3D11Buffer *create_buffer_(unsigned int line, ID3D11Device *device, @@ -1272,7 +1287,6 @@ static BOOL init_test_context_(unsigned int line, struct d3d11_test_context *con { unsigned int rt_width, rt_height; struct device_desc device_desc; - D3D11_VIEWPORT vp; HRESULT hr; RECT rect;
@@ -1304,13 +1318,7 @@ static BOOL init_test_context_(unsigned int line, struct d3d11_test_context *con
ID3D11DeviceContext_OMSetRenderTargets(context->immediate_context, 1, &context->backbuffer_rtv, NULL);
- vp.TopLeftX = 0.0f; - vp.TopLeftY = 0.0f; - vp.Width = rt_width; - vp.Height = rt_height; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context->immediate_context, 1, &vp); + set_viewport(context->immediate_context, 0.0f, 0.0f, rt_width, rt_height, 0.0f, 1.0f);
return TRUE; } @@ -5129,7 +5137,6 @@ static void test_occlusion_query(void) unsigned int data_size, i; ID3D11Texture2D *texture; ID3D11Device *device; - D3D11_VIEWPORT vp; union { UINT64 uint; @@ -5227,13 +5234,7 @@ static void test_occlusion_query(void) ok(SUCCEEDED(hr), "Failed to create render target view, hr %#x.\n", hr);
ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL); - vp.TopLeftX = 0.0f; - vp.TopLeftY = 0.0f; - vp.Width = texture_desc.Width; - vp.Height = texture_desc.Height; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, texture_desc.Width, texture_desc.Height, 0.0f, 1.0f);
ID3D11DeviceContext_Begin(context, query); for (i = 0; i < 100; i++) @@ -5255,9 +5256,7 @@ static void test_occlusion_query(void) hr = ID3D11Device_CreateQuery(device, &query_desc, (ID3D11Query **)&query); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- vp.Width = 64.0f; - vp.Height = 64.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 64.0f, 64.0f, 0.0f, 1.0f); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); ID3D11DeviceContext_Begin(context, query); draw_color_quad(&test_context, &red); @@ -5977,7 +5976,6 @@ static void test_blend(void) ID3D11VertexShader *vs; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; ID3D11Buffer *vb; DWORD color; HRESULT hr; @@ -6143,13 +6141,7 @@ static void test_blend(void)
ID3D11DeviceContext_OMSetRenderTargets(context, 1, &offscreen_rtv, NULL);
- vp.TopLeftX = 0.0f; - vp.TopLeftY = 0.0f; - vp.Width = 128.0f; - vp.Height = 128.0f; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 128.0f, 128.0f, 0.0f, 1.0f);
ID3D11DeviceContext_ClearRenderTargetView(context, offscreen_rtv, red);
@@ -8656,7 +8648,6 @@ static void test_multiple_render_targets(void) ID3D11VertexShader *vs; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; ID3D11Buffer *vb; ULONG refcount; HRESULT hr; @@ -8775,13 +8766,7 @@ static void test_multiple_render_targets(void) ID3D11DeviceContext_VSSetShader(context, vs, NULL, 0); ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
- vp.TopLeftX = 0.0f; - vp.TopLeftY = 0.0f; - vp.Width = 640.0f; - vp.Height = 480.0f; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 1.0f);
for (i = 0; i < ARRAY_SIZE(rtv); ++i) ID3D11DeviceContext_ClearRenderTargetView(context, rtv[i], red); @@ -12353,7 +12338,6 @@ static void test_swapchain_flip(void) ID3D11VertexShader *vs; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; ID3D11Buffer *vb; ULONG refcount; DWORD color; @@ -12492,13 +12476,7 @@ static void test_swapchain_flip(void) hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)offscreen, NULL, &offscreen_rtv); ok(SUCCEEDED(hr), "Failed to create rendertarget view, hr %#x.\n", hr); ID3D11DeviceContext_OMSetRenderTargets(context, 1, &offscreen_rtv, NULL); - vp.TopLeftX = 0; - vp.TopLeftY = 0; - vp.Width = 640; - vp.Height = 480; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 1.0f);
vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(quad), quad);
@@ -13156,12 +13134,10 @@ static void test_initial_depth_stencil_state(void) /* check if depth function is D3D11_COMPARISON_LESS */ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 0.5f, 0); - vp.MinDepth = vp.MaxDepth = 0.4f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.4f, 0.4f); draw_color_quad(&test_context, &green); draw_color_quad(&test_context, &red); - vp.MinDepth = vp.MaxDepth = 0.6f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.6f, 0.6f); draw_color_quad(&test_context, &red); check_texture_color(test_context.backbuffer, 0xff00ff00, 1); check_texture_float(texture, 0.4f, 1); @@ -13182,7 +13158,6 @@ static void test_draw_depth_only(void) ID3D11Texture2D *texture; ID3D11Device *device; unsigned int i, j; - D3D11_VIEWPORT vp; struct vec4 depth; ID3D11Buffer *cb; HRESULT hr; @@ -13279,13 +13254,7 @@ static void test_draw_depth_only(void) depth.x = 1.0f / 16.0f * (j + 4 * i); ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, &depth, 0, 0);
- vp.TopLeftX = 160.0f * j; - vp.TopLeftY = 120.0f * i; - vp.Width = 160.0f; - vp.Height = 120.0f; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 160.0f * j, 120.0f * i, 160.0f, 120.0f, 0.0f, 1.0f);
draw_quad(&test_context); } @@ -13323,7 +13292,6 @@ static void test_draw_uav_only(void) ID3D11Texture2D *texture; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; HRESULT hr;
static const DWORD ps_code[] = @@ -13377,10 +13345,7 @@ static void test_draw_uav_only(void) 0, 1, &uav, NULL);
ID3D11DeviceContext_ClearUnorderedAccessViewUint(context, uav, values); - memset(&vp, 0, sizeof(vp)); - vp.Width = 10.0f; - vp.Height = 10.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 10.0f, 10.0f, 0.0f, 0.0f); ID3D11DeviceContext_ClearUnorderedAccessViewUint(context, uav, values); draw_quad(&test_context); check_texture_color(texture, 100, 1); @@ -18576,7 +18541,6 @@ static void test_atomic_instructions(void) ID3D11ComputeShader *cs; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; unsigned int i, j; HRESULT hr;
@@ -18726,13 +18690,7 @@ static void test_atomic_instructions(void) hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)out_buffer, &uav_desc, &out_uav); ok(SUCCEEDED(hr), "Failed to create unordered access view, hr %#x.\n", hr);
- vp.TopLeftX = 0.0f; - vp.TopLeftY = 0.0f; - vp.Width = 1.0f; - vp.Height = 1.0f; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f);
hr = ID3D11Device_CreatePixelShader(device, ps_atomics_code, sizeof(ps_atomics_code), NULL, &ps); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); @@ -23996,7 +23954,6 @@ static void test_fractional_viewports(void) ID3D11Device *device; ID3D11Texture2D *rt; UINT offset, stride; - D3D11_VIEWPORT vp; ID3D11Buffer *vb; HRESULT hr;
@@ -24111,13 +24068,8 @@ static void test_fractional_viewports(void)
for (i = 0; i < ARRAY_SIZE(viewport_offsets); ++i) { - vp.TopLeftX = viewport_offsets[i]; - vp.TopLeftY = viewport_offsets[i]; - vp.Width = texture_desc.Width; - vp.Height = texture_desc.Height; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, viewport_offsets[i], viewport_offsets[i], + texture_desc.Width, texture_desc.Height, 0.0f, 1.0f); ID3D11DeviceContext_ClearRenderTargetView(context, rtv, white); ID3D11DeviceContext_Draw(context, 4, 0); get_texture_readback(rt, 0, &rb); @@ -24162,7 +24114,6 @@ static void test_early_depth_stencil(void) ID3D11DepthStencilView *dsv; ID3D11PixelShader *ps; ID3D11Device *device; - D3D11_VIEWPORT vp; HRESULT hr;
static const DWORD ps_code[] = @@ -24231,12 +24182,7 @@ static void test_early_depth_stencil(void) ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
- memset(&vp, 0, sizeof(vp)); - vp.Width = 1.0f; - vp.Height = 100.0f; - vp.MinDepth = 0.5f; - vp.MaxDepth = 0.5f; - ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + set_viewport(context, 0.0f, 0.0f, 1.0f, 100.0f, 0.5f, 0.5f); ID3D11DeviceContext_OMSetDepthStencilState(context, depth_stencil_state, 0); ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context, 1, &test_context.backbuffer_rtv, dsv, 1, 1, &uav, NULL);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 120 +++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 62 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 4f6664d918ca..8279e7b105cf 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -1273,6 +1273,7 @@ struct d3d11_test_context
ID3D11InputLayout *input_layout; ID3D11VertexShader *vs; + const DWORD *vs_code; ID3D11Buffer *vs_cb; ID3D11Buffer *vb;
@@ -1351,13 +1352,39 @@ static void release_test_context_(unsigned int line, struct d3d11_test_context * ok_(__FILE__, line)(!ref, "Device has %u references left.\n", ref); }
-static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context, +#define draw_quad(context) draw_quad_vs_(__LINE__, context, NULL, 0) +#define draw_quad_vs(a, b, c) draw_quad_vs_(__LINE__, a, b, c) +static void draw_quad_vs_(unsigned int line, struct d3d11_test_context *context, const DWORD *vs_code, size_t vs_code_size) { static const D3D11_INPUT_ELEMENT_DESC default_layout_desc[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; + static const DWORD default_vs_code[] = + { +#if 0 + float4 main(float4 position : POSITION) : SV_POSITION + { + return position; + } +#endif + 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006, + 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044, + 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000, + 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, + 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, + 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200, + 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000, + 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000, + 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040, + 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c, + 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, + 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + }; static const struct vec3 quad[] = { {-1.0f, -1.0f, 0.0f}, @@ -1370,14 +1397,28 @@ static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context, unsigned int stride, offset; HRESULT hr;
+ if (!vs_code) + { + vs_code = default_vs_code; + vs_code_size = sizeof(default_vs_code); + } + if (!context->input_layout) { hr = ID3D11Device_CreateInputLayout(device, default_layout_desc, ARRAY_SIZE(default_layout_desc), vs_code, vs_code_size, &context->input_layout); ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + } + + if (context->vs_code != vs_code) + { + if (context->vs) + ID3D11VertexShader_Release(context->vs);
hr = ID3D11Device_CreateVertexShader(device, vs_code, vs_code_size, NULL, &context->vs); - ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); + ok_(__FILE__, line)(hr == S_OK, "Failed to create vertex shader, hr %#x.\n", hr); + + context->vs_code = vs_code; }
if (!context->vb) @@ -1393,37 +1434,6 @@ static void draw_quad_vs(unsigned int line, struct d3d11_test_context *context, ID3D11DeviceContext_Draw(context->immediate_context, 4, 0); }
-#define draw_quad(context) draw_quad_(__LINE__, context) -static void draw_quad_(unsigned int line, struct d3d11_test_context *context) -{ - static const DWORD vs_code[] = - { -#if 0 - float4 main(float4 position : POSITION) : SV_POSITION - { - return position; - } -#endif - 0x43425844, 0x4fb19b86, 0x955fa240, 0x1a630688, 0x24eb9db4, 0x00000001, 0x000001e0, 0x00000006, - 0x00000038, 0x00000084, 0x000000d0, 0x00000134, 0x00000178, 0x000001ac, 0x53414e58, 0x00000044, - 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, - 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000, - 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, - 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, - 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c, 0x0000005c, 0xfffe0200, - 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240001, 0x00000000, - 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000, 0x90ff0000, 0xa0e40000, - 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853, 0x0000003c, 0x00010040, - 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, - 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x4e475349, 0x0000002c, - 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, - 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, - 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, - }; - - draw_quad_vs(__LINE__, context, vs_code, sizeof(vs_code)); -} - #define draw_quad_z(context, z) draw_quad_z_(__LINE__, context, z) static void draw_quad_z_(unsigned int line, struct d3d11_test_context *context, float z) { @@ -1457,7 +1467,7 @@ static void draw_quad_z_(unsigned int line, struct d3d11_test_context *context, (ID3D11Resource *)context->vs_cb, 0, NULL, &data, 0, 0);
ID3D11DeviceContext_VSSetConstantBuffers(context->immediate_context, 0, 1, &context->vs_cb); - draw_quad_vs(__LINE__, context, vs_code, sizeof(vs_code)); + draw_quad_vs_(__LINE__, context, vs_code, sizeof(vs_code)); }
static void set_quad_color(struct d3d11_test_context *context, const struct vec4 *color) @@ -1466,8 +1476,10 @@ static void set_quad_color(struct d3d11_test_context *context, const struct vec4 (ID3D11Resource *)context->ps_cb, 0, NULL, color, 0, 0); }
-#define draw_color_quad(context, color) draw_color_quad_(__LINE__, context, color) -static void draw_color_quad_(unsigned int line, struct d3d11_test_context *context, const struct vec4 *color) +#define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0) +#define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d) +static void draw_color_quad_(unsigned int line, struct d3d11_test_context *context, + const struct vec4 *color, const DWORD *vs_code, size_t vs_code_size) { static const DWORD ps_color_code[] = { @@ -1509,7 +1521,7 @@ static void draw_color_quad_(unsigned int line, struct d3d11_test_context *conte
set_quad_color(context, color);
- draw_quad_(line, context); + draw_quad_vs_(line, context, vs_code, vs_code_size); }
static void test_create_device(void) @@ -13495,8 +13507,6 @@ float4 main(const ps_in v) : SV_TARGET colors_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(colors), &colors); index_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(index), NULL);
- hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs); - ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
@@ -13511,7 +13521,7 @@ float4 main(const ps_in v) : SV_TARGET index[0] = test_data[i].index; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)index_cb, 0, NULL, &index, 0, 0);
- draw_quad(&test_context); + draw_quad_vs(&test_context, vs_code, sizeof(vs_code)); check_texture_color(test_context.backbuffer, test_data[i].expected, 1); }
@@ -13620,9 +13630,6 @@ static void test_vs_input_relative_addressing(void) offset = 0; ID3D11DeviceContext_IASetVertexBuffers(context, 1, 1, &vb, &stride, &offset);
- hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs); - ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); - hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); @@ -13632,7 +13639,7 @@ static void test_vs_input_relative_addressing(void) *index = i; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cb, 0, NULL, index, 0, 0); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_quad(&test_context); + draw_quad_vs(&test_context, vs_code, sizeof(vs_code)); check_texture_color(test_context.backbuffer, colors[i], 1); }
@@ -24943,9 +24950,6 @@ static void test_clip_distance(void) offset = 0; ID3D11DeviceContext_IASetVertexBuffers(context, 1, 1, &vb, &stride, &offset);
- hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs); - ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); - memset(&cb_data, 0, sizeof(cb_data)); cb_data.tessellation_factor = 1.0f; vs_cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data); @@ -24958,7 +24962,7 @@ static void test_clip_distance(void)
/* vertex shader */ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code)); check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
check_clip_distance(&test_context, vb); @@ -25020,11 +25024,6 @@ static void test_clip_distance(void) ID3D11DeviceContext_DSSetShader(context, NULL, NULL, 0); ID3D11DeviceContext_GSSetShader(context, NULL, NULL, 0);
- ID3D11VertexShader_Release(test_context.vs); - hr = ID3D11Device_CreateVertexShader(device, vs_multiple_code, sizeof(vs_multiple_code), - NULL, &test_context.vs); - ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); - cb_data.use_constant = FALSE; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vs_cb, 0, NULL, &cb_data, 0, 0);
@@ -25032,7 +25031,7 @@ static void test_clip_distance(void) vertices[i].clip_distance0 = 1.0f; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code)); check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
for (i = 0; i < ARRAY_SIZE(vertices); ++i) @@ -25042,7 +25041,7 @@ static void test_clip_distance(void) } ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code)); get_texture_readback(test_context.backbuffer, 0, &rb); SetRect(&rect, 0, 0, 320, 240); check_readback_data_color(&rb, &rect, 0xff00ff00, 1); @@ -25057,7 +25056,7 @@ static void test_clip_distance(void) cb_data.clip_distance1 = 0.0f; ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vs_cb, 0, NULL, &cb_data, 0, 0); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_multiple_code, sizeof(vs_multiple_code)); check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
if (hs) @@ -25212,9 +25211,6 @@ static void test_combined_clip_and_cull_distances(void) offset = 0; ID3D11DeviceContext_IASetVertexBuffers(context, 1, 1, &vb, &stride, &offset);
- hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &test_context.vs); - ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); - ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); draw_color_quad(&test_context, &green); check_texture_color(test_context.backbuffer, 0xff00ff00, 1); @@ -25232,7 +25228,7 @@ static void test_combined_clip_and_cull_distances(void) ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code));
for (k = 0; k < ARRAY_SIZE(expected_color); ++k) expected_color[k] = test->triangle_visible[k] ? 0xff00ff00 : 0xffffffff; @@ -25263,7 +25259,7 @@ static void test_combined_clip_and_cull_distances(void) ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code)); check_texture_color(test_context.backbuffer, 0xffffffff, 1);
for (j = 0; j < ARRAY_SIZE(vertices); ++j) @@ -25273,7 +25269,7 @@ static void test_combined_clip_and_cull_distances(void) memset(vertices, 0, sizeof(vertices)); ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)vb, 0, NULL, vertices, 0, 0); ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white); - draw_color_quad(&test_context, &green); + draw_color_quad_vs(&test_context, &green, vs_code, sizeof(vs_code)); check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
ID3D11Buffer_Release(vb);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10core/tests/device.c | 139 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index d3e359e019e5..3fdac8cb0ecc 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -16568,6 +16568,144 @@ static void test_multiple_viewports(void) release_test_context(&test_context); }
+static void test_multisample_resolve(void) +{ + struct d3d10core_test_context test_context; + D3D10_RENDER_TARGET_VIEW_DESC rtv_desc; + ID3D10Texture2D *texture, *ms_texture; + D3D10_TEXTURE2D_DESC texture_desc; + ID3D10RenderTargetView *rtv; + ID3D10Device *device; + unsigned int i; + HRESULT hr; + + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f}; + static const struct vec4 color = {0.25f, 0.5f, 0.75f, 1.0f}; + static const struct + { + DXGI_FORMAT src_format; + DXGI_FORMAT dst_format; + DXGI_FORMAT format; + + DXGI_FORMAT rtv_format; + + const struct vec4 *color; + DWORD expected_color; + + BOOL todo; + } + tests[] = + { + {DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &green, 0xff00ff00}, + {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &green, 0xff00ff00}, + {DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &color, 0xffbf7f40}, + {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &color, 0xffe1bc89}, + + {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &green, 0xff00ff00, TRUE}, + {DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &green, 0xff00ff00, TRUE}, + {DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &color, 0xffe1bc89, TRUE}, + {DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, + &color, 0xffe1bc89, TRUE}, + + {DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &green, 0xff00ff00, TRUE}, + {DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &green, 0xff00ff00, TRUE}, + {DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &color, 0xffbf7f40, TRUE}, + {DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_TYPELESS, + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM, + &color, 0xffbf7f40, TRUE}, + }; + + if (!init_test_context(&test_context)) + return; + device = test_context.device; + + if (FAILED(hr = ID3D10Device_CheckMultisampleQualityLevels(device, + DXGI_FORMAT_R8G8B8A8_TYPELESS, 4, &i))) + { + skip("4xMSAA not supported.\n"); + release_test_context(&test_context); + return; + } + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.Format = tests[i].dst_format; + hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + + texture_desc.Format = tests[i].src_format; + texture_desc.SampleDesc.Count = 4; + texture_desc.SampleDesc.Quality = 0; + hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &ms_texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + rtv_desc.Format = tests[i].rtv_format; + rtv_desc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2DMS; + hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)ms_texture, &rtv_desc, &rtv); + ok(hr == S_OK, "Failed to create render target view, hr %#x.\n", hr); + + ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL); + ID3D10Device_ClearRenderTargetView(device, rtv, white); + draw_color_quad(&test_context, tests[i].color); + ID3D10Device_ResolveSubresource(device, (ID3D10Resource *)texture, 0, + (ID3D10Resource *)ms_texture, 0, tests[i].format); + todo_wine_if(tests[i].todo) + check_texture_color(texture, tests[i].expected_color, 2); + + ID3D10RenderTargetView_Release(rtv); + ID3D10Texture2D_Release(ms_texture); + ID3D10Texture2D_Release(texture); + } + + release_test_context(&test_context); +} + START_TEST(device) { unsigned int argc, i; @@ -16670,4 +16808,5 @@ START_TEST(device) test_generate_mips(); test_alpha_to_coverage(); test_multiple_viewports(); + test_multisample_resolve(); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com