summaryrefslogtreecommitdiffstats
path: root/tools/render-test/vk-util.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-06-28 11:14:48 -0700
committerGitHub <noreply@github.com>2018-06-28 11:14:48 -0700
commitdfe13b54286b27dd15f591455bbb86b7798285c2 (patch)
tree4a11f01feaae059b6c11bdfbe12a614228af6dd5 /tools/render-test/vk-util.cpp
parent22033f06573f900dc030c487b2c30feddf3d8f16 (diff)
Share graphics API layer between tests/examples (#603)
The `render-test` project has an in-progress graphics API abstraction layer, and it makes sense to share this code with our examples rather than write a bunch of redundant code between examples and tests. Most of this change is just moving files from `tools/render-test/*` to a new library project at `tools/slang-graphics/`. The most complicated code change there is renaming from `render_test` to `slang_graphics`. The existing `hello` example was ported to use the graphics API layer instead of raw D3D11 API calls. It is still hard-coded to use the D3D11 back-end and the `SLANG_DXBC` target, so more work is needed if we want to actually support multiple APIs in the examples. I also went ahead and implemented an extremely rudimentary set of APIs to abstract over the Windows platform calls that were being made in the example, so that we could potentially run that same example on other platforms. I did *not* port `render-test` to use those APIs, and I also did not implement them for anything but Windows (my assumption is that for most other platforms we would just use SDL2, and require people to ensure it is installed to their machine before building Slang examples).
Diffstat (limited to 'tools/render-test/vk-util.cpp')
-rw-r--r--tools/render-test/vk-util.cpp59
1 files changed, 0 insertions, 59 deletions
diff --git a/tools/render-test/vk-util.cpp b/tools/render-test/vk-util.cpp
deleted file mode 100644
index 925001144..000000000
--- a/tools/render-test/vk-util.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// vk-util.cpp
-#include "vk-util.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-namespace renderer_test {
-
-/* static */VkFormat VulkanUtil::getVkFormat(Format format)
-{
- switch (format)
- {
- case Format::RGBA_Float32: return VK_FORMAT_R32G32B32A32_SFLOAT;
- case Format::RGB_Float32: return VK_FORMAT_R32G32B32_SFLOAT;
- case Format::RG_Float32: return VK_FORMAT_R32G32_SFLOAT;
- case Format::R_Float32: return VK_FORMAT_R32_SFLOAT;
- case Format::RGBA_Unorm_UInt8: return VK_FORMAT_R8G8B8A8_UNORM;
- case Format::R_UInt32: return VK_FORMAT_R32_UINT;
-
- case Format::D_Float32: return VK_FORMAT_D32_SFLOAT;
- case Format::D_Unorm24_S8: return VK_FORMAT_D24_UNORM_S8_UINT;
-
- default: return VK_FORMAT_UNDEFINED;
- }
-}
-
-/* static */SlangResult VulkanUtil::toSlangResult(VkResult res)
-{
- return (res == VK_SUCCESS) ? SLANG_OK : SLANG_FAIL;
-}
-
-/* static */Slang::Result VulkanUtil::handleFail(VkResult res)
-{
- if (res != VK_SUCCESS)
- {
- assert(!"Vulkan returned a failure");
- }
- return toSlangResult(res);
-}
-
-/* static */void VulkanUtil::checkFail(VkResult res)
-{
- assert(res != VK_SUCCESS);
- assert(!"Vulkan check failed");
-
-}
-
-/* static */VkPrimitiveTopology VulkanUtil::getVkPrimitiveTopology(PrimitiveTopology topology)
-{
- switch (topology)
- {
- case PrimitiveTopology::TriangleList: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
- default: break;
- }
- assert(!"Unknown topology");
- return VK_PRIMITIVE_TOPOLOGY_MAX_ENUM;
-}
-
-} // renderer_test