We can return WINED3DOK_NOAUTOGEN only when all other resource usages are supported.
Fixes 25a8773d21d0 ("wined3d: Advertise AUTOGENMIPMAP only for renderable and filterable formats."). The problem was present before 25a8773d21d0, but the mentioned commit made it much worse. Previously, it was an issue only for OpenGL implementations which do not support the GL_SGIS_generate_mipmap extension.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c145944e11b9..1586bdc82147 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -5273,10 +5273,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad { const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx]; const struct wined3d_gl_info *gl_info = &adapter->gl_info; - const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id, - WINED3DUSAGE_RENDERTARGET); - const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage); + const struct wined3d_format *adapter_format, *format; enum wined3d_gl_resource_type gl_type, gl_type_end; + BOOL mipmap_autogen_supported; DWORD format_flags = 0; DWORD allowed_usage;
@@ -5289,6 +5288,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad if (adapter_idx >= wined3d->adapter_count) return WINED3DERR_INVALIDCALL;
+ adapter_format = wined3d_get_format(gl_info, adapter_format_id, WINED3DUSAGE_RENDERTARGET); + format = wined3d_get_format(gl_info, check_format_id, usage); + switch (resource_type) { case WINED3D_RTYPE_NONE: @@ -5387,14 +5389,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad return WINED3DERR_NOTAVAILABLE; }
- if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && (!gl_info->supported[SGIS_GENERATE_MIPMAP] - || (format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) - != (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))) - { - TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n"); - return WINED3DOK_NOAUTOGEN; - } - + mipmap_autogen_supported = gl_info->supported[SGIS_GENERATE_MIPMAP]; for (; gl_type <= gl_type_end; ++gl_type) { if ((format->flags[gl_type] & format_flags) != format_flags) @@ -5423,6 +5418,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad debug_d3dformat(check_format_id)); return WINED3DERR_NOTAVAILABLE; } + + if ((format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) + != (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) + { + mipmap_autogen_supported = FALSE; + } + } + + if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !mipmap_autogen_supported) + { + TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n"); + return WINED3DOK_NOAUTOGEN; }
return WINED3D_OK;
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d9/tests/device.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 866f435f8368..1a226ec9f1d8 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -11497,6 +11497,27 @@ static void test_swapchain_parameters(void)
static void test_check_device_format(void) { + static const D3DFORMAT adapter_formats[] = + { + D3DFMT_A8R8G8B8, + D3DFMT_X8R8G8B8, + }; + static const D3DFORMAT mipmap_autogen_formats[] = + { + D3DFMT_R8G8B8, + D3DFMT_A8R8G8B8, + D3DFMT_X8R8G8B8, + D3DFMT_R5G6B5, + D3DFMT_X1R5G5B5, + D3DFMT_A8P8, + D3DFMT_P8, + D3DFMT_A1R5G5B5, + D3DFMT_A4R4G4B4, + }; + + D3DFORMAT adapter_format, format; + BOOL render_target_supported; + unsigned int i, j; IDirect3D9 *d3d; HRESULT hr;
@@ -11538,6 +11559,32 @@ static void test_check_device_format(void) D3DUSAGE_SOFTWAREPROCESSING, D3DRTYPE_INDEXBUFFER, D3DFMT_INDEX16); todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ for (i = 0; i < ARRAY_SIZE(adapter_formats); ++i) + { + adapter_format = adapter_formats[i]; + + for (j = 0; j < ARRAY_SIZE(mipmap_autogen_formats); ++j) + { + format = mipmap_autogen_formats[j]; + + hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, adapter_format, + D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, format); + ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr); + render_target_supported = hr == D3D_OK; + + hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, adapter_format, + D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP, D3DRTYPE_TEXTURE, format); + if (render_target_supported) + { + ok(hr == D3D_OK || hr == D3DOK_NOAUTOGEN, "Got unexpected hr %#x.\n", hr); + } + else + { + ok(hr == D3DERR_NOTAVAILABLE, "Got unexpected hr %#x.\n", hr); + } + } + } + IDirect3D9_Release(d3d); }
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=34708
Your paranoid android.
=== w8 (32 bit device) === device.c:3965: Test failed: Failed to reset device, hr 0x88760868, i=1.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
The d3d11_device_CheckFormatSupport() function should filter the format support based on the device feature level.
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
I forget to submit this patch before the code freeze. Anyway, it's a non-invasive change.
For https://bugs.winehq.org/show_bug.cgi?id=40046
--- dlls/d3d10core/tests/device.c | 15 ++++++++------- dlls/d3d11/device.c | 6 ++++-- 2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 5221c0ea3a39..980d405ce810 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -11006,6 +11006,7 @@ static void check_format_support(const unsigned int *format_support, continue; }
+ todo_wine ok(supported, "Format %#x - %s supported, format support %#x.\n", format, feature_name, format_support[format]); } @@ -11015,6 +11016,7 @@ static void test_required_format_support(void) { unsigned int format_support[DXGI_FORMAT_B4G4R4A4_UNORM + 1]; ID3D10Device *device; + unsigned int support; DXGI_FORMAT format; ULONG refcount; HRESULT hr; @@ -11031,20 +11033,19 @@ static void test_required_format_support(void) return; }
+ support = 0xdeadbeef; + hr = ID3D10Device_CheckFormatSupport(device, ~0u, &support); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(!support, "Got unexpected format support %#x.\n", support); + memset(format_support, 0, sizeof(format_support)); for (format = DXGI_FORMAT_UNKNOWN; format <= DXGI_FORMAT_B4G4R4A4_UNORM; ++format) { hr = ID3D10Device_CheckFormatSupport(device, format, &format_support[format]); - todo_wine ok(hr == S_OK || (hr == E_FAIL && !format_support[format]), + ok(hr == S_OK || (hr == E_FAIL && !format_support[format]), "Got unexpected result for format %#x: hr %#x, format_support %#x.\n", format, hr, format_support[format]); } - if (hr == E_NOTIMPL) - { - skip("CheckFormatSupport not implemented.\n"); - ID3D10Device_Release(device); - return; - }
check_format_support(format_support, index_buffers, ARRAY_SIZE(index_buffers), D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER, "index buffer"); diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 820463c27599..b2a40b3c6d31 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -5417,10 +5417,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateCounter(ID3D10Device1 *iface static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 *iface, DXGI_FORMAT format, UINT *format_support) { - FIXME("iface %p, format %s, format_support %p stub!\n", + struct d3d_device *device = impl_from_ID3D10Device(iface); + + TRACE("iface %p, format %s, format_support %p.\n", iface, debug_dxgi_format(format), format_support);
- return E_NOTIMPL; + return d3d11_device_CheckFormatSupport(&device->ID3D11Device_iface, format, format_support); }
static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
Fixes a crash in Fallout 4.
--- dlls/wined3d/arb_program_shader.c | 1 + dlls/wined3d/glsl_shader.c | 1 + dlls/wined3d/shader.c | 1 + dlls/wined3d/shader_sm4.c | 2 ++ dlls/wined3d/wined3d_private.h | 1 + 5 files changed, 6 insertions(+)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 6941a2bb3c89..11141b6f6403 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5089,6 +5089,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DSY */ shader_hw_dsy, /* WINED3DSIH_DSY_COARSE */ NULL, /* WINED3DSIH_DSY_FINE */ NULL, + /* WINED3DSIH_EVAL_SAMPLE_INDEX */ NULL, /* WINED3DSIH_ELSE */ shader_hw_else, /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_EMIT_STREAM */ NULL, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 32a75bf56288..e18a99f066a0 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11080,6 +11080,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DSY */ shader_glsl_map2gl, /* WINED3DSIH_DSY_COARSE */ shader_glsl_map2gl, /* WINED3DSIH_DSY_FINE */ shader_glsl_map2gl, + /* WINED3DSIH_EVAL_SAMPLE_INDEX */ NULL, /* WINED3DSIH_ELSE */ shader_glsl_else, /* WINED3DSIH_EMIT */ shader_glsl_emit, /* WINED3DSIH_EMIT_STREAM */ shader_glsl_emit, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 04ced904481c..e59b9e5bfbe1 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -125,6 +125,7 @@ static const char * const shader_opcode_names[] = /* WINED3DSIH_DSY */ "dsy", /* WINED3DSIH_DSY_COARSE */ "deriv_rty_coarse", /* WINED3DSIH_DSY_FINE */ "deriv_rty_fine", + /* WINED3DSIH_EVAL_SAMPLE_INDEX */ "eval_sample_index", /* WINED3DSIH_ELSE */ "else", /* WINED3DSIH_EMIT */ "emit", /* WINED3DSIH_EMIT_STREAM */ "emit_stream", diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index 2665a67b80a6..7c3e8b8aa53c 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -297,6 +297,7 @@ enum wined3d_sm4_opcode WINED3D_SM5_OP_IMM_ATOMIC_UMAX = 0xbc, WINED3D_SM5_OP_IMM_ATOMIC_UMIN = 0xbd, WINED3D_SM5_OP_SYNC = 0xbe, + WINED3D_SM5_OP_EVAL_SAMPLE_INDEX = 0xcc, WINED3D_SM5_OP_DCL_GS_INSTANCES = 0xce, };
@@ -1107,6 +1108,7 @@ static const struct wined3d_sm4_opcode_info opcode_table[] = {WINED3D_SM5_OP_IMM_ATOMIC_UMIN, WINED3DSIH_IMM_ATOMIC_UMIN, "uU", "iu"}, {WINED3D_SM5_OP_SYNC, WINED3DSIH_SYNC, "", "", shader_sm5_read_sync}, + {WINED3D_SM5_OP_EVAL_SAMPLE_INDEX, WINED3DSIH_EVAL_SAMPLE_INDEX, "f", "fi"}, {WINED3D_SM5_OP_DCL_GS_INSTANCES, WINED3DSIH_DCL_GS_INSTANCES, "", "", shader_sm4_read_declaration_count}, }; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ab24f12a8a40..20f53aa9e961 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -761,6 +761,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER WINED3DSIH_DSY, WINED3DSIH_DSY_COARSE, WINED3DSIH_DSY_FINE, + WINED3DSIH_EVAL_SAMPLE_INDEX, WINED3DSIH_ELSE, WINED3DSIH_EMIT, WINED3DSIH_EMIT_STREAM,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10core/tests/device.c | 392 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 364 insertions(+), 28 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 980d405ce810..8eb11da47d5b 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -1116,12 +1116,13 @@ static void draw_quad_(unsigned int line, struct d3d10core_test_context *context default_vs_code, sizeof(default_vs_code), &context->input_layout); ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
- context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); - hr = ID3D10Device_CreateVertexShader(device, default_vs_code, sizeof(default_vs_code), &context->vs); ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); }
+ if (!context->vb) + context->vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); + ID3D10Device_IASetInputLayout(context->device, context->input_layout); ID3D10Device_IASetPrimitiveTopology(context->device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); stride = sizeof(*quad); @@ -8263,11 +8264,8 @@ done: static void test_cb_relative_addressing(void) { struct d3d10core_test_context test_context; - ID3D10Buffer *vb, *colors_cb, *index_cb; - ID3D10InputLayout *input_layout; + ID3D10Buffer *colors_cb, *index_cb; unsigned int i, index[4] = {0}; - unsigned int stride, offset; - ID3D10VertexShader *vs; ID3D10PixelShader *ps; ID3D10Device *device; DWORD color; @@ -8343,13 +8341,6 @@ float4 main(const ps_in v) : SV_TARGET 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e, }; - static const struct vec2 quad[] = - { - {-1.0f, -1.0f}, - {-1.0f, 1.0f}, - { 1.0f, -1.0f}, - { 1.0f, 1.0f}, - }; static const struct { float color[4]; @@ -8394,24 +8385,17 @@ float4 main(const ps_in v) : SV_TARGET device = test_context.device;
hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), - vs_code, sizeof(vs_code), &input_layout); + vs_code, sizeof(vs_code), &test_context.input_layout); ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
- vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad); colors_cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(colors), &colors); index_cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(index), NULL);
- hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs); + hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &test_context.vs); ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
- ID3D10Device_IASetInputLayout(device, input_layout); - ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - stride = sizeof(*quad); - offset = 0; - ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset); - ID3D10Device_VSSetShader(device, vs); ID3D10Device_VSSetConstantBuffers(device, 0, 1, &index_cb); ID3D10Device_VSSetConstantBuffers(device, 1, 1, &colors_cb); ID3D10Device_PSSetShader(device, ps); @@ -8423,8 +8407,7 @@ float4 main(const ps_in v) : SV_TARGET index[0] = test_data[i].index; ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)index_cb, 0, NULL, index, 0, 0);
- ID3D10Device_Draw(device, 4, 0); - + draw_quad(&test_context); color = get_texture_color(test_context.backbuffer, 319, 239); ok(compare_color(color, test_data[i].expected, 1), "Got unexpected color 0x%08x for index %d.\n", color, test_data[i].index); @@ -8432,11 +8415,7 @@ float4 main(const ps_in v) : SV_TARGET
ID3D10Buffer_Release(index_cb); ID3D10Buffer_Release(colors_cb); - ID3D10PixelShader_Release(ps); - ID3D10VertexShader_Release(vs); - ID3D10Buffer_Release(vb); - ID3D10InputLayout_Release(input_layout); release_test_context(&test_context); }
@@ -13157,6 +13136,362 @@ static void test_format_compatibility(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+static void check_clip_distance(struct d3d10core_test_context *test_context, ID3D10Buffer *vb) +{ + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + struct vertex + { + float clip_distance0; + float clip_distance1; + }; + + ID3D10Device *device = test_context->device; + struct resource_readback rb; + struct vertex vertices[4]; + unsigned int i; + RECT rect; + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = 1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context->backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + check_texture_color(test_context->backbuffer, 0xff00ff00, 1); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = 0.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context->backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + check_texture_color(test_context->backbuffer, 0xff00ff00, 1); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = -1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context->backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + check_texture_color(test_context->backbuffer, 0xffffffff, 1); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = i < 2 ? 1.0f : -1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context->backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + get_texture_readback(test_context->backbuffer, 0, &rb); + SetRect(&rect, 0, 0, 320, 480); + check_readback_data_color(&rb, &rect, 0xff00ff00, 1); + SetRect(&rect, 320, 0, 320, 480); + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = i % 2 ? 1.0f : -1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context->backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + get_texture_readback(test_context->backbuffer, 0, &rb); + SetRect(&rect, 0, 0, 640, 240); + check_readback_data_color(&rb, &rect, 0xff00ff00, 1); + SetRect(&rect, 0, 240, 640, 240); + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); +} + +static void test_clip_distance(void) +{ + struct d3d10core_test_context test_context; + struct resource_readback rb; + unsigned int offset, stride; + ID3D10Buffer *vs_cb, *gs_cb; + ID3D10GeometryShader *gs; + ID3D10Device *device; + ID3D10Buffer *vb; + unsigned int i; + HRESULT hr; + RECT rect; + + static const DWORD vs_code[] = + { +#if 0 + bool use_constant; + float clip_distance; + + struct input + { + float4 position : POSITION; + float distance0 : CLIP_DISTANCE0; + float distance1 : CLIP_DISTANCE1; + }; + + struct vertex + { + float4 position : SV_POSITION; + float user_clip : CLIP_DISTANCE; + float clip : SV_ClipDistance; + }; + + void main(input vin, out vertex vertex) + { + vertex.position = vin.position; + vertex.user_clip = vin.distance0; + vertex.clip = vin.distance0; + if (use_constant) + vertex.clip = clip_distance; + } +#endif + 0x43425844, 0x09dfef58, 0x88570f2e, 0x1ebcf953, 0x9f97e22a, 0x00000001, 0x000001dc, 0x00000003, + 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002, + 0x00000001, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f, + 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, + 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, + 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, + 0x52444853, 0x000000b4, 0x00010040, 0x0000002d, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, + 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x04000067, 0x001020f2, + 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002, + 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102012, + 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012, 0x00000002, 0x0020800a, 0x00000000, + 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a, 0x00000001, 0x0100003e, + }; + static const DWORD vs_multiple_code[] = + { +#if 0 + bool use_constant; + float clip_distance0; + float clip_distance1; + + struct input + { + float4 position : POSITION; + float distance0 : CLIP_DISTANCE0; + float distance1 : CLIP_DISTANCE1; + }; + + struct vertex + { + float4 position : SV_POSITION; + float user_clip : CLIP_DISTANCE; + float2 clip : SV_ClipDistance; + }; + + void main(input vin, out vertex vertex) + { + vertex.position = vin.position; + vertex.user_clip = vin.distance0; + vertex.clip.x = vin.distance0; + if (use_constant) + vertex.clip.x = clip_distance0; + vertex.clip.y = vin.distance1; + if (use_constant) + vertex.clip.y = clip_distance1; + } +#endif + 0x43425844, 0xef5cc236, 0xe2fbfa69, 0x560b6591, 0x23037999, 0x00000001, 0x00000214, 0x00000003, + 0x0000002c, 0x0000009c, 0x00000120, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000059, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000101, 0x00000059, 0x00000001, 0x00000000, 0x00000003, 0x00000002, + 0x00000101, 0x49534f50, 0x4e4f4954, 0x494c4300, 0x49445f50, 0x4e415453, 0xab004543, 0x4e47534f, + 0x0000007c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, + 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, + 0x00000000, 0x00000002, 0x00000003, 0x00000002, 0x00000c03, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, + 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, + 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101012, 0x00000001, 0x0300005f, 0x00101012, + 0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, + 0x04000067, 0x00102032, 0x00000002, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, + 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010100a, 0x00000001, 0x0b000037, 0x00102012, + 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0010100a, + 0x00000001, 0x0b000037, 0x00102022, 0x00000002, 0x0020800a, 0x00000000, 0x00000000, 0x0020802a, + 0x00000000, 0x00000000, 0x0010100a, 0x00000002, 0x0100003e, + }; + static const DWORD gs_code[] = + { +#if 0 + bool use_constant; + float clip_distance; + + struct vertex + { + float4 position : SV_POSITION; + float user_clip : CLIP_DISTANCE; + float clip : SV_ClipDistance; + }; + + [maxvertexcount(3)] + void main(triangle vertex input[3], inout TriangleStream<vertex> output) + { + vertex o; + o = input[0]; + o.clip = input[0].user_clip; + if (use_constant) + o.clip = clip_distance; + output.Append(o); + o = input[1]; + o.clip = input[1].user_clip; + if (use_constant) + o.clip = clip_distance; + output.Append(o); + o = input[2]; + o.clip = input[2].user_clip; + if (use_constant) + o.clip = clip_distance; + output.Append(o); + } +#endif + 0x43425844, 0x9b0823e9, 0xab3ed100, 0xba0ff618, 0x1bbd1cb8, 0x00000001, 0x00000338, 0x00000003, + 0x0000002c, 0x000000b0, 0x00000134, 0x4e475349, 0x0000007c, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000101, 0x0000006a, 0x00000000, 0x00000002, 0x00000003, 0x00000002, + 0x00000001, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154, 0x56530045, + 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x4e47534f, 0x0000007c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x0000006a, 0x00000000, 0x00000002, 0x00000003, + 0x00000002, 0x00000e01, 0x505f5653, 0x5449534f, 0x004e4f49, 0x50494c43, 0x5349445f, 0x434e4154, + 0x56530045, 0x696c435f, 0x73694470, 0x636e6174, 0xabab0065, 0x52444853, 0x000001fc, 0x00020040, + 0x0000007f, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x05000061, 0x002010f2, 0x00000003, + 0x00000000, 0x00000001, 0x0400005f, 0x00201012, 0x00000003, 0x00000001, 0x0400005f, 0x00201012, + 0x00000003, 0x00000002, 0x02000068, 0x00000001, 0x0100185d, 0x0100285c, 0x04000067, 0x001020f2, + 0x00000000, 0x00000001, 0x03000065, 0x00102012, 0x00000001, 0x04000067, 0x00102012, 0x00000002, + 0x00000002, 0x0200005e, 0x00000003, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, + 0x00000000, 0x06000036, 0x00102012, 0x00000001, 0x0020100a, 0x00000000, 0x00000001, 0x0c000037, + 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, + 0x0020100a, 0x00000000, 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000, + 0x01000013, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000001, 0x00000000, 0x06000036, + 0x00102012, 0x00000001, 0x0020100a, 0x00000001, 0x00000001, 0x0c000037, 0x00100012, 0x00000000, + 0x0020800a, 0x00000000, 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000001, + 0x00000001, 0x05000036, 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x06000036, + 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036, 0x00102012, 0x00000001, + 0x0020100a, 0x00000002, 0x00000001, 0x0c000037, 0x00100012, 0x00000000, 0x0020800a, 0x00000000, + 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0020100a, 0x00000002, 0x00000001, 0x05000036, + 0x00102012, 0x00000002, 0x0010000a, 0x00000000, 0x01000013, 0x0100003e, + }; + static const D3D10_INPUT_ELEMENT_DESC layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"CLIP_DISTANCE", 0, DXGI_FORMAT_R32_FLOAT, 1, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"CLIP_DISTANCE", 1, DXGI_FORMAT_R32_FLOAT, 1, 4, D3D10_INPUT_PER_VERTEX_DATA, 0}, + }; + struct + { + float clip_distance0; + float clip_distance1; + } + vertices[] = + { + {1.0f, 1.0f}, + {1.0f, 1.0f}, + {1.0f, 1.0f}, + {1.0f, 1.0f}, + }; + 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}; + struct + { + BOOL use_constant; + float clip_distance0; + float clip_distance1; + float tessellation_factor; + } cb_data; + + if (!init_test_context(&test_context)) + return; + device = test_context.device; + + hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), + vs_code, sizeof(vs_code), &test_context.input_layout); + ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + + vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(vertices), vertices); + stride = sizeof(*vertices); + offset = 0; + ID3D10Device_IASetVertexBuffers(device, 1, 1, &vb, &stride, &offset); + + hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &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, D3D10_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data); + ID3D10Device_VSSetConstantBuffers(device, 0, 1, &vs_cb); + gs_cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(cb_data), &cb_data); + ID3D10Device_GSSetConstantBuffers(device, 0, 1, &gs_cb); + + /* vertex shader */ + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + draw_color_quad(&test_context, &green); + check_texture_color(test_context.backbuffer, 0xff00ff00, 1); + + check_clip_distance(&test_context, vb); + + cb_data.use_constant = TRUE; + cb_data.clip_distance0 = -1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vs_cb, 0, NULL, &cb_data, 0, 0); + + /* geometry shader */ + hr = ID3D10Device_CreateGeometryShader(device, gs_code, sizeof(gs_code), &gs); + ok(SUCCEEDED(hr), "Failed to create geometry shader, hr %#x.\n", hr); + ID3D10Device_GSSetShader(device, gs); + + check_clip_distance(&test_context, vb); + + cb_data.use_constant = TRUE; + cb_data.clip_distance0 = 1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)gs_cb, 0, NULL, &cb_data, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + ID3D10Device_Draw(device, 4, 0); + check_texture_color(test_context.backbuffer, 0xff00ff00, 1); + + /* multiple clip distances */ + ID3D10Device_GSSetShader(device, NULL); + + ID3D10VertexShader_Release(test_context.vs); + hr = ID3D10Device_CreateVertexShader(device, vs_multiple_code, sizeof(vs_multiple_code), &test_context.vs); + ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); + + cb_data.use_constant = FALSE; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vs_cb, 0, NULL, &cb_data, 0, 0); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + vertices[i].clip_distance0 = 1.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + draw_color_quad(&test_context, &green); + check_texture_color(test_context.backbuffer, 0xff00ff00, 1); + + for (i = 0; i < ARRAY_SIZE(vertices); ++i) + { + vertices[i].clip_distance0 = i < 2 ? 1.0f : -1.0f; + vertices[i].clip_distance1 = i % 2 ? 1.0f : -1.0f; + } + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vb, 0, NULL, vertices, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + draw_color_quad(&test_context, &green); + get_texture_readback(test_context.backbuffer, 0, &rb); + SetRect(&rect, 0, 0, 320, 240); + check_readback_data_color(&rb, &rect, 0xff00ff00, 1); + SetRect(&rect, 0, 240, 320, 480); + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + SetRect(&rect, 320, 0, 640, 480); + check_readback_data_color(&rb, &rect, 0xffffffff, 1); + release_resource_readback(&rb); + + cb_data.use_constant = TRUE; + cb_data.clip_distance0 = 0.0f; + cb_data.clip_distance1 = 0.0f; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)vs_cb, 0, NULL, &cb_data, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + draw_color_quad(&test_context, &green); + check_texture_color(test_context.backbuffer, 0xff00ff00, 1); + + ID3D10GeometryShader_Release(gs); + ID3D10Buffer_Release(vb); + ID3D10Buffer_Release(vs_cb); + ID3D10Buffer_Release(gs_cb); + release_test_context(&test_context); +} + START_TEST(device) { test_feature_level(); @@ -13231,4 +13566,5 @@ START_TEST(device) test_stream_output(); test_stream_output_resume(); test_format_compatibility(); + test_clip_distance(); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10core/tests/device.c | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 8eb11da47d5b..6aaeb339658c 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -8419,6 +8419,124 @@ float4 main(const ps_in v) : SV_TARGET release_test_context(&test_context); }
+static void test_vs_input_relative_addressing(void) +{ + struct d3d10core_test_context test_context; + unsigned int offset, stride; + unsigned int index[4] = {0}; + ID3D10PixelShader *ps; + ID3D10Buffer *vb, *cb; + ID3D10Device *device; + unsigned int i; + HRESULT hr; + + static const DWORD vs_code[] = + { +#if 0 + struct vertex + { + float4 position : POSITION; + float4 colors[4] : COLOR; + }; + + uint index; + + void main(vertex vin, out float4 position : SV_Position, + out float4 color : COLOR) + { + position = vin.position; + color = vin.colors[index]; + } +#endif + 0x43425844, 0x8623dd89, 0xe37fecf5, 0xea3fdfe1, 0xdf36e4e4, 0x00000001, 0x000001f4, 0x00000003, + 0x0000002c, 0x000000c4, 0x00000118, 0x4e475349, 0x00000090, 0x00000005, 0x00000008, 0x00000080, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000089, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x00000089, 0x00000001, 0x00000000, 0x00000003, 0x00000002, + 0x00000f0f, 0x00000089, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000f0f, 0x00000089, + 0x00000003, 0x00000000, 0x00000003, 0x00000004, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, + 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x000000d4, + 0x00010040, 0x00000035, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300005f, 0x001010f2, + 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, 0x0300005f, + 0x001010f2, 0x00000003, 0x0300005f, 0x001010f2, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, + 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x02000068, 0x00000001, 0x0400005b, 0x001010f2, + 0x00000001, 0x00000004, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x06000036, + 0x00100012, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x07000036, 0x001020f2, 0x00000001, + 0x00d01e46, 0x00000001, 0x0010000a, 0x00000000, 0x0100003e, + }; + static const DWORD ps_code[] = + { +#if 0 + struct vs_out + { + float4 position : SV_POSITION; + float4 color : COLOR; + }; + + float4 main(struct vs_out i) : SV_TARGET + { + return i.color; + } +#endif + 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003, + 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, + 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e, + }; + static const D3D10_INPUT_ELEMENT_DESC layout_desc[] = + { + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1}, + {"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 4, D3D10_INPUT_PER_INSTANCE_DATA, 1}, + {"COLOR", 2, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 8, D3D10_INPUT_PER_INSTANCE_DATA, 1}, + {"COLOR", 3, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 12, D3D10_INPUT_PER_INSTANCE_DATA, 1}, + }; + static const unsigned int colors[] = {0xff0000ff, 0xff00ff00, 0xffff0000, 0xff0f0f0f}; + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + + if (!init_test_context(&test_context)) + return; + device = test_context.device; + + hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc), + vs_code, sizeof(vs_code), &test_context.input_layout); + ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr); + + cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(index), NULL); + ID3D10Device_VSSetConstantBuffers(device, 0, 1, &cb); + + vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(colors), colors); + stride = sizeof(colors); + offset = 0; + ID3D10Device_IASetVertexBuffers(device, 1, 1, &vb, &stride, &offset); + + hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &test_context.vs); + ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr); + + hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps); + ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); + ID3D10Device_PSSetShader(device, ps); + + for (i = 0; i < ARRAY_SIZE(colors); ++i) + { + *index = i; + ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0, NULL, index, 0, 0); + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + draw_quad(&test_context); + check_texture_color(test_context.backbuffer, colors[i], 1); + } + + ID3D10Buffer_Release(cb); + ID3D10Buffer_Release(vb); + ID3D10PixelShader_Release(ps); + release_test_context(&test_context); +} + static void test_swapchain_formats(void) { DXGI_SWAP_CHAIN_DESC swapchain_desc; @@ -13531,6 +13649,7 @@ START_TEST(device) test_copy_subresource_region(); test_check_multisample_quality_levels(); test_cb_relative_addressing(); + test_vs_input_relative_addressing(); test_swapchain_formats(); test_swapchain_views(); test_swapchain_flip();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10core/tests/device.c | 74 ++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 22 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 6aaeb339658c..7bbd7a7ecca8 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -9074,10 +9074,58 @@ static void test_clear_depth_stencil_view(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+static void test_initial_depth_stencil_state(void) +{ + static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f}; + static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f}; + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + struct d3d10core_test_context test_context; + D3D10_TEXTURE2D_DESC texture_desc; + ID3D10DepthStencilView *dsv; + ID3D10Texture2D *texture; + ID3D10Device *device; + unsigned int count; + D3D10_VIEWPORT vp; + HRESULT hr; + + if (!init_test_context(&test_context)) + return; + device = test_context.device; + + ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.Format = DXGI_FORMAT_D32_FLOAT; + texture_desc.BindFlags = D3D10_BIND_DEPTH_STENCIL; + hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + + hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)texture, NULL, &dsv); + ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr); + + ID3D10Device_OMSetRenderTargets(device, 1, &test_context.backbuffer_rtv, dsv); + + count = 1; + ID3D10Device_RSGetViewports(device, &count, &vp); + + /* check if depth function is D3D10_COMPARISON_LESS */ + ID3D10Device_ClearRenderTargetView(device, test_context.backbuffer_rtv, white); + ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 0.5f, 0); + vp.MinDepth = vp.MaxDepth = 0.4f; + ID3D10Device_RSSetViewports(device, 1, &vp); + draw_color_quad(&test_context, &green); + draw_color_quad(&test_context, &red); + vp.MinDepth = vp.MaxDepth = 0.6f; + ID3D10Device_RSSetViewports(device, 1, &vp); + draw_color_quad(&test_context, &red); + check_texture_color(test_context.backbuffer, 0xff00ff00, 1); + check_texture_float(texture, 0.4f, 1); + + ID3D10DepthStencilView_Release(dsv); + ID3D10Texture2D_Release(texture); + release_test_context(&test_context); +} + static void test_draw_depth_only(void) { - ID3D10DepthStencilState *depth_stencil_state; - D3D10_DEPTH_STENCIL_DESC depth_stencil_desc; struct d3d10core_test_context test_context; ID3D10PixelShader *ps_color, *ps_depth; D3D10_TEXTURE2D_DESC texture_desc; @@ -9132,32 +9180,15 @@ static void test_draw_depth_only(void)
cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(depth), NULL);
- texture_desc.Width = 640; - texture_desc.Height = 480; - texture_desc.MipLevels = 1; - texture_desc.ArraySize = 1; + ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc); texture_desc.Format = DXGI_FORMAT_D32_FLOAT; - texture_desc.SampleDesc.Count = 1; - texture_desc.SampleDesc.Quality = 0; - texture_desc.Usage = D3D10_USAGE_DEFAULT; texture_desc.BindFlags = D3D10_BIND_DEPTH_STENCIL; - texture_desc.CPUAccessFlags = 0; - texture_desc.MiscFlags = 0; - hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture); ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)texture, NULL, &dsv); ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
- depth_stencil_desc.DepthEnable = TRUE; - depth_stencil_desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL; - depth_stencil_desc.DepthFunc = D3D10_COMPARISON_LESS; - depth_stencil_desc.StencilEnable = FALSE; - - hr = ID3D10Device_CreateDepthStencilState(device, &depth_stencil_desc, &depth_stencil_state); - ok(SUCCEEDED(hr), "Failed to create depth stencil state, hr %#x.\n", hr); - hr = ID3D10Device_CreatePixelShader(device, ps_color_code, sizeof(ps_color_code), &ps_color); ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr); hr = ID3D10Device_CreatePixelShader(device, ps_depth_code, sizeof(ps_depth_code), &ps_depth); @@ -9166,7 +9197,6 @@ static void test_draw_depth_only(void) ID3D10Device_PSSetConstantBuffers(device, 0, 1, &cb); ID3D10Device_PSSetShader(device, ps_color); ID3D10Device_OMSetRenderTargets(device, 0, NULL, dsv); - ID3D10Device_OMSetDepthStencilState(device, depth_stencil_state, 0);
ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0); check_texture_float(texture, 1.0f, 1); @@ -9231,7 +9261,6 @@ static void test_draw_depth_only(void) ID3D10PixelShader_Release(ps_color); ID3D10PixelShader_Release(ps_depth); ID3D10DepthStencilView_Release(dsv); - ID3D10DepthStencilState_Release(depth_stencil_state); ID3D10Texture2D_Release(texture); release_test_context(&test_context); } @@ -13655,6 +13684,7 @@ START_TEST(device) test_swapchain_flip(); test_clear_render_target_view(); test_clear_depth_stencil_view(); + test_initial_depth_stencil_state(); test_draw_depth_only(); test_shader_stage_input_output_matching(); test_shader_interstage_interface();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
2017-12-11 10:25 GMT+01:00 Józef Kucia jkucia@codeweavers.com:
We can return WINED3DOK_NOAUTOGEN only when all other resource usages are supported.
Fixes 25a8773d21d0 ("wined3d: Advertise AUTOGENMIPMAP only for renderable and filterable formats."). The problem was present before 25a8773d21d0, but the mentioned commit made it much worse. Previously, it was an issue only for OpenGL implementations which do not support the GL_SGIS_generate_mipmap extension.
Signed-off-by: Józef Kucia jkucia@codeweavers.com
Thanks for the fix!
Signed-off-by: Matteo Bruni mbruni@codeweavers.com