]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/vulkan.h
Only mark Result as checked if that specific value was checked
[libs/gl.git] / source / backends / vulkan / vulkan.h
index 373b75aed5284d2f1d6d124b773d67f2e431e60b..c41813fa8a588f4f822942b92eba72c859f913b9 100644 (file)
@@ -85,7 +85,7 @@ public:
        Result(Result &&r): result(r.result), function(r.function) { r.result = VK_SUCCESS; }
        ~Result() noexcept(false) { if(!checked) check(); }
 
-       bool operator==(VkResult r) { checked = true; return result==r; }
+       bool operator==(VkResult r) { bool m = (result==r); checked |= m; return m; }
        void check() { if(result!=VK_SUCCESS) throw Graphics::vulkan_error(result, function); }
 };
 
@@ -106,6 +106,7 @@ private:
        PFN_vkBeginCommandBuffer vkBeginCommandBuffer = 0;  // 6.4
        PFN_vkEndCommandBuffer vkEndCommandBuffer = 0;  // 6.4
        PFN_vkQueueSubmit vkQueueSubmit = 0;  // 6.5
+       PFN_vkCmdExecuteCommands vkCmdExecuteCommands = 0;  // 6.7
        PFN_vkCreateFence vkCreateFence = 0;  // 7.3
        PFN_vkDestroyFence vkDestroyFence = 0;  // 7.3
        PFN_vkGetFenceStatus vkGetFenceStatus = 0;  // 7.3
@@ -133,10 +134,16 @@ private:
        PFN_vkUnmapMemory vkUnmapMemory = 0;  // 11.2.9
        PFN_vkCreateBuffer vkCreateBuffer = 0;  // 12.1
        PFN_vkDestroyBuffer vkDestroyBuffer = 0;  // 12.1
+       PFN_vkCreateImage vkCreateImage = 0;  // 12.3
+       PFN_vkDestroyImage vkDestroyImage = 0;  // 12.3
        PFN_vkCreateImageView vkCreateImageView = 0;  // 12.5
        PFN_vkDestroyImageView vkDestroyImageView = 0;  // 12.5
        PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = 0;  // 12.7
+       PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements = 0;  // 12.7
        PFN_vkBindBufferMemory vkBindBufferMemory = 0;  // 12.7
+       PFN_vkBindImageMemory vkBindImageMemory = 0;  // 12.7
+       PFN_vkCreateSampler vkCreateSampler = 0;  // 13
+       PFN_vkDestroySampler vkDestroySampler = 0;  // 13
        PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout = 0;  // 14.2.1
        PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout = 0;  // 14.2.1
        PFN_vkCreatePipelineLayout vkCreatePipelineLayout = 0;  // 14.2.2
@@ -148,6 +155,8 @@ private:
        PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets = 0;  // 14.2.7
        PFN_vkCmdPushConstants vkCmdPushConstants = 0;  // 14.2.10
        PFN_vkCmdCopyBuffer vkCmdCopyBuffer = 0;  // 19.2
+       PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage = 0;  // 19.4
+       PFN_vkCmdBlitImage vkCmdBlitImage = 0;  // 19.5
        PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer = 0;  // 20.3
        PFN_vkCmdDrawIndexed vkCmdDrawIndexed = 0;  // 20.3
        PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers = 0;  // 21.2
@@ -193,6 +202,9 @@ public:
        Result QueueSubmit(std::uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence) const
        { return { vkQueueSubmit(graphicsQueue, submitCount, pSubmits, handle_cast<::VkFence>(fence)), "vkQueueSubmit" }; }
 
+       void CmdExecuteCommands(VkCommandBuffer commandBuffer, std::uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) const
+       { vkCmdExecuteCommands(handle_cast<::VkCommandBuffer>(commandBuffer), commandBufferCount, handle_cast<const ::VkCommandBuffer *>(pCommandBuffers)); }
+
        // Chapter 7: Synchronization and Cache Control
        Result CreateFence(const VkFenceCreateInfo &rCreateInfo, VkFence &rFence) const
        { return { vkCreateFence(device, &rCreateInfo, 0, handle_cast<::VkFence *>(&rFence)), "vkCreateFence" }; }
