Skip to content

Commit 0c6f293

Browse files
azhirnovTheMostDiligent
authored andcommitted
DXC: don't optimize shader in debug mode
(possible fix for #244)
1 parent 93f1101 commit 0c6f293

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

Graphics/ShaderTools/src/DXCompiler.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,12 @@ void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI,
749749
{
750750
L"-spirv",
751751
L"-fspv-reflect",
752-
//L"-WX", // Warnings as errors
753-
L"-O3", // Optimization level 3
754-
L"-Zpc" // Matrices in column-major order
752+
L"-Zpc", // Matrices in column-major order
753+
#ifdef DILIGENT_DEBUG
754+
L"-Od",
755+
#else
756+
L"-O3"
757+
#endif
755758
});
756759

757760
if (m_APIVersion >= VK_API_VERSION_1_2 && ShaderModel >= ShaderVersion{6, 3})

Tests/DiligentCoreAPITest/assets/shaders/PipelineResourceSignature/GraphicsAndMeshShader.hlsl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
cbuffer Constants
1+
struct VSOutput
22
{
3-
float4 g_Data;
3+
float4 f4Position : SV_Position;
4+
float4 f4Color : COLOR;
45
};
56

6-
77
float4 CheckValue(float4 Val, float4 Expected)
88
{
99
return float4(Val.x == Expected.x ? 1.0 : 0.0,
@@ -12,6 +12,13 @@ float4 CheckValue(float4 Val, float4 Expected)
1212
Val.w == Expected.w ? 1.0 : 0.0);
1313
}
1414

15+
16+
#if defined(VERTEX_SHADER) || defined(MESH_SHADER)
17+
cbuffer Constants
18+
{
19+
float4 g_Data;
20+
};
21+
1522
float4 VerifyResourcesVS()
1623
{
1724
float4 AllCorrect = float4(1.0, 1.0, 1.0, 1.0);
@@ -20,13 +27,6 @@ float4 VerifyResourcesVS()
2027
return AllCorrect;
2128
}
2229

23-
24-
struct VSOutput
25-
{
26-
float4 f4Position : SV_Position;
27-
float4 f4Color : COLOR;
28-
};
29-
3030
void VSMain(in uint VertId : SV_VertexID,
3131
out VSOutput Out)
3232
{
@@ -64,8 +64,10 @@ void MSMain( uint I : SV_GroupIndex,
6464
I % 3 == 2 ? 1.0 : 0.0,
6565
1.0) * VerifyResourcesVS();
6666
}
67+
#endif
6768

6869

70+
#ifdef PIXEL_SHADER
6971
Texture2D g_Texture;
7072
SamplerState g_Texture_sampler;
7173

@@ -82,3 +84,4 @@ float4 PSMain(in VSOutput In) : SV_Target
8284
{
8385
return In.f4Color * VerifyResourcesPS();
8486
}
87+
#endif

0 commit comments

Comments
 (0)