Skip to content

Commit 827bf17

Browse files
EngineFactoryGL: do not show warning in SetPreferredAdapter if discrete GPU is not requested
1 parent 4d07755 commit 827bf17

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,34 +139,35 @@ static void SetDefaultGraphicsAdapterInfo(GraphicsAdapterInfo& AdapterInfo)
139139

140140
static void SetPreferredAdapter(const EngineGLCreateInfo& EngineCI)
141141
{
142-
bool EnableDedicatedGPU = EngineCI.PreferredAdapterType == ADAPTER_TYPE_DISCRETE;
143-
#if PLATFORM_WIN32
144-
const HMODULE ModuleHandle = GetModuleHandle(nullptr);
145-
Uint64* const NvOptimusEnablement = reinterpret_cast<Uint64*>(GetProcAddress(ModuleHandle, "NvOptimusEnablement"));
146-
Uint64* const AmdPowerXpressRequestHighPerformance = reinterpret_cast<Uint64*>(GetProcAddress(ModuleHandle, "AmdPowerXpressRequestHighPerformance"));
147-
if (!NvOptimusEnablement && !AmdPowerXpressRequestHighPerformance)
148-
{
149-
LOG_WARNING_MESSAGE("Neither NvOptimusEnablement nor AmdPowerXpressRequestHighPerformance symbols found. "
150-
"You need to explicitly define these variables in your executable file: "
151-
"https://gist.github.com/statico/6809850727c708f08458, "
152-
"or you can use the `Diligent-GLAdapterSelector` object library as source input to your executable target: "
153-
"`target_sources(MyExecutable PRIVATE $<TARGET_OBJECTS:Diligent-GLAdapterSelector>)`, "
154-
"see https://cmake.org/cmake/help/v3.16/manual/cmake-buildsystem.7.html#object-libraries.");
155-
}
156-
if (AmdPowerXpressRequestHighPerformance)
142+
if (EngineCI.PreferredAdapterType == ADAPTER_TYPE_DISCRETE)
157143
{
158-
*AmdPowerXpressRequestHighPerformance = EnableDedicatedGPU;
159-
}
160-
if (NvOptimusEnablement)
161-
{
162-
*NvOptimusEnablement = EnableDedicatedGPU;
163-
}
164-
#elif PLAtTFORM_LINUX
165-
setenv("DRI_PRIME", EnableDedicatedGPU ? "1" : "0", 1);
144+
#if PLATFORM_WIN32
145+
const HMODULE ModuleHandle = GetModuleHandle(nullptr);
146+
Uint64* const NvOptimusEnablement = reinterpret_cast<Uint64*>(GetProcAddress(ModuleHandle, "NvOptimusEnablement"));
147+
Uint64* const AmdPowerXpressRequestHighPerformance = reinterpret_cast<Uint64*>(GetProcAddress(ModuleHandle, "AmdPowerXpressRequestHighPerformance"));
148+
if (!NvOptimusEnablement && !AmdPowerXpressRequestHighPerformance)
149+
{
150+
LOG_WARNING_MESSAGE("Neither NvOptimusEnablement nor AmdPowerXpressRequestHighPerformance symbols found. "
151+
"You need to explicitly define these variables in your executable file: "
152+
"https://gist.github.com/statico/6809850727c708f08458, "
153+
"or you can use the `Diligent-GLAdapterSelector` object library as source input to your executable target: "
154+
"`target_sources(MyExecutable PRIVATE $<TARGET_OBJECTS:Diligent-GLAdapterSelector>)`, "
155+
"see https://cmake.org/cmake/help/v3.16/manual/cmake-buildsystem.7.html#object-libraries.");
156+
}
157+
if (AmdPowerXpressRequestHighPerformance)
158+
{
159+
*AmdPowerXpressRequestHighPerformance = 1;
160+
}
161+
if (NvOptimusEnablement)
162+
{
163+
*NvOptimusEnablement = 1;
164+
}
165+
#elif PLATFORM_LINUX
166+
setenv("DRI_PRIME", "1", 1);
166167
#else
167-
if (EnableDedicatedGPU)
168168
LOG_WARNING_MESSAGE("Setting preferred adapter type isn't supported on this platform");
169169
#endif
170+
}
170171
}
171172

172173
void EngineFactoryOpenGLImpl::EnumerateAdapters(Version MinVersion,

0 commit comments

Comments
 (0)