mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 15:40:11 +01:00
radv: Always compile accel structure shaders on demand.
Some CTS tests enable all extensions ... , which combined with having no shader cache on some platforms results in some CTS tests timing out (in particular tests recreating the device all the time). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20422>
This commit is contained in:
parent
ef37407971
commit
0d5570bb47
3 changed files with 53 additions and 24 deletions
|
|
@ -91,6 +91,8 @@ struct scratch_layout {
|
|||
uint32_t ir_offset;
|
||||
};
|
||||
|
||||
static VkResult radv_device_init_accel_struct_build_state(struct radv_device *device);
|
||||
|
||||
static enum radv_accel_struct_build_type
|
||||
build_type(uint32_t leaf_count, const VkAccelerationStructureBuildGeometryInfoKHR *build_info)
|
||||
{
|
||||
|
|
@ -169,9 +171,12 @@ get_build_layout(struct radv_device *device, uint32_t leaf_count,
|
|||
}
|
||||
|
||||
if (scratch) {
|
||||
radix_sort_vk_memory_requirements_t requirements;
|
||||
radix_sort_vk_get_memory_requirements(device->meta_state.accel_struct_build.radix_sort,
|
||||
leaf_count, &requirements);
|
||||
radix_sort_vk_memory_requirements_t requirements = {
|
||||
0,
|
||||
};
|
||||
if (radv_device_init_accel_struct_build_state(device) == VK_SUCCESS)
|
||||
radix_sort_vk_get_memory_requirements(device->meta_state.accel_struct_build.radix_sort,
|
||||
leaf_count, &requirements);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
|
@ -365,6 +370,9 @@ create_build_pipeline_spv(struct radv_device *device, const uint32_t *spv, uint3
|
|||
unsigned push_constant_size, VkPipeline *pipeline,
|
||||
VkPipelineLayout *layout)
|
||||
{
|
||||
if (*pipeline)
|
||||
return VK_SUCCESS;
|
||||
|
||||
const VkPipelineLayoutCreateInfo pl_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = 0,
|
||||
|
|
@ -387,10 +395,12 @@ create_build_pipeline_spv(struct radv_device *device, const uint32_t *spv, uint3
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = radv_CreatePipelineLayout(radv_device_to_handle(device), &pl_create_info,
|
||||
&device->meta_state.alloc, layout);
|
||||
if (result != VK_SUCCESS)
|
||||
goto cleanup;
|
||||
if (!*layout) {
|
||||
result = radv_CreatePipelineLayout(radv_device_to_handle(device), &pl_create_info,
|
||||
&device->meta_state.alloc, layout);
|
||||
if (result != VK_SUCCESS)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VkPipelineShaderStageCreateInfo shader_stage = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
|
|
@ -430,11 +440,14 @@ radix_sort_fill_buffer(VkCommandBuffer commandBuffer,
|
|||
size, data);
|
||||
}
|
||||
|
||||
VkResult
|
||||
static VkResult
|
||||
radv_device_init_accel_struct_build_state(struct radv_device *device)
|
||||
{
|
||||
VkResult result;
|
||||
|
||||
if (device->meta_state.accel_struct_build.radix_sort)
|
||||
return VK_SUCCESS;
|
||||
|
||||
result = create_build_pipeline_spv(device, leaf_spv, sizeof(leaf_spv), sizeof(struct leaf_args),
|
||||
&device->meta_state.accel_struct_build.leaf_pipeline,
|
||||
&device->meta_state.accel_struct_build.leaf_p_layout);
|
||||
|
|
@ -477,13 +490,6 @@ radv_device_init_accel_struct_build_state(struct radv_device *device)
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = create_build_pipeline_spv(device, copy_spv, sizeof(copy_spv), sizeof(struct copy_args),
|
||||
&device->meta_state.accel_struct_build.copy_pipeline,
|
||||
&device->meta_state.accel_struct_build.copy_p_layout);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result =
|
||||
create_build_pipeline_spv(device, morton_spv, sizeof(morton_spv), sizeof(struct morton_args),
|
||||
&device->meta_state.accel_struct_build.morton_pipeline,
|
||||
|
|
@ -504,6 +510,14 @@ radv_device_init_accel_struct_build_state(struct radv_device *device)
|
|||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
radv_device_init_accel_struct_copy_state(struct radv_device *device)
|
||||
{
|
||||
return create_build_pipeline_spv(device, copy_spv, sizeof(copy_spv), sizeof(struct copy_args),
|
||||
&device->meta_state.accel_struct_build.copy_pipeline,
|
||||
&device->meta_state.accel_struct_build.copy_p_layout);
|
||||
}
|
||||
|
||||
struct bvh_state {
|
||||
uint32_t internal_node_base;
|
||||
uint32_t node_count;
|
||||
|
|
@ -860,6 +874,12 @@ radv_CmdBuildAccelerationStructuresKHR(
|
|||
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
|
||||
VkResult result = radv_device_init_accel_struct_build_state(cmd_buffer->device);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
enum radv_cmd_flush_bits flush_bits =
|
||||
RADV_CMD_FLAG_CS_PARTIAL_FLUSH |
|
||||
radv_src_access_flush(cmd_buffer, VK_ACCESS_2_SHADER_READ_BIT | VK_ACCESS_2_SHADER_WRITE_BIT,
|
||||
|
|
@ -988,6 +1008,12 @@ radv_CmdCopyAccelerationStructureKHR(VkCommandBuffer commandBuffer,
|
|||
RADV_FROM_HANDLE(radv_acceleration_structure, dst, pInfo->dst);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
|
||||
VkResult result = radv_device_init_accel_struct_copy_state(cmd_buffer->device);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
radv_meta_save(
|
||||
&saved_state, cmd_buffer,
|
||||
RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_DESCRIPTORS | RADV_META_SAVE_CONSTANTS);
|
||||
|
|
@ -1053,6 +1079,12 @@ radv_CmdCopyMemoryToAccelerationStructureKHR(
|
|||
RADV_FROM_HANDLE(radv_acceleration_structure, dst, pInfo->dst);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
|
||||
VkResult result = radv_device_init_accel_struct_copy_state(cmd_buffer->device);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
radv_meta_save(
|
||||
&saved_state, cmd_buffer,
|
||||
RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_DESCRIPTORS | RADV_META_SAVE_CONSTANTS);
|
||||
|
|
@ -1082,6 +1114,12 @@ radv_CmdCopyAccelerationStructureToMemoryKHR(
|
|||
RADV_FROM_HANDLE(radv_acceleration_structure, src, pInfo->src);
|
||||
struct radv_meta_saved_state saved_state;
|
||||
|
||||
VkResult result = radv_device_init_accel_struct_copy_state(cmd_buffer->device);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
}
|
||||
|
||||
radv_meta_save(
|
||||
&saved_state, cmd_buffer,
|
||||
RADV_META_SAVE_COMPUTE_PIPELINE | RADV_META_SAVE_DESCRIPTORS | RADV_META_SAVE_CONSTANTS);
|
||||
|
|
|
|||
|
|
@ -478,12 +478,6 @@ radv_device_init_meta(struct radv_device *device)
|
|||
goto fail_fmask_copy;
|
||||
}
|
||||
|
||||
if (device->vk.enabled_extensions.KHR_acceleration_structure) {
|
||||
result = radv_device_init_accel_struct_build_state(device);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_accel_struct_build;
|
||||
}
|
||||
|
||||
result = radv_device_init_meta_etc_decode_state(device, on_demand);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail_etc_decode;
|
||||
|
|
@ -502,8 +496,6 @@ fail_dgc:
|
|||
radv_device_finish_dgc_prepare_state(device);
|
||||
fail_etc_decode:
|
||||
radv_device_finish_meta_etc_decode_state(device);
|
||||
fail_accel_struct_build:
|
||||
radv_device_finish_accel_struct_build_state(device);
|
||||
fail_fmask_copy:
|
||||
radv_device_finish_meta_fmask_copy_state(device);
|
||||
fail_fmask_expand:
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ void radv_device_finish_meta_dcc_retile_state(struct radv_device *device);
|
|||
|
||||
void radv_device_finish_meta_copy_vrs_htile_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_accel_struct_build_state(struct radv_device *device);
|
||||
void radv_device_finish_accel_struct_build_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_meta_etc_decode_state(struct radv_device *device, bool on_demand);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue