• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef R600_SHADER_COMMON_H
25 #define R600_SHADER_COMMON_H
26 
27 #include "r600_asm.h"
28 
29 #include "compiler/shader_enums.h"
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* Valid shader configurations:
37  *
38  * API shaders       VS | TCS | TES | GS |pass| PS
39  * are compiled as:     |     |     |    |thru|
40  *                      |     |     |    |    |
41  * Only VS & PS:     VS | --  | --  | -- | -- | PS
42  * With GS:          ES | --  | --  | GS | VS | PS
43  * With Tessel.:     LS | HS  | VS  | -- | -- | PS
44  * With both:        LS | HS  | ES  | GS | VS | PS
45  */
46 
47 struct r600_shader_io {
48 	gl_varying_slot		varying_slot;
49 	gl_system_value		system_value; /* Input only */
50 	gl_frag_result		frag_result;
51 	unsigned		gpr;
52 	int			spi_sid;
53 	unsigned		interpolate;
54 	unsigned		ij_index;
55 	unsigned		interpolate_location; //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
56 	unsigned		lds_pos; /* for evergreen */
57 	unsigned		write_mask;
58 	int			export_param; /* Output only */
59 	int			ring_offset;
60 	unsigned		uses_interpolate_at_centroid;
61 };
62 
63 struct r600_shader_atomic {
64 	unsigned start, end;
65 	unsigned buffer_id;
66 	unsigned hw_idx;
67 };
68 
69 #define R600_SHADER_MAX_INPUTS (32 /* generic */ + 32 /* patch */ + 16 /* others */)
70 #define R600_SHADER_MAX_OUTPUTS (32 /* generic */ + 32 /* patch */ + 16 /* others */)
71 
72 struct r600_shader {
73 	unsigned		processor_type;
74 	struct r600_bytecode		bc;
75 	unsigned		ninput;
76 	unsigned		noutput;
77 	unsigned                nhwatomic;
78 	unsigned		nlds;
79 	unsigned		nsys_inputs;
80 	unsigned		highest_export_param;
81 	struct r600_shader_io	input[R600_SHADER_MAX_INPUTS];
82 	struct r600_shader_io	output[R600_SHADER_MAX_OUTPUTS];
83 	struct r600_shader_atomic atomics[8];
84 	unsigned                nhwatomic_ranges;
85 	bool			uses_kill;
86 	bool			fs_write_all;
87 	bool			two_side;
88 	bool			needs_scratch_space;
89 	/* Real number of ps color exports compiled in the bytecode */
90 	unsigned		nr_ps_color_exports;
91 	unsigned                ps_color_export_mask;
92 	unsigned                ps_export_highest;
93 	/* bit n is set if the shader writes gl_ClipDistance[n] */
94 	unsigned		cc_dist_mask;
95 	unsigned		clip_dist_write;
96 	unsigned                cull_dist_write;
97 	bool			vs_position_window_space;
98 	/* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
99 	bool			vs_out_misc_write;
100 	bool			vs_out_point_size;
101 	bool			vs_out_layer;
102 	bool			vs_out_viewport;
103 	bool			vs_out_edgeflag;
104 	bool			has_txq_cube_array_z_comp;
105 	bool			uses_tex_buffers;
106 	bool                 gs_prim_id_input;
107 	bool                 gs_tri_strip_adj_fix;
108 	uint8_t			ps_conservative_z;
109 
110 	/* Size in bytes of a data item in the ring(s) (single vertex data).
111 	   Stages with only one ring items 123 will be set to 0. */
112 	unsigned		ring_item_sizes[4];
113 
114 	unsigned		indirect_files;
115 	unsigned		max_arrays;
116 	unsigned		num_arrays;
117 	unsigned		vs_as_es;
118 	unsigned		vs_as_ls;
119 	unsigned		vs_as_gs_a;
120 	unsigned                tes_as_es;
121 	unsigned                tcs_prim_mode;
122 	unsigned                num_loops;
123 
124 	struct r600_shader_array * arrays;
125 
126 	bool			uses_doubles;
127 	bool                 uses_atomics;
128 	bool			uses_images;
129 	bool			uses_helper_invocation;
130 	bool			uses_interpolate_at_sample;
131 	uint8_t                 atomic_base;
132 	uint8_t			rat_base;
133 	uint8_t                 image_size_const_offset;
134         bool			disable_sb;
135 };
136 
137 union r600_shader_key {
138 	struct {
139 		unsigned	nr_cbufs:4;
140 		unsigned        first_atomic_counter:4;
141 		unsigned        image_size_const_offset:5;
142 		unsigned	color_two_side:1;
143 		unsigned	alpha_to_one:1;
144 		unsigned        apply_sample_id_mask:1;
145 		unsigned        dual_source_blend:1;
146 	} ps;
147 	struct {
148 		unsigned        first_atomic_counter:4;
149 		unsigned	as_es:1; /* export shader */
150 		unsigned	as_ls:1; /* local shader */
151 		unsigned	as_gs_a:1;
152 	} vs;
153 	struct {
154 		unsigned        first_atomic_counter:4;
155 		unsigned	as_es:1;
156 	} tes;
157 	struct {
158 		unsigned        first_atomic_counter:4;
159 		unsigned	prim_mode:3;
160 	} tcs;
161 	struct {
162 		unsigned        first_atomic_counter:4;
163 		unsigned        tri_strip_adj_fix:1;
164 	} gs;
165 };
166 
167 struct r600_shader_array {
168 	unsigned gpr_start;
169 	unsigned gpr_count;
170 	unsigned comp_mask;
171 };
172 
173 #ifdef __cplusplus
174 }  // extern "C"
175 #endif
176 
177 
178 #endif
179