mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-19 12:20:40 +02:00
anv: use internal rt-null-ahs when any_hit is null
Tested on BMG and PTL using both settings for RT_CTRL. Cc: mesa-stable Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35044>
This commit is contained in:
parent
0f591425c9
commit
5828612da2
3 changed files with 62 additions and 0 deletions
|
|
@ -3941,6 +3941,64 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
|||
*/
|
||||
anv_shader_bin_unref(device, device->rt_trivial_return);
|
||||
|
||||
struct brw_rt_null_ahs {
|
||||
char name[16];
|
||||
struct brw_bs_prog_key key;
|
||||
} null_return_key = {
|
||||
.name = "rt-null-ahs",
|
||||
};
|
||||
device->rt_null_ahs =
|
||||
anv_device_search_for_kernel(device, device->internal_cache,
|
||||
&null_return_key, sizeof(null_return_key),
|
||||
&cache_hit);
|
||||
if (device->rt_null_ahs == NULL) {
|
||||
void *tmp_ctx = ralloc_context(NULL);
|
||||
nir_shader *null_ahs_nir =
|
||||
brw_nir_create_null_ahs_shader(device->physical->compiler, tmp_ctx);
|
||||
|
||||
NIR_PASS_V(null_ahs_nir, brw_nir_lower_rt_intrinsics,
|
||||
&null_return_key.key.base, device->info);
|
||||
|
||||
struct brw_bs_prog_data return_prog_data = { 0, };
|
||||
struct brw_compile_bs_params params = {
|
||||
.base = {
|
||||
.nir = null_ahs_nir,
|
||||
.log_data = device,
|
||||
.mem_ctx = tmp_ctx,
|
||||
},
|
||||
.key = &null_return_key.key,
|
||||
.prog_data = &return_prog_data,
|
||||
};
|
||||
const unsigned *return_data =
|
||||
brw_compile_bs(device->physical->compiler, ¶ms);
|
||||
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = MESA_SHADER_CALLABLE,
|
||||
.key_data = &null_return_key,
|
||||
.key_size = sizeof(null_return_key),
|
||||
.kernel_data = return_data,
|
||||
.kernel_size = return_prog_data.base.program_size,
|
||||
.prog_data = &return_prog_data.base,
|
||||
.prog_data_size = sizeof(return_prog_data),
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
|
||||
device->rt_null_ahs =
|
||||
anv_device_upload_kernel(device, device->internal_cache,
|
||||
&upload_params);
|
||||
|
||||
ralloc_free(tmp_ctx);
|
||||
|
||||
if (device->rt_null_ahs == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
/* The cache already has a reference and it's not going anywhere so there
|
||||
* is no need to hold a second reference.
|
||||
*/
|
||||
anv_shader_bin_unref(device, device->rt_null_ahs);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2088,6 +2088,7 @@ struct anv_device {
|
|||
|
||||
struct anv_shader_bin *rt_trampoline;
|
||||
struct anv_shader_bin *rt_trivial_return;
|
||||
struct anv_shader_bin *rt_null_ahs;
|
||||
|
||||
enum anv_rt_bvh_build_method bvh_build_method;
|
||||
|
||||
|
|
|
|||
|
|
@ -2204,10 +2204,13 @@ genX(ray_tracing_pipeline_emit)(struct anv_ray_tracing_pipeline *pipeline)
|
|||
|
||||
case VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR: {
|
||||
struct GENX(RT_TRIANGLES_SBT_HANDLE) sh = {};
|
||||
struct anv_device *device = pipeline->base.device;
|
||||
if (group->closest_hit)
|
||||
sh.ClosestHit = anv_shader_bin_get_bsr(group->closest_hit, 32);
|
||||
if (group->any_hit)
|
||||
sh.AnyHit = anv_shader_bin_get_bsr(group->any_hit, 24);
|
||||
else
|
||||
sh.AnyHit = anv_shader_bin_get_bsr(device->rt_null_ahs, 24);
|
||||
GENX(RT_TRIANGLES_SBT_HANDLE_pack)(NULL, group->handle, &sh);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue