Skip to content

Commit

Permalink
Allow overriding MessageCallback in GPUTestingEnvironment
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve J. Cai authored and TheMostDiligent committed Sep 30, 2023
1 parent f5e0fbb commit a346b2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Tests/GPUTestFramework/include/GPUTestingEnvironment.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2023 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -61,6 +61,8 @@ class GPUTestingEnvironment : public TestingEnvironment
bool EnableDeviceSimulation = false;

DeviceFeatures Features{DEVICE_FEATURE_STATE_OPTIONAL};

DebugMessageCallbackType MessageCallback = TestingEnvironment::MessageCallback;
};
GPUTestingEnvironment(const CreateInfo& CI, const SwapChainDesc& SCDesc);

Expand Down
14 changes: 7 additions & 7 deletions Tests/GPUTestFramework/src/GPUTestingEnvironment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2023 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -231,7 +231,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
# endif

auto* pFactoryD3D11 = GetEngineFactoryD3D11();
pFactoryD3D11->SetMessageCallback(MessageCallback);
pFactoryD3D11->SetMessageCallback(EnvCI.MessageCallback);

EngineD3D11CreateInfo EngineCI;
EngineCI.GraphicsAPIVersion = Version{11, 0};
Expand Down Expand Up @@ -273,7 +273,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
}
# endif
auto* pFactoryD3D12 = GetEngineFactoryD3D12();
pFactoryD3D12->SetMessageCallback(MessageCallback);
pFactoryD3D12->SetMessageCallback(EnvCI.MessageCallback);

if (!pFactoryD3D12->LoadD3D12())
{
Expand Down Expand Up @@ -338,7 +338,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
}
# endif
auto* pFactoryOpenGL = GetEngineFactoryOpenGL();
pFactoryOpenGL->SetMessageCallback(MessageCallback);
pFactoryOpenGL->SetMessageCallback(EnvCI.MessageCallback);
EnumerateAdapters(pFactoryOpenGL, Version{},
[](const GraphicsAdapterInfo& AdapterInfo, Uint32 AdapterId) {
return std::vector<DisplayModeAttribs>{};
Expand Down Expand Up @@ -374,7 +374,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
# endif

auto* pFactoryVk = GetEngineFactoryVk();
pFactoryVk->SetMessageCallback(MessageCallback);
pFactoryVk->SetMessageCallback(EnvCI.MessageCallback);

if (EnvCI.EnableDeviceSimulation)
pFactoryVk->EnableDeviceSimulation();
Expand Down Expand Up @@ -421,7 +421,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
case RENDER_DEVICE_TYPE_METAL:
{
auto* pFactoryMtl = GetEngineFactoryMtl();
pFactoryMtl->SetMessageCallback(MessageCallback);
pFactoryMtl->SetMessageCallback(EnvCI.MessageCallback);

EnumerateAdapters(pFactoryMtl, Version{},
[](const GraphicsAdapterInfo& AdapterInfo, Uint32 AdapterId) {
Expand Down Expand Up @@ -564,7 +564,7 @@ GPUTestingEnvironment::GPUTestingEnvironment(const CreateInfo& EnvCI, const Swap
# else
m_ArchiverFactory = Diligent::GetArchiverFactory();
# endif
m_ArchiverFactory->SetMessageCallback(MessageCallback);
m_ArchiverFactory->SetMessageCallback(EnvCI.MessageCallback);
}
#endif
}
Expand Down

0 comments on commit a346b2a

Please sign in to comment.