vkd3d: Allocate query pools based on type index instead of D3D12 type.
Postbuild info is a query in Vulkan, but not so in D3D12. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
parent
d88ce7cdea
commit
4365f9962f
|
@ -1905,44 +1905,37 @@ static bool d3d12_command_allocator_allocate_scratch_memory(struct d3d12_command
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct vkd3d_query_pool *d3d12_command_allocator_find_active_query_pool(struct d3d12_command_allocator *allocator,
|
static struct vkd3d_query_pool *d3d12_command_allocator_get_active_query_pool_from_type_index(
|
||||||
D3D12_QUERY_HEAP_TYPE heap_type)
|
struct d3d12_command_allocator *allocator, uint32_t type_index)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
return &allocator->active_query_pools[type_index];
|
||||||
|
|
||||||
static const struct
|
|
||||||
{
|
|
||||||
D3D12_QUERY_HEAP_TYPE heap_type;
|
|
||||||
uint32_t index;
|
|
||||||
}
|
|
||||||
map[] =
|
|
||||||
{
|
|
||||||
{ D3D12_QUERY_HEAP_TYPE_OCCLUSION, VKD3D_QUERY_TYPE_INDEX_OCCLUSION },
|
|
||||||
{ D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS, VKD3D_QUERY_TYPE_INDEX_PIPELINE_STATISTICS },
|
|
||||||
{ D3D12_QUERY_HEAP_TYPE_SO_STATISTICS, VKD3D_QUERY_TYPE_INDEX_TRANSFORM_FEEDBACK },
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(map); i++)
|
|
||||||
{
|
|
||||||
if (map[i].heap_type == heap_type)
|
|
||||||
return &allocator->active_query_pools[map[i].index];
|
|
||||||
}
|
|
||||||
|
|
||||||
ERR("Unhandled query heap type %u.\n", heap_type);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool d3d12_command_allocator_allocate_query(struct d3d12_command_allocator *allocator,
|
static uint32_t d3d12_query_heap_type_to_type_index(D3D12_QUERY_HEAP_TYPE heap_type)
|
||||||
D3D12_QUERY_HEAP_TYPE heap_type, VkQueryPool *query_pool, uint32_t *query_index)
|
|
||||||
{
|
{
|
||||||
struct vkd3d_query_pool *pool = d3d12_command_allocator_find_active_query_pool(allocator, heap_type);
|
switch (heap_type)
|
||||||
|
{
|
||||||
|
case D3D12_QUERY_HEAP_TYPE_OCCLUSION:
|
||||||
|
return VKD3D_QUERY_TYPE_INDEX_OCCLUSION;
|
||||||
|
case D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS:
|
||||||
|
return VKD3D_QUERY_TYPE_INDEX_PIPELINE_STATISTICS;
|
||||||
|
case D3D12_QUERY_HEAP_TYPE_SO_STATISTICS:
|
||||||
|
return VKD3D_QUERY_TYPE_INDEX_TRANSFORM_FEEDBACK;
|
||||||
|
default:
|
||||||
|
return UINT32_MAX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pool)
|
static bool d3d12_command_allocator_allocate_query_from_type_index(
|
||||||
return false;
|
struct d3d12_command_allocator *allocator,
|
||||||
|
uint32_t type_index, VkQueryPool *query_pool, uint32_t *query_index)
|
||||||
|
{
|
||||||
|
struct vkd3d_query_pool *pool = d3d12_command_allocator_get_active_query_pool_from_type_index(allocator, type_index);
|
||||||
|
assert(pool);
|
||||||
|
|
||||||
if (pool->next_index >= pool->query_count)
|
if (pool->next_index >= pool->query_count)
|
||||||
{
|
{
|
||||||
if (FAILED(d3d12_device_get_query_pool(allocator->device, heap_type, pool)))
|
if (FAILED(d3d12_device_get_query_pool(allocator->device, type_index, pool)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (vkd3d_array_reserve((void**)&allocator->query_pools, &allocator->query_pools_size,
|
if (vkd3d_array_reserve((void**)&allocator->query_pools, &allocator->query_pools_size,
|
||||||
|
@ -1957,6 +1950,13 @@ static bool d3d12_command_allocator_allocate_query(struct d3d12_command_allocato
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool d3d12_command_allocator_allocate_query_from_heap_type(struct d3d12_command_allocator *allocator,
|
||||||
|
D3D12_QUERY_HEAP_TYPE heap_type, VkQueryPool *query_pool, uint32_t *query_index)
|
||||||
|
{
|
||||||
|
uint32_t type_index = d3d12_query_heap_type_to_type_index(heap_type);
|
||||||
|
return d3d12_command_allocator_allocate_query_from_type_index(allocator, type_index, query_pool, query_index);
|
||||||
|
}
|
||||||
|
|
||||||
/* ID3D12CommandList */
|
/* ID3D12CommandList */
|
||||||
static inline struct d3d12_command_list *impl_from_ID3D12GraphicsCommandList(d3d12_command_list_iface *iface)
|
static inline struct d3d12_command_list *impl_from_ID3D12GraphicsCommandList(d3d12_command_list_iface *iface)
|
||||||
{
|
{
|
||||||
|
@ -2646,7 +2646,7 @@ static void d3d12_command_list_reset_active_query(struct d3d12_command_list *lis
|
||||||
if (!d3d12_command_list_add_pending_query(list, query))
|
if (!d3d12_command_list_add_pending_query(list, query))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!d3d12_command_allocator_allocate_query(list->allocator,
|
if (!d3d12_command_allocator_allocate_query_from_heap_type(list->allocator,
|
||||||
query->heap->desc.Type, &query->vk_pool, &query->vk_index))
|
query->heap->desc.Type, &query->vk_pool, &query->vk_index))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2675,7 +2675,7 @@ static bool d3d12_command_list_enable_query(struct d3d12_command_list *list,
|
||||||
query->state = VKD3D_ACTIVE_QUERY_RESET;
|
query->state = VKD3D_ACTIVE_QUERY_RESET;
|
||||||
query->resolve_index = 0;
|
query->resolve_index = 0;
|
||||||
|
|
||||||
if (!d3d12_command_allocator_allocate_query(list->allocator,
|
if (!d3d12_command_allocator_allocate_query_from_heap_type(list->allocator,
|
||||||
heap->desc.Type, &query->vk_pool, &query->vk_index))
|
heap->desc.Type, &query->vk_pool, &query->vk_index))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -2172,29 +2172,29 @@ void d3d12_device_return_descriptor_heap_gpu_va(struct d3d12_device *device, uin
|
||||||
pthread_mutex_unlock(&device->mutex);
|
pthread_mutex_unlock(&device->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT d3d12_device_create_query_pool(struct d3d12_device *device, D3D12_QUERY_HEAP_TYPE heap_type, struct vkd3d_query_pool *pool)
|
static HRESULT d3d12_device_create_query_pool(struct d3d12_device *device, uint32_t type_index, struct vkd3d_query_pool *pool)
|
||||||
{
|
{
|
||||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||||
VkQueryPoolCreateInfo pool_info;
|
VkQueryPoolCreateInfo pool_info;
|
||||||
VkResult vr;
|
VkResult vr;
|
||||||
|
|
||||||
TRACE("device %p, heap_type %u, pool %p.\n", device, heap_type, pool);
|
TRACE("device %p, type_index %u, pool %p.\n", device, type_index, pool);
|
||||||
|
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
|
||||||
pool_info.pNext = NULL;
|
pool_info.pNext = NULL;
|
||||||
pool_info.flags = 0;
|
pool_info.flags = 0;
|
||||||
pool_info.pipelineStatistics = 0;
|
pool_info.pipelineStatistics = 0;
|
||||||
|
|
||||||
switch (heap_type)
|
switch (type_index)
|
||||||
{
|
{
|
||||||
case D3D12_QUERY_HEAP_TYPE_OCCLUSION:
|
case VKD3D_QUERY_TYPE_INDEX_OCCLUSION:
|
||||||
/* Expect a large number of occlusion queries
|
/* Expect a large number of occlusion queries
|
||||||
* to be used within a single command list */
|
* to be used within a single command list */
|
||||||
pool_info.queryType = VK_QUERY_TYPE_OCCLUSION;
|
pool_info.queryType = VK_QUERY_TYPE_OCCLUSION;
|
||||||
pool_info.queryCount = 4096;
|
pool_info.queryCount = 4096;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS:
|
case VKD3D_QUERY_TYPE_INDEX_PIPELINE_STATISTICS:
|
||||||
pool_info.queryType = VK_QUERY_TYPE_PIPELINE_STATISTICS;
|
pool_info.queryType = VK_QUERY_TYPE_PIPELINE_STATISTICS;
|
||||||
pool_info.queryCount = 128;
|
pool_info.queryCount = 128;
|
||||||
pool_info.pipelineStatistics =
|
pool_info.pipelineStatistics =
|
||||||
|
@ -2211,13 +2211,23 @@ static HRESULT d3d12_device_create_query_pool(struct d3d12_device *device, D3D12
|
||||||
VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
|
VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_QUERY_HEAP_TYPE_SO_STATISTICS:
|
case VKD3D_QUERY_TYPE_INDEX_TRANSFORM_FEEDBACK:
|
||||||
pool_info.queryType = VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT;
|
pool_info.queryType = VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT;
|
||||||
pool_info.queryCount = 128;
|
pool_info.queryCount = 128;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VKD3D_QUERY_TYPE_INDEX_RT_COMPACTED_SIZE:
|
||||||
|
pool_info.queryType = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR;
|
||||||
|
pool_info.queryCount = 128;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VKD3D_QUERY_TYPE_INDEX_RT_SERIALIZE_SIZE:
|
||||||
|
pool_info.queryType = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR;
|
||||||
|
pool_info.queryCount = 128;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Unhandled query type %u.\n", heap_type);
|
ERR("Unhandled query type %u.\n", type_index);
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2227,7 +2237,7 @@ static HRESULT d3d12_device_create_query_pool(struct d3d12_device *device, D3D12
|
||||||
return hresult_from_vk_result(vr);
|
return hresult_from_vk_result(vr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pool->heap_type = heap_type;
|
pool->type_index = type_index;
|
||||||
pool->query_count = pool_info.queryCount;
|
pool->query_count = pool_info.queryCount;
|
||||||
pool->next_index = 0;
|
pool->next_index = 0;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -2242,7 +2252,7 @@ static void d3d12_device_destroy_query_pool(struct d3d12_device *device, const s
|
||||||
VK_CALL(vkDestroyQueryPool(device->vk_device, pool->vk_query_pool, NULL));
|
VK_CALL(vkDestroyQueryPool(device->vk_device, pool->vk_query_pool, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT d3d12_device_get_query_pool(struct d3d12_device *device, D3D12_QUERY_HEAP_TYPE heap_type, struct vkd3d_query_pool *pool)
|
HRESULT d3d12_device_get_query_pool(struct d3d12_device *device, uint32_t type_index, struct vkd3d_query_pool *pool)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -2250,7 +2260,7 @@ HRESULT d3d12_device_get_query_pool(struct d3d12_device *device, D3D12_QUERY_HEA
|
||||||
|
|
||||||
for (i = 0; i < device->query_pool_count; i++)
|
for (i = 0; i < device->query_pool_count; i++)
|
||||||
{
|
{
|
||||||
if (device->query_pools[i].heap_type == heap_type)
|
if (device->query_pools[i].type_index == type_index)
|
||||||
{
|
{
|
||||||
*pool = device->query_pools[i];
|
*pool = device->query_pools[i];
|
||||||
pool->next_index = 0;
|
pool->next_index = 0;
|
||||||
|
@ -2262,7 +2272,7 @@ HRESULT d3d12_device_get_query_pool(struct d3d12_device *device, D3D12_QUERY_HEA
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&device->mutex);
|
pthread_mutex_unlock(&device->mutex);
|
||||||
return d3d12_device_create_query_pool(device, heap_type, pool);
|
return d3d12_device_create_query_pool(device, type_index, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void d3d12_device_return_query_pool(struct d3d12_device *device, const struct vkd3d_query_pool *pool)
|
void d3d12_device_return_query_pool(struct d3d12_device *device, const struct vkd3d_query_pool *pool)
|
||||||
|
|
|
@ -1328,13 +1328,15 @@ struct vkd3d_scratch_buffer
|
||||||
#define VKD3D_QUERY_TYPE_INDEX_OCCLUSION (0u)
|
#define VKD3D_QUERY_TYPE_INDEX_OCCLUSION (0u)
|
||||||
#define VKD3D_QUERY_TYPE_INDEX_PIPELINE_STATISTICS (1u)
|
#define VKD3D_QUERY_TYPE_INDEX_PIPELINE_STATISTICS (1u)
|
||||||
#define VKD3D_QUERY_TYPE_INDEX_TRANSFORM_FEEDBACK (2u)
|
#define VKD3D_QUERY_TYPE_INDEX_TRANSFORM_FEEDBACK (2u)
|
||||||
#define VKD3D_VIRTUAL_QUERY_TYPE_COUNT (3u)
|
#define VKD3D_QUERY_TYPE_INDEX_RT_COMPACTED_SIZE (3u)
|
||||||
|
#define VKD3D_QUERY_TYPE_INDEX_RT_SERIALIZE_SIZE (4u)
|
||||||
|
#define VKD3D_VIRTUAL_QUERY_TYPE_COUNT (5u)
|
||||||
#define VKD3D_VIRTUAL_QUERY_POOL_COUNT (128u)
|
#define VKD3D_VIRTUAL_QUERY_POOL_COUNT (128u)
|
||||||
|
|
||||||
struct vkd3d_query_pool
|
struct vkd3d_query_pool
|
||||||
{
|
{
|
||||||
D3D12_QUERY_HEAP_TYPE heap_type;
|
|
||||||
VkQueryPool vk_query_pool;
|
VkQueryPool vk_query_pool;
|
||||||
|
uint32_t type_index;
|
||||||
uint32_t query_count;
|
uint32_t query_count;
|
||||||
uint32_t next_index;
|
uint32_t next_index;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue