r600g: take into account offset to system inputs at tgsi_interp_egcm()
[mesa.git] / src / gallium / drivers / r600 / r600_shader.h
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 #ifndef R600_SHADER_H
24 #define R600_SHADER_H
25
26 #include "r600_asm.h"
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /* Valid shader configurations:
34 *
35 * API shaders VS | TCS | TES | GS |pass| PS
36 * are compiled as: | | | |thru|
37 * | | | | |
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
42 */
43
44 struct r600_shader_io {
45 unsigned name;
46 unsigned gpr;
47 unsigned done;
48 int sid;
49 int spi_sid;
50 unsigned interpolate;
51 unsigned ij_index;
52 unsigned interpolate_location; // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
53 unsigned lds_pos; /* for evergreen */
54 unsigned back_color_input;
55 unsigned write_mask;
56 int ring_offset;
57 };
58
59 struct r600_shader {
60 unsigned processor_type;
61 struct r600_bytecode bc;
62 unsigned ninput;
63 unsigned noutput;
64 unsigned nlds;
65 unsigned nsys_inputs;
66 struct r600_shader_io input[64];
67 struct r600_shader_io output[64];
68 boolean uses_kill;
69 boolean fs_write_all;
70 boolean two_side;
71 /* Number of color outputs in the TGSI shader,
72 * sometimes it could be higher than nr_cbufs (bug?).
73 * Also with writes_all property on eg+ it will be set to max CB number */
74 unsigned nr_ps_max_color_exports;
75 /* Real number of ps color exports compiled in the bytecode */
76 unsigned nr_ps_color_exports;
77 /* bit n is set if the shader writes gl_ClipDistance[n] */
78 unsigned clip_dist_write;
79 boolean vs_position_window_space;
80 /* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
81 boolean vs_out_misc_write;
82 boolean vs_out_point_size;
83 boolean vs_out_layer;
84 boolean vs_out_viewport;
85 boolean vs_out_edgeflag;
86 boolean has_txq_cube_array_z_comp;
87 boolean uses_tex_buffers;
88 boolean gs_prim_id_input;
89
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 ps_prim_id_input;
105 struct r600_shader_array * arrays;
106
107 boolean uses_doubles;
108 };
109
110 union r600_shader_key {
111 struct {
112 unsigned nr_cbufs:4;
113 unsigned color_two_side:1;
114 unsigned alpha_to_one:1;
115 } ps;
116 struct {
117 unsigned prim_id_out:8;
118 unsigned as_es:1; /* export shader */
119 unsigned as_ls:1; /* local shader */
120 unsigned as_gs_a:1;
121 } vs;
122 struct {
123 unsigned as_es:1;
124 } tes;
125 struct {
126 unsigned prim_mode:3;
127 } tcs;
128 };
129
130 struct r600_shader_array {
131 unsigned gpr_start;
132 unsigned gpr_count;
133 unsigned comp_mask;
134 };
135
136 struct r600_pipe_shader {
137 struct r600_pipe_shader_selector *selector;
138 struct r600_pipe_shader *next_variant;
139 /* for GS - corresponding copy shader (installed as VS) */
140 struct r600_pipe_shader *gs_copy_shader;
141 struct r600_shader shader;
142 struct r600_command_buffer command_buffer; /* register writes */
143 struct r600_resource *bo;
144 unsigned sprite_coord_enable;
145 unsigned flatshade;
146 unsigned pa_cl_vs_out_cntl;
147 unsigned nr_ps_color_outputs;
148 union r600_shader_key key;
149 unsigned db_shader_control;
150 unsigned ps_depth_export;
151 unsigned enabled_stream_buffers_mask;
152 };
153
154 /* return the table index 0-5 for TGSI_INTERPOLATE_LINEAR/PERSPECTIVE and
155 TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */
156 int eg_get_interpolator_index(unsigned interpolate, unsigned location);
157
158 int r600_get_lds_unique_index(unsigned semantic_name, unsigned index);
159
160 #ifdef __cplusplus
161 } // extern "C"
162 #endif
163
164
165 #endif