mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 15:11:46 +00:00
vk: Check for the time query support on the graphics queue (#884)
This commit is contained in:
parent
73f46089cc
commit
e7e46f8c7c
3 changed files with 13 additions and 6 deletions
|
@ -158,6 +158,7 @@ void VulkanDevice::SelectPhysicalDevice()
|
|||
if (queueFamily.queueCount > 0 && (queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT))
|
||||
{
|
||||
dev.graphicsFamily = i;
|
||||
dev.graphicsTimeQueries = queueFamily.timestampValidBits != 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +206,7 @@ void VulkanDevice::SelectPhysicalDevice()
|
|||
PhysicalDevice = *SupportedDevices[selected].device;
|
||||
graphicsFamily = SupportedDevices[selected].graphicsFamily;
|
||||
presentFamily = SupportedDevices[selected].presentFamily;
|
||||
graphicsTimeQueries = SupportedDevices[selected].graphicsTimeQueries;
|
||||
}
|
||||
|
||||
bool VulkanDevice::SupportsDeviceExtension(const char *ext) const
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
VulkanPhysicalDevice *device = nullptr;
|
||||
int graphicsFamily = -1;
|
||||
int presentFamily = -1;
|
||||
bool graphicsTimeQueries = false;
|
||||
};
|
||||
|
||||
class VulkanDevice
|
||||
|
@ -76,6 +77,7 @@ public:
|
|||
|
||||
int graphicsFamily = -1;
|
||||
int presentFamily = -1;
|
||||
bool graphicsTimeQueries = false;
|
||||
|
||||
private:
|
||||
void CreateInstance();
|
||||
|
|
|
@ -172,11 +172,14 @@ void VulkanFrameBuffer::InitializeState()
|
|||
mRenderState.reset(new VkRenderState());
|
||||
#endif
|
||||
|
||||
QueryPoolBuilder querybuilder;
|
||||
querybuilder.setQueryType(VK_QUERY_TYPE_TIMESTAMP, MaxTimestampQueries);
|
||||
mTimestampQueryPool = querybuilder.create(device);
|
||||
if (device->graphicsTimeQueries)
|
||||
{
|
||||
QueryPoolBuilder querybuilder;
|
||||
querybuilder.setQueryType(VK_QUERY_TYPE_TIMESTAMP, MaxTimestampQueries);
|
||||
mTimestampQueryPool = querybuilder.create(device);
|
||||
|
||||
GetDrawCommands()->resetQueryPool(mTimestampQueryPool.get(), 0, MaxTimestampQueries);
|
||||
GetDrawCommands()->resetQueryPool(mTimestampQueryPool.get(), 0, MaxTimestampQueries);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::Update()
|
||||
|
@ -831,7 +834,7 @@ void VulkanFrameBuffer::PushGroup(const FString &name)
|
|||
if (!gpuStatActive)
|
||||
return;
|
||||
|
||||
if (mNextTimestampQuery < VulkanFrameBuffer::MaxTimestampQueries)
|
||||
if (mNextTimestampQuery < VulkanFrameBuffer::MaxTimestampQueries && device->graphicsTimeQueries)
|
||||
{
|
||||
TimestampQuery q;
|
||||
q.name = name;
|
||||
|
@ -851,7 +854,7 @@ void VulkanFrameBuffer::PopGroup()
|
|||
TimestampQuery &q = timeElapsedQueries[mGroupStack.back()];
|
||||
mGroupStack.pop_back();
|
||||
|
||||
if (mNextTimestampQuery < VulkanFrameBuffer::MaxTimestampQueries)
|
||||
if (mNextTimestampQuery < VulkanFrameBuffer::MaxTimestampQueries && device->graphicsTimeQueries)
|
||||
{
|
||||
q.endIndex = mNextTimestampQuery++;
|
||||
GetDrawCommands()->writeTimestamp(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, mTimestampQueryPool.get(), q.endIndex);
|
||||
|
|
Loading…
Reference in a new issue