summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/anv_query.c56
-rw-r--r--src/vulkan/gen8_cmd_buffer.c27
2 files changed, 53 insertions, 30 deletions
diff --git a/src/vulkan/anv_query.c b/src/vulkan/anv_query.c
index 320d42cb6fd..911b9a41264 100644
--- a/src/vulkan/anv_query.c
+++ b/src/vulkan/anv_query.c
@@ -38,17 +38,22 @@ VkResult anv_CreateQueryPool(
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_query_pool *pool;
VkResult result;
- size_t size;
+ uint32_t slot_size;
+ uint64_t size;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO);
switch (pCreateInfo->queryType) {
case VK_QUERY_TYPE_OCCLUSION:
+ slot_size = sizeof(struct anv_query_pool_slot);
break;
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
return VK_ERROR_INCOMPATIBLE_DRIVER;
+ case VK_QUERY_TYPE_TIMESTAMP:
+ slot_size = sizeof(uint64_t);
+ break;
default:
- unreachable("");
+ assert(!"Invalid query type");
}
pool = anv_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
@@ -56,7 +61,10 @@ VkResult anv_CreateQueryPool(
if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- size = pCreateInfo->entryCount * sizeof(struct anv_query_pool_slot);
+ pool->type = pCreateInfo->queryType;
+ pool->slots = pCreateInfo->entryCount;
+
+ size = pCreateInfo->entryCount * slot_size;
result = anv_bo_init_new(&pool->bo, device, size);
if (result != VK_SUCCESS)
goto fail;
@@ -91,16 +99,14 @@ VkResult anv_GetQueryPoolResults(
VkQueryPool queryPool,
uint32_t startQuery,
uint32_t queryCount,
- size_t* pDataSize,
+ size_t dataSize,
void* pData,
+ VkDeviceSize stride,
VkQueryResultFlags flags)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_query_pool, pool, queryPool);
- struct anv_query_pool_slot *slot = pool->bo.map;
int64_t timeout = INT64_MAX;
- uint32_t *dst32 = pData;
- uint64_t *dst64 = pData;
uint64_t result;
int ret;
@@ -110,12 +116,8 @@ VkResult anv_GetQueryPoolResults(
return VK_ERROR_INCOMPATIBLE_DRIVER;
}
- assert(pool->type == VK_QUERY_TYPE_OCCLUSION);
-
- if (flags & VK_QUERY_RESULT_64_BIT)
- *pDataSize = queryCount * sizeof(uint64_t);
- else
- *pDataSize = queryCount * sizeof(uint32_t);
+ assert(pool->type == VK_QUERY_TYPE_OCCLUSION ||
+ pool->type == VK_QUERY_TYPE_TIMESTAMP);
if (pData == NULL)
return VK_SUCCESS;
@@ -129,15 +131,37 @@ VkResult anv_GetQueryPoolResults(
}
}
+ void *data_end = pData + dataSize;
+
for (uint32_t i = 0; i < queryCount; i++) {
- result = slot[startQuery + i].end - slot[startQuery + i].begin;
+ switch (pool->type) {
+ case VK_QUERY_TYPE_OCCLUSION: {
+ struct anv_query_pool_slot *slot = pool->bo.map;
+ result = slot[startQuery + i].end - slot[startQuery + i].begin;
+ break;
+ }
+ case VK_QUERY_TYPE_PIPELINE_STATISTICS:
+ /* Not yet implemented */
+ break;
+ case VK_QUERY_TYPE_TIMESTAMP: {
+ uint64_t *slot = pool->bo.map;
+ result = slot[startQuery + i];
+ break;
+ }
+ default:
+ assert(!"Invalid query type");
+ }
+
if (flags & VK_QUERY_RESULT_64_BIT) {
- *dst64++ = result;
+ *(uint64_t *)pData = result;
} else {
if (result > UINT32_MAX)
result = UINT32_MAX;
- *dst32++ = result;
+ *(uint32_t *)pData = result;
}
+ pData += stride;
+ if (pData >= data_end)
+ break;
}
return VK_SUCCESS;
diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c
index 23dc9ad5748..6d0ac25b6d8 100644
--- a/src/vulkan/gen8_cmd_buffer.c
+++ b/src/vulkan/gen8_cmd_buffer.c
@@ -854,33 +854,32 @@ void genX(CmdEndQuery)(
void genX(CmdWriteTimestamp)(
VkCommandBuffer commandBuffer,
- VkTimestampType timestampType,
- VkBuffer destBuffer,
- VkDeviceSize destOffset)
+ VkPipelineStageFlagBits pipelineStage,
+ VkQueryPool queryPool,
+ uint32_t entry)
{
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
- ANV_FROM_HANDLE(anv_buffer, buffer, destBuffer);
- struct anv_bo *bo = buffer->bo;
+ ANV_FROM_HANDLE(anv_query_pool, pool, queryPool);
- switch (timestampType) {
- case VK_TIMESTAMP_TYPE_TOP:
+ assert(pool->type == VK_QUERY_TYPE_TIMESTAMP);
+
+ switch (pipelineStage) {
+ case VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT:
anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM),
.RegisterAddress = TIMESTAMP,
- .MemoryAddress = { bo, buffer->offset + destOffset });
+ .MemoryAddress = { &pool->bo, entry * 8 });
anv_batch_emit(&cmd_buffer->batch, GENX(MI_STORE_REGISTER_MEM),
.RegisterAddress = TIMESTAMP + 4,
- .MemoryAddress = { bo, buffer->offset + destOffset + 4 });
+ .MemoryAddress = { &pool->bo, entry * 8 + 4 });
break;
- case VK_TIMESTAMP_TYPE_BOTTOM:
+ default:
+ /* Everything else is bottom-of-pipe */
anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL),
.DestinationAddressType = DAT_PPGTT,
.PostSyncOperation = WriteTimestamp,
.Address = /* FIXME: This is only lower 32 bits */
- { bo, buffer->offset + destOffset });
- break;
-
- default:
+ { &pool->bo, entry * 8 });
break;
}
}