2019-04-22 15:58:27 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
//TODO VkPerformanceQuerySubmitInfoKHR
|
2020-02-23 13:20:32 +01:00
|
|
|
//TODO query test
|
2020-02-22 22:50:53 +01:00
|
|
|
|
2020-02-23 13:20:32 +01:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAcquireProfilingLockKHR(
|
2020-02-22 22:50:53 +01:00
|
|
|
VkDevice device,
|
|
|
|
const VkAcquireProfilingLockInfoKHR* pInfo)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkAcquireProfilingLockKHR);
|
2020-02-22 22:50:53 +01:00
|
|
|
//TODO
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILEEND(rpi_vkAcquireProfilingLockKHR);
|
2020-02-22 22:50:53 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-02-23 13:20:32 +01:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkReleaseProfilingLockKHR(
|
2020-02-22 22:50:53 +01:00
|
|
|
VkDevice device)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkReleaseProfilingLockKHR);
|
2020-02-22 22:50:53 +01:00
|
|
|
//TODO
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILEEND(rpi_vkReleaseProfilingLockKHR);
|
2020-02-22 22:50:53 +01:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateQueryPool(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkDevice device,
|
|
|
|
const VkQueryPoolCreateInfo* pCreateInfo,
|
|
|
|
const VkAllocationCallbacks* pAllocator,
|
|
|
|
VkQueryPool* pQueryPool)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkCreateQueryPool);
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
assert(device);
|
|
|
|
assert(pQueryPool);
|
|
|
|
|
|
|
|
_queryPool* qp = ALLOCATE(sizeof(_queryPool), 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
2019-09-08 00:30:52 +02:00
|
|
|
|
2020-02-24 22:56:14 +01:00
|
|
|
if(pCreateInfo->queryType == VK_QUERY_TYPE_OCCLUSION)
|
2019-09-08 00:30:52 +02:00
|
|
|
{
|
|
|
|
UNSUPPORTED(VK_QUERY_TYPE_OCCLUSION);
|
|
|
|
}
|
2020-02-24 22:56:14 +01:00
|
|
|
else if(pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS)
|
|
|
|
{
|
|
|
|
UNSUPPORTED(VK_QUERY_TYPE_PIPELINE_STATISTICS);
|
|
|
|
}
|
|
|
|
else if(pCreateInfo->queryType == VK_QUERY_TYPE_TIMESTAMP)
|
|
|
|
{
|
|
|
|
UNSUPPORTED(VK_QUERY_TYPE_TIMESTAMP);
|
|
|
|
}
|
2020-02-22 22:50:53 +01:00
|
|
|
else if(pCreateInfo->queryType == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR)
|
|
|
|
{
|
|
|
|
qp->queryCount = pCreateInfo->queryCount;
|
|
|
|
qp->type = pCreateInfo->queryType;
|
|
|
|
qp->queryPool = ALLOCATE(sizeof(_query) * qp->queryCount, 1, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
|
|
|
|
|
|
|
VkQueryPoolPerformanceCreateInfoKHR ci = *(VkQueryPoolPerformanceCreateInfoKHR*)pCreateInfo->pNext;
|
|
|
|
|
|
|
|
for(uint32_t c = 0; c < qp->queryCount; ++c)
|
|
|
|
{
|
|
|
|
assert(ci.counterIndexCount <= VC4_PERFCNT_NUM_EVENTS);
|
|
|
|
qp->queryPool[c].numEnabledCounters = ci.counterIndexCount;
|
|
|
|
memcpy(qp->queryPool[c].enabledCounters, ci.pCounterIndices, sizeof(uint32_t) * ci.counterIndexCount);
|
|
|
|
|
|
|
|
for(uint32_t d = 0; d < ci.counterIndexCount; d += DRM_VC4_MAX_PERF_COUNTERS)
|
|
|
|
{
|
2020-02-24 20:45:11 +01:00
|
|
|
qp->queryPool[c].perfmonIDs[d / DRM_VC4_MAX_PERF_COUNTERS] = vc4_create_perfmon(controlFd, &qp->queryPool[c].enabledCounters[d], qp->queryPool[c].numEnabledCounters > DRM_VC4_MAX_PERF_COUNTERS ? DRM_VC4_MAX_PERF_COUNTERS : qp->queryPool[c].numEnabledCounters);
|
2020-02-24 22:45:47 +01:00
|
|
|
memset(&qp->queryPool[c].counterValues[d / DRM_VC4_MAX_PERF_COUNTERS][0], 0, sizeof(uint64_t) * DRM_VC4_MAX_PERF_COUNTERS);
|
2020-02-22 22:50:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pQueryPool = qp;
|
|
|
|
}
|
2019-09-08 00:30:52 +02:00
|
|
|
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILEEND(rpi_vkCreateQueryPool);
|
2019-04-22 15:58:27 +02:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdResetQueryPool(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t firstQuery,
|
|
|
|
uint32_t queryCount)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkCmdResetQueryPool);
|
2019-09-08 00:30:52 +02:00
|
|
|
//TODO
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILEEND(rpi_vkCmdResetQueryPool);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkDestroyQueryPool(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkDevice device,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
const VkAllocationCallbacks* pAllocator)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkDestroyQueryPool);
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
assert(device);
|
|
|
|
assert(queryPool);
|
|
|
|
|
|
|
|
_queryPool* qp = queryPool;
|
|
|
|
|
|
|
|
for(uint32_t c = 0; c < qp->queryCount; ++c)
|
|
|
|
{
|
2020-02-23 14:29:01 +01:00
|
|
|
for(uint32_t d = 0; d < qp->queryPool[c].numEnabledCounters; d += DRM_VC4_MAX_PERF_COUNTERS)
|
2020-02-22 22:50:53 +01:00
|
|
|
{
|
2020-02-24 20:45:11 +01:00
|
|
|
vc4_destroy_perfmon(controlFd, qp->queryPool[c].perfmonIDs[d / DRM_VC4_MAX_PERF_COUNTERS]);
|
2020-02-22 22:50:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FREE(qp->queryPool);
|
2020-05-18 20:39:33 +02:00
|
|
|
|
|
|
|
PROFILEEND(rpi_vkDestroyQueryPool);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdEndQuery(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t query)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkCmdEndQuery);
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
assert(commandBuffer);
|
|
|
|
assert(queryPool);
|
|
|
|
|
2020-02-24 22:45:47 +01:00
|
|
|
_commandBuffer* cmdBuf = commandBuffer;
|
|
|
|
|
|
|
|
cmdBuf->perfmonID = 0;
|
2020-05-18 20:39:33 +02:00
|
|
|
|
|
|
|
PROFILEEND(rpi_vkCmdEndQuery);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBeginQuery(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t query,
|
|
|
|
VkQueryControlFlags flags)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkCmdBeginQuery);
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
assert(commandBuffer);
|
|
|
|
assert(queryPool);
|
|
|
|
|
2020-02-24 22:45:47 +01:00
|
|
|
//TODO flags
|
|
|
|
|
|
|
|
_commandBuffer* cmdBuf = commandBuffer;
|
|
|
|
_queryPool* qp = queryPool;
|
|
|
|
|
|
|
|
|
|
|
|
//pass id will select the perfmon at submit
|
|
|
|
cmdBuf->perfmonID = qp->queryPool[query].perfmonIDs;
|
2020-05-18 20:39:33 +02:00
|
|
|
|
|
|
|
PROFILEEND(rpi_vkCmdBeginQuery);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdCopyQueryPoolResults(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t firstQuery,
|
|
|
|
uint32_t queryCount,
|
|
|
|
VkBuffer dstBuffer,
|
|
|
|
VkDeviceSize dstOffset,
|
|
|
|
VkDeviceSize stride,
|
|
|
|
VkQueryResultFlags flags)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkCmdCopyQueryPoolResults);
|
|
|
|
|
2019-09-08 00:30:52 +02:00
|
|
|
//TODO
|
2020-05-18 20:39:33 +02:00
|
|
|
|
|
|
|
PROFILEEND(rpi_vkCmdCopyQueryPoolResults);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkGetQueryPoolResults(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkDevice device,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t firstQuery,
|
|
|
|
uint32_t queryCount,
|
|
|
|
size_t dataSize,
|
|
|
|
void* pData,
|
|
|
|
VkDeviceSize stride,
|
|
|
|
VkQueryResultFlags flags)
|
|
|
|
{
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILESTART(rpi_vkGetQueryPoolResults);
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
assert(device);
|
|
|
|
assert(queryPool);
|
|
|
|
|
|
|
|
//TODO flags
|
2020-02-23 14:29:01 +01:00
|
|
|
//TODO return values etc.
|
2020-02-22 22:50:53 +01:00
|
|
|
|
|
|
|
_queryPool* qp = queryPool;
|
|
|
|
|
|
|
|
for(uint32_t c = firstQuery; c < queryCount; ++c)
|
|
|
|
{
|
2020-02-23 14:29:01 +01:00
|
|
|
for(uint32_t d = 0; d < qp->queryPool[c].numEnabledCounters; d += DRM_VC4_MAX_PERF_COUNTERS)
|
|
|
|
{
|
2020-02-24 22:45:47 +01:00
|
|
|
vc4_perfmon_get_values(controlFd, qp->queryPool[c].perfmonIDs[d / DRM_VC4_MAX_PERF_COUNTERS], &qp->queryPool[c].counterValues[d / DRM_VC4_MAX_PERF_COUNTERS][0]);
|
2020-02-23 14:29:01 +01:00
|
|
|
}
|
|
|
|
|
2020-02-22 22:50:53 +01:00
|
|
|
uint32_t counter = 0;
|
|
|
|
for(uint32_t d = 0; d < dataSize; d += stride, ++counter)
|
|
|
|
{
|
|
|
|
VkPerformanceCounterResultKHR* result = ((char*)pData) + d;
|
2020-02-24 22:45:47 +01:00
|
|
|
result->uint64 = qp->queryPool[c].counterValues[counter / DRM_VC4_MAX_PERF_COUNTERS][counter % DRM_VC4_MAX_PERF_COUNTERS];
|
2020-02-22 22:50:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-18 20:39:33 +02:00
|
|
|
PROFILEEND(rpi_vkGetQueryPoolResults);
|
2019-04-22 15:58:27 +02:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-09-30 00:52:21 +02:00
|
|
|
VKAPI_ATTR void VKAPI_CALL rpi_vkCmdWriteTimestamp(
|
2019-04-22 15:58:27 +02:00
|
|
|
VkCommandBuffer commandBuffer,
|
|
|
|
VkPipelineStageFlagBits pipelineStage,
|
|
|
|
VkQueryPool queryPool,
|
|
|
|
uint32_t query)
|
|
|
|
{
|
2020-02-24 22:56:14 +01:00
|
|
|
UNSUPPORTED(VK_QUERY_TYPE_TIMESTAMP);
|
2019-04-22 15:58:27 +02:00
|
|
|
}
|