From 2ee39578223a066501fd35ab59a6fd413fc518a9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 4 Aug 2021 15:58:24 +0200 Subject: [PATCH] Renderer: Add NAZARA_REQUEST_DEDICATED_GPU macro --- examples/DeferredShading/main.cpp | 2 ++ examples/PhysicsDemo/main.cpp | 2 ++ examples/RenderTest/main.cpp | 2 ++ include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/GpuSwitch.hpp | 20 ++++++++++++++++++++ 5 files changed, 27 insertions(+) create mode 100644 include/Nazara/Renderer/GpuSwitch.hpp diff --git a/examples/DeferredShading/main.cpp b/examples/DeferredShading/main.cpp index 95b13bff3..ff261d90e 100644 --- a/examples/DeferredShading/main.cpp +++ b/examples/DeferredShading/main.cpp @@ -15,6 +15,8 @@ #include #include +NAZARA_REQUEST_DEDICATED_GPU() + /* [layout(std140)] struct PointLight diff --git a/examples/PhysicsDemo/main.cpp b/examples/PhysicsDemo/main.cpp index 15f5d378b..d9a7dbaea 100644 --- a/examples/PhysicsDemo/main.cpp +++ b/examples/PhysicsDemo/main.cpp @@ -18,6 +18,8 @@ #include #include +NAZARA_REQUEST_DEDICATED_GPU() + int main() { std::filesystem::path resourceDir = "resources"; diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp index 7e598fac9..e559f2c74 100644 --- a/examples/RenderTest/main.cpp +++ b/examples/RenderTest/main.cpp @@ -8,6 +8,8 @@ #include #include +NAZARA_REQUEST_DEDICATED_GPU() + const char shaderSource[] = R"( option red: bool; diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 2714ea822..4401150fb 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/GpuSwitch.hpp b/include/Nazara/Renderer/GpuSwitch.hpp new file mode 100644 index 000000000..a12669876 --- /dev/null +++ b/include/Nazara/Renderer/GpuSwitch.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +#ifdef NAZARA_PLATFORM_WINDOWS + +#define NAZARA_REQUEST_DEDICATED_GPU() \ +extern "C" \ +{ \ + NAZARA_EXPORT unsigned long NvOptimusEnablement = 1; \ + NAZARA_EXPORT unsigned long AmdPowerXpressRequestHighPerformance = 1; \ +} + +#else + +#define NAZARA_REQUEST_DEDICATED_GPU() + +#endif