diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-05-03 14:25:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-03 14:25:13 -0400 |
| commit | 367f3a78a40731da45ee12b9a18c94707f1d1429 (patch) | |
| tree | 5993ef627e1a094ea1d401c31e6b00e3c63c308a /tools/render-test/vk-util.h | |
| parent | 78935493587ec65a199d844327613021667acc1b (diff) | |
Feature/vulkan first render (#545)
* First pass at InputLayout for Vulkan
Add support for RGBA_Float32
* Use VulkanModule and VulkanApi to handle accessing Vulkan types.
* First pass at Vulkan swap chain/Device queue.
* Added VulkanUtil for generic function functions.
* Move more functionality to VulkanApi and VulkanUtil.
Make Buffer able to initialize itself.
* More tidy up around VulkanDeviceQueue
* First pass use of VulkanDeviceQueue in VkRenderer
* First pass use of VulkanSwapChain on VkRenderer
* Added depth formats.
Binding for constant and vertex buffers for Vulkan.
* Setting up VkImageView on backbuffers.
* First pass support for setting up vkRenderPass.
* Fixes to work around Vulkan swap chain/verification issues.
* Added support for Pipeline and a pipeline cache.
* Working without waiting - because use of pipeline cache.
* Added support for VkFramebuffer in Vulkan.
* First pass at creating Vulkan graphics pipeline.
* More efforts to get Vulkan to render.
* Small improvement for checking of Binding flags.
* Removed setConstantBuffers from the Renderer interface - so that all resource binding takes place through the BindingState.
To make this work required a 'hack' in render-test main.cpp - so that the constant buffer binding that is needed in some tests is only added when it doesn't clash.
* RendererID -> unified into RendererType. Added getRendererType to Renderer interface.
Added ProjectionStyle, and function to get from RendererType.
Added getIdentityProjection to RendererUtil - to get projection that is the 'identity' - but hits the same pixels for all projection styles.
* Fix build problem on Win32 on Vulkan where should use VK_NULL_HANDLE.
* Improve naming, comments. Remove dead code.
* Remove unwanted comment.
Diffstat (limited to 'tools/render-test/vk-util.h')
| -rw-r--r-- | tools/render-test/vk-util.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/render-test/vk-util.h b/tools/render-test/vk-util.h new file mode 100644 index 000000000..6e2c2388c --- /dev/null +++ b/tools/render-test/vk-util.h @@ -0,0 +1,39 @@ +// vk-util.h +#pragma once + +#include "vk-api.h" +#include "render.h" + +// Macros to make testing vulkan return codes simpler + +/// SLANG_VK_RETURN_ON_FAIL can be used in a similar way to SLANG_RETURN_ON_FAIL macro, except it will turn a vulkan failure into Slang::Result in the process +/// Calls handleFail which on debug builds asserts +#define SLANG_VK_RETURN_ON_FAIL(x) { VkResult _res = x; if (_res != VK_SUCCESS) { return VulkanUtil::handleFail(_res); } } + +/// Is similar to SLANG_VK_RETURN_ON_FAIL, but does not return. Will call checkFail on failure - which asserts on debug builds. +#define SLANG_VK_CHECK(x) { VkResult _res = x; if (_res != VK_SUCCESS) { VulkanUtil::checkFail(_res); } } + +namespace renderer_test { + +// Utility functions for Vulkan +struct VulkanUtil +{ + /// Get the equivalent VkFormat from the format + /// Returns VK_FORMAT_UNDEFINED if a match is not found + static VkFormat getVkFormat(Format format); + + /// Called by SLANG_VK_RETURN_FAIL if a res is a failure. + /// On debug builds this will cause an assertion on failure. + static Slang::Result handleFail(VkResult res); + /// Called when a failure has occurred with SLANG_VK_CHECK - will typically assert. + static void checkFail(VkResult res); + + /// Get the VkPrimitiveTopology for the given topology. + /// Returns VK_PRIMITIVE_TOPOLOGY_MAX_ENUM on failure + static VkPrimitiveTopology getVkPrimitiveTopology(PrimitiveTopology topology); + + /// Returns Slang::Result equivalent of a VkResult + static Slang::Result toSlangResult(VkResult res); +}; + +} // renderer_test |
