Skip to content

Commit c495fd2

Browse files
authored
Add DXC tests to SPIRVShaderResourcesTest (#736)
1 parent 5434a10 commit c495fd2

File tree

5 files changed

+221
-46
lines changed

5 files changed

+221
-46
lines changed

Tests/DiligentCoreTest/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ if(WEBGPU_SUPPORTED)
6464
target_link_libraries(DiligentCoreTest PRIVATE libtint)
6565
endif()
6666

67+
if (PLATFORM_WIN32)
68+
copy_shader_compiler_dlls(DiligentCoreTest DXCOMPILER_FOR_SPIRV YES)
69+
endif()
70+
6771
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE} ${SHADERS}})
6872

6973
set_target_properties(DiligentCoreTest

Tests/DiligentCoreTest/assets/shaders/SPIRV/MixedResources.psh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@ RWTexture2D<float4> StorageTex : register(u1);
2727
// Sampler
2828
SamplerState Sampler : register(s0);
2929

30-
// Test for push constants
30+
// Test struct for push constants
3131
struct PushConstants_t
3232
{
3333
float2 Offset;
3434
float Time;
3535
uint FrameCount;
3636
};
3737

38-
[[vk::push_constant]]
39-
cbuffer PushConstants
40-
{
41-
PushConstants_t g_PushConstants;
42-
};
38+
//note that cbuffer PushConstants is not allowed in DXC, but ConstantBuffer<PushConstants_t> is allowed
39+
[[vk::push_constant]] ConstantBuffer<PushConstants_t> PushConstants;
4340

4441
float4 main() : SV_Target
4542
{
@@ -59,8 +56,8 @@ float4 main() : SV_Target
5956
StorageTex[uint2(0, 0)] = color;
6057

6158
// Use push constant data
62-
color.xy += g_PushConstants.Offset;
63-
color.rgb *= sin(g_PushConstants.Time) * 0.5 + 0.5;
59+
color.xy += PushConstants.Offset;
60+
color.rgb *= sin(PushConstants.Time) * 0.5 + 0.5;
6461

6562
return color;
6663
}
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Test for push constants
1+
// Test struct for push constants
22
struct PushConstants_t
33
{
44
float4x4 g_MVPMatrix;
@@ -8,19 +8,16 @@ struct PushConstants_t
88
uint g_Padding;
99
};
1010

11-
[[vk::push_constant]]
12-
cbuffer PushConstants
13-
{
14-
PushConstants_t g_PushConstants;
15-
};
11+
//note that cbuffer PushConstants is not allowed in DXC, but ConstantBuffer<PushConstants_t> is allowed
12+
[[vk::push_constant]] ConstantBuffer<PushConstants_t> PushConstants;
1613

1714
float4 main() : SV_Target
1815
{
1916
// Use push constant data through the structure instance
20-
float4 result = g_PushConstants.g_Color * g_PushConstants.g_Scale;
17+
float4 result = PushConstants.g_Color * PushConstants.g_Scale;
2118

2219
// Apply offset to result (simplified example)
23-
result.xy += g_PushConstants.g_Offset;
20+
result.xy += PushConstants.g_Offset;
2421

2522
return result;
2623
}

Tests/DiligentCoreTest/assets/shaders/SPIRV/UniformBuffers.psh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// Test for uniform buffers (constant buffers)
2-
cbuffer CB0 : register(b0)
3-
{
4-
float4x4 g_WorldViewProj;
5-
};
62

73
cbuffer CB1 : register(b1)
84
{

0 commit comments

Comments
 (0)