Queries


Queries provide a mechanism to return information about the processing of a sequence of Vulkan commands. Query operations are asynchronous, and as such, their results are not returned immediately. Instead, their results, and their availability status are stored in a Query Pool. The state of these queries can be read back on the host, or copied to a buffer object on the device.

The supported query types are Occlusion Queries, Pipeline Statistics Queries, and Timestamp Queries.

VkResult vkCreateQueryPool( VkDevice const VkQueryPoolCreateInfo* const VkAllocationCallbacks* VkQueryPool* device, pCreateInfo, pAllocator, pQueryPool);

FVulkanQueryPool::FVulkanQueryPool(FVulkanDevice* InDevice, FVulkanCommandBufferManager* CommandBufferManager, uint32 InMaxQueries, VkQueryType InQueryType, bool bInShouldAddReset)

void vkDestroyQueryPool( VkDevice VkQueryPool const VkAllocationCallbacks* device, queryPool, pAllocator);

FVulkanQueryPool::~FVulkanQueryPool()

void vkCmdResetQueryPool( VkCommandBuffer VkQueryPool uint32_t uint32_t commandBuffer, queryPool, firstQuery, queryCount);

void FVulkanCmdBuffer::End()

void FVulkanCommandBufferManager::FlushResetQueryPools()

void FVulkanOcclusionQueryPool::Reset(FVulkanCmdBuffer* InCmdBuffer, uint32 InFrameNumber)

void FVulkanGPUProfiler::BeginFrame()

void vkResetQueryPool( VkDevice VkQueryPool uint32_t uint32_t device, queryPool, firstQuery, queryCount);

void vkCmdBeginQuery( VkCommandBuffer VkQueryPool uint32_t VkQueryControlFlags commandBuffer, queryPool, query, flags);

void FVulkanCommandListContext::RHIBeginRenderQuery(FRHIRenderQuery* QueryRHI)

void vkCmdEndQuery( VkCommandBuffer VkQueryPool uint32_t commandBuffer, queryPool, query);

void FVulkanCommandListContext::RHIEndRenderQuery(FRHIRenderQuery* QueryRHI)

VkResult vkGetQueryPoolResults( VkDevice VkQueryPool uint32_t uint32_t size_t void* VkDeviceSize VkQueryResultFlags device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);

bool FVulkanOcclusionQueryPool::InternalTryGetResults(bool bWait)

void vkCmdCopyQueryPoolResults( VkCommandBuffer VkQueryPool uint32_t uint32_t VkBuffer VkDeviceSize VkDeviceSize VkQueryResultFlags commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);

void FVulkanCmdBuffer::End()

Occlusion Queries

Pipeline Statistics Queries

typedef enum VkQueryPipelineStatisticFlagBits { VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001, VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002, VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004, VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 0x00000008, VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 0x00000010, VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 0x00000020, VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 0x00000040, VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 0x00000080, VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100, VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, } VkQueryPipelineStatisticFlagBits;

Timestamp Queries

void vkCmdWriteTimestamp2( VkCommandBuffer VkPipelineStageFlags2 VkQueryPool uint32_t commandBuffer, stage, queryPool, query); void vkCmdWriteTimestamp( VkCommandBuffer VkPipelineStageFlagBits VkQueryPool uint32_t commandBuffer, pipelineStage, queryPool, query);

typedef enum VkPipelineStageFlagBits { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008, VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010, VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020, VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 0x00002000, VK_PIPELINE_STAGE_HOST_BIT = 0x00004000, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000, // Provided by VK_VERSION_1_3 VK_PIPELINE_STAGE_NONE = 0, } VkPipelineStageFlagBits;

void FVulkanCommandListContext::RHIEndRenderQuery(FRHIRenderQuery* QueryRHI)

void FVulkanGPUTiming::StartTiming(FVulkanCmdBuffer* CmdBuffer)

void FVulkanGPUTiming::EndTiming(FVulkanCmdBuffer* CmdBuffer)

本节教程就到此结束,希望大家继续阅读我之后的教程。

谢谢大家,再见!


原创技术文章,撰写不易,转载请注明出处:电子设备中的画家|王烁 于 2021 年 5 月 10 日发表,原文链接(http://geekfaner.com/shineengine/blog20_Vulkanv1.2_6.html)