xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/r600/r600_shader_common.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2010 Jerome Glisse <[email protected]>
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef R600_SHADER_COMMON_H
7 #define R600_SHADER_COMMON_H
8 
9 #include "r600_asm.h"
10 
11 #include "compiler/shader_enums.h"
12 
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* Valid shader configurations:
19  *
20  * API shaders       VS | TCS | TES | GS |pass| PS
21  * are compiled as:     |     |     |    |thru|
22  *                      |     |     |    |    |
23  * Only VS & PS:     VS | --  | --  | -- | -- | PS
24  * With GS:          ES | --  | --  | GS | VS | PS
25  * With Tessel.:     LS | HS  | VS  | -- | -- | PS
26  * With both:        LS | HS  | ES  | GS | VS | PS
27  */
28 
29 struct r600_shader_io {
30 	gl_varying_slot		varying_slot;
31 	gl_system_value		system_value; /* Input only */
32 	gl_frag_result		frag_result;
33 	unsigned		gpr;
34 	int			spi_sid;
35 	unsigned		interpolate;
36 	unsigned		ij_index;
37 	unsigned		interpolate_location; //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
38 	unsigned		lds_pos; /* for evergreen */
39 	unsigned		write_mask;
40 	int			export_param; /* Output only */
41 	int			ring_offset;
42 	unsigned		uses_interpolate_at_centroid;
43 };
44 
45 struct r600_shader_atomic {
46 	unsigned start, end;
47 	unsigned buffer_id;
48 	unsigned hw_idx;
49 };
50 
51 #define R600_SHADER_MAX_INPUTS (32 /* generic */ + 32 /* patch */ + 16 /* others */)
52 #define R600_SHADER_MAX_OUTPUTS (32 /* generic */ + 32 /* patch */ + 16 /* others */)
53 
54 struct r600_shader {
55 	unsigned		processor_type;
56 	struct r600_bytecode		bc;
57 	unsigned		ninput;
58 	unsigned		noutput;
59 	unsigned                nhwatomic;
60 	unsigned		nlds;
61 	unsigned		nsys_inputs;
62 	unsigned		highest_export_param;
63 	struct r600_shader_io	input[R600_SHADER_MAX_INPUTS];
64 	struct r600_shader_io	output[R600_SHADER_MAX_OUTPUTS];
65 	struct r600_shader_atomic atomics[8];
66 	unsigned                nhwatomic_ranges;
67 	bool			uses_kill;
68 	bool			fs_write_all;
69 	bool			two_side;
70 	bool			needs_scratch_space;
71 	/* Real number of ps color exports compiled in the bytecode */
72 	unsigned		nr_ps_color_exports;
73 	unsigned                ps_color_export_mask;
74 	unsigned                ps_export_highest;
75 	/* bit n is set if the shader writes gl_ClipDistance[n] */
76 	unsigned		cc_dist_mask;
77 	unsigned		clip_dist_write;
78 	unsigned                cull_dist_write;
79 	bool			vs_position_window_space;
80 	/* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
81 	bool			vs_out_misc_write;
82 	bool			vs_out_point_size;
83 	bool			vs_out_layer;
84 	bool			vs_out_viewport;
85 	bool			vs_out_edgeflag;
86 	bool			has_txq_cube_array_z_comp;
87 	bool			uses_tex_buffers;
88 	bool                 gs_prim_id_input;
89 	bool                 gs_tri_strip_adj_fix;
90 	uint8_t			ps_conservative_z;
91 
92 	/* Size in bytes of a data item in the ring(s) (single vertex data).
93 	   Stages with only one ring items 123 will be set to 0. */
94 	unsigned		ring_item_sizes[4];
95 
96 	unsigned		indirect_files;
97 	unsigned		max_arrays;
98 	unsigned		num_arrays;
99 	unsigned		vs_as_es;
100 	unsigned		vs_as_ls;
101 	unsigned		vs_as_gs_a;
102 	unsigned                tes_as_es;
103 	unsigned                tcs_prim_mode;
104 	unsigned                num_loops;
105 
106 	struct r600_shader_array * arrays;
107 
108 	bool			uses_doubles;
109 	bool                 uses_atomics;
110 	bool			uses_images;
111 	bool			uses_helper_invocation;
112 	bool			uses_interpolate_at_sample;
113 	uint8_t                 atomic_base;
114 	uint8_t			rat_base;
115 	uint8_t                 image_size_const_offset;
116         bool			disable_sb;
117 };
118 
119 union r600_shader_key {
120 	struct {
121 		unsigned	nr_cbufs:4;
122 		unsigned        first_atomic_counter:4;
123 		unsigned        image_size_const_offset:5;
124 		unsigned	color_two_side:1;
125 		unsigned	alpha_to_one:1;
126 		unsigned        apply_sample_id_mask:1;
127 		unsigned        dual_source_blend:1;
128 	} ps;
129 	struct {
130 		unsigned        first_atomic_counter:4;
131 		unsigned	as_es:1; /* export shader */
132 		unsigned	as_ls:1; /* local shader */
133 		unsigned	as_gs_a:1;
134 	} vs;
135 	struct {
136 		unsigned        first_atomic_counter:4;
137 		unsigned	as_es:1;
138 	} tes;
139 	struct {
140 		unsigned        first_atomic_counter:4;
141 		unsigned	prim_mode:3;
142 	} tcs;
143 	struct {
144 		unsigned        first_atomic_counter:4;
145 		unsigned        tri_strip_adj_fix:1;
146 	} gs;
147 };
148 
149 struct r600_shader_array {
150 	unsigned gpr_start;
151 	unsigned gpr_count;
152 	unsigned comp_mask;
153 };
154 
155 #ifdef __cplusplus
156 }  // extern "C"
157 #endif
158 
159 
160 #endif
161