Lines Matching defs:shader

190    /* idx of the next shader to run in the next iteration of the main loop.
201 /* global address of the SBT entry used for the shader */
257 create_rt_variables(nir_shader *shader, const VkRayTracingPipelineCreateInfoKHR *create_info,
263 vars.idx = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "idx");
264 vars.arg = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "arg");
265 vars.stack_ptr = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "stack_ptr");
267 nir_variable_create(shader, nir_var_shader_temp, glsl_uint64_t_type(), "shader_record_ptr");
271 nir_variable_create(shader, nir_var_shader_temp, glsl_uint64_t_type(), "accel_struct");
272 vars.flags = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "ray_flags");
273 vars.cull_mask = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "cull_mask");
275 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "sbt_offset");
277 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "sbt_stride");
279 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "miss_index");
280 vars.origin = nir_variable_create(shader, nir_var_shader_temp, vec3_type, "ray_origin");
281 vars.tmin = nir_variable_create(shader, nir_var_shader_temp, glsl_float_type(), "ray_tmin");
282 vars.direction = nir_variable_create(shader, nir_var_shader_temp, vec3_type, "ray_direction");
283 vars.tmax = nir_variable_create(shader, nir_var_shader_temp, glsl_float_type(), "ray_tmax");
286 shader, nir_var_shader_temp, glsl_uint_type(), "custom_instance_and_mask");
288 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "primitive_id");
290 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "geometry_id_and_flags");
292 nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "instance_id");
294 nir_variable_create(shader, nir_var_shader_temp, glsl_uint64_t_type(), "instance_addr");
295 vars.hit_kind = nir_variable_create(shader, nir_var_shader_temp, glsl_uint_type(), "hit_kind");
296 vars.opaque = nir_variable_create(shader, nir_var_shader_temp, glsl_bool_type(), "opaque");
299 nir_variable_create(shader, nir_var_shader_temp, glsl_bool_type(), "main_loop_case_visited");
301 nir_variable_create(shader, nir_var_shader_temp, glsl_bool_type(), "ahit_accept");
303 nir_variable_create(shader, nir_var_shader_temp, glsl_bool_type(), "ahit_terminate");
351 * in case e.g. an anyhit shader reject the collision. So there are inner variables that get copied
359 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_idx");
361 b->shader, nir_var_shader_temp, glsl_uint64_t_type(), "inner_shader_record_ptr");
363 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_primitive_id");
365 b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_geometry_id_and_flags");
367 nir_variable_create(b->shader, nir_var_shader_temp, glsl_float_type(), "inner_tmax");
369 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_instance_id");
370 inner_vars.instance_addr = nir_variable_create(b->shader, nir_var_shader_temp,
373 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_hit_kind");
375 b->shader, nir_var_shader_temp, glsl_uint_type(), "inner_custom_instance_and_mask");
429 /* This lowers all the RT instructions that we do not want to pass on to the combined shader and
430 * that we can implement using the variables from the shader we are going to inline into. */
432 lower_rt_instructions(nir_shader *shader, struct rt_variables *vars, unsigned call_idx_base)
435 nir_builder_init(&b_shader, nir_shader_get_entrypoint(shader));
437 nir_foreach_block (block, nir_shader_get_entrypoint(shader)) {
513 if (shader->info.stage == MESA_SHADER_RAYGEN) {
726 nir_metadata_preserve(nir_shader_get_entrypoint(shader), nir_metadata_none);
730 insert_rt_case(nir_builder *b, nir_shader *shader, struct rt_variables *vars, nir_ssa_def *idx,
735 nir_opt_dead_cf(shader);
737 struct rt_variables src_vars = create_rt_variables(shader, vars->create_info, vars->stack_sizes);
740 NIR_PASS_V(shader, lower_rt_instructions, &src_vars, call_idx_base);
742 NIR_PASS(_, shader, nir_opt_remove_phis);
743 NIR_PASS(_, shader, nir_lower_returns);
744 NIR_PASS(_, shader, nir_opt_dce);
746 reserve_stack_size(vars, shader->scratch_size);
750 nir_inline_function_impl(b, nir_shader_get_entrypoint(shader), NULL, var_remap);
753 /* Adopt the instructions from the source shader, since they are merely moved, not cloned. */
754 ralloc_adopt(ralloc_context(b->shader), ralloc_context(shader));
760 lower_rt_derefs(nir_shader *shader)
762 nir_function_impl *impl = nir_shader_get_entrypoint(shader);
822 nir_shader *shader = radv_shader_spirv_to_nir(device, &rt_stage, &key);
824 if (shader->info.stage == MESA_SHADER_RAYGEN || shader->info.stage == MESA_SHADER_CLOSEST_HIT ||
825 shader->info.stage == MESA_SHADER_CALLABLE || shader->info.stage == MESA_SHADER_MISS) {
826 nir_block *last_block = nir_impl_last_block(nir_shader_get_entrypoint(shader));
828 nir_builder_init(&b_inner, nir_shader_get_entrypoint(shader));
833 NIR_PASS(_, shader, nir_lower_vars_to_explicit_types,
837 NIR_PASS(_, shader, lower_rt_derefs);
839 NIR_PASS(_, shader, nir_lower_explicit_io, nir_var_function_temp,
842 return shader;
952 /* Inline the any_hit shader into the intersection shader so we don't have
953 * to implement yet another shader call interface here. Neither do any recursion.
1033 /* Eliminate the casts introduced for the commit return of the any-hit shader. */
1040 * the current state of the traversal vs. what we'd give to a shader. e.g. what
1063 ret.origin = nir_variable_create(b->shader, nir_var_shader_temp, vec3_type, "traversal_origin");
1064 ret.dir = nir_variable_create(b->shader, nir_var_shader_temp, vec3_type, "traversal_dir");
1066 nir_variable_create(b->shader, nir_var_shader_temp, vec3_type, "traversal_inv_dir");
1067 ret.sbt_offset_and_flags = nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(),
1069 ret.instance_id = nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(),
1072 b->shader, nir_var_shader_temp, glsl_uint_type(), "traversal_custom_instance_and_mask");
1074 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint64_t_type(), "instance_addr");
1075 ret.hit = nir_variable_create(b->shader, nir_var_shader_temp, glsl_bool_type(), "traversal_hit");
1076 ret.bvh_base = nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint64_t_type(),
1079 nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(), "traversal_stack_ptr");
1080 ret.top_stack = nir_variable_create(b->shader, nir_var_shader_temp, glsl_uint_type(),
1272 /* For AABBs the intersection shader writes the hit kind, and only does it if it is the
1391 b.shader->info.internal = false;
1392 b.shader->info.workgroup_size[0] = 8;
1393 b.shader->info.workgroup_size[1] = device->physical_device->rt_wave_size == 64 ? 8 : 4;
1394 struct rt_variables vars = create_rt_variables(b.shader, pCreateInfo, dst_vars->stack_sizes);
1399 nir_variable *stack_var = nir_variable_create(b.shader, nir_var_mem_shared,
1575 /* Initialize follow-up shader. */
1586 /* should_return is set if we had a hit but we won't be calling the closest hit shader and hence
1587 * need to return immediately to the calling shader. */
1596 /* Only load the miss shader if we actually miss. It is valid to not specify an SBT pointer
1602 return b.shader;
1611 nir_shader *shader = build_traversal_shader(device, pCreateInfo, vars, var_remap);
1613 /* For now, just inline the traversal shader */
1616 nir_inline_function_impl(b, nir_shader_get_entrypoint(shader), NULL, var_remap);
1619 /* Adopt the instructions from the source shader, since they are merely moved, not cloned. */
1620 ralloc_adopt(ralloc_context(b->shader), ralloc_context(shader));
1671 unreachable("Invalid stage type in RT shader");
1716 move_rt_instructions(nir_shader *shader)
1718 nir_cursor target = nir_before_cf_list(&nir_shader_get_entrypoint(shader)->body);
1720 nir_foreach_block (block, nir_shader_get_entrypoint(shader)) {
1734 nir_metadata_preserve(nir_shader_get_entrypoint(shader),
1746 b.shader->info.internal = false;
1747 b.shader->info.workgroup_size[0] = 8;
1748 b.shader->info.workgroup_size[1] = device->physical_device->rt_wave_size == 64 ? 8 : 4;
1750 struct rt_variables vars = create_rt_variables(b.shader, pCreateInfo, stack_sizes);
1770 * shader of stage x always gets id x and the resume shader ids then come after
1803 /* Put something so scratch gets enabled in the shader. */
1804 b.shader->scratch_size = 16;
1806 b.shader->scratch_size = compute_rt_stack_size(pCreateInfo, stack_sizes);
1809 nir_index_ssa_defs(nir_shader_get_entrypoint(b.shader));
1810 nir_metadata_preserve(nir_shader_get_entrypoint(b.shader), nir_metadata_none);
1812 return b.shader;
1826 nir_shader *shader = NULL;
1880 shader = create_rt_shader(device, &local_create_info, stack_sizes);
1881 module.nir = shader;
1902 /* For General and ClosestHit shaders, we can use the shader ID directly as handle.
1931 ralloc_free(shader);