Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrhivulkan.cpp File Reference

(73a18c3eba6fe5b4ff80f386028dd892da5944d6)

#include "qrhivulkan_p.h"
#include <qpa/qplatformvulkaninstance.h>
#include "vk_mem_alloc.h"
#include <qmath.h>
#include <QVulkanFunctions>
#include <QtGui/qwindow.h>
#include <private/qvulkandefaultinstance_p.h>
#include <optional>
Include dependency graph for qrhivulkan.cpp:

Go to the source code of this file.

Classes

struct  MultiViewRenderPassSetupHelper
struct  QVkPipelineCacheDataHeader

Macros

#define VMA_IMPLEMENTATION
#define VMA_DYNAMIC_VULKAN_FUNCTIONS   1
#define VMA_STATIC_VULKAN_FUNCTIONS   0
#define VMA_RECORDING_ENABLED   0
#define VMA_DEDICATED_ALLOCATION   0
#define VMA_ASSERT(expr)
#define VMA_LEAK_LOG_FORMAT(format, ...)

Functions

template<typename... Args>
static void debugVmaLeak (const char *format, Args &&... args)
template<class Int>
Int aligned (Int v, Int byteAlign)
 \variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetInstanceProcAddr (VkInstance, const char *pName)
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetDeviceProcAddr (VkDevice device, const char *pName)
static VmaAllocation toVmaAllocation (QVkAlloc a)
static VmaAllocator toVmaAllocator (QVkAllocator a)
static bool qvk_debug_filter (QVulkanInstance::DebugMessageSeverityFlags severity, QVulkanInstance::DebugMessageTypeFlags type, const void *callbackData)
static QRhiDriverInfo::DeviceType toRhiDeviceType (VkPhysicalDeviceType type)
static void fillDriverInfo (QRhiDriverInfo *info, const VkPhysicalDeviceProperties &physDevProperties)
template<typename T>
static void addToChain (T *head, void *entry)
static VkFormat toVkTextureFormat (QRhiTexture::Format format, QRhiTexture::Flags flags)
static QRhiTexture::Format swapchainReadbackTextureFormat (VkFormat format, QRhiTexture::Flags *flags)
static constexpr bool isDepthTextureFormat (QRhiTexture::Format format)
static constexpr bool isStencilTextureFormat (QRhiTexture::Format format)
static constexpr VkImageAspectFlags aspectMaskForTextureFormat (QRhiTexture::Format format)
static void fillRenderPassCreateInfo (VkRenderPassCreateInfo *rpInfo, VkSubpassDescription *subpassDesc, QVkRenderPassDescriptor *rpD)
static QRhiPassResourceTracker::UsageState toPassTrackerUsageState (const QVkBuffer::UsageState &bufUsage)
static QRhiPassResourceTracker::UsageState toPassTrackerUsageState (const QVkTexture::UsageState &texUsage)
template<typename T>
void qrhivk_accumulateComputeResource (T *writtenResources, QRhiResource *resource, QRhiShaderResourceBinding::Type bindingType, int loadTypeVal, int storeTypeVal, int loadStoreTypeVal)
static bool accessIsWrite (VkAccessFlags access)
static void qrhivk_releaseBuffer (const QRhiVulkan::DeferredReleaseEntry &e, void *allocator)
static void qrhivk_releaseRenderBuffer (const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df)
static void qrhivk_releaseTexture (const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df, void *allocator)
static void qrhivk_releaseSampler (const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df)
static VkAccessFlags toVkAccess (QRhiPassResourceTracker::BufferAccess access)
static VkPipelineStageFlags toVkPipelineStage (QRhiPassResourceTracker::BufferStage stage)
static QVkBuffer::UsageState toVkBufferUsageState (QRhiPassResourceTracker::UsageState usage)
static VkImageLayout toVkLayout (QRhiPassResourceTracker::TextureAccess access)
static VkAccessFlags toVkAccess (QRhiPassResourceTracker::TextureAccess access)
static VkPipelineStageFlags toVkPipelineStage (QRhiPassResourceTracker::TextureStage stage)
static QVkTexture::UsageState toVkTextureUsageState (QRhiPassResourceTracker::UsageState usage)
static QVkRenderTargetDatamaybeRenderTargetData (QVkCommandBuffer *cbD)
static VkBufferUsageFlagBits toVkBufferUsage (QRhiBuffer::UsageFlags usage)
static VkFilter toVkFilter (QRhiSampler::Filter f)
static VkSamplerMipmapMode toVkMipmapMode (QRhiSampler::Filter f)
static VkSamplerAddressMode toVkAddressMode (QRhiSampler::AddressMode m)
static VkShaderStageFlagBits toVkShaderStage (QRhiShaderStage::Type type)
static VkFormat toVkAttributeFormat (QRhiVertexInputAttribute::Format format)
static VkPrimitiveTopology toVkTopology (QRhiGraphicsPipeline::Topology t)
static VkCullModeFlags toVkCullMode (QRhiGraphicsPipeline::CullMode c)
static VkFrontFace toVkFrontFace (QRhiGraphicsPipeline::FrontFace f)
static VkColorComponentFlags toVkColorComponents (QRhiGraphicsPipeline::ColorMask c)
static VkBlendFactor toVkBlendFactor (QRhiGraphicsPipeline::BlendFactor f)
static VkBlendOp toVkBlendOp (QRhiGraphicsPipeline::BlendOp op)
static VkCompareOp toVkCompareOp (QRhiGraphicsPipeline::CompareOp op)
static VkStencilOp toVkStencilOp (QRhiGraphicsPipeline::StencilOp op)
static VkPolygonMode toVkPolygonMode (QRhiGraphicsPipeline::PolygonMode mode)
static void fillVkStencilOpState (VkStencilOpState *dst, const QRhiGraphicsPipeline::StencilOpState &src)
static VkDescriptorType toVkDescriptorType (const QRhiShaderResourceBinding::Data *b)
static VkShaderStageFlags toVkShaderStageFlags (QRhiShaderResourceBinding::StageFlags stage)
static VkCompareOp toVkTextureCompareOp (QRhiSampler::CompareOp op)
static bool attachmentDescriptionEquals (const VkAttachmentDescription &a, const VkAttachmentDescription &b)
static bool hdrFormatMatchesVkSurfaceFormat (QRhiSwapChain::Format f, const VkSurfaceFormatKHR &s)
static bool isSrgbFormat (VkFormat format)

