diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 066dbf46f62..c280d6813b2 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3505,10 +3505,12 @@ VkResult anv_CreateDevice( MAX_CUSTOM_BORDER_COLORS, sizeof(struct gfx8_border_color), 64); if (device->vk.enabled_extensions.EXT_descriptor_buffer) { - anv_state_reserved_pool_init(&device->custom_border_colors_db, - &device->dynamic_state_db_pool, - MAX_CUSTOM_BORDER_COLORS, - sizeof(struct gfx8_border_color), 64); + result = anv_state_reserved_array_pool_init(&device->custom_border_colors_db, + &device->dynamic_state_db_pool, + MAX_CUSTOM_BORDER_COLORS, + sizeof(struct gfx8_border_color), 64); + if (result != VK_SUCCESS) + goto fail_dynamic_state_db_pool; } result = anv_state_pool_init(&device->instruction_state_pool, device, @@ -3519,7 +3521,7 @@ VkResult anv_CreateDevice( .max_size = device->physical->va.instruction_state_pool.size, }); if (result != VK_SUCCESS) - goto fail_dynamic_state_db_pool; + goto fail_reserved_array_pool; if (device->info->verx10 >= 125) { /* Put the scratch surface states at the beginning of the internal @@ -3932,12 +3934,13 @@ VkResult anv_CreateDevice( anv_state_pool_finish(&device->scratch_surface_state_pool); fail_instruction_state_pool: anv_state_pool_finish(&device->instruction_state_pool); + fail_reserved_array_pool: + if (device->vk.enabled_extensions.EXT_descriptor_buffer) + anv_state_reserved_array_pool_finish(&device->custom_border_colors_db); fail_dynamic_state_db_pool: anv_state_reserved_pool_finish(&device->custom_border_colors); - if (device->vk.enabled_extensions.EXT_descriptor_buffer) { - anv_state_reserved_pool_finish(&device->custom_border_colors_db); + if (device->vk.enabled_extensions.EXT_descriptor_buffer) anv_state_pool_finish(&device->dynamic_state_db_pool); - } fail_dynamic_state_pool: anv_state_pool_finish(&device->dynamic_state_pool); fail_general_state_pool: @@ -4032,7 +4035,7 @@ void anv_DestroyDevice( anv_state_pool_free(&device->dynamic_state_db_pool, device->cps_states_db); anv_state_pool_free(&device->dynamic_state_db_pool, device->slice_hash_db); anv_state_pool_free(&device->dynamic_state_db_pool, device->border_colors_db); - anv_state_reserved_pool_finish(&device->custom_border_colors_db); + anv_state_reserved_array_pool_finish(&device->custom_border_colors_db); } #endif @@ -5188,6 +5191,26 @@ anv_fill_buffer_surface_state(struct anv_device *device, .stride_B = stride); } +VkResult anv_GetSamplerOpaqueCaptureDescriptorDataEXT( + VkDevice _device, + const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, + void* pData) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_sampler, sampler, pInfo->sampler); + + if (sampler->custom_border_color_db.alloc_size != 0) { + *((uint32_t *)pData) = + anv_state_reserved_array_pool_state_index( + &device->custom_border_colors_db, + sampler->custom_border_color_db); + } else { + *((uint32_t *)pData) = 0; + } + + return VK_SUCCESS; +} + void anv_DestroySampler( VkDevice _device, VkSampler _sampler, @@ -5209,8 +5232,8 @@ void anv_DestroySampler( sampler->custom_border_color); } if (sampler->custom_border_color_db.map) { - anv_state_reserved_pool_free(&device->custom_border_colors_db, - sampler->custom_border_color_db); + anv_state_reserved_array_pool_free(&device->custom_border_colors_db, + sampler->custom_border_color_db); } vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 6d349d8e8cf..d4f5c207546 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1807,7 +1807,7 @@ struct anv_device { struct anv_state_pool push_descriptor_buffer_pool; struct anv_state_reserved_pool custom_border_colors; - struct anv_state_reserved_pool custom_border_colors_db; + struct anv_state_reserved_array_pool custom_border_colors_db; /** BO used for various workarounds * diff --git a/src/intel/vulkan/genX_init_state.c b/src/intel/vulkan/genX_init_state.c index bff236528ba..c1f71e3eed0 100644 --- a/src/intel/vulkan/genX_init_state.c +++ b/src/intel/vulkan/genX_init_state.c @@ -1159,8 +1159,24 @@ VkResult genX(CreateSampler)( memcpy(border_color_ptr, color.u32, sizeof(color)); if (device->vk.enabled_extensions.EXT_descriptor_buffer) { - sampler->custom_border_color_db = - anv_state_reserved_pool_alloc(&device->custom_border_colors_db); + if (pCreateInfo->flags & VK_SAMPLER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT) { + const VkOpaqueCaptureDescriptorDataCreateInfoEXT *opaque_info = + vk_find_struct_const(pCreateInfo->pNext, + OPAQUE_CAPTURE_DESCRIPTOR_DATA_CREATE_INFO_EXT); + if (opaque_info) { + uint32_t alloc_idx = *((const uint32_t *)opaque_info->opaqueCaptureDescriptorData); + sampler->custom_border_color_db = + anv_state_reserved_array_pool_alloc_index(&device->custom_border_colors_db, alloc_idx); + } else { + sampler->custom_border_color_db = + anv_state_reserved_array_pool_alloc(&device->custom_border_colors_db, true); + } + } else { + sampler->custom_border_color_db = + anv_state_reserved_array_pool_alloc(&device->custom_border_colors_db, false); + } + if (sampler->custom_border_color_db.alloc_size == 0) + return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY); border_color_db_offset = sampler->custom_border_color_db.offset; memcpy(sampler->custom_border_color_db.map, color.u32, sizeof(color)); }