iris: Make iris_has_color_unresolved more generic
[mesa.git] / src / amd / vulkan / radv_query.c
index 07a1c3871871aa91ddf156303fbc618b165b1e71..66a9fe94b900a9993cbbc4d07f4574bfc24016c3 100644 (file)
@@ -203,7 +203,7 @@ build_occlusion_query_shader(struct radv_device *device) {
        nir_builder_instr_insert(&b, &src_buf->instr);
 
        nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
-       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b, 32);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -395,7 +395,7 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {
        nir_builder_instr_insert(&b, &src_buf->instr);
 
        nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
-       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b, 32);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -635,7 +635,7 @@ build_tfb_query_shader(struct radv_device *device)
 
        /* Compute global ID. */
        nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
-       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b, 32);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -837,7 +837,7 @@ build_timestamp_query_shader(struct radv_device *device)
 
        /* Compute global ID. */
        nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b);
-       nir_ssa_def *wg_id = nir_load_work_group_id(&b);
+       nir_ssa_def *wg_id = nir_load_work_group_id(&b, 32);
        nir_ssa_def *block_size = nir_imm_ivec4(&b,
                                                b.shader->info.cs.local_size[0],
                                                b.shader->info.cs.local_size[1],
@@ -1269,6 +1269,17 @@ radv_query_pool_needs_gds(struct radv_device *device,
               (pool->pipeline_stats_mask & VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT);
 }
 
+static void
+radv_destroy_query_pool(struct radv_device *device,
+                       const VkAllocationCallbacks *pAllocator,
+                       struct radv_query_pool *pool)
+{
+       if (pool->bo)
+               device->ws->buffer_destroy(pool->bo);
+       vk_object_base_finish(&pool->base);
+       vk_free2(&device->vk.alloc, pAllocator, pool);
+}
+
 VkResult radv_CreateQueryPool(
        VkDevice                                    _device,
        const VkQueryPoolCreateInfo*                pCreateInfo,
@@ -1276,13 +1287,15 @@ VkResult radv_CreateQueryPool(
        VkQueryPool*                                pQueryPool)
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
-       struct radv_query_pool *pool = vk_alloc2(&device->alloc, pAllocator,
+       struct radv_query_pool *pool = vk_alloc2(&device->vk.alloc, pAllocator,
                                               sizeof(*pool), 8,
                                               VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
 
        if (!pool)
                return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
 
+       vk_object_base_init(&device->vk, &pool->base,
+                           VK_OBJECT_TYPE_QUERY_POOL);
 
        switch(pCreateInfo->queryType) {
        case VK_QUERY_TYPE_OCCLUSION:
@@ -1311,17 +1324,14 @@ VkResult radv_CreateQueryPool(
        pool->bo = device->ws->buffer_create(device->ws, pool->size,
                                             64, RADEON_DOMAIN_GTT, RADEON_FLAG_NO_INTERPROCESS_SHARING,
                                             RADV_BO_PRIORITY_QUERY_POOL);
-
        if (!pool->bo) {
-               vk_free2(&device->alloc, pAllocator, pool);
+               radv_destroy_query_pool(device, pAllocator, pool);
                return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
        }
 
        pool->ptr = device->ws->buffer_map(pool->bo);
-
        if (!pool->ptr) {
-               device->ws->buffer_destroy(pool->bo);
-               vk_free2(&device->alloc, pAllocator, pool);
+               radv_destroy_query_pool(device, pAllocator, pool);
                return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
        }
 
@@ -1340,8 +1350,7 @@ void radv_DestroyQueryPool(
        if (!pool)
                return;
 
-       device->ws->buffer_destroy(pool->bo);
-       vk_free2(&device->alloc, pAllocator, pool);
+       radv_destroy_query_pool(device, pAllocator, pool);
 }
 
 VkResult radv_GetQueryPoolResults(
@@ -1359,6 +1368,9 @@ VkResult radv_GetQueryPoolResults(
        char *data = pData;
        VkResult result = VK_SUCCESS;
 
+       if (radv_device_is_lost(device))
+               return VK_ERROR_DEVICE_LOST;
+
        for(unsigned i = 0; i < queryCount; ++i, data += stride) {
                char *dest = data;
                unsigned query = firstQuery + i;
@@ -1673,7 +1685,7 @@ void radv_CmdResetQueryPool(
        RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
        RADV_FROM_HANDLE(radv_query_pool, pool, queryPool);
        uint32_t value = pool->type == VK_QUERY_TYPE_TIMESTAMP
-                        ? TIMESTAMP_NOT_READY : 0;
+                        ? (uint32_t)TIMESTAMP_NOT_READY : 0;
        uint32_t flush_bits = 0;
 
        /* Make sure to sync all previous work if the given command buffer has
@@ -1708,7 +1720,7 @@ void radv_ResetQueryPool(
        RADV_FROM_HANDLE(radv_query_pool, pool, queryPool);
 
        uint32_t value = pool->type == VK_QUERY_TYPE_TIMESTAMP
-                        ? TIMESTAMP_NOT_READY : 0;
+                        ? (uint32_t)TIMESTAMP_NOT_READY : 0;
        uint32_t *data =  (uint32_t*)(pool->ptr + firstQuery * pool->stride);
        uint32_t *data_end = (uint32_t*)(pool->ptr + (firstQuery + queryCount) * pool->stride);