git.s-ol.nu ~forks/DiligentCore / 36d040c
Fixed ShaderResourceLayoutTest for non-separable programs assiduous 6 months ago
1 changed file(s) with 73 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
368368 ASSERT_NE(pPS, nullptr);
369369
370370
371 std::vector<ShaderResourceVariableDesc> Vars;
372
373 auto AddVar = [&](const char* Name, SHADER_RESOURCE_VARIABLE_TYPE VarType) //
374 {
375 if (deviceCaps.Features.SeparablePrograms)
376 {
377 // Use separate variables for each stage
378 Vars.emplace_back(SHADER_TYPE_VERTEX, Name, VarType);
379 Vars.emplace_back(SHADER_TYPE_PIXEL, Name, VarType);
380 }
381 else
382 {
383 // Use one shared variable
384 Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, Name, VarType);
385 }
386 };
371387 // clang-format off
372 ShaderResourceVariableDesc Vars[] =
373 {
374 {SHADER_TYPE_VERTEX, "g_Tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
375 {SHADER_TYPE_PIXEL, "g_Tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
376 {SHADER_TYPE_VERTEX, "g_Tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
377 {SHADER_TYPE_PIXEL, "g_Tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
378 {SHADER_TYPE_VERTEX, "g_Tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
379 {SHADER_TYPE_PIXEL, "g_Tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
380
381 {SHADER_TYPE_VERTEX, "g_Tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
382 {SHADER_TYPE_PIXEL, "g_Tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
383 {SHADER_TYPE_VERTEX, "g_Tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
384 {SHADER_TYPE_PIXEL, "g_Tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
385 {SHADER_TYPE_VERTEX, "g_Tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
386 {SHADER_TYPE_PIXEL, "g_Tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}
387 };
388 AddVar("g_Tex2D_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
389 AddVar("g_Tex2D_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
390 AddVar("g_Tex2D_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
391
392 AddVar("g_Tex2DArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
393 AddVar("g_Tex2DArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
394 AddVar("g_Tex2DArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
395
388396 std::vector<ImmutableSamplerDesc> ImtblSamplers;
389397 if (TestImtblSamplers)
390398 {
402410 // clang-format on
403411
404412 PipelineResourceLayoutDesc ResourceLayout;
405 ResourceLayout.Variables = Vars;
406 ResourceLayout.NumVariables = _countof(Vars);
413 ResourceLayout.Variables = Vars.data();
414 ResourceLayout.NumVariables = static_cast<Uint32>(Vars.size());
407415 ResourceLayout.ImmutableSamplers = ImtblSamplers.data();
408416 ResourceLayout.NumImmutableSamplers = static_cast<Uint32>(ImtblSamplers.size());
409417
606614 ASSERT_NE(pPS, nullptr);
607615
608616
617 std::vector<ShaderResourceVariableDesc> Vars;
618
619 auto AddVar = [&](const char* Name, SHADER_RESOURCE_VARIABLE_TYPE VarType) //
620 {
621 if (deviceCaps.Features.SeparablePrograms)
622 {
623 // Use separate variables for each stage
624 Vars.emplace_back(SHADER_TYPE_VERTEX, Name, VarType);
625 Vars.emplace_back(SHADER_TYPE_PIXEL, Name, VarType);
626 }
627 else
628 {
629 // Use one shared variable
630 Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, Name, VarType);
631 }
632 };
609633 // clang-format off
610 ShaderResourceVariableDesc Vars[] =
611 {
612 {SHADER_TYPE_VERTEX, "g_Buff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
613 {SHADER_TYPE_PIXEL, "g_Buff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
614 {SHADER_TYPE_VERTEX, "g_Buff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
615 {SHADER_TYPE_PIXEL, "g_Buff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
616 {SHADER_TYPE_VERTEX, "g_Buff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
617 {SHADER_TYPE_PIXEL, "g_Buff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
618
619 {SHADER_TYPE_VERTEX, "g_BuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
620 {SHADER_TYPE_PIXEL, "g_BuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
621 {SHADER_TYPE_VERTEX, "g_BuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
622 {SHADER_TYPE_PIXEL, "g_BuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
623 {SHADER_TYPE_VERTEX, "g_BuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
624 {SHADER_TYPE_PIXEL, "g_BuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}
625 };
634 AddVar("g_Buff_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
635 AddVar("g_Buff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
636 AddVar("g_Buff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
637
638 AddVar("g_BuffArr_Static", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
639 AddVar("g_BuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
640 AddVar("g_BuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
626641 // clang-format on
627642
628643 PipelineResourceLayoutDesc ResourceLayout;
629 ResourceLayout.Variables = Vars;
630 ResourceLayout.NumVariables = _countof(Vars);
644 ResourceLayout.Variables = Vars.data();
645 ResourceLayout.NumVariables = static_cast<Uint32>(Vars.size());
631646
632647 RefCntAutoPtr<IPipelineState> pPSO;
633648 RefCntAutoPtr<IShaderResourceBinding> pSRB;
11381153 ASSERT_NE(pVS, nullptr);
11391154 ASSERT_NE(pPS, nullptr);
11401155
1156 std::vector<ShaderResourceVariableDesc> Vars;
1157
1158 auto AddVar = [&](const char* Name, SHADER_RESOURCE_VARIABLE_TYPE VarType) //
1159 {
1160 if (deviceCaps.Features.SeparablePrograms)
1161 {
1162 // Use separate variables for each stage
1163 Vars.emplace_back(SHADER_TYPE_VERTEX, Name, VarType);
1164 Vars.emplace_back(SHADER_TYPE_PIXEL, Name, VarType);
1165 }
1166 else
1167 {
1168 // Use one shared variable
1169 Vars.emplace_back(SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, Name, VarType);
1170 }
1171 };
11411172
11421173 // clang-format off
1143 std::vector<ShaderResourceVariableDesc> Vars =
1144 {
1145 {SHADER_TYPE_VERTEX, "UniformBuff_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
1146 {SHADER_TYPE_PIXEL, "UniformBuff_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC},
1147 {SHADER_TYPE_VERTEX, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
1148 {SHADER_TYPE_PIXEL, "UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE},
1149 {SHADER_TYPE_VERTEX, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC},
1150 {SHADER_TYPE_PIXEL, "UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}
1151 };
1174 AddVar("UniformBuff_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
1175 AddVar("UniformBuff_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
1176 AddVar("UniformBuff_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
11521177
11531178 if (CBArraysSupported)
11541179 {
1155 Vars.emplace_back(SHADER_TYPE_VERTEX, "UniformBuffArr_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
1156 Vars.emplace_back(SHADER_TYPE_PIXEL, "UniformBuffArr_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
1157 Vars.emplace_back(SHADER_TYPE_VERTEX, "UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
1158 Vars.emplace_back(SHADER_TYPE_PIXEL, "UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
1159 Vars.emplace_back(SHADER_TYPE_VERTEX, "UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
1160 Vars.emplace_back(SHADER_TYPE_PIXEL, "UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
1180 AddVar("UniformBuffArr_Stat", SHADER_RESOURCE_VARIABLE_TYPE_STATIC);
1181 AddVar("UniformBuffArr_Mut", SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE);
1182 AddVar("UniformBuffArr_Dyn", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC);
11611183 };
11621184 // clang-format on
11631185