Skip to content
Permalink
Browse files

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

  • Loading branch information...
kvark authored and dpjudas committed Jul 3, 2019
1 parent 73f4608 commit e7e46f8c7c83ebf01a72da44c9403251eb2d9263
@@ -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 @@ class VulkanCompatibleDevice
VulkanPhysicalDevice *device = nullptr;
int graphicsFamily = -1;
int presentFamily = -1;
bool graphicsTimeQueries = false;
};

class VulkanDevice
@@ -76,6 +77,7 @@ class VulkanDevice

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

0 comments on commit e7e46f8

Please sign in to comment.
You can’t perform that action at this time.