summaryrefslogtreecommitdiff
path: root/tools/render-test/vk-api.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-05-03 14:25:13 -0400
committerGitHub <noreply@github.com>2018-05-03 14:25:13 -0400
commit367f3a78a40731da45ee12b9a18c94707f1d1429 (patch)
tree5993ef627e1a094ea1d401c31e6b00e3c63c308a /tools/render-test/vk-api.h
parent78935493587ec65a199d844327613021667acc1b (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-api.h')
-rw-r--r--tools/render-test/vk-api.h187
1 files changed, 187 insertions, 0 deletions
diff --git a/tools/render-test/vk-api.h b/tools/render-test/vk-api.h
new file mode 100644
index 000000000..1616a4065
--- /dev/null
+++ b/tools/render-test/vk-api.h
@@ -0,0 +1,187 @@
+// vk-api.h
+#pragma once
+
+#include "vk-module.h"
+
+namespace renderer_test {
+
+#define VK_API_GLOBAL_PROCS(x) \
+ x(vkGetInstanceProcAddr) \
+ x(vkCreateInstance) \
+ /* */
+
+#define VK_API_INSTANCE_PROCS(x) \
+ x(vkCreateDevice) \
+ x(vkCreateDebugReportCallbackEXT) \
+ x(vkDestroyDebugReportCallbackEXT) \
+ x(vkDebugReportMessageEXT) \
+ x(vkEnumeratePhysicalDevices) \
+ x(vkGetPhysicalDeviceProperties) \
+ x(vkGetPhysicalDeviceFeatures) \
+ x(vkGetPhysicalDeviceMemoryProperties) \
+ x(vkGetPhysicalDeviceQueueFamilyProperties) \
+ x(vkGetPhysicalDeviceFormatProperties) \
+ x(vkGetDeviceProcAddr) \
+ /* */
+
+#define VK_API_DEVICE_PROCS(x) \
+ x(vkCreateDescriptorPool) \
+ x(vkDestroyDescriptorPool) \
+ x(vkGetDeviceQueue) \
+ x(vkQueueSubmit) \
+ x(vkQueueWaitIdle) \
+ x(vkCreateBuffer) \
+ x(vkGetBufferMemoryRequirements) \
+ x(vkAllocateMemory) \
+ x(vkBindBufferMemory) \
+ x(vkMapMemory) \
+ x(vkUnmapMemory) \
+ x(vkCmdCopyBuffer) \
+ x(vkDestroyBuffer) \
+ x(vkFreeMemory) \
+ x(vkCreateDescriptorSetLayout) \
+ x(vkDestroyDescriptorSetLayout) \
+ x(vkAllocateDescriptorSets) \
+ x(vkUpdateDescriptorSets) \
+ x(vkCreatePipelineLayout) \
+ x(vkDestroyPipelineLayout) \
+ x(vkCreateComputePipelines) \
+ x(vkCreateGraphicsPipelines) \
+ x(vkDestroyPipeline) \
+ x(vkCreateShaderModule) \
+ x(vkDestroyShaderModule) \
+ x(vkCreateFramebuffer) \
+ x(vkDestroyFramebuffer) \
+ \
+ x(vkCmdBindPipeline) \
+ x(vkCmdBindDescriptorSets) \
+ x(vkCmdDispatch) \
+ x(vkCmdDraw) \
+ x(vkCmdSetScissor) \
+ x(vkCmdSetViewport) \
+ x(vkCmdBindVertexBuffers) \
+ x(vkCmdBindIndexBuffer) \
+ x(vkCmdBeginRenderPass) \
+ x(vkCmdEndRenderPass) \
+ \
+ x(vkCreateFence) \
+ x(vkDestroyFence) \
+ x(vkResetFences) \
+ x(vkGetFenceStatus) \
+ x(vkWaitForFences) \
+ \
+ x(vkCreateSemaphore) \
+ x(vkDestroySemaphore) \
+ \
+ x(vkCreateEvent) \
+ x(vkDestroyEvent) \
+ x(vkGetEventStatus) \
+ x(vkSetEvent) \
+ x(vkResetEvent) \
+ \
+ x(vkCreateCommandPool) \
+ x(vkDestroyCommandPool) \
+ \
+ x(vkFreeCommandBuffers) \
+ x(vkAllocateCommandBuffers) \
+ x(vkBeginCommandBuffer) \
+ x(vkEndCommandBuffer) \
+ x(vkResetCommandBuffer) \
+ \
+ x(vkCreateImageView) \
+ x(vkDestroyImageView) \
+ \
+ x(vkCreateRenderPass) \
+ x(vkDestroyRenderPass) \
+ /* */
+
+#if SLANG_WINDOWS_FAMILY
+# define VK_API_INSTANCE_PLATFORM_KHR_PROCS(x) \
+ x(vkCreateWin32SurfaceKHR) \
+ /* */
+#else
+# define VK_API_INSTANCE_PLATFORM_KHR_PROCS(x) \
+ x(vkCreateXlibSurfaceKHR) \
+ /* */
+#endif
+
+#define VK_API_INSTANCE_KHR_PROCS(x) \
+ VK_API_INSTANCE_PLATFORM_KHR_PROCS(x) \
+ x(vkGetPhysicalDeviceSurfaceSupportKHR) \
+ x(vkGetPhysicalDeviceSurfaceFormatsKHR) \
+ x(vkGetPhysicalDeviceSurfacePresentModesKHR) \
+ x(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
+ x(vkDestroySurfaceKHR) \
+ /* */
+
+#define VK_API_DEVICE_KHR_PROCS(x) \
+ x(vkQueuePresentKHR) \
+ x(vkCreateSwapchainKHR) \
+ x(vkGetSwapchainImagesKHR) \
+ x(vkDestroySwapchainKHR) \
+ x(vkAcquireNextImageKHR) \
+ /* */
+
+#define VK_API_ALL_GLOBAL_PROCS(x) \
+ VK_API_GLOBAL_PROCS(x)
+
+#define VK_API_ALL_INSTANCE_PROCS(x) \
+ VK_API_INSTANCE_PROCS(x) \
+ VK_API_INSTANCE_KHR_PROCS(x)
+
+#define VK_API_ALL_DEVICE_PROCS(x) \
+ VK_API_DEVICE_PROCS(x) \
+ VK_API_DEVICE_KHR_PROCS(x)
+
+#define VK_API_ALL_PROCS(x) \
+ VK_API_ALL_GLOBAL_PROCS(x) \
+ VK_API_ALL_INSTANCE_PROCS(x) \
+ VK_API_ALL_DEVICE_PROCS(x) \
+ /* */
+
+#define VK_API_DECLARE_PROC(NAME) PFN_##NAME NAME = nullptr;
+
+struct VulkanApi
+{
+ VK_API_ALL_PROCS(VK_API_DECLARE_PROC)
+
+ enum class ProcType
+ {
+ Global,
+ Instance,
+ Device,
+ };
+
+ /// Returns true if all the functions in the class are defined
+ bool areDefined(ProcType type) const;
+
+ /// Sets up global parameters
+ Slang::Result initGlobalProcs(const VulkanModule& module);
+ /// Initialize the instance functions
+ Slang::Result initInstanceProcs(VkInstance instance);
+
+ /// Called before initDevice
+ Slang::Result initPhysicalDevice(VkPhysicalDevice physicalDevice);
+
+ /// Initialize the device functions
+ Slang::Result initDeviceProcs(VkDevice device);
+
+ /// Type bits control which indices are tested against bit 0 for testing at index 0
+ /// properties - a memory type must have all the bits set as passed in
+ /// Returns -1 if couldn't find an appropriate memory type index
+ int findMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) const;
+
+ /// Given queue required flags, finds a queue
+ int findQueue(VkQueueFlags reqFlags) const;
+
+ const VulkanModule* m_module = nullptr; ///< Module this was all loaded from
+ VkInstance m_instance = VK_NULL_HANDLE;
+ VkDevice m_device = VK_NULL_HANDLE;
+ VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE;
+
+ VkPhysicalDeviceProperties m_deviceProperties;
+ VkPhysicalDeviceFeatures m_deviceFeatures;
+ VkPhysicalDeviceMemoryProperties m_deviceMemoryProperties;
+};
+
+} // renderer_test