Variables

static QVulkanInstanceglobalVulkanInstance
struct { 
   VkSampleCountFlagBits   mask 
   int   count 
qvk_sampleCounts []

Macro Definition Documentation

◆ VMA_ASSERT

#define VMA_ASSERT ( expr)
Value:
Q_ASSERT(expr)
#define Q_ASSERT(cond)
Definition qrandom.cpp:48

Definition at line 15 of file qrhivulkan.cpp.

◆ VMA_DEDICATED_ALLOCATION

#define VMA_DEDICATED_ALLOCATION   0

Definition at line 11 of file qrhivulkan.cpp.

◆ VMA_DYNAMIC_VULKAN_FUNCTIONS

#define VMA_DYNAMIC_VULKAN_FUNCTIONS   1

Definition at line 8 of file qrhivulkan.cpp.

◆ VMA_IMPLEMENTATION

#define VMA_IMPLEMENTATION

Definition at line 7 of file qrhivulkan.cpp.

◆ VMA_LEAK_LOG_FORMAT

#define VMA_LEAK_LOG_FORMAT ( format,
... )
Value:
debugVmaLeak(format, __VA_ARGS__)
static void debugVmaLeak(const char *format, Args &&... args)
EGLint EGLint EGLint format

Definition at line 34 of file qrhivulkan.cpp.

◆ VMA_RECORDING_ENABLED

#define VMA_RECORDING_ENABLED   0

Definition at line 10 of file qrhivulkan.cpp.

◆ VMA_STATIC_VULKAN_FUNCTIONS

#define VMA_STATIC_VULKAN_FUNCTIONS   0

Definition at line 9 of file qrhivulkan.cpp.

Function Documentation

◆ accessIsWrite()

bool accessIsWrite ( VkAccessFlags access)
inlinestatic

Definition at line 3794 of file qrhivulkan.cpp.

◆ addToChain()

template<typename T>
void addToChain ( T * head,
void * entry )
inlinestatic

Definition at line 519 of file qrhivulkan.cpp.

◆ aligned()

template<class Int>
Int aligned ( Int v,
Int byteAlign )
inline

\variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::waitSemaphores

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::signalSemaphoreCount

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::signalSemaphores

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::presentWaitSemaphoreCount

