The current workaround is broken for texture cube arrays, which already have 4 components.
Sampling with the components not packed together apparently succeeds with newer NVidia drivers, so just remove the workaround. Tested with 470.103.01 on a GTX 1060.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52886 Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v2: Improve the subject message.
libs/vkd3d-shader/spirv.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index bb5e8c6f4..d746a35ae 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -8336,10 +8336,10 @@ static void vkd3d_dxbc_compiler_emit_sample(struct vkd3d_dxbc_compiler *compiler static void vkd3d_dxbc_compiler_emit_sample_c(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { - uint32_t sampled_type_id, coordinate_id, dref_id, val_id, type_id; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_dst_param *dst = instruction->dst; const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t sampled_type_id, coordinate_id, dref_id, val_id; SpvImageOperandsMask operands_mask = 0; unsigned int image_operand_count = 0; struct vkd3d_shader_image image; @@ -8371,10 +8371,6 @@ static void vkd3d_dxbc_compiler_emit_sample_c(struct vkd3d_dxbc_compiler *compil sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, 1); coordinate_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_ALL); dref_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[3], VKD3DSP_WRITEMASK_0); - /* XXX: Nvidia is broken and expects that the D_ref is packed together with coordinates. */ - type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); - coordinate_id = vkd3d_spirv_build_op_composite_insert1(builder, - type_id, dref_id, coordinate_id, image.resource_type_info->coordinate_component_count); val_id = vkd3d_spirv_build_op_image_sample_dref(builder, op, sampled_type_id, image.sampled_image_id, coordinate_id, dref_id, operands_mask, image_operands, image_operand_count);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- tests/d3d12.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 7 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index c992c6dec..015c31225 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -14588,7 +14588,82 @@ static void test_sample_c_lz(void) 0x00000000, 0x0100003e, }; static const D3D12_SHADER_BYTECODE ps_cube = {ps_cube_code, sizeof(ps_cube_code)}; - static const float depth_values[] = {1.0f, 0.0f, 0.5f, 0.6f, 0.4f, 0.1f}; + static const DWORD ps_cube_array_code[] = + { +#if 0 + TextureCubeArray t; + SamplerComparisonState s; + + float ref; + float layer; + + float4 main(float4 position : SV_Position) : SV_Target + { + float2 p; + p.x = position.x / 640.0f; + p.y = position.y / 480.0f; + + float3 coord; + switch ((uint)layer % 6) + { + case 0: + coord = float3(1.0f, p.x, p.y); + break; + case 1: + coord = float3(-1.0f, p.x, p.y); + break; + case 2: + coord = float3(p.x, 1.0f, p.y); + break; + case 3: + coord = float3(p.x, -1.0f, p.y); + break; + case 4: + coord = float3(p.x, p.y, 1.0f); + break; + case 5: + default: + coord = float3(p.x, p.y, -1.0f); + break; + } + + return t.SampleCmpLevelZero(s, float4(coord, (uint)layer / 6), ref); + } +#endif + 0x43425844, 0xafbb850b, 0x724ab414, 0x56cdc3a8, 0x6b9fd1af, 0x00000001, 0x00000360, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000002c4, 0x00000041, + 0x000000b1, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000, + 0x00000000, 0x04005058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, + 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0600001c, 0x00100012, + 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0900004e, 0x00100012, 0x00000000, 0x00100012, + 0x00000001, 0x0010000a, 0x00000000, 0x00004001, 0x00000006, 0x0300004c, 0x0010000a, 0x00000001, + 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000001, 0x00004001, 0x3f800000, + 0x0a000038, 0x00100062, 0x00000001, 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, + 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036, 0x00100012, + 0x00000001, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000001, 0x00101106, 0x00000000, + 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, + 0x00000002, 0x0a000038, 0x00100052, 0x00000001, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, + 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000001, 0x00004001, 0x3f800000, + 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000001, 0x00101106, + 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, + 0x00000001, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004, 0x0a000038, + 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, + 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x01000002, 0x0100000a, + 0x0a000038, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, + 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0xbf800000, 0x01000002, + 0x01000017, 0x05000056, 0x00100082, 0x00000001, 0x0010000a, 0x00000000, 0x0c000047, 0x00100012, + 0x00000000, 0x00100e46, 0x00000001, 0x00107006, 0x00000000, 0x00106000, 0x00000000, 0x0020800a, + 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps_cube_array = {ps_cube_array_code, sizeof(ps_cube_array_code)}; + static const float depth_values[] = + { + 1.0f, 0.0f, 0.5f, 0.6f, 0.4f, 0.1f, + 0.2f, 0.9f, 0.0f, 1.0f, 0.8f, 0.3f, + }; static const struct { unsigned int layer; @@ -14597,12 +14672,18 @@ static void test_sample_c_lz(void) } tests[] = { - {0, 0.5f, 0.0f}, - {1, 0.5f, 1.0f}, - {2, 0.5f, 0.0f}, - {3, 0.5f, 0.0f}, - {4, 0.5f, 1.0f}, - {5, 0.5f, 1.0f}, + { 0, 0.5f, 0.0f}, + { 1, 0.5f, 1.0f}, + { 2, 0.5f, 0.0f}, + { 3, 0.5f, 0.0f}, + { 4, 0.5f, 1.0f}, + { 5, 0.5f, 1.0f}, + { 6, 0.5f, 1.0f}, + { 7, 0.5f, 0.0f}, + { 8, 0.5f, 1.0f}, + { 9, 0.5f, 0.0f}, + {10, 0.5f, 0.0f}, + {11, 0.5f, 1.0f},
{0, 0.0f, 0.0f}, {1, 0.0f, 0.0f}, @@ -14737,6 +14818,60 @@ static void test_sample_c_lz(void) srv_desc.TextureCube.MipLevels = 2; ID3D12Device_CreateShaderResourceView(context.device, ds.texture, &srv_desc, cpu_handle);
+ for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + if (tests[i].layer >= 6) + continue; + + vkd3d_test_set_context("test %u", i); + + ps_constant.x = tests[i].d_ref; + ps_constant.y = tests[i].layer; + + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, clear_color, 0, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap); + ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, + get_gpu_descriptor_handle(&context, heap, 0)); + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 4, &ps_constant.x, 0); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + /* Avoid testing values affected by seamless cube map filtering. */ + set_rect(&rect, 100, 100, 540, 380); + check_readback_data_float(&rb, &rect, tests[i].expected, 2); + release_resource_readback(&rb); + + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); + } + vkd3d_test_set_context(NULL); + + ID3D12PipelineState_Release(context.pipeline_state); + + /* cube array texture */ + context.pipeline_state = create_pipeline_state(context.device, + context.root_signature, context.render_target_desc.Format, NULL, &ps_cube_array, NULL); + + memset(&srv_desc, 0, sizeof(srv_desc)); + srv_desc.Format = DXGI_FORMAT_R32_FLOAT; + srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; + srv_desc.TextureCubeArray.MostDetailedMip = 0; + srv_desc.TextureCubeArray.MipLevels = 2; + srv_desc.TextureCubeArray.First2DArrayFace = 0; + srv_desc.TextureCubeArray.NumCubes = ARRAY_SIZE(depth_values) / 6; + ID3D12Device_CreateShaderResourceView(context.device, ds.texture, &srv_desc, cpu_handle); + for (i = 0; i < ARRAY_SIZE(tests); ++i) { vkd3d_test_set_context("test %u", i);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com