2023-03-28 22:13:23 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2023 Valve Corporation
|
|
|
|
|
*
|
2024-04-05 16:28:39 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2023-03-28 22:13:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef RADV_NIR_H
|
|
|
|
|
#define RADV_NIR_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include "amd_family.h"
|
2025-02-06 12:09:38 +01:00
|
|
|
#include "nir_defines.h"
|
2023-03-28 22:13:23 +02:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
typedef struct nir_shader nir_shader;
|
|
|
|
|
struct radeon_info;
|
2023-07-25 09:56:44 +02:00
|
|
|
struct radv_shader_stage;
|
2023-03-28 22:13:23 +02:00
|
|
|
struct radv_shader_info;
|
|
|
|
|
struct radv_shader_args;
|
2023-08-08 18:37:58 +02:00
|
|
|
struct radv_shader_layout;
|
2023-03-28 22:13:23 +02:00
|
|
|
struct radv_device;
|
2024-01-11 15:32:38 +01:00
|
|
|
struct radv_graphics_state_key;
|
2023-03-28 22:13:23 +02:00
|
|
|
|
2025-02-17 23:40:01 +01:00
|
|
|
bool radv_nir_apply_pipeline_layout(nir_shader *shader, struct radv_device *device,
|
2024-01-09 13:57:42 +01:00
|
|
|
const struct radv_shader_stage *stage);
|
2023-03-28 22:13:23 +02:00
|
|
|
|
2025-02-17 23:35:55 +01:00
|
|
|
bool radv_nir_lower_abi(nir_shader *shader, enum amd_gfx_level gfx_level, const struct radv_shader_stage *stage,
|
2024-01-11 15:32:38 +01:00
|
|
|
const struct radv_graphics_state_key *gfx_state, uint32_t address32_hi);
|
2023-03-28 22:13:23 +02:00
|
|
|
|
2023-07-20 21:13:22 +02:00
|
|
|
bool radv_nir_lower_hit_attrib_derefs(nir_shader *shader);
|
|
|
|
|
|
2023-11-15 15:03:09 +01:00
|
|
|
bool radv_nir_lower_ray_payload_derefs(nir_shader *shader, uint32_t offset);
|
|
|
|
|
|
2024-01-09 13:58:43 +01:00
|
|
|
bool radv_nir_lower_ray_queries(nir_shader *shader, struct radv_device *device);
|
2023-03-28 22:13:23 +02:00
|
|
|
|
2023-07-25 09:56:44 +02:00
|
|
|
bool radv_nir_lower_vs_inputs(nir_shader *shader, const struct radv_shader_stage *vs_stage,
|
2024-03-28 13:44:11 +01:00
|
|
|
const struct radv_graphics_state_key *gfx_state, const struct radeon_info *gpu_info);
|
2023-03-28 22:13:23 +02:00
|
|
|
|
radv: optimize VS input load components to constants earlier
This helps some linking optimizations.
fossil-db (navi21):
Totals from 2262 (2.85% of 79395) affected shaders:
MaxWaves: 57680 -> 57738 (+0.10%); split: +0.11%, -0.01%
Instrs: 1061526 -> 1053937 (-0.71%); split: -0.79%, +0.07%
CodeSize: 5766352 -> 5736784 (-0.51%); split: -0.60%, +0.08%
VGPRs: 89376 -> 89000 (-0.42%); split: -0.43%, +0.01%
Latency: 4102938 -> 4059773 (-1.05%); split: -1.14%, +0.08%
InvThroughput: 1105885 -> 1092291 (-1.23%); split: -1.24%, +0.01%
VClause: 18917 -> 18972 (+0.29%); split: -0.12%, +0.41%
SClause: 28839 -> 28115 (-2.51%); split: -3.32%, +0.81%
Copies: 73396 -> 72671 (-0.99%); split: -1.63%, +0.65%
PreSGPRs: 65866 -> 65838 (-0.04%); split: -0.22%, +0.17%
PreVGPRs: 69752 -> 69278 (-0.68%)
VALU: 680351 -> 673489 (-1.01%); split: -1.03%, +0.02%
SALU: 121459 -> 121515 (+0.05%); split: -0.00%, +0.05%
VMEM: 29632 -> 30021 (+1.31%); split: -0.02%, +1.33%
SMEM: 73744 -> 73836 (+0.12%); split: -0.01%, +0.14%
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31593>
2024-09-23 09:56:07 +01:00
|
|
|
bool radv_nir_optimize_vs_inputs_to_const(nir_shader *shader, const struct radv_graphics_state_key *gfx_state);
|
|
|
|
|
|
2023-03-16 13:05:07 -07:00
|
|
|
bool radv_nir_lower_primitive_shading_rate(nir_shader *nir, enum amd_gfx_level gfx_level);
|
|
|
|
|
|
2023-07-25 09:56:44 +02:00
|
|
|
bool radv_nir_lower_fs_intrinsics(nir_shader *nir, const struct radv_shader_stage *fs_stage,
|
2024-01-11 15:32:38 +01:00
|
|
|
const struct radv_graphics_state_key *gfx_state);
|
2023-03-29 18:46:11 +02:00
|
|
|
|
2025-06-17 11:23:19 +02:00
|
|
|
bool radv_nir_lower_fs_input_attachment(nir_shader *nir);
|
|
|
|
|
|
2024-01-11 15:32:38 +01:00
|
|
|
bool radv_nir_lower_fs_barycentric(nir_shader *shader, const struct radv_graphics_state_key *gfx_state,
|
|
|
|
|
unsigned rast_prim);
|
2022-05-26 11:37:24 +02:00
|
|
|
|
2024-01-21 17:48:44 +09:00
|
|
|
bool radv_nir_lower_intrinsics_early(nir_shader *nir, bool lower_view_index_to_zero);
|
2023-03-29 18:54:07 +02:00
|
|
|
|
2024-09-16 17:51:09 +02:00
|
|
|
bool radv_nir_lower_view_index(nir_shader *nir);
|
2023-03-16 13:25:16 -07:00
|
|
|
|
2023-03-29 19:12:06 +02:00
|
|
|
bool radv_nir_lower_viewport_to_zero(nir_shader *nir);
|
|
|
|
|
|
2023-03-29 19:12:41 +02:00
|
|
|
bool radv_nir_export_multiview(nir_shader *nir);
|
|
|
|
|
|
2025-06-25 17:45:31 -04:00
|
|
|
void radv_nir_lower_io_vars_to_scalar(nir_shader *nir, nir_variable_mode mask);
|
2023-03-29 22:30:45 +02:00
|
|
|
|
2024-03-07 13:51:59 +01:00
|
|
|
unsigned radv_map_io_driver_location(unsigned semantic);
|
|
|
|
|
|
2024-11-19 14:49:17 +01:00
|
|
|
bool radv_recompute_fs_input_bases(nir_shader *nir);
|
|
|
|
|
|
2023-03-29 22:30:45 +02:00
|
|
|
void radv_nir_lower_io(struct radv_device *device, nir_shader *nir);
|
|
|
|
|
|
2023-07-25 09:56:44 +02:00
|
|
|
bool radv_nir_lower_io_to_mem(struct radv_device *device, struct radv_shader_stage *stage);
|
2023-03-29 22:30:45 +02:00
|
|
|
|
2025-01-22 03:52:10 -08:00
|
|
|
bool radv_nir_lower_cooperative_matrix(nir_shader *shader, enum amd_gfx_level gfx_level, unsigned wave_size);
|
2023-07-16 01:01:55 +02:00
|
|
|
|
2025-04-06 13:09:19 +02:00
|
|
|
bool radv_nir_opt_cooperative_matrix(nir_shader *shader, enum amd_gfx_level gfx_level);
|
|
|
|
|
|
2024-03-01 11:48:17 +01:00
|
|
|
bool radv_nir_lower_draw_id_to_zero(nir_shader *shader);
|
|
|
|
|
|
2024-03-20 16:43:43 +01:00
|
|
|
bool radv_nir_remap_color_attachment(nir_shader *shader, const struct radv_graphics_state_key *gfx_state);
|
|
|
|
|
|
2025-03-19 21:26:19 +01:00
|
|
|
bool radv_nir_lower_printf(nir_shader *shader);
|
|
|
|
|
|
2023-02-20 16:31:06 +01:00
|
|
|
typedef struct radv_nir_opt_tid_function_options {
|
|
|
|
|
bool use_masked_swizzle_amd : 1;
|
|
|
|
|
bool use_dpp16_shift_amd : 1;
|
|
|
|
|
bool use_shuffle_xor : 1;
|
|
|
|
|
bool use_clustered_rotate : 1;
|
|
|
|
|
/* The can be smaller than the api subgroup/ballot size
|
|
|
|
|
* if some invocations are always inactive.
|
|
|
|
|
*/
|
|
|
|
|
uint8_t hw_subgroup_size;
|
|
|
|
|
uint8_t hw_ballot_bit_size;
|
|
|
|
|
uint8_t hw_ballot_num_comp;
|
|
|
|
|
} radv_nir_opt_tid_function_options;
|
|
|
|
|
|
|
|
|
|
bool radv_nir_opt_tid_function(nir_shader *shader, const radv_nir_opt_tid_function_options *options);
|
|
|
|
|
|
radv: Optimize fs builtins using static gfx state
The values of some builtins are known at compile time when the
application creates pipelines with static state.
Stats for graphics pipelines:
Totals from 568 (0.71% of 80536) affected shaders:
MaxWaves: 12364 -> 12502 (+1.12%); split: +1.26%, -0.15%
Instrs: 515696 -> 501182 (-2.81%); split: -2.85%, +0.04%
CodeSize: 2815736 -> 2741464 (-2.64%); split: -2.69%, +0.05%
VGPRs: 29528 -> 29160 (-1.25%); split: -1.71%, +0.46%
SpillSGPRs: 212 -> 215 (+1.42%)
Latency: 5515421 -> 5409125 (-1.93%); split: -2.05%, +0.13%
InvThroughput: 1293512 -> 1277913 (-1.21%); split: -1.27%, +0.06%
VClause: 10570 -> 10295 (-2.60%); split: -2.74%, +0.14%
SClause: 19040 -> 18531 (-2.67%); split: -2.83%, +0.16%
Copies: 37189 -> 35431 (-4.73%); split: -5.31%, +0.58%
Branches: 11391 -> 11070 (-2.82%); split: -2.92%, +0.11%
PreSGPRs: 27848 -> 27313 (-1.92%); split: -1.95%, +0.03%
PreVGPRs: 24847 -> 24106 (-2.98%); split: -3.00%, +0.02%
VALU: 359356 -> 348779 (-2.94%); split: -2.97%, +0.03%
SALU: 59135 -> 57448 (-2.85%); split: -3.11%, +0.26%
VMEM: 14674 -> 14313 (-2.46%)
SMEM: 30901 -> 30342 (-1.81%); split: -1.84%, +0.03%
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32793>
2024-12-28 14:05:07 +01:00
|
|
|
bool radv_nir_opt_fs_builtins(nir_shader *shader, const struct radv_graphics_state_key *gfx_state);
|
|
|
|
|
|
2025-10-03 18:01:15 +02:00
|
|
|
bool radv_nir_lower_immediate_samplers(nir_shader *shader, struct radv_device *device,
|
|
|
|
|
const struct radv_shader_stage *stage);
|
|
|
|
|
|
2023-03-28 22:13:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* RADV_NIR_H */
|