1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-12-05 17:24:14 +01:00
rpi-vk-driver/driver/query.c

189 lines
5.9 KiB
C
Raw Normal View History

2019-04-22 15:58:27 +02:00
#include "common.h"
//TODO VkPerformanceQuerySubmitInfoKHR
2020-02-23 13:20:32 +01:00
//TODO query test
2020-02-23 13:20:32 +01:00
VKAPI_ATTR VkResult VKAPI_CALL rpi_vkAcquireProfilingLockKHR(
VkDevice device,
const VkAcquireProfilingLockInfoKHR* pInfo)
{
//TODO
return VK_SUCCESS;
}
2020-02-23 13:20:32 +01:00
VKAPI_ATTR void VKAPI_CALL rpi_vkReleaseProfilingLockKHR(
VkDevice device)
{
//TODO
}
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)
{
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);
}
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)
{
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);
}
}
*pQueryPool = qp;
}
2019-09-08 00:30:52 +02:00
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)
{
2019-09-08 00:30:52 +02:00
//TODO
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)
{
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)
{
vc4_destroy_perfmon(controlFd, qp->queryPool[c].perfmonIDs[d / DRM_VC4_MAX_PERF_COUNTERS]);
}
}
FREE(qp->queryPool);
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)
{
assert(commandBuffer);
assert(queryPool);
2020-02-24 22:45:47 +01:00
_commandBuffer* cmdBuf = commandBuffer;
cmdBuf->perfmonID = 0;
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)
{
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;
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)
{
2019-09-08 00:30:52 +02:00
//TODO
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)
{
assert(device);
assert(queryPool);
//TODO flags
2020-02-23 14:29:01 +01:00
//TODO return values etc.
_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
}
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];
}
}
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
}