2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
33 /* Valid shader configurations:
35 * API shaders VS | TCS | TES | GS |pass| PS
36 * are compiled as: | | | |thru|
38 * Only VS & PS: VS | -- | -- | -- | -- | PS
39 * With GS: ES | -- | -- | GS | VS | PS
40 * With Tessel.: LS | HS | VS | -- | -- | PS
41 * With both: LS | HS | ES | GS | VS | PS
44 struct r600_shader_io
{
52 unsigned interpolate_location
; // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
53 unsigned lds_pos
; /* for evergreen */
54 unsigned back_color_input
;
59 struct r600_shader_atomic
{
67 unsigned processor_type
;
68 struct r600_bytecode bc
;
74 struct r600_shader_io input
[64];
75 struct r600_shader_io output
[64];
76 struct r600_shader_atomic atomics
[8];
77 unsigned nhwatomic_ranges
;
81 boolean needs_scratch_space
;
82 /* Number of color outputs in the TGSI shader,
83 * sometimes it could be higher than nr_cbufs (bug?).
84 * Also with writes_all property on eg+ it will be set to max CB number */
85 unsigned nr_ps_max_color_exports
;
86 /* Real number of ps color exports compiled in the bytecode */
87 unsigned nr_ps_color_exports
;
88 unsigned ps_color_export_mask
;
89 unsigned ps_export_highest
;
90 /* bit n is set if the shader writes gl_ClipDistance[n] */
91 unsigned cc_dist_mask
;
92 unsigned clip_dist_write
;
93 unsigned cull_dist_write
;
94 boolean vs_position_window_space
;
95 /* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
96 boolean vs_out_misc_write
;
97 boolean vs_out_point_size
;
99 boolean vs_out_viewport
;
100 boolean vs_out_edgeflag
;
101 boolean has_txq_cube_array_z_comp
;
102 boolean uses_tex_buffers
;
103 boolean gs_prim_id_input
;
104 boolean gs_tri_strip_adj_fix
;
105 uint8_t ps_conservative_z
;
107 /* Size in bytes of a data item in the ring(s) (single vertex data).
108 Stages with only one ring items 123 will be set to 0. */
109 unsigned ring_item_sizes
[4];
111 unsigned indirect_files
;
118 unsigned tcs_prim_mode
;
119 unsigned ps_prim_id_input
;
120 struct r600_shader_array
* arrays
;
122 boolean uses_doubles
;
123 boolean uses_atomics
;
125 boolean uses_helper_invocation
;
128 uint8_t image_size_const_offset
;
131 union r600_shader_key
{
134 unsigned first_atomic_counter
:4;
135 unsigned image_size_const_offset
:5;
136 unsigned color_two_side
:1;
137 unsigned alpha_to_one
:1;
140 unsigned prim_id_out
:8;
141 unsigned first_atomic_counter
:4;
142 unsigned as_es
:1; /* export shader */
143 unsigned as_ls
:1; /* local shader */
147 unsigned first_atomic_counter
:4;
151 unsigned first_atomic_counter
:4;
152 unsigned prim_mode
:3;
155 unsigned first_atomic_counter
:4;
156 unsigned tri_strip_adj_fix
:1;
160 struct r600_shader_array
{
166 struct r600_pipe_shader
{
167 struct r600_pipe_shader_selector
*selector
;
168 struct r600_pipe_shader
*next_variant
;
169 /* for GS - corresponding copy shader (installed as VS) */
170 struct r600_pipe_shader
*gs_copy_shader
;
171 struct r600_shader shader
;
172 struct r600_command_buffer command_buffer
; /* register writes */
173 struct r600_resource
*bo
;
174 unsigned sprite_coord_enable
;
176 unsigned pa_cl_vs_out_cntl
;
177 unsigned nr_ps_color_outputs
;
178 unsigned ps_color_export_mask
;
180 union r600_shader_key key
;
181 unsigned db_shader_control
;
182 unsigned ps_depth_export
;
183 unsigned enabled_stream_buffers_mask
;
184 unsigned scratch_space_needed
; /* size of scratch space (if > 0) counted in vec4 */
187 /* return the table index 0-5 for TGSI_INTERPOLATE_LINEAR/PERSPECTIVE and
188 TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */
189 int eg_get_interpolator_index(unsigned interpolate
, unsigned location
);
191 int r600_get_lds_unique_index(unsigned semantic_name
, unsigned index
);