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;
|
|
|
|
|
struct radv_pipeline_layout;
|
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
|
|
|
|
2024-01-09 13:57:42 +01:00
|
|
|
void radv_nir_apply_pipeline_layout(nir_shader *shader, struct radv_device *device,
|
|
|
|
|
const struct radv_shader_stage *stage);
|
2023-03-28 22:13:23 +02:00
|
|
|
|
2024-01-09 13:57:42 +01:00
|
|
|
void 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
|
|
|
|
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);
|
|
|
|
|
|
2023-03-29 22:30:45 +02:00
|
|
|
void radv_nir_lower_io_to_scalar_early(nir_shader *nir, nir_variable_mode mask);
|
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
|
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);
|
|
|
|
|
|
2023-03-28 22:13:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* RADV_NIR_H */
|