When non-zero, this applies to the next vkQueuePresentKHR() call. See \l{https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPresentInfoKHR.html}{VkPresentInfoKHR} for details.

\variable QRhiVulkanQueueSubmitParams::presentWaitSemaphores

See \l{https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPresentInfoKHR.html}{VkPresentInfoKHR} for details.

Definition at line 372 of file qrhivulkan.cpp.

◆ aspectMaskForTextureFormat()

constexpr VkImageAspectFlags aspectMaskForTextureFormat ( QRhiTexture::Format format)
inlinestaticconstexpr

Definition at line 1479 of file qrhivulkan.cpp.

◆ attachmentDescriptionEquals()

bool attachmentDescriptionEquals ( const VkAttachmentDescription & a,
const VkAttachmentDescription & b )
inlinestatic

Definition at line 7486 of file qrhivulkan.cpp.

◆ debugVmaLeak()

template<typename... Args>
void debugVmaLeak ( const char * format,
Args &&... args )
static

Definition at line 22 of file qrhivulkan.cpp.

◆ fillDriverInfo()

void fillDriverInfo ( QRhiDriverInfo * info,
const VkPhysicalDeviceProperties & physDevProperties )
inlinestatic

Definition at line 510 of file qrhivulkan.cpp.

◆ fillRenderPassCreateInfo()

void fillRenderPassCreateInfo ( VkRenderPassCreateInfo * rpInfo,
VkSubpassDescription * subpassDesc,
QVkRenderPassDescriptor * rpD )
static

Definition at line 1845 of file qrhivulkan.cpp.

References QVkRenderPassDescriptor::hasDepthStencil.

◆ fillVkStencilOpState()

void fillVkStencilOpState ( VkStencilOpState * dst,
const QRhiGraphicsPipeline::StencilOpState & src )
inlinestatic

Definition at line 6682 of file qrhivulkan.cpp.

◆ hdrFormatMatchesVkSurfaceFormat()

bool hdrFormatMatchesVkSurfaceFormat ( QRhiSwapChain::Format f,
const VkSurfaceFormatKHR & s )
inlinestatic

Definition at line 8687 of file qrhivulkan.cpp.

◆ isDepthTextureFormat()

constexpr bool isDepthTextureFormat ( QRhiTexture::Format format)
inlinestaticconstexpr

Definition at line 1452 of file qrhivulkan.cpp.

◆ isSrgbFormat()

bool isSrgbFormat ( VkFormat format)
inlinestatic

Definition at line 8770 of file qrhivulkan.cpp.

◆ isStencilTextureFormat()

constexpr bool isStencilTextureFormat ( QRhiTexture::Format format)
inlinestaticconstexpr

Definition at line 1467 of file qrhivulkan.cpp.

◆ maybeRenderTargetData()

QVkRenderTargetData * maybeRenderTargetData ( QVkCommandBuffer * cbD)
inlinestatic

◆ qrhivk_accumulateComputeResource()

template<typename T>
void qrhivk_accumulateComputeResource ( T * writtenResources,
QRhiResource * resource,
QRhiShaderResourceBinding::Type bindingType,
int loadTypeVal,
int storeTypeVal,
int loadStoreTypeVal )
inline

Definition at line 3456 of file qrhivulkan.cpp.

◆ qrhivk_releaseBuffer()

void qrhivk_releaseBuffer ( const QRhiVulkan::DeferredReleaseEntry & e,
void * allocator )
static

Definition at line 4593 of file qrhivulkan.cpp.

References QVK_FRAMES_IN_FLIGHT.

Referenced by QRhiVulkan::executeDeferredReleases().

Here is the caller graph for this function:

◆ qrhivk_releaseRenderBuffer()

void qrhivk_releaseRenderBuffer ( const QRhiVulkan::DeferredReleaseEntry & e,
VkDevice dev,
QVulkanDeviceFunctions * df )
static

Definition at line 4601 of file qrhivulkan.cpp.

◆ qrhivk_releaseSampler()

void qrhivk_releaseSampler ( const QRhiVulkan::DeferredReleaseEntry & e,
VkDevice dev,
QVulkanDeviceFunctions * df )
static

Definition at line 4620 of file qrhivulkan.cpp.

◆ qrhivk_releaseTexture()

void qrhivk_releaseTexture ( const QRhiVulkan::DeferredReleaseEntry & e,
VkDevice dev,
QVulkanDeviceFunctions * df,
void * allocator )
static

