Debian Codegraph @

src/panfrost/compiler/pan_nir.h

raw
1 /*
2 * Copyright (C) 2025 Collabora, Ltd.
3 * SPDX-License-Identifier: MIT
4 */
5
6 #ifndef __PAN_NIR_H__
7 #define __PAN_NIR_H__
8
9 #include "nir.h"
10 #include "nir_builder.h"
11 #include "pan_compiler.h"
12
13 struct util_format_description;
14
15 static inline nir_def *
16 pan_nir_tile_rt_sample(nir_builder *b, nir_def *rt, nir_def *sample)
17 {
18 /* y = 255 means "current pixel" */
19 return nir_pack_32_4x8_split(b, nir_u2u8(b, sample),
20 nir_u2u8(b, rt),
21 nir_imm_intN_t(b, 0, 8),
22 nir_imm_intN_t(b, 255, 8));
23 }
24
25 static inline nir_def *
26 pan_nir_tile_location_sample(nir_builder *b, gl_frag_result location,
27 nir_def *sample)
28 {
29 uint8_t rt;
30 if (location == FRAG_RESULT_DEPTH) {
31 rt = 255;
32 } else if (location == FRAG_RESULT_STENCIL) {
33 rt = 254;
34 } else {
35 assert(location >= FRAG_RESULT_DATA0);
36 rt = location - FRAG_RESULT_DATA0;
37 }
38
39 return pan_nir_tile_rt_sample(b, nir_imm_int(b, rt), sample);
40 }
41
42 static inline nir_def *
43 pan_nir_tile_default_coverage(nir_builder *b)
44 {
45 return nir_iand_imm(b, nir_load_cumulative_coverage_pan(b), 0x1f);
46 }
47
48 bool pan_nir_lower_bool_to_bitsize(nir_shader *shader);
49
50 bool pan_nir_lower_vertex_id(nir_shader *shader);
51
52 bool pan_nir_lower_image_ms(nir_shader *shader);
53
54 bool pan_nir_lower_var_special_pan(nir_shader *shader);
55 bool pan_nir_lower_noperspective_vs(nir_shader *shader);
56 bool pan_nir_lower_noperspective_fs(nir_shader *shader);
57
58 bool pan_nir_lower_vs_outputs(nir_shader *shader, uint64_t gpu_id,
59 const struct pan_varying_layout *varying_layout,
60 bool has_idvs, bool *needs_extended_fifo);
61
62 bool pan_nir_lower_fs_inputs(nir_shader *shader, uint64_t gpu_id,
63 const struct pan_varying_layout *varying_layout,
64 struct pan_shader_info *info);
65
66 bool pan_nir_lower_helper_invocation(nir_shader *shader);
67 bool pan_nir_lower_sample_pos(nir_shader *shader);
68 bool pan_nir_lower_xfb(nir_shader *nir);
69
70 bool pan_nir_lower_image_index(nir_shader *shader,
71 unsigned vs_img_attrib_offset);
72 bool pan_nir_lower_texel_buffer_fetch_index(nir_shader *shader,
73 unsigned attrib_offset);
74
75 nir_alu_type
76 pan_unpacked_type_for_format(const struct util_format_description *desc);
77
78 bool pan_nir_lower_framebuffer(nir_shader *shader,
79 const enum pipe_format *rt_fmts,
80 uint8_t raw_fmt_mask,
81 unsigned blend_shader_nr_samples,
82 bool broken_ld_special);
83
84 bool pan_nir_lower_fs_outputs(nir_shader *shader, bool skip_atest);
85
86 uint32_t pan_nir_collect_noperspective_varyings_fs(nir_shader *s);
87
88 bool pan_nir_resize_varying_io(nir_shader *nir,
89 const struct pan_varying_layout *varying_layout);
90
91 #endif /* __PAN_NIR_H__ */