Skip to content

Commit

Permalink
Allow specific GL version to be specified for Testbed, e.g. 'gl410'.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Aug 30, 2023
1 parent a71d1d0 commit 3ab07cb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions tests/Testbed/TestCommandBufferSubmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };
Expand Down
21 changes: 20 additions & 1 deletion tests/Testbed/TestbedContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Testbed/TestbedContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
47 changes: 39 additions & 8 deletions tests/Testbed/TestbedMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "TestbedContext.h"
#include <string>
#include <regex>


using namespace LLGL;
Expand All @@ -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";
Expand All @@ -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();
}

Expand All @@ -50,22 +76,27 @@ int main(int argc, char* argv[])
Log::RegisterCallbackStd();

// Gather all explicitly specified module names
std::vector<std::string> enabledModules;
std::vector<ModuleAndVersion> enabledModules;
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] != '-')
enabledModules.push_back(GetRendererModule(argv[i]));
}

if (enabledModules.empty())
enabledModules = RenderSystem::FindModules();
{
std::vector<std::string> 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");
Expand Down

0 comments on commit 3ab07cb

Please sign in to comment.