Bläddra i källkod

turnip: Implement vkCreateQueryPool for occlusion queries

Like anv_CreateQueryPool.
turnip-occlusion-query2
Brian Ho 7 år sedan
förälder
incheckning
b5e9c6d4b0
1 ändrade filer med 45 tillägg och 1 borttagningar
  1. 45
    1
      src/freedreno/vulkan/tu_query.c

+ 45
- 1
src/freedreno/vulkan/tu_query.c Visa fil

@@ -33,6 +33,12 @@

#include "nir/nir_builder.h"

struct PACKED occlusion_query_slot {
uint64_t available; /* 0 when unavailable, 1 when available */
uint64_t begin;
uint64_t end;
};

VkResult
tu_CreateQueryPool(VkDevice _device,
const VkQueryPoolCreateInfo *pCreateInfo,
@@ -40,14 +46,52 @@ tu_CreateQueryPool(VkDevice _device,
VkQueryPool *pQueryPool)
{
TU_FROM_HANDLE(tu_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO);
assert(pCreateInfo->queryCount > 0);

uint32_t slot_size;
switch (pCreateInfo->queryType) {
case VK_QUERY_TYPE_OCCLUSION:
slot_size = sizeof(struct occlusion_query_slot);
break;
case VK_QUERY_TYPE_PIPELINE_STATISTICS:
case VK_QUERY_TYPE_TIMESTAMP:
unreachable("Unimplemented query type");
default:
assert(!"Invalid query type");
}

struct tu_query_pool *pool =
vk_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);

if (!pool)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);

struct tu_bo *bo = malloc(sizeof(struct tu_bo));
if (!bo)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
VkResult result = tu_bo_init_new(device, bo,
pCreateInfo->queryCount * slot_size);
if (result != VK_SUCCESS) {
free(bo);
return result;
}
result = tu_bo_map(device, bo);
if (result != VK_SUCCESS) {
tu_bo_finish(device, bo);
free(bo);
return result;
}
/* Initialize all query statuses to unavailable */
memset(bo->map, 0, bo->size);

pool->type = pCreateInfo->queryType;
pool->stride = slot_size;
pool->size = pCreateInfo->queryCount;
pool->pipeline_statistics = pCreateInfo->pipelineStatistics;
pool->bo = bo;
*pQueryPool = tu_query_pool_to_handle(pool);

return VK_SUCCESS;
}


Laddar…
Avbryt
Spara