@@ -63,29 +63,7 @@ std::vector<unsigned int> LoadSPIRVFromHLSL(const char* FilePath, SHADER_TYPE Sh
6363{
6464 std::vector<unsigned int > SPIRV;
6565
66- #if DILIGENT_NO_HLSL
67- // When DILIGENT_NO_HLSL is defined, use {FilePath}.spv as raw SPIRV shader source.
68- // i.e. FilePath="Textures.psh", then we load RAW SPIRV from "Textures.psh.spv"
69- std::string SPIRVFilePath = std::string (FilePath) + " .spv" ;
70-
71- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceStreamFactory;
72- CreateDefaultShaderSourceStreamFactory (" shaders/SPIRV" , &pShaderSourceStreamFactory);
73- if (!pShaderSourceStreamFactory)
74- return {};
75-
76- RefCntAutoPtr<IFileStream> pSPIRVStream;
77- pShaderSourceStreamFactory->CreateInputStream (SPIRVFilePath.c_str (), &pSPIRVStream);
78- if (!pSPIRVStream)
79- return {};
80-
81- const size_t ByteCodeSize = pSPIRVStream->GetSize ();
82- if (ByteCodeSize == 0 || ByteCodeSize % 4 != 0 )
83- return {};
84-
85- SPIRV.resize (ByteCodeSize / 4 );
86- pSPIRVStream->Read (SPIRV.data (), ByteCodeSize);
87-
88- #else
66+ #if !DILIGENT_NO_HLSL
8967
9068 ShaderCreateInfo ShaderCI;
9169 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
@@ -103,6 +81,7 @@ std::vector<unsigned int> LoadSPIRVFromHLSL(const char* FilePath, SHADER_TYPE Sh
10381 GLSLangUtils::InitializeGlslang ();
10482 SPIRV = GLSLangUtils::HLSLtoSPIRV (ShaderCI, GLSLangUtils::SpirvVersion::Vk100, nullptr , nullptr );
10583 GLSLangUtils::FinalizeGlslang ();
84+
10685#endif
10786
10887 return SPIRV;
@@ -112,30 +91,8 @@ std::vector<unsigned int> LoadSPIRVFromGLSL(const char* FilePath, SHADER_TYPE Sh
11291{
11392 std::vector<unsigned int > SPIRV;
11493
115- #if DILIGENT_NO_GLSLANG
116- // When DILIGENT_NO_GLSLANG is defined, use {FilePath}.spv as raw SPIRV shader source.
117- // i.e. FilePath="AtomicCounters.glsl", then we load RAW SPIRV from "AtomicCounters.glsl.spv"
118- std::string SPIRVFilePath = std::string (FilePath) + " .spv" ;
119-
120- RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceStreamFactory;
121- CreateDefaultShaderSourceStreamFactory (" shaders/SPIRV" , &pShaderSourceStreamFactory);
122- if (!pShaderSourceStreamFactory)
123- return {};
124-
125- RefCntAutoPtr<IFileStream> pSPIRVStream;
126- pShaderSourceStreamFactory->CreateInputStream (SPIRVFilePath.c_str (), &pSPIRVStream);
127- if (!pSPIRVStream)
128- return {};
129-
130- const size_t ByteCodeSize = pSPIRVStream->GetSize ();
131- if (ByteCodeSize == 0 || ByteCodeSize % 4 != 0 )
132- return {};
133-
134- SPIRV.resize (ByteCodeSize / 4 );
135- pSPIRVStream->Read (SPIRV.data (), ByteCodeSize);
136-
137- #else
138-
94+ #if !DILIGENT_NO_GLSLANG
95+
13996 RefCntAutoPtr<IShaderSourceInputStreamFactory> pShaderSourceStreamFactory;
14097 CreateDefaultShaderSourceStreamFactory (" shaders/SPIRV" , &pShaderSourceStreamFactory);
14198 if (!pShaderSourceStreamFactory)
@@ -187,6 +144,10 @@ void TestSPIRVResources(const char* FilePa
187144 const char * CombinedSamplerSuffix = nullptr ,
188145 bool IsGLSL = false )
189146{
147+ #if DILIGENT_NO_GLSLANG || DILIGENT_NO_HLSL
148+ GTEST_SKIP ();
149+ #endif
150+
190151 const auto SPIRV = IsGLSL ? LoadSPIRVFromGLSL (FilePath, ShaderType) : LoadSPIRVFromHLSL (FilePath, ShaderType);
191152 ASSERT_FALSE (SPIRV.empty ()) << " Failed to compile HLSL to SPIRV: " << FilePath;
192153
0 commit comments