Skip to content

Commit e98eb3a

Browse files
Fixed image format mismatch Vulkan warnings in archve and RT tests
1 parent 31f7d05 commit e98eb3a

File tree

2 files changed

+49
-16
lines changed

2 files changed

+49
-16
lines changed

Tests/DiligentCoreAPITest/include/InlineShaders/RayTracingTestHLSL.h

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,8 +44,12 @@ struct RTPayload
4444
// clang-format off
4545
const std::string RayTracingTest1_RG = RayTracingTest_Payload +
4646
R"hlsl(
47-
RaytracingAccelerationStructure g_TLAS : register(t0);
48-
RWTexture2D<float4> g_ColorBuffer : register(u0);
47+
RaytracingAccelerationStructure g_TLAS : register(t0);
48+
49+
#ifdef VULKAN
50+
[[vk::image_format("rgba8")]]
51+
#endif
52+
RWTexture2D<float4> g_ColorBuffer : register(u0);
4953
5054
[shader("raygeneration")]
5155
void main()
@@ -94,8 +98,12 @@ void main(inout RTPayload payload, in BuiltInTriangleIntersectionAttributes attr
9498

9599
const std::string RayTracingTest2_RG = RayTracingTest_Payload +
96100
R"hlsl(
97-
RaytracingAccelerationStructure g_TLAS : register(t0);
98-
RWTexture2D<float4> g_ColorBuffer : register(u0);
101+
RaytracingAccelerationStructure g_TLAS : register(t0);
102+
103+
#ifdef VULKAN
104+
[[vk::image_format("rgba8")]]
105+
#endif
106+
RWTexture2D<float4> g_ColorBuffer : register(u0);
99107
100108
[shader("raygeneration")]
101109
void main()
@@ -156,8 +164,12 @@ void main(inout RTPayload payload, in BuiltInTriangleIntersectionAttributes attr
156164

157165
const std::string RayTracingTest3_RG = RayTracingTest_Payload +
158166
R"hlsl(
159-
RaytracingAccelerationStructure g_TLAS : register(t0);
160-
RWTexture2D<float4> g_ColorBuffer : register(u0);
167+
RaytracingAccelerationStructure g_TLAS : register(t0);
168+
169+
#ifdef VULKAN
170+
[[vk::image_format("rgba8")]]
171+
#endif
172+
RWTexture2D<float4> g_ColorBuffer : register(u0);
161173
162174
[shader("raygeneration")]
163175
void main()
@@ -239,8 +251,12 @@ void main()
239251

240252
const std::string RayTracingTest4_RG = RayTracingTest_Payload +
241253
R"hlsl(
242-
RaytracingAccelerationStructure g_TLAS : register(t0);
243-
RWTexture2D<float4> g_ColorBuffer : register(u0);
254+
RaytracingAccelerationStructure g_TLAS : register(t0);
255+
256+
#ifdef VULKAN
257+
[[vk::image_format("rgba8")]]
258+
#endif
259+
RWTexture2D<float4> g_ColorBuffer : register(u0);
244260
245261
[shader("raygeneration")]
246262
void main()
@@ -336,7 +352,11 @@ void main(inout RTPayload payload, in BuiltInTriangleIntersectionAttributes attr
336352
const std::string RayTracingTest5_RG = RayTracingTest_Payload +
337353
R"hlsl(
338354
RaytracingAccelerationStructure g_TLAS;
339-
RWTexture2D<float4> g_ColorBuffer;
355+
356+
#ifdef VULKAN
357+
[[vk::image_format("rgba8")]]
358+
#endif
359+
RWTexture2D<float4> g_ColorBuffer;
340360
341361
[shader("raygeneration")]
342362
void main()
@@ -421,7 +441,11 @@ void main(inout RTPayload payload, in BuiltInTriangleIntersectionAttributes attr
421441

422442
const std::string RayTracingTest6_RG{R"hlsl(
423443
RaytracingAccelerationStructure g_TLAS;
424-
RWTexture2D<float4> g_ColorBuffer;
444+
445+
#ifdef VULKAN
446+
[[vk::image_format("rgba8")]]
447+
#endif
448+
RWTexture2D<float4> g_ColorBuffer;
425449
426450
float4 HitShader(float2 attrBarycentrics)
427451
{
@@ -538,7 +562,11 @@ float4 main(in PSInput PSIn) : SV_Target
538562

539563
const std::string RayTracingTest8_CS{R"hlsl(
540564
RaytracingAccelerationStructure g_TLAS;
541-
RWTexture2D<float4> g_ColorBuffer;
565+
566+
#ifdef VULKAN
567+
[[vk::image_format("rgba8")]]
568+
#endif
569+
RWTexture2D<float4> g_ColorBuffer;
542570
543571
float4 HitShader(float2 attrBarycentrics)
544572
{

Tests/DiligentCoreAPITest/src/ArchiveTest.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,9 @@ namespace HLSL
12981298
// Test shader source as string
12991299
const std::string ComputePSOTest_CS{R"(
13001300
1301+
#if defined(VULKAN) && defined(DXCOMPILER)
1302+
[[vk::image_format("rgba8")]]
1303+
#endif
13011304
RWTexture2D</*format=rgba8*/ float4> g_tex2DUAV : register(u0);
13021305
13031306
[numthreads(16, 16, 1)]
@@ -1332,6 +1335,8 @@ void CreateComputeShader(IRenderDevice* pDevice,
13321335
// Test shader source string
13331336
ShaderCI.Source = HLSL::ComputePSOTest_CS.c_str();
13341337

1338+
ShaderCI.CompileFlags |= SHADER_COMPILE_FLAG_HLSL_TO_SPIRV_VIA_GLSL;
1339+
13351340
if (ppCS != nullptr)
13361341
pDevice->CreateShader(ShaderCI, ppCS);
13371342

@@ -1714,10 +1719,6 @@ void TestRayTracingPipeline(bool CompileAsync = false)
17141719
ASSERT_NE(pUnpackedPSO, nullptr);
17151720
}
17161721

1717-
RefCntAutoPtr<IShaderResourceBinding> pRayTracingSRB;
1718-
pRefPSO->CreateShaderResourceBinding(&pRayTracingSRB, true);
1719-
ASSERT_NE(pRayTracingSRB, nullptr);
1720-
17211722
// Create BLAS & TLAS
17221723
RefCntAutoPtr<IBottomLevelAS> pBLAS;
17231724
RefCntAutoPtr<ITopLevelAS> pTLAS;
@@ -1866,6 +1867,10 @@ void TestRayTracingPipeline(bool CompileAsync = false)
18661867
ASSERT_EQ(pUnpackedPSO->GetStatus(CompileAsync), PIPELINE_STATE_STATUS_READY);
18671868
ASSERT_EQ(pRefPSO->GetStatus(CompileAsync), PIPELINE_STATE_STATUS_READY);
18681869

1870+
RefCntAutoPtr<IShaderResourceBinding> pRayTracingSRB;
1871+
pRefPSO->CreateShaderResourceBinding(&pRayTracingSRB, true);
1872+
ASSERT_NE(pRayTracingSRB, nullptr);
1873+
18691874
RefCntAutoPtr<IShaderBindingTable> pRefPSO_SBT;
18701875
CreateSBT(pRefPSO_SBT, pRefPSO);
18711876

0 commit comments

Comments
 (0)