@@ -44,23 +44,26 @@ using namespace Diligent::Testing;
4444
4545namespace
4646{
47- std::unique_ptr<IDXCompiler> g_pDXCompiler;
4847
4948class SPIRVShaderResourcesTest : public ::testing::Test
5049{
50+ public:
51+ static std::unique_ptr<IDXCompiler> DXCompiler;
52+
5153protected:
54+
5255 static void SetUpTestSuite ()
5356 {
5457 GLSLangUtils::InitializeGlslang ();
5558
56- g_pDXCompiler = CreateDXCompiler (DXCompilerTarget::Vulkan, 0 , nullptr );
59+ DXCompiler = CreateDXCompiler (DXCompilerTarget::Vulkan, 0 , nullptr );
5760 }
5861
5962 static void TearDownTestSuite ()
6063 {
6164 GLSLangUtils::FinalizeGlslang ();
6265
63- g_pDXCompiler .reset ();
66+ DXCompiler .reset ();
6467 }
6568};
6669
@@ -83,7 +86,7 @@ std::vector<unsigned int> LoadSPIRVFromHLSL(const char* FilePath, SHADER_TYPE Sh
8386 if (UseDXC)
8487 {
8588 // Use DXC to compile HLSL to SPIR-V.
86- if (!g_pDXCompiler || !g_pDXCompiler ->IsLoaded ())
89+ if (!SPIRVShaderResourcesTest::DXCompiler || !SPIRVShaderResourcesTest::DXCompiler ->IsLoaded ())
8790 return {};
8891
8992 ShaderCreateInfo ShaderCI;
@@ -103,7 +106,7 @@ std::vector<unsigned int> LoadSPIRVFromHLSL(const char* FilePath, SHADER_TYPE Sh
103106 ShaderCI.pShaderSourceStreamFactory = pShaderSourceStreamFactory;
104107
105108 RefCntAutoPtr<IDataBlob> pCompilerOutput;
106- g_pDXCompiler ->Compile (ShaderCI, ShaderVersion{6 , 0 }, nullptr , nullptr , &SPIRV, &pCompilerOutput);
109+ SPIRVShaderResourcesTest::DXCompiler ->Compile (ShaderCI, ShaderVersion{6 , 0 }, nullptr , nullptr , &SPIRV, &pCompilerOutput);
107110
108111 if (pCompilerOutput && pCompilerOutput->GetSize () > 0 )
109112 {
@@ -244,7 +247,7 @@ void TestSPIRVResources(const char* FilePa
244247
245248 if (!IsGLSL)
246249 {
247- if (g_pDXCompiler && g_pDXCompiler ->IsLoaded ())
250+ if (SPIRVShaderResourcesTest::DXCompiler && SPIRVShaderResourcesTest::DXCompiler ->IsLoaded ())
248251 {
249252 // Test with DXC
250253 const auto & SPIRV_DXC = LoadSPIRVFromHLSL (FilePath, ShaderType, true );
0 commit comments