Definition at line 4608 of file qrhivulkan.cpp.

◆ qvk_debug_filter()

bool qvk_debug_filter ( QVulkanInstance::DebugMessageSeverityFlags severity,
QVulkanInstance::DebugMessageTypeFlags type,
const void * callbackData )
static

Definition at line 461 of file qrhivulkan.cpp.

◆ swapchainReadbackTextureFormat()

QRhiTexture::Format swapchainReadbackTextureFormat ( VkFormat format,
QRhiTexture::Flags * flags )
inlinestatic

Definition at line 1424 of file qrhivulkan.cpp.

◆ toPassTrackerUsageState() [1/2]

QRhiPassResourceTracker::UsageState toPassTrackerUsageState ( const QVkBuffer::UsageState & bufUsage)
inlinestatic

Definition at line 3108 of file qrhivulkan.cpp.

References QRhiPassResourceTracker::UsageState::access, QRhiPassResourceTracker::UsageState::layout, and QRhiPassResourceTracker::UsageState::stage.

Referenced by QRhiVulkan::trackedRegisterBuffer().

Here is the caller graph for this function:

◆ toPassTrackerUsageState() [2/2]

QRhiPassResourceTracker::UsageState toPassTrackerUsageState ( const QVkTexture::UsageState & texUsage)
inlinestatic

Definition at line 3117 of file qrhivulkan.cpp.

References QRhiPassResourceTracker::UsageState::access, QRhiPassResourceTracker::UsageState::layout, and QRhiPassResourceTracker::UsageState::stage.

Referenced by QRhiVulkan::trackedRegisterTexture().

Here is the caller graph for this function:

◆ toRhiDeviceType()

QRhiDriverInfo::DeviceType toRhiDeviceType ( VkPhysicalDeviceType type)
inlinestatic

Definition at line 492 of file qrhivulkan.cpp.

◆ toVkAccess() [1/2]

VkAccessFlags toVkAccess ( QRhiPassResourceTracker::BufferAccess access)
inlinestatic

Definition at line 4958 of file qrhivulkan.cpp.

◆ toVkAccess() [2/2]

VkAccessFlags toVkAccess ( QRhiPassResourceTracker::TextureAccess access)
inlinestatic

Definition at line 5038 of file qrhivulkan.cpp.

References QRhiPassResourceTracker::TexShadingRate.

◆ toVkAddressMode()

VkSamplerAddressMode toVkAddressMode ( QRhiSampler::AddressMode m)
inlinestatic

Definition at line 6400 of file qrhivulkan.cpp.

◆ toVkAttributeFormat()

VkFormat toVkAttributeFormat ( QRhiVertexInputAttribute::Format format)
inlinestatic

Definition at line 6434 of file qrhivulkan.cpp.

◆ toVkBlendFactor()

VkBlendFactor toVkBlendFactor ( QRhiGraphicsPipeline::BlendFactor f)
inlinestatic

Definition at line 6558 of file qrhivulkan.cpp.

◆ toVkBlendOp()

VkBlendOp toVkBlendOp ( QRhiGraphicsPipeline::BlendOp op)
inlinestatic

Definition at line 6604 of file qrhivulkan.cpp.

◆ toVkBufferUsage()

VkBufferUsageFlagBits toVkBufferUsage ( QRhiBuffer::UsageFlags usage)
inlinestatic

Definition at line 6360 of file qrhivulkan.cpp.

◆ toVkBufferUsageState()

◆ toVkColorComponents()

VkColorComponentFlags toVkColorComponents ( QRhiGraphicsPipeline::ColorMask c)
inlinestatic

Definition at line 6544 of file qrhivulkan.cpp.

◆ toVkCompareOp()

VkCompareOp toVkCompareOp ( QRhiGraphicsPipeline::CompareOp op)
inlinestatic

Definition at line 6622 of file qrhivulkan.cpp.

◆ toVkCullMode()

VkCullModeFlags toVkCullMode ( QRhiGraphicsPipeline::CullMode c)
inlinestatic

Definition at line 6518 of file qrhivulkan.cpp.

◆ toVkDescriptorType()

VkDescriptorType toVkDescriptorType ( const QRhiShaderResourceBinding::Data * b)
inlinestatic

Definition at line 6690 of file qrhivulkan.cpp.

◆ toVkFilter()

VkFilter toVkFilter ( QRhiSampler::Filter f)
inlinestatic

