diff options
Diffstat (limited to 'tools/slang-test/test-context.h')
| -rw-r--r-- | tools/slang-test/test-context.h | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index b07ca94e6..95b46fe6e 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -8,16 +8,78 @@ #include "../../source/core/slang-std-writers.h" #include "../../source/core/dictionary.h" #include "../../source/core/slang-test-tool-util.h" +#include "../../source/core/slang-render-api-util.h" #include "options.h" +enum class BackendType +{ + Unknown = -1, + Dxc, + Fxc, + Glslang, + CountOf, +}; + +typedef uint32_t BackendFlags; +struct BackendFlag +{ + enum Enum : uint32_t + { + Dxc = 1 << int(BackendType::Dxc), + Fxc = 1 << int(BackendType::Fxc), + Glslang = 1 << int(BackendType::Glslang), + }; +}; + +/// Structure that describes requirements needs to run - such as rendering APIs or +/// back-end availability +struct TestRequirements +{ + TestRequirements& addUsed(BackendType type) + { + if (type != BackendType::Unknown) + { + usedBackendFlags |= BackendFlags(1) << int(type); + } + return *this; + } + TestRequirements& addUsed(Slang::RenderApiType type) + { + using namespace Slang; + if (type != RenderApiType::Unknown) + { + usedRenderApiFlags |=RenderApiFlags(1) << int(type); + } + return *this; + } + TestRequirements& addUsedBackends(BackendFlags flags) + { + usedBackendFlags |= flags; + return *this; + } + TestRequirements& addUsedRenderApis(Slang::RenderApiFlags flags) + { + usedRenderApiFlags |= flags; + return *this; + } + /// True if has this render api as used + bool isUsed(Slang::RenderApiType apiType) const + { + return (apiType != Slang::RenderApiType::Unknown) && ((usedRenderApiFlags & (Slang::RenderApiFlags(1) << int(apiType))) != 0); + } + + Slang::RenderApiType explicitRenderApi = Slang::RenderApiType::Unknown; ///< The render api explicitly specified + BackendFlags usedBackendFlags = 0; ///< Used backends + Slang::RenderApiFlags usedRenderApiFlags = 0; ///< Used render api flags (some might be implied) +}; + class TestContext { public: typedef Slang::TestToolUtil::InnerMainFunc InnerMainFunc; - /// Get the slang session SlangSession* getSession() const { return m_session; } @@ -28,6 +90,11 @@ class TestContext /// Set the function for the shared library void setInnerMainFunc(const Slang::String& name, InnerMainFunc func); + /// If true tests aren't being run just the information on testing is being accumulated + bool isCollectingRequirements() const { return testRequirements != nullptr; } + /// If set, then tests are executed + bool isExecuting() const { return testRequirements == nullptr; } + /// Ctor TestContext(); /// Dtor @@ -37,6 +104,13 @@ class TestContext TestReporter* reporter = nullptr; TestCategorySet categorySet; + /// If set then tests are not run, but their requirements are set + TestRequirements* testRequirements = nullptr; + + BackendFlags availableBackendFlags = 0; + Slang::RenderApiFlags availableRenderApiFlags = 0; + bool isAvailableRenderApiFlagsValid = false; + protected: struct SharedLibraryTool { |
