v3dv: don't lower fsat on V3D 7.x

This requires that our nir options are different across V3D versions
so we can't use a static global any more.

Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30086>
This commit is contained in:
Iago Toral Quiroga 2024-07-10 08:28:04 +02:00
parent 5b1e88760a
commit bb63b7b802
6 changed files with 78 additions and 73 deletions

View file

@ -136,7 +136,7 @@ create_event_pipelines(struct v3dv_device *device)
VkPipeline pipeline;
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
if (!device->events.set_event_pipeline) {
nir_shader *set_event_cs_nir = get_set_event_cs(options);

View file

@ -582,7 +582,7 @@ create_color_clear_pipeline(struct v3dv_device *device,
VkPipeline *pipeline)
{
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
nir_shader *vs_nir = get_clear_rect_vs(options);
nir_shader *fs_nir = get_color_clear_rect_fs(options, rt_idx, format);
@ -647,7 +647,7 @@ create_depth_clear_pipeline(struct v3dv_device *device,
assert(has_depth || has_stencil);
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
nir_shader *vs_nir = get_clear_rect_vs(options);
nir_shader *fs_nir = has_depth ? get_depth_clear_rect_fs(options) : NULL;

View file

@ -2431,7 +2431,7 @@ create_texel_buffer_copy_pipeline(struct v3dv_device *device,
assert(vk_format_is_color(format));
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
nir_shader *vs_nir = get_texel_buffer_copy_vs(options);
nir_shader *fs_nir = get_texel_buffer_copy_fs(options, format, cswizzle);
@ -4094,7 +4094,7 @@ create_blit_pipeline(struct v3dv_device *device,
assert(vk_format_is_color(src_format));
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
const enum glsl_sampler_dim sampler_dim =
get_sampler_dim(src_type, src_samples);

View file

@ -168,69 +168,74 @@ static const struct spirv_to_nir_options default_spirv_options = {
.shared_addr_format = nir_address_format_32bit_offset,
};
const nir_shader_compiler_options v3dv_nir_options = {
.lower_uadd_sat = true,
.lower_usub_sat = true,
.lower_iadd_sat = true,
.lower_all_io_to_temps = true,
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_insert_byte = true,
.lower_insert_word = true,
.lower_bitfield_insert = true,
.lower_bitfield_extract = true,
.lower_bitfield_reverse = true,
.lower_bit_count = true,
.lower_cs_local_id_to_index = true,
.lower_ffract = true,
.lower_fmod = true,
.lower_pack_unorm_2x16 = true,
.lower_pack_snorm_2x16 = true,
.lower_unpack_unorm_2x16 = true,
.lower_unpack_snorm_2x16 = true,
.lower_pack_unorm_4x8 = true,
.lower_pack_snorm_4x8 = true,
.lower_unpack_unorm_4x8 = true,
.lower_unpack_snorm_4x8 = true,
.lower_pack_half_2x16 = true,
.lower_unpack_half_2x16 = true,
.lower_pack_32_2x16 = true,
.lower_pack_32_2x16_split = true,
.lower_unpack_32_2x16_split = true,
.lower_mul_2x32_64 = true,
.lower_fdiv = true,
.lower_find_lsb = true,
.lower_ffma16 = true,
.lower_ffma32 = true,
.lower_ffma64 = true,
.lower_flrp32 = true,
.lower_fpow = true,
.lower_fsat = true,
.lower_fsqrt = true,
.lower_ifind_msb = true,
.lower_isign = true,
.lower_ldexp = true,
.lower_mul_high = true,
.lower_wpos_pntc = false,
.lower_to_scalar = true,
.lower_device_index_to_zero = true,
.lower_fquantize2f16 = true,
.has_fsub = true,
.has_isub = true,
.vertex_id_zero_based = false, /* FIXME: to set this to true, the intrinsic
* needs to be supported */
.lower_interpolate_at = true,
.max_unroll_iterations = 16,
.force_indirect_unrolling = (nir_var_shader_in | nir_var_function_temp),
.divergence_analysis_options =
nir_divergence_multiple_workgroup_per_compute_subgroup,
.discard_is_demote = true,
};
const nir_shader_compiler_options *
v3dv_pipeline_get_nir_options(void)
v3dv_pipeline_get_nir_options(const struct v3d_device_info *devinfo)
{
return &v3dv_nir_options;
static bool initialized = false;
static nir_shader_compiler_options options = {
.lower_uadd_sat = true,
.lower_usub_sat = true,
.lower_iadd_sat = true,
.lower_all_io_to_temps = true,
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_insert_byte = true,
.lower_insert_word = true,
.lower_bitfield_insert = true,
.lower_bitfield_extract = true,
.lower_bitfield_reverse = true,
.lower_bit_count = true,
.lower_cs_local_id_to_index = true,
.lower_ffract = true,
.lower_fmod = true,
.lower_pack_unorm_2x16 = true,
.lower_pack_snorm_2x16 = true,
.lower_unpack_unorm_2x16 = true,
.lower_unpack_snorm_2x16 = true,
.lower_pack_unorm_4x8 = true,
.lower_pack_snorm_4x8 = true,
.lower_unpack_unorm_4x8 = true,
.lower_unpack_snorm_4x8 = true,
.lower_pack_half_2x16 = true,
.lower_unpack_half_2x16 = true,
.lower_pack_32_2x16 = true,
.lower_pack_32_2x16_split = true,
.lower_unpack_32_2x16_split = true,
.lower_mul_2x32_64 = true,
.lower_fdiv = true,
.lower_find_lsb = true,
.lower_ffma16 = true,
.lower_ffma32 = true,
.lower_ffma64 = true,
.lower_flrp32 = true,
.lower_fpow = true,
.lower_fsqrt = true,
.lower_ifind_msb = true,
.lower_isign = true,
.lower_ldexp = true,
.lower_mul_high = true,
.lower_wpos_pntc = false,
.lower_to_scalar = true,
.lower_device_index_to_zero = true,
.lower_fquantize2f16 = true,
.has_fsub = true,
.has_isub = true,
.vertex_id_zero_based = false, /* FIXME: to set this to true, the intrinsic
* needs to be supported */
.lower_interpolate_at = true,
.max_unroll_iterations = 16,
.force_indirect_unrolling = (nir_var_shader_in | nir_var_function_temp),
.divergence_analysis_options =
nir_divergence_multiple_workgroup_per_compute_subgroup,
.discard_is_demote = true,
};
if (!initialized) {
options.lower_fsat = devinfo->ver < 71;
initialized = true;
}
return &options;
}
static const struct vk_ycbcr_conversion_state *
@ -340,7 +345,7 @@ shader_module_compile_to_nir(struct v3dv_device *device,
nir_shader *nir;
const nir_shader_compiler_options *nir_options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
gl_shader_stage gl_stage = broadcom_shader_stage_to_gl(stage->stage);
@ -1830,7 +1835,7 @@ pipeline_stage_get_nir(struct v3dv_pipeline_stage *p_stage,
nir_shader *nir = NULL;
const nir_shader_compiler_options *nir_options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&pipeline->device->devinfo);
nir = v3dv_pipeline_cache_search_for_nir(pipeline, cache,
nir_options,
@ -2239,7 +2244,7 @@ pipeline_add_multiview_gs(struct v3dv_pipeline *pipeline,
nir_shader *vs_nir = p_stage_vs->nir;
const nir_shader_compiler_options *options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&pipeline->device->devinfo);
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_GEOMETRY, options,
"multiview broadcast gs");
nir_shader *nir = b.shader;
@ -2448,7 +2453,7 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
/* Add a no-op fragment shader if needed */
if (!pipeline->stages[BROADCOM_SHADER_FRAGMENT]) {
const nir_shader_compiler_options *compiler_options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&pipeline->device->devinfo);
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT,
compiler_options,
"noop_fs");

View file

@ -2374,7 +2374,7 @@ v3dv_cmd_buffer_get_descriptor_state(struct v3dv_cmd_buffer *cmd_buffer,
return &cmd_buffer->state.gfx.descriptor_state;
}
const nir_shader_compiler_options *v3dv_pipeline_get_nir_options(void);
const nir_shader_compiler_options *v3dv_pipeline_get_nir_options(const struct v3d_device_info *devinfo);
uint32_t v3dv_physical_device_vendor_id(const struct v3dv_physical_device *dev);
uint32_t v3dv_physical_device_device_id(const struct v3dv_physical_device *dev);

View file

@ -1097,7 +1097,7 @@ cmd_buffer_emit_copy_query_pool_results(struct v3dv_cmd_buffer *cmd_buffer,
uint32_t pipeline_idx = copy_pipeline_index_from_flags(flags);
if (!device->queries.copy_pipeline[pipeline_idx]) {
const nir_shader_compiler_options *compiler_options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
nir_shader *copy_query_results_cs_nir =
get_copy_query_results_cs(compiler_options, flags);
VkResult result =
@ -1653,7 +1653,7 @@ create_query_pipelines(struct v3dv_device *device)
}
const nir_shader_compiler_options *compiler_options =
v3dv_pipeline_get_nir_options();
v3dv_pipeline_get_nir_options(&device->devinfo);
if (!device->queries.avail_pipeline) {
nir_shader *set_query_availability_cs_nir =