Skip to content

Commit bcea8aa

Browse files
committed
make "g_pDXCompiler" static member of a the test class
1 parent a65d481 commit bcea8aa

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Tests/DiligentCoreTest/src/ShaderTools/SPIRVShaderResourcesTest.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,26 @@ using namespace Diligent::Testing;
4444

4545
namespace
4646
{
47-
std::unique_ptr<IDXCompiler> g_pDXCompiler;
4847

4948
class SPIRVShaderResourcesTest : public ::testing::Test
5049
{
50+
public:
51+
static std::unique_ptr<IDXCompiler> DXCompiler;
52+
5153
protected:
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

Comments
 (0)