|
Rendu
A lightweight rendering engine for experimentations
|
Utility functions for the Vulkan backend. More...
Functions | |
| bool | checkLayersSupport (const std::vector< const char * > &requestedLayers) |
| bool | checkExtensionsSupport (const std::vector< const char * > &requestedExtensions) |
| std::vector< const char * > | getRequiredInstanceExtensions (bool enableDebugMarkers, bool enablePortability) |
| bool | checkDeviceExtensionsSupport (VkPhysicalDevice device, const std::vector< const char * > &requestedExtensions, bool &hasPortability) |
| bool | getQueueFamilies (VkPhysicalDevice device, VkSurfaceKHR surface, int &graphicsFamily, int &presentFamily) |
| Layout | convertFormat (const VkFormat &format) |
| Layout | findSupportedFormat (const VkPhysicalDevice &physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) |
| void | typesFromShape (const TextureShape &shape, VkImageType &imgType, VkImageViewType &viewType) |
| VkCommandBuffer | beginSyncOperations (GPUContext &context) |
| void | endSyncOperations (VkCommandBuffer &commandBuffer, GPUContext &context) |
| void | imageLayoutBarrier (VkCommandBuffer &commandBuffer, GPUTexture &texture, VkImageLayout newLayout, uint mipStart, uint mipCount, uint layerStart, uint layerCount) |
| void | mipLayoutBarrier (VkCommandBuffer &commandBuffer, const Texture &texture, VkImageLayout newLayout, uint mip) |
| void | textureLayoutBarrier (VkCommandBuffer &commandBuffer, const Texture &texture, VkImageLayout newLayout) |
| void | createCommandBuffers (GPUContext &context, uint count) |
| void | checkResult (VkResult status) |
| VkSamplerAddressMode | getGPUWrapping (Wrap mode) |
| void | getGPUFilters (Filter filtering, VkFilter &imgFiltering, VkSamplerMipmapMode &mipFiltering) |
| unsigned int | getGPULayout (Layout typedFormat, VkFormat &format) |
| glm::uvec2 | copyTextureRegionToBuffer (VkCommandBuffer &commandBuffer, const Texture &srcTexture, std::shared_ptr< Buffer > &dstBuffer, uint mipStart, uint mipCount, uint layerStart, uint layerCount, const glm::uvec2 &offset, const glm::uvec2 &size) |
| void | blitTexture (VkCommandBuffer &commandBuffer, const Texture &src, const Texture &dst, uint mipStartSrc, uint mipStartDst, uint mipCount, uint layerStartSrc, uint layerStartDst, uint layerCount, const glm::uvec2 &srcBaseOffset, const glm::uvec2 &srcBaseSize, const glm::uvec2 &dstBaseOffset, const glm::uvec2 &dstBaseSize, Filter filter) |
| void | setDebugName (GPUContext &context, VkObjectType type, uint64_t handle, const char *format,...) |
Utility functions for the Vulkan backend.
| VkCommandBuffer VkUtils::beginSyncOperations | ( | GPUContext & | context | ) |
Start a one-shot command buffer.
| context | the GPU internal context |
| void VkUtils::blitTexture | ( | VkCommandBuffer & | commandBuffer, |
| const Texture & | src, | ||
| const Texture & | dst, | ||
| uint | mipStartSrc, | ||
| uint | mipStartDst, | ||
| uint | mipCount, | ||
| uint | layerStartSrc, | ||
| uint | layerStartDst, | ||
| uint | layerCount, | ||
| const glm::uvec2 & | srcBaseOffset, | ||
| const glm::uvec2 & | srcBaseSize, | ||
| const glm::uvec2 & | dstBaseOffset, | ||
| const glm::uvec2 & | dstBaseSize, | ||
| Filter | filter | ||
| ) |
Blit a texture region to another texture region.
| commandBuffer | the command buffer to record the operation on |
| src | the source texture |
| dst | the destination texture |
| mipStartSrc | first mip to copy from |
| mipStartDst | first mip to copy to |
| mipCount | number of mip levels to copy |
| layerStartSrc | first layer to copy from |
| layerStartDst | first layer to copy to |
| layerCount | number of layers to copy |
| srcBaseOffset | top-left corner pixel coordinates of the region to copy from |
| srcBaseSize | pixel dimensions of the region to copy from |
| dstBaseOffset | top-left corner pixel coordinates of the region to copy to |
| dstBaseSize | pixel dimensions of the region to copy to |
| filter | interpolation filtering to apply if regions have different dimensions |
| bool VkUtils::checkDeviceExtensionsSupport | ( | VkPhysicalDevice | device, |
| const std::vector< const char * > & | requestedExtensions, | ||
| bool & | hasPortability | ||
| ) |
Check if the Vulkan device supports some extensions and/or portability.
| device | the physical device handle |
| requestedExtensions | list of extension names |
| hasPortability | will denote if the device support portability |
| bool VkUtils::checkExtensionsSupport | ( | const std::vector< const char * > & | requestedExtensions | ) |
Check if the Vulkan instance supports some extensions.
| requestedExtensions | list of extension names |
| bool VkUtils::checkLayersSupport | ( | const std::vector< const char * > & | requestedLayers | ) |
Check if the Vulkan instance supports some validation layers.
| requestedLayers | list of layer names |
| void VkUtils::checkResult | ( | VkResult | status | ) |
Log a Vulkan return code as a human-readable string.
| status | the status to check |
| Layout VkUtils::convertFormat | ( | const VkFormat & | format | ) |
Convert Vulkan format to Rendu format
| format | Vulkan format |
| glm::uvec2 VkUtils::copyTextureRegionToBuffer | ( | VkCommandBuffer & | commandBuffer, |
| const Texture & | srcTexture, | ||
| std::shared_ptr< Buffer > & | dstBuffer, | ||
| uint | mipStart, | ||
| uint | mipCount, | ||
| uint | layerStart, | ||
| uint | layerCount, | ||
| const glm::uvec2 & | offset, | ||
| const glm::uvec2 & | size | ||
| ) |
Copy a texture region to a transfer buffer allocated internally.
| commandBuffer | the command buffer to record the operation on |
| srcTexture | the source texture |
| dstBuffer | will point to the destination buffer |
| mipStart | first mip to copy |
| mipCount | number of mip levels to copy |
| layerStart | first layer to copy |
| layerCount | number of layers to copy |
| offset | top-left corner pixel coordinates of the region to copy |
| size | pixel dimensions of the region to copy |
| void VkUtils::createCommandBuffers | ( | GPUContext & | context, |
| uint | count | ||
| ) |
Create per-frame command buffers on the context.
| context | the GPU internal context |
| count | number of command buffers to create |
| void VkUtils::endSyncOperations | ( | VkCommandBuffer & | commandBuffer, |
| GPUContext & | context | ||
| ) |
Finish and submit a one-shot command buffer, waiting for queue completion.
| commandBuffer | the command buffer to complete |
| context | the GPU internal context |
| Layout VkUtils::findSupportedFormat | ( | const VkPhysicalDevice & | physicalDevice, |
| const std::vector< VkFormat > & | candidates, | ||
| VkImageTiling | tiling, | ||
| VkFormatFeatureFlags | features | ||
| ) |
Find the optimal image format from a list based on tiling and feature constraints
| physicalDevice | the physical device handle |
| candidates | list of possible formats to select from |
| tiling | type of tiling to support |
| features | feature flags to support |
| void VkUtils::getGPUFilters | ( | Filter | filtering, |
| VkFilter & | imgFiltering, | ||
| VkSamplerMipmapMode & | mipFiltering | ||
| ) |
Convert a Rendu texture filter to an interpolation and mip map Vulkan filterings.
| filtering | the texture filtering |
| imgFiltering | will contain the corresponding Vulkan image filtering |
| mipFiltering | will contain the corresponding Vulkan mipmap mode |
| unsigned int VkUtils::getGPULayout | ( | Layout | typedFormat, |
| VkFormat & | format | ||
| ) |
Convert a Rendu texture layout to a format and channel count.
| typedFormat | the texture layout |
| format | will contain the corresponding Vulkan format |
| VkSamplerAddressMode VkUtils::getGPUWrapping | ( | Wrap | mode | ) |
Convert a Rendu texture wrapping to a Vulkan address mode.
| mode | the texture wrapping |
| bool VkUtils::getQueueFamilies | ( | VkPhysicalDevice | device, |
| VkSurfaceKHR | surface, | ||
| int & | graphicsFamily, | ||
| int & | presentFamily | ||
| ) |
Query the graphics and present queue families indices.
| device | the physical device handle |
| surface | the display surface |
| graphicsFamily | will contain the graphics queue family index |
| presentFamily | will contain the present queue family index |
| std::vector< const char * > VkUtils::getRequiredInstanceExtensions | ( | bool | enableDebugMarkers, |
| bool | enablePortability | ||
| ) |
Query the instance extensions required by the system (swapchain, debug layers,...)
| enableDebugMarkers | should debug marker extension be included |
| enablePortability | should portability extension be included |
| void VkUtils::imageLayoutBarrier | ( | VkCommandBuffer & | commandBuffer, |
| GPUTexture & | texture, | ||
| VkImageLayout | newLayout, | ||
| uint | mipStart, | ||
| uint | mipCount, | ||
| uint | layerStart, | ||
| uint | layerCount | ||
| ) |
Apply a layout transition barrier to a texture region.
| commandBuffer | the command buffer to record the operation on |
| texture | the texture to transition |
| newLayout | the new layout to apply |
| mipStart | first mip to apply the transition to |
| mipCount | number of mip levels to transition |
| layerStart | first layer to apply the transition to |
| layerCount | number of layers to transition |
| void VkUtils::mipLayoutBarrier | ( | VkCommandBuffer & | commandBuffer, |
| const Texture & | texture, | ||
| VkImageLayout | newLayout, | ||
| uint | mip | ||
| ) |
Apply a layout transition barrier to a whole mip level.
| commandBuffer | the command buffer to record the operation on |
| texture | the texture to transition |
| newLayout | the new layout to apply |
| mip | the mip level to transition |
| void VkUtils::setDebugName | ( | GPUContext & | context, |
| VkObjectType | type, | ||
| uint64_t | handle, | ||
| const char * | format, | ||
| ... | |||
| ) |
Associate a debug name to a Vulkan object for validation layers and captures.
| context | the GPU context |
| type | the type of the object |
| handle | the handle to the object, casted as a raw integer |
| format | name string format |
| ... | name string arguments |
| void VkUtils::textureLayoutBarrier | ( | VkCommandBuffer & | commandBuffer, |
| const Texture & | texture, | ||
| VkImageLayout | newLayout | ||
| ) |
Apply a layout transition barrier to a whole texture.
| commandBuffer | the command buffer to record the operation on |
| texture | the texture to transition |
| newLayout | the new layout to apply |
| void VkUtils::typesFromShape | ( | const TextureShape & | shape, |
| VkImageType & | imgType, | ||
| VkImageViewType & | viewType | ||
| ) |
Convert a Rendu texture shape to an image and image view types.
| shape | the texture shape |
| imgType | will contain the corresponding image type |
| viewType | will contain the corresponding image view type |