@@ -280,6 +292,12 @@ public:
        void DestroyBuffer(VkBuffer image) const
        { vkDestroyBuffer(device, handle_cast<::VkBuffer>(image), 0); }
 
+       Result CreateImage(const VkImageCreateInfo &rCreateInfo, VkImage &rImage) const
+       { return { vkCreateImage(device, &rCreateInfo, 0, handle_cast<::VkImage *>(&rImage)), "vkCreateImage" }; }
+
+       void DestroyImage(VkImage image) const
+       { vkDestroyImage(device, handle_cast<::VkImage>(image), 0); }
+
        Result CreateImageView(const VkImageViewCreateInfo &rCreateInfo, VkImageView &rView) const
        { return { vkCreateImageView(device, &rCreateInfo, 0, handle_cast<::VkImageView *>(&rView)), "vkCreateImageView" }; }
 
@@ -289,9 +307,22 @@ public:
        void GetBufferMemoryRequirements(VkBuffer image, VkMemoryRequirements &rMemoryRequirements) const
        { vkGetBufferMemoryRequirements(device, handle_cast<::VkBuffer>(image), &rMemoryRequirements); }
 
+       void GetImageMemoryRequirements(VkImage image, VkMemoryRequirements &rMemoryRequirements) const
+       { vkGetImageMemoryRequirements(device, handle_cast<::VkImage>(image), &rMemoryRequirements); }
+
        Result BindBufferMemory(VkBuffer image, VkDeviceMemory memory, VkDeviceSize memoryOffset) const
        { return { vkBindBufferMemory(device, handle_cast<::VkBuffer>(image), handle_cast<::VkDeviceMemory>(memory), memoryOffset), "vkBindBufferMemory" }; }
 
+       Result BindImageMemory(VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset) const
+       { return { vkBindImageMemory(device, handle_cast<::VkImage>(image), handle_cast<::VkDeviceMemory>(memory), memoryOffset), "vkBindImageMemory" }; }
+
+       // Chapter 13: Samplers
+       Result CreateSampler(const VkSamplerCreateInfo &rCreateInfo, VkSampler &rSampler) const
+       { return { vkCreateSampler(device, &rCreateInfo, 0, handle_cast<::VkSampler *>(&rSampler)), "vkCreateSampler" }; }
+
+       void DestroySampler(VkSampler sampler) const
+       { vkDestroySampler(device, handle_cast<::VkSampler>(sampler), 0); }
+
        // Chapter 14: Resource Descriptors
        Result CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &rCreateInfo, VkDescriptorSetLayout &rSetLayout) const
        { return { vkCreateDescriptorSetLayout(device, &rCreateInfo, 0, handle_cast<::VkDescriptorSetLayout *>(&rSetLayout)), "vkCreateDescriptorSetLayout" }; }
@@ -327,6 +358,12 @@ public:
        void CmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, std::uint32_t regionCount, const VkBufferCopy *pRegions) const
        { vkCmdCopyBuffer(handle_cast<::VkCommandBuffer>(commandBuffer), handle_cast<::VkBuffer>(srcBuffer), handle_cast<::VkBuffer>(dstBuffer), regionCount, pRegions); }
 
+       void CmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, std::uint32_t regionCount, const VkBufferImageCopy *pRegions) const
+       { vkCmdCopyBufferToImage(handle_cast<::VkCommandBuffer>(commandBuffer), handle_cast<::VkBuffer>(srcBuffer), handle_cast<::VkImage>(dstImage), dstImageLayout, regionCount, pRegions); }
+
+       void CmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) const
+       { vkCmdBlitImage(handle_cast<::VkCommandBuffer>(commandBuffer), handle_cast<::VkImage>(srcImage), srcImageLayout, handle_cast<::VkImage>(dstImage), dstImageLayout, regionCount, pRegions, filter); }
+
        // Chapter 20: Drawing Commands
        void CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) const
        { vkCmdBindIndexBuffer(handle_cast<::VkCommandBuffer>(commandBuffer), handle_cast<::VkBuffer>(buffer), offset, indexType); }