Definition at line 6374 of file qrhivulkan.cpp.

◆ toVkFrontFace()

VkFrontFace toVkFrontFace ( QRhiGraphicsPipeline::FrontFace f)
inlinestatic

Definition at line 6532 of file qrhivulkan.cpp.

◆ toVkLayout()

VkImageLayout toVkLayout ( QRhiPassResourceTracker::TextureAccess access)
inlinestatic

Definition at line 5012 of file qrhivulkan.cpp.

◆ toVkMipmapMode()

VkSamplerMipmapMode toVkMipmapMode ( QRhiSampler::Filter f)
inlinestatic

Definition at line 6386 of file qrhivulkan.cpp.

◆ toVkPipelineStage() [1/2]

VkPipelineStageFlags toVkPipelineStage ( QRhiPassResourceTracker::BufferStage stage)
inlinestatic

Definition at line 4980 of file qrhivulkan.cpp.

◆ toVkPipelineStage() [2/2]

VkPipelineStageFlags toVkPipelineStage ( QRhiPassResourceTracker::TextureStage stage)
inlinestatic

Definition at line 5062 of file qrhivulkan.cpp.

◆ toVkPolygonMode()

VkPolygonMode toVkPolygonMode ( QRhiGraphicsPipeline::PolygonMode mode)
inlinestatic

Definition at line 6670 of file qrhivulkan.cpp.

◆ toVkShaderStage()

VkShaderStageFlagBits toVkShaderStage ( QRhiShaderStage::Type type)
inlinestatic

Definition at line 6414 of file qrhivulkan.cpp.

◆ toVkShaderStageFlags()

VkShaderStageFlags toVkShaderStageFlags ( QRhiShaderResourceBinding::StageFlags stage)
inlinestatic

Definition at line 6721 of file qrhivulkan.cpp.

◆ toVkStencilOp()

VkStencilOp toVkStencilOp ( QRhiGraphicsPipeline::StencilOp op)
inlinestatic

Definition at line 6646 of file qrhivulkan.cpp.

◆ toVkTextureCompareOp()

VkCompareOp toVkTextureCompareOp ( QRhiSampler::CompareOp op)
inlinestatic

Definition at line 6739 of file qrhivulkan.cpp.

◆ toVkTextureFormat()

VkFormat toVkTextureFormat ( QRhiTexture::Format format,
QRhiTexture::Flags flags )
inlinestatic

Definition at line 1307 of file qrhivulkan.cpp.

◆ toVkTextureUsageState()

◆ toVkTopology()

VkPrimitiveTopology toVkTopology ( QRhiGraphicsPipeline::Topology t)
inlinestatic

Definition at line 6496 of file qrhivulkan.cpp.

◆ toVmaAllocation()

VmaAllocation toVmaAllocation ( QVkAlloc a)
inlinestatic

Definition at line 389 of file qrhivulkan.cpp.

◆ toVmaAllocator()

VmaAllocator toVmaAllocator ( QVkAllocator a)
inlinestatic

Definition at line 394 of file qrhivulkan.cpp.

◆ wrap_vkGetDeviceProcAddr()

VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetDeviceProcAddr ( VkDevice device,
const char * pName )
static

Definition at line 384 of file qrhivulkan.cpp.

◆ wrap_vkGetInstanceProcAddr()

VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL wrap_vkGetInstanceProcAddr ( VkInstance ,
const char * pName )
static

Definition at line 379 of file qrhivulkan.cpp.

Variable Documentation

◆ count

int count

Definition at line 4736 of file qrhivulkan.cpp.

◆ globalVulkanInstance

QVulkanInstance * globalVulkanInstance
static

Definition at line 377 of file qrhivulkan.cpp.

◆ mask

VkSampleCountFlagBits mask

Definition at line 4735 of file qrhivulkan.cpp.

◆ [struct]

struct { ... } qvk_sampleCounts
Initial value:
= {
{ VK_SAMPLE_COUNT_1_BIT, 1 },
{ VK_SAMPLE_COUNT_2_BIT, 2 },
{ VK_SAMPLE_COUNT_4_BIT, 4 },
{ VK_SAMPLE_COUNT_8_BIT, 8 },
{ VK_SAMPLE_COUNT_16_BIT, 16 },
{ VK_SAMPLE_COUNT_32_BIT, 32 },
{ VK_SAMPLE_COUNT_64_BIT, 64 }
}