From 3ab07cba11bb92cc8569fdd4797e5d82b8affbb7 Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Tue, 29 Aug 2023 22:12:42 -0400 Subject: [PATCH] Allow specific GL version to be specified for Testbed, e.g. 'gl410'. --- .../GLCoreProfile/GLCoreExtensionLoader.cpp | 1 + tests/Testbed/TestCommandBufferSubmit.cpp | 4 +- tests/Testbed/TestbedContext.cpp | 21 ++++++++- tests/Testbed/TestbedContext.h | 2 +- tests/Testbed/TestbedMain.cpp | 47 +++++++++++++++---- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensionLoader.cpp b/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensionLoader.cpp index 44a7be5737..df69b49f63 100644 --- a/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensionLoader.cpp +++ b/sources/Renderer/OpenGL/GLCoreProfile/GLCoreExtensionLoader.cpp @@ -305,6 +305,7 @@ static bool DECL_LOADGLEXT_PROC(ARB_shader_objects_30) return true; } +//TODO: no determined yet when to load this extension static bool DECL_LOADGLEXT_PROC(ARB_shader_objects_40) { LOAD_GLPROC( glUniform1dv ); diff --git a/tests/Testbed/TestCommandBufferSubmit.cpp b/tests/Testbed/TestCommandBufferSubmit.cpp index 43da921c4b..efd407a9ff 100644 --- a/tests/Testbed/TestCommandBufferSubmit.cpp +++ b/tests/Testbed/TestCommandBufferSubmit.cpp @@ -19,8 +19,8 @@ DEF_TEST( CommandBufferSubmit ) const ClearValue clearValues[] = { - ClearValue{ 0.2f, 1.0f, 0.2f, 1 }, - ClearValue{ 0.2f, 0.4f, 0.8f, 1 } + ClearValue{ 0.2f, 1.0f, 0.2f, 1 }, // Green + ClearValue{ 0.2f, 0.4f, 0.8f, 1 } // Blue }; const TextureRegion texRegion{ Offset3D{ 0, 0, 0 }, Extent3D{ 1, 1, 1 } }; diff --git a/tests/Testbed/TestbedContext.cpp b/tests/Testbed/TestbedContext.cpp index 7a360ff14e..77c85acde3 100644 --- a/tests/Testbed/TestbedContext.cpp +++ b/tests/Testbed/TestbedContext.cpp @@ -51,13 +51,24 @@ static std::string SanitizePath(std::string path) return path; } -TestbedContext::TestbedContext(const char* moduleName, int argc, char* argv[]) : +static void ConfigureOpenGL(RendererConfigurationOpenGL& cfg, int version) +{ + if (version != 0) + { + cfg.majorVersion = (version / 100) % 10; + cfg.minorVersion = (version / 10) % 10; + } +} + +TestbedContext::TestbedContext(const char* moduleName, int version, int argc, char* argv[]) : moduleName { moduleName }, outputDir { SanitizePath(FindOutputDir(argc, argv)) }, verbose { HasArgument(argc, argv, "-v") || HasArgument(argc, argv, "--verbose") }, showTiming { HasArgument(argc, argv, "-t") || HasArgument(argc, argv, "--timing") }, fastTest { HasArgument(argc, argv, "-f") || HasArgument(argc, argv, "--fast") } { + RendererConfigurationOpenGL cfgGL; + RenderSystemDescriptor rendererDesc; { rendererDesc.moduleName = this->moduleName; @@ -68,6 +79,14 @@ TestbedContext::TestbedContext(const char* moduleName, int argc, char* argv[]) : rendererDesc.profiler = &profiler; rendererDesc.debugger = &debugger; #endif + + if (::strcmp(moduleName, "OpenGL") == 0) + { + // OpenGL specific configuration + ConfigureOpenGL(cfgGL, version); + rendererDesc.rendererConfig = &cfgGL; + rendererDesc.rendererConfigSize = sizeof(cfgGL); + } } if ((renderer = RenderSystem::Load(rendererDesc)) != nullptr) { diff --git a/tests/Testbed/TestbedContext.h b/tests/Testbed/TestbedContext.h index 82d2aa5f89..c47910789e 100644 --- a/tests/Testbed/TestbedContext.h +++ b/tests/Testbed/TestbedContext.h @@ -34,7 +34,7 @@ class TestbedContext public: - TestbedContext(const char* moduleName, int argc, char* argv[]); + TestbedContext(const char* moduleName, int version, int argc, char* argv[]); void RunAllTests(); diff --git a/tests/Testbed/TestbedMain.cpp b/tests/Testbed/TestbedMain.cpp index bd208a2876..b180d69dcf 100644 --- a/tests/Testbed/TestbedMain.cpp +++ b/tests/Testbed/TestbedMain.cpp @@ -7,6 +7,7 @@ #include "TestbedContext.h" #include +#include using namespace LLGL; @@ -19,16 +20,37 @@ static void RunRendererIndependentTests() Log::Printf("=============================\n\n"); } -static void RunTestbedForRenderer(const char* moduleName, int argc, char* argv[]) +static void RunTestbedForRenderer(const char* moduleName, int version, int argc, char* argv[]) { - Log::Printf("Run Testbed: %s\n", moduleName); + if (version != 0) + Log::Printf("Run Testbed: %s (%d)\n", moduleName, version); + else + Log::Printf("Run Testbed: %s\n", moduleName); Log::Printf("=============================\n"); - TestbedContext context{ moduleName, argc, argv }; + TestbedContext context{ moduleName, version, argc, argv }; context.RunAllTests(); Log::Printf("=============================\n\n"); } -static const char* GetRendererModule(const std::string& name) +struct ModuleAndVersion +{ + std::string name; + int version; + + ModuleAndVersion(const char* name, int version = 0) : + name { name }, + version { version } + { + } + + ModuleAndVersion(const std::string& name, int version = 0) : + name { name }, + version { version } + { + } +}; + +static ModuleAndVersion GetRendererModule(const std::string& name) { if (name == "gl" || name == "opengl") return "OpenGL"; @@ -42,6 +64,10 @@ static const char* GetRendererModule(const std::string& name) return "Direct3D12"; if (name == "null") return "Null"; + if (std::regex_match(name, std::regex(R"(gl\d{3})"))) + return ModuleAndVersion{ "OpenGL", std::atoi(name.c_str() + 2) }; + if (std::regex_match(name, std::regex(R"(opengl\d{3})"))) + return ModuleAndVersion{ "OpenGL", std::atoi(name.c_str() + 6) }; return name.c_str(); } @@ -50,7 +76,7 @@ int main(int argc, char* argv[]) Log::RegisterCallbackStd(); // Gather all explicitly specified module names - std::vector enabledModules; + std::vector enabledModules; for (int i = 1; i < argc; ++i) { if (argv[i][0] != '-') @@ -58,14 +84,19 @@ int main(int argc, char* argv[]) } if (enabledModules.empty()) - enabledModules = RenderSystem::FindModules(); + { + std::vector availableModules = RenderSystem::FindModules(); + enabledModules.reserve(availableModules.size()); + for (const std::string& module : availableModules) + enabledModules.push_back(module); + } // Run renderer independent tests RunRendererIndependentTests(); // Run renderer specific tests - for (const std::string& moduleName : enabledModules) - RunTestbedForRenderer(moduleName.c_str(), argc - 1, argv + 1); + for (const ModuleAndVersion& module : enabledModules) + RunTestbedForRenderer(module.name.c_str(), module.version, argc - 1, argv + 1); #ifdef _WIN32 system("pause");