radv: remove radv_device::physical_device
Get the logical device object using the base object. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28500>
This commit is contained in:

committed by
Marge Bot

parent
310597cab6
commit
896c9cf486
@@ -304,6 +304,7 @@ nir_shader *
|
||||
radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_stage *stage,
|
||||
const struct radv_spirv_to_nir_options *options, bool is_internal)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
unsigned subgroup_size = 64, ballot_bit_size = 64;
|
||||
const unsigned required_subgroup_size = stage->key.subgroup_required_size * 32;
|
||||
if (required_subgroup_size) {
|
||||
@@ -340,7 +341,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
.device = device,
|
||||
.object = stage->spirv.object,
|
||||
};
|
||||
const bool has_fragment_shader_interlock = radv_has_pops(device->physical_device);
|
||||
const bool has_fragment_shader_interlock = radv_has_pops(pdev);
|
||||
const struct spirv_to_nir_options spirv_options = {
|
||||
.caps =
|
||||
{
|
||||
@@ -359,7 +360,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
.device_group = true,
|
||||
.draw_parameters = true,
|
||||
.float_controls = true,
|
||||
.float16 = device->physical_device->info.has_packed_math_16bit,
|
||||
.float16 = pdev->info.has_packed_math_16bit,
|
||||
.float32_atomic_add = true,
|
||||
.float32_atomic_min_max = true,
|
||||
.float64 = true,
|
||||
@@ -411,7 +412,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
.variable_pointers = true,
|
||||
.vk_memory_model = true,
|
||||
.vk_memory_model_device_scope = true,
|
||||
.fragment_shading_rate = device->physical_device->info.gfx_level >= GFX10_3,
|
||||
.fragment_shading_rate = pdev->info.gfx_level >= GFX10_3,
|
||||
.workgroup_memory_explicit_layout = true,
|
||||
.cooperative_matrix = true,
|
||||
},
|
||||
@@ -426,11 +427,11 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
.func = radv_spirv_nir_debug,
|
||||
.private_data = &spirv_debug_data,
|
||||
},
|
||||
.force_tex_non_uniform = device->physical_device->cache_key.tex_non_uniform,
|
||||
.force_ssbo_non_uniform = device->physical_device->cache_key.ssbo_non_uniform,
|
||||
.force_tex_non_uniform = pdev->cache_key.tex_non_uniform,
|
||||
.force_ssbo_non_uniform = pdev->cache_key.ssbo_non_uniform,
|
||||
};
|
||||
nir = spirv_to_nir(spirv, stage->spirv.size / 4, spec_entries, num_spec_entries, stage->stage, stage->entrypoint,
|
||||
&spirv_options, &device->physical_device->nir_options[stage->stage]);
|
||||
&spirv_options, &pdev->nir_options[stage->stage]);
|
||||
nir->info.internal |= is_internal;
|
||||
assert(nir->info.stage == stage->stage);
|
||||
nir_validate_shader(nir, "after spirv_to_nir");
|
||||
@@ -507,7 +508,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
|
||||
|
||||
NIR_PASS(_, nir, nir_propagate_invariant, device->physical_device->cache_key.invariant_geom);
|
||||
NIR_PASS(_, nir, nir_propagate_invariant, pdev->cache_key.invariant_geom);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_clip_cull_distance_arrays);
|
||||
|
||||
@@ -515,11 +516,11 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
nir->info.stage == MESA_SHADER_GEOMETRY)
|
||||
NIR_PASS_V(nir, nir_shader_gather_xfb_info);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_discard_or_demote, device->physical_device->cache_key.lower_discard_to_demote);
|
||||
NIR_PASS(_, nir, nir_lower_discard_or_demote, pdev->cache_key.lower_discard_to_demote);
|
||||
|
||||
nir_lower_doubles_options lower_doubles = nir->options->lower_doubles_options;
|
||||
|
||||
if (device->physical_device->info.gfx_level == GFX6) {
|
||||
if (pdev->info.gfx_level == GFX6) {
|
||||
/* GFX6 doesn't support v_floor_f64 and the precision
|
||||
* of v_fract_f64 which is used to implement 64-bit
|
||||
* floor is less than what Vulkan requires.
|
||||
@@ -537,7 +538,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
/* Mesh shaders run as NGG which can implement local_invocation_index from
|
||||
* the wave ID in merged_wave_info, but they don't have local_invocation_ids on GFX10.3.
|
||||
*/
|
||||
.lower_cs_local_id_to_index = nir->info.stage == MESA_SHADER_MESH && !device->physical_device->mesh_fast_launch_2,
|
||||
.lower_cs_local_id_to_index = nir->info.stage == MESA_SHADER_MESH && !pdev->mesh_fast_launch_2,
|
||||
.lower_local_invocation_index = nir->info.stage == MESA_SHADER_COMPUTE &&
|
||||
((nir->info.workgroup_size[0] == 1) + (nir->info.workgroup_size[1] == 1) +
|
||||
(nir->info.workgroup_size[2] == 1)) == 2,
|
||||
@@ -569,10 +570,10 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
.lower_txf_offset = true,
|
||||
.lower_tg4_offsets = true,
|
||||
.lower_txs_cube_array = true,
|
||||
.lower_to_fragment_fetch_amd = device->physical_device->use_fmask,
|
||||
.lower_to_fragment_fetch_amd = pdev->use_fmask,
|
||||
.lower_lod_zero_width = true,
|
||||
.lower_invalid_implicit_lod = true,
|
||||
.lower_1d = device->physical_device->info.gfx_level == GFX9,
|
||||
.lower_1d = pdev->info.gfx_level == GFX9,
|
||||
};
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_tex, &tex_options);
|
||||
@@ -597,7 +598,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
NIR_PASS(_, nir, nir_lower_global_vars_to_local);
|
||||
NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
|
||||
|
||||
bool gfx7minus = device->physical_device->info.gfx_level <= GFX7;
|
||||
bool gfx7minus = pdev->info.gfx_level <= GFX7;
|
||||
bool has_inverse_ballot = true;
|
||||
#if LLVM_AVAILABLE
|
||||
has_inverse_ballot = !radv_use_llvm_for_stage(device, nir->info.stage) || LLVM_VERSION_MAJOR >= 17;
|
||||
@@ -690,7 +691,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
nir->info.stage == MESA_SHADER_MESH) &&
|
||||
nir->info.outputs_written & BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_SHADING_RATE)) {
|
||||
/* Lower primitive shading rate to match HW requirements. */
|
||||
NIR_PASS(_, nir, radv_nir_lower_primitive_shading_rate, device->physical_device->info.gfx_level);
|
||||
NIR_PASS(_, nir, radv_nir_lower_primitive_shading_rate, pdev->info.gfx_level);
|
||||
}
|
||||
|
||||
/* Indirect lowering must be called after the radv_optimize_nir() loop
|
||||
@@ -698,8 +699,8 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
|
||||
* bloat the instruction count of the loop and cause it to be
|
||||
* considered too large for unrolling.
|
||||
*/
|
||||
if (ac_nir_lower_indirect_derefs(nir, device->physical_device->info.gfx_level) &&
|
||||
!stage->key.optimisations_disabled && nir->info.stage != MESA_SHADER_COMPUTE) {
|
||||
if (ac_nir_lower_indirect_derefs(nir, pdev->info.gfx_level) && !stage->key.optimisations_disabled &&
|
||||
nir->info.stage != MESA_SHADER_COMPUTE) {
|
||||
/* Optimize the lowered code before the linking optimizations. */
|
||||
radv_optimize_nir(nir, false);
|
||||
}
|
||||
@@ -775,6 +776,7 @@ void
|
||||
radv_lower_ngg(struct radv_device *device, struct radv_shader_stage *ngg_stage,
|
||||
const struct radv_graphics_state_key *gfx_state)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
const struct radv_shader_info *info = &ngg_stage->info;
|
||||
nir_shader *nir = ngg_stage->nir;
|
||||
|
||||
@@ -818,19 +820,19 @@ radv_lower_ngg(struct radv_device *device, struct radv_shader_stage *ngg_stage,
|
||||
nir->info.shared_size = info->ngg_info.lds_size;
|
||||
|
||||
ac_nir_lower_ngg_options options = {0};
|
||||
options.family = device->physical_device->info.family;
|
||||
options.gfx_level = device->physical_device->info.gfx_level;
|
||||
options.family = pdev->info.family;
|
||||
options.gfx_level = pdev->info.gfx_level;
|
||||
options.max_workgroup_size = info->workgroup_size;
|
||||
options.wave_size = info->wave_size;
|
||||
options.clip_cull_dist_mask = info->outinfo.clip_dist_mask | info->outinfo.cull_dist_mask;
|
||||
options.vs_output_param_offset = info->outinfo.vs_output_param_offset;
|
||||
options.has_param_exports = info->outinfo.param_exports || info->outinfo.prim_param_exports;
|
||||
options.can_cull = nir->info.stage != MESA_SHADER_GEOMETRY && info->has_ngg_culling;
|
||||
options.disable_streamout = !device->physical_device->use_ngg_streamout;
|
||||
options.disable_streamout = !pdev->use_ngg_streamout;
|
||||
options.has_gen_prim_query = info->has_prim_query;
|
||||
options.has_xfb_prim_query = info->has_xfb_query;
|
||||
options.has_gs_invocations_query = device->physical_device->info.gfx_level < GFX11;
|
||||
options.has_gs_primitives_query = device->physical_device->info.gfx_level < GFX11;
|
||||
options.has_gs_invocations_query = pdev->info.gfx_level < GFX11;
|
||||
options.has_gs_primitives_query = pdev->info.gfx_level < GFX11;
|
||||
options.force_vrs = info->force_vrs_per_vertex;
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_TESS_EVAL) {
|
||||
@@ -862,8 +864,7 @@ radv_lower_ngg(struct radv_device *device, struct radv_shader_stage *ngg_stage,
|
||||
bool scratch_ring = false;
|
||||
NIR_PASS_V(nir, ac_nir_lower_ngg_ms, options.gfx_level, options.clip_cull_dist_mask,
|
||||
options.vs_output_param_offset, options.has_param_exports, &scratch_ring, info->wave_size,
|
||||
hw_workgroup_size, gfx_state->has_multiview_view_index, info->ms.has_query,
|
||||
device->physical_device->mesh_fast_launch_2);
|
||||
hw_workgroup_size, gfx_state->has_multiview_view_index, info->ms.has_query, pdev->mesh_fast_launch_2);
|
||||
ngg_stage->info.ms.needs_ms_scratch_ring = scratch_ring;
|
||||
} else {
|
||||
unreachable("invalid SW stage passed to radv_lower_ngg");
|
||||
@@ -933,6 +934,7 @@ static struct radv_shader_arena *
|
||||
radv_create_shader_arena(struct radv_device *device, struct radv_shader_free_list *free_list, unsigned min_size,
|
||||
unsigned arena_size, bool replayable, uint64_t replay_va)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
union radv_shader_arena_block *alloc = NULL;
|
||||
struct radv_shader_arena *arena = calloc(1, sizeof(struct radv_shader_arena));
|
||||
if (!arena)
|
||||
@@ -948,7 +950,7 @@ radv_create_shader_arena(struct radv_device *device, struct radv_shader_free_lis
|
||||
if (device->shader_use_invisible_vram)
|
||||
flags |= RADEON_FLAG_NO_CPU_ACCESS;
|
||||
else
|
||||
flags |= (device->physical_device->info.cpdma_prefetch_writes_memory ? 0 : RADEON_FLAG_READ_ONLY);
|
||||
flags |= (pdev->info.cpdma_prefetch_writes_memory ? 0 : RADEON_FLAG_READ_ONLY);
|
||||
|
||||
if (replayable)
|
||||
flags |= RADEON_FLAG_REPLAYABLE;
|
||||
@@ -1079,7 +1081,9 @@ insert_block(struct radv_device *device, union radv_shader_arena_block *hole, ui
|
||||
union radv_shader_arena_block *
|
||||
radv_alloc_shader_memory(struct radv_device *device, uint32_t size, bool replayable, void *ptr)
|
||||
{
|
||||
size = ac_align_shader_binary_for_prefetch(&device->physical_device->info, size);
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
|
||||
size = ac_align_shader_binary_for_prefetch(&pdev->info, size);
|
||||
size = align(size, RADV_SHADER_ALLOC_ALIGNMENT);
|
||||
|
||||
mtx_lock(&device->shader_arena_mutex);
|
||||
@@ -1402,7 +1406,8 @@ radv_destroy_shader_upload_queue(struct radv_device *device)
|
||||
static bool
|
||||
radv_should_use_wgp_mode(const struct radv_device *device, gl_shader_stage stage, const struct radv_shader_info *info)
|
||||
{
|
||||
enum amd_gfx_level chip = device->physical_device->info.gfx_level;
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
enum amd_gfx_level chip = pdev->info.gfx_level;
|
||||
switch (stage) {
|
||||
case MESA_SHADER_COMPUTE:
|
||||
case MESA_SHADER_TESS_CTRL:
|
||||
@@ -1422,13 +1427,13 @@ static bool
|
||||
radv_open_rtld_binary(struct radv_device *device, const struct radv_shader_binary *binary,
|
||||
struct ac_rtld_binary *rtld_binary)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
const char *elf_data = (const char *)((struct radv_shader_binary_rtld *)binary)->data;
|
||||
size_t elf_size = ((struct radv_shader_binary_rtld *)binary)->elf_size;
|
||||
struct ac_rtld_symbol lds_symbols[3];
|
||||
unsigned num_lds_symbols = 0;
|
||||
|
||||
if (device->physical_device->info.gfx_level >= GFX9 &&
|
||||
(binary->info.stage == MESA_SHADER_GEOMETRY || binary->info.is_ngg)) {
|
||||
if (pdev->info.gfx_level >= GFX9 && (binary->info.stage == MESA_SHADER_GEOMETRY || binary->info.is_ngg)) {
|
||||
struct ac_rtld_symbol *sym = &lds_symbols[num_lds_symbols++];
|
||||
sym->name = "esgs_ring";
|
||||
sym->size = binary->info.ngg_info.esgs_ring_size;
|
||||
@@ -1448,7 +1453,7 @@ radv_open_rtld_binary(struct radv_device *device, const struct radv_shader_binar
|
||||
}
|
||||
|
||||
struct ac_rtld_open_info open_info = {
|
||||
.info = &device->physical_device->info,
|
||||
.info = &pdev->info,
|
||||
.shader_type = binary->info.stage,
|
||||
.wave_size = binary->info.wave_size,
|
||||
.num_parts = 1,
|
||||
@@ -1466,6 +1471,7 @@ static bool
|
||||
radv_postprocess_binary_config(struct radv_device *device, struct radv_shader_binary *binary,
|
||||
const struct radv_shader_args *args)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
struct ac_shader_config *config = &binary->config;
|
||||
|
||||
if (binary->type == RADV_BINARY_TYPE_RTLD) {
|
||||
@@ -1478,13 +1484,13 @@ radv_postprocess_binary_config(struct radv_device *device, struct radv_shader_bi
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ac_rtld_read_config(&device->physical_device->info, &rtld_binary, config)) {
|
||||
if (!ac_rtld_read_config(&pdev->info, &rtld_binary, config)) {
|
||||
ac_rtld_close(&rtld_binary);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rtld_binary.lds_size > 0) {
|
||||
unsigned encode_granularity = device->physical_device->info.lds_encode_granularity;
|
||||
unsigned encode_granularity = pdev->info.lds_encode_granularity;
|
||||
config->lds_size = DIV_ROUND_UP(rtld_binary.lds_size, encode_granularity);
|
||||
}
|
||||
if (!config->lds_size && binary->info.stage == MESA_SHADER_TESS_CTRL) {
|
||||
@@ -1499,7 +1505,6 @@ radv_postprocess_binary_config(struct radv_device *device, struct radv_shader_bi
|
||||
|
||||
const struct radv_shader_info *info = &binary->info;
|
||||
gl_shader_stage stage = binary->info.stage;
|
||||
const struct radv_physical_device *pdev = device->physical_device;
|
||||
bool scratch_enabled = config->scratch_bytes_per_wave > 0;
|
||||
bool trap_enabled = !!device->trap_handler_shader;
|
||||
unsigned vgpr_comp_cnt = 0;
|
||||
@@ -2064,7 +2069,8 @@ unsigned
|
||||
radv_get_max_waves(const struct radv_device *device, const struct ac_shader_config *conf,
|
||||
const struct radv_shader_info *info)
|
||||
{
|
||||
const struct radeon_info *gpu_info = &device->physical_device->info;
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
const struct radeon_info *gpu_info = &pdev->info;
|
||||
const enum amd_gfx_level gfx_level = gpu_info->gfx_level;
|
||||
const uint8_t wave_size = info->wave_size;
|
||||
gl_shader_stage stage = info->stage;
|
||||
@@ -2109,7 +2115,8 @@ radv_get_max_waves(const struct radv_device *device, const struct ac_shader_conf
|
||||
unsigned
|
||||
radv_get_max_scratch_waves(const struct radv_device *device, struct radv_shader *shader)
|
||||
{
|
||||
const unsigned num_cu = device->physical_device->info.num_cu;
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
const unsigned num_cu = pdev->info.num_cu;
|
||||
|
||||
return MIN2(device->scratch_waves, 4 * num_cu * shader->max_waves);
|
||||
}
|
||||
@@ -2423,10 +2430,12 @@ radv_fill_nir_compiler_options(struct radv_nir_compiler_options *options, struct
|
||||
bool can_dump_shader, bool is_meta_shader, bool keep_shader_info,
|
||||
bool keep_statistic_info)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
|
||||
/* robust_buffer_access_llvm here used by LLVM only, pipeline robustness is not exposed there. */
|
||||
options->robust_buffer_access_llvm = device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_1;
|
||||
options->wgp_mode = should_use_wgp;
|
||||
options->info = &device->physical_device->info;
|
||||
options->info = &pdev->info;
|
||||
options->dump_shader = can_dump_shader;
|
||||
options->dump_preoptir = options->dump_shader && device->instance->debug_flags & RADV_DEBUG_PREOPTIR;
|
||||
options->record_ir = keep_shader_info;
|
||||
@@ -2607,6 +2616,7 @@ radv_aco_build_shader_part(void **bin, uint32_t num_sgprs, uint32_t num_vgprs, c
|
||||
struct radv_shader *
|
||||
radv_create_rt_prolog(struct radv_device *device)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
struct radv_shader *prolog;
|
||||
struct radv_shader_args in_args = {0};
|
||||
struct radv_shader_args out_args = {0};
|
||||
@@ -2618,13 +2628,13 @@ radv_create_rt_prolog(struct radv_device *device)
|
||||
info.stage = MESA_SHADER_COMPUTE;
|
||||
info.loads_push_constants = true;
|
||||
info.desc_set_used_mask = -1; /* just to force indirection */
|
||||
info.wave_size = device->physical_device->rt_wave_size;
|
||||
info.wave_size = pdev->rt_wave_size;
|
||||
info.workgroup_size = info.wave_size;
|
||||
info.user_data_0 = R_00B900_COMPUTE_USER_DATA_0;
|
||||
info.cs.is_rt_shader = true;
|
||||
info.cs.uses_dynamic_rt_callable_stack = true;
|
||||
info.cs.block_size[0] = 8;
|
||||
info.cs.block_size[1] = device->physical_device->rt_wave_size == 64 ? 8 : 4;
|
||||
info.cs.block_size[1] = pdev->rt_wave_size == 64 ? 8 : 4;
|
||||
info.cs.block_size[2] = 1;
|
||||
info.cs.uses_thread_id[0] = true;
|
||||
info.cs.uses_thread_id[1] = true;
|
||||
@@ -2739,6 +2749,7 @@ struct radv_shader_part *
|
||||
radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_key *key,
|
||||
struct radv_shader_part_binary **binary_out)
|
||||
{
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
struct radv_shader_part *epilog;
|
||||
struct radv_shader_args args = {0};
|
||||
struct radv_nir_compiler_options options = {0};
|
||||
@@ -2748,7 +2759,7 @@ radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_ke
|
||||
|
||||
struct radv_shader_info info = {0};
|
||||
info.stage = MESA_SHADER_FRAGMENT;
|
||||
info.wave_size = device->physical_device->ps_wave_size;
|
||||
info.wave_size = pdev->ps_wave_size;
|
||||
info.workgroup_size = 64;
|
||||
|
||||
radv_declare_ps_epilog_args(device, key, &args);
|
||||
|
Reference in New Issue
Block a user