git.s-ol.nu ~forks/DiligentCore / 449edf8
Fixed test failures in d3d12_sw mode due to bugs in WARP assiduous 4 months ago
3 changed file(s) with 29 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
150150 uint RWStructBuffIdx = index % NUM_RWSTRUCT_BUFFERS;
151151 uint RWFmtBuffIdx = index % NUM_RWFMT_BUFFERS;
152152
153 #ifdef USE_D3D12_WARP_BUG_WORKAROUND
154 ConstBuffIdx = 0;
155 #endif
156
153157 float4 AllCorrect = float4(1.0, 1.0, 1.0, 1.0);
154158 AllCorrect *= CheckValue(g_Textures[TEXTURES_NONUNIFORM(TexIdx)].SampleLevel(g_Samplers[NonUniformResourceIndex(SamIdx)], coord, 0.0), TexRefValues[TexIdx]);
155159 AllCorrect *= CheckValue(g_ConstantBuffers[CONST_BUFFERS_NONUNIFORM(ConstBuffIdx)].Data, ConstBuffRefValues[ConstBuffIdx]);
21532153 ShaderCreateInfo ShaderCI;
21542154 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
21552155 ShaderCI.UseCombinedTextureSamplers = true;
2156 if (UseArray && pEnv->NeedWARPResourceArrayIndexingBugWorkaround())
2157 {
2158 // As of Windows version 2004 (build 19041), there is a bug in D3D12 WARP rasterizer:
2159 // Shader resource array indexing always references array element 0 when shaders are compiled
2160 // with shader model 5.1.
2161 // Use SM5.0 with old compiler as a workaround.
2162 ShaderCI.ShaderCompiler = SHADER_COMPILER_DEFAULT;
2163 ShaderCI.HLSLVersion = ShaderVersion{5, 0};
2164 }
2156
2157 auto SelectShaderCompiler = [UseArray, pEnv](ShaderCreateInfo& ShaderCI) //
2158 {
2159 if (UseArray && pEnv->NeedWARPResourceArrayIndexingBugWorkaround())
2160 {
2161 // As of Windows version 2004 (build 19041), there is a bug in D3D12 WARP rasterizer:
2162 // Shader resource array indexing always references array element 0 when shaders are compiled
2163 // with shader model 5.1.
2164 // Use SM5.0 with old compiler as a workaround.
2165 ShaderCI.ShaderCompiler = SHADER_COMPILER_DEFAULT;
2166 ShaderCI.HLSLVersion = ShaderVersion{5, 0};
2167 }
2168 else
2169 {
2170 ShaderCI.ShaderCompiler = pEnv->GetDefaultCompiler(ShaderCI.SourceLanguage);
2171 }
2172 };
21652173
21662174 RefCntAutoPtr<IShader> pVS;
21672175 {
21912199 {
21922200 ShaderCI.Source = UseArray ? HLSL::DrawTest_VSFormattedBufferArray.c_str() : HLSL::DrawTest_VSFormattedBuffers.c_str();
21932201 }
2194 ShaderCI.ShaderCompiler = pEnv->GetDefaultCompiler(ShaderCI.SourceLanguage);
2202 SelectShaderCompiler(ShaderCI);
21952203 pDevice->CreateShader(ShaderCI, &pVS);
21962204 ASSERT_NE(pVS, nullptr);
21972205 }
21992207 RefCntAutoPtr<IShader> pPS;
22002208 {
22012209 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
2202 ShaderCI.ShaderCompiler = pEnv->GetDefaultCompiler(ShaderCI.SourceLanguage);
22032210 ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL;
22042211 ShaderCI.EntryPoint = "main";
22052212 ShaderCI.Desc.Name = "Draw command test structured buffers - PS";
22062213 ShaderCI.Source = HLSL::DrawTest_PS.c_str();
2214 SelectShaderCompiler(ShaderCI);
22072215 pDevice->CreateShader(ShaderCI, &pPS);
22082216 ASSERT_NE(pPS, nullptr);
22092217 }
17101710 Macros.AddShaderMacro("RWSTRUCT_BUFFERS_NONUNIFORM_INDEXING", UAVBufferNonUniformIndexing ? 1 : 0);
17111711 Macros.AddShaderMacro("RWFMT_BUFFERS_NONUNIFORM_INDEXING", UAVBufferNonUniformIndexing ? 1 : 0);
17121712
1713 if (pEnv->NeedWARPResourceArrayIndexingBugWorkaround())
1714 {
1715 // Constant buffer indexing does not work properly in D3D12 WARP - only the 0th element is accessed correctly
1716 Macros.AddShaderMacro("USE_D3D12_WARP_BUG_WORKAROUND", 1);
1717 }
1718
17131719 if (IsGLSL)
17141720 Macros.AddShaderMacro("float4", "vec4");
17151721 for (Uint32 i = 0; i < TexArraySize; ++i)