summaryrefslogtreecommitdiff
path: root/tools/slang-test/render-api-util.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-04-10 17:53:03 -0400
committerGitHub <noreply@github.com>2018-04-10 17:53:03 -0400
commitc4004b32ca2c0effb455ec847114240db3cb993b (patch)
tree7530f131892e2973929948e61e46e957d38510a2 /tools/slang-test/render-api-util.h
parent5298ccf7da486d0010c6157974d5dd9a5556f265 (diff)
Feature/dx12 compute (#482)
* Dx12 rendering works in test framework. * Turn on dx12 render tests. * Getting simpler dx12 compute tests to work. * With expected data in test - check for specialized and then for the default, so that multiple test can share the same expected data, but specialized cases can still be set. * Fixed construction and binding on dx12 textures. * Control which render apis used in test from command line. * Small aesthetic fixes in render-test/main.cpp. * Fix binding problem for uavs/srvs dx12. Previously tried to create srv/uav for StorageBuffers (like dx11 does), but the binding breaks as you can end up with two srvs using the same register. First pass at fixing problems with Texture creation for dx12 - assertions were hit with 3d or array textures. * Fixes to improve Dx12 setup shader resource views for cubemaps/arrays. * Fixed d3d12 textureSamplingTest - problem was that cubemap/array textures were not being uploaded correctly. * Changed the order of how binding of constant buffers (as just set on the Renderer) indexes. Previously they were given the lowest indices, but they clashed with the indices from the 'Binding'. Changing this means all tests run on d3d12. * Add code to allow use of warp (although not command line switchable yet). Fix problem setting up raw UAV - as identified by warp. * Added RenderApiUtil - which can detect if a render api is potentially available. * Moved render flag testing/parsing into RenderApiUtil. * Fix signed/unsigned warning. * Fixes around enums prefixed with k on the review of feature/dx12 compute branch.
Diffstat (limited to 'tools/slang-test/render-api-util.h')
-rw-r--r--tools/slang-test/render-api-util.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/slang-test/render-api-util.h b/tools/slang-test/render-api-util.h
new file mode 100644
index 000000000..0f941f05d
--- /dev/null
+++ b/tools/slang-test/render-api-util.h
@@ -0,0 +1,61 @@
+#ifndef SLANG_RENDER_API_UTIL_H
+#define SLANG_RENDER_API_UTIL_H
+
+#include "../../source/core/slang-string.h"
+#include "../../source/core/slang-result.h"
+
+
+enum class RenderApiType
+{
+ Unknown = -1,
+ OpenGl = 0,
+ Vulkan,
+ D3D12,
+ D3D11,
+ CountOf,
+};
+
+// Use a struct wrapped Enum instead of enum class, cos we want to be able to manipulate as integrals
+struct RenderApiFlag
+{
+ enum Enum
+ {
+ OpenGl = 1 << int(RenderApiType::OpenGl),
+ Vulkan = 1 << int(RenderApiType::Vulkan),
+ D3D12 = 1 << int(RenderApiType::D3D12),
+ D3D11 = 1 << int(RenderApiType::D3D11),
+ AllOf = (1 << int(RenderApiType::CountOf)) - 1 ///< All bits set
+ };
+};
+
+struct RenderApiUtil
+{
+ struct Info
+ {
+ RenderApiType type; ///< The type
+ const char* names; ///< Comma separated list of names associated with the type
+ };
+
+ /// Returns true if the API is available.
+ static bool calcHasApi(RenderApiType type);
+
+ /// Returns a combination of RenderApiFlag bits which if set indicates that the API is available.
+ static int getAvailableApis();
+
+ /// Returns -1 if unknown
+ static RenderApiType findApiTypeByName(const Slang::UnownedStringSlice& name);
+ /// Returns 0 if none found.
+ static int findApiFlagsByName(const Slang::UnownedStringSlice& name);
+
+ /// Parse api flags string (comma delimited list of api names, or 'all' for all)
+ /// For example "all,-dx12" would be all apis, except dx12
+ static Slang::Result parseApiFlags(const Slang::UnownedStringSlice& text, int* apiBitsOut);
+
+ /// Get information about a render API
+ static const Info& getInfo(RenderApiType type) { return s_infos[int(type)]; }
+
+ /// Static information about each render api
+ static const Info s_infos[int(RenderApiType::CountOf)];
+};
+
+#endif // SLANG_RENDER_API_UTIL_H \ No newline at end of file