vk: Check for the time query support on the graphics queue (#884)

This commit is contained in:
Dzmitry Malyshau 2019-07-03 10:49:06 -04:00 committed by Magnus Norddahl
parent 73f46089cc
commit e7e46f8c7c
3 changed files with 13 additions and 6 deletions

View file

@ -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

View file

@ -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();

View file

@ -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);