r600: Turn 'r600_shader_key' struct into union
[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
34 struct r600_shader_io {
35 unsigned name;
36 unsigned gpr;
37 unsigned done;
38 int sid;
39 int spi_sid;
40 unsigned interpolate;
41 unsigned ij_index;
42 unsigned interpolate_location; // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
43 unsigned lds_pos; /* for evergreen */
44 unsigned back_color_input;
45 unsigned write_mask;
46 int ring_offset;
47 };
48
49 struct r600_shader {
50 unsigned processor_type;
51 struct r600_bytecode bc;
52 unsigned ninput;
53 unsigned noutput;
54 unsigned nlds;
55 struct r600_shader_io input[40];
56 struct r600_shader_io output[40];
57 boolean uses_kill;
58 boolean fs_write_all;
59 boolean two_side;
60 /* Number of color outputs in the TGSI shader,
61 * sometimes it could be higher than nr_cbufs (bug?).
62 * Also with writes_all property on eg+ it will be set to max CB number */
63 unsigned nr_ps_max_color_exports;
64 /* Real number of ps color exports compiled in the bytecode */
65 unsigned nr_ps_color_exports;
66 /* bit n is set if the shader writes gl_ClipDistance[n] */
67 unsigned clip_dist_write;
68 boolean vs_position_window_space;
69 /* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
70 boolean vs_out_misc_write;
71 boolean vs_out_point_size;
72 boolean vs_out_layer;
73 boolean vs_out_viewport;
74 boolean vs_out_edgeflag;
75 boolean has_txq_cube_array_z_comp;
76 boolean uses_tex_buffers;
77 boolean gs_prim_id_input;
78 /* Temporarily workaround SB not handling CF_INDEX_[01] index registers */
79 boolean uses_index_registers;
80
81 /* geometry shader properties */
82 unsigned gs_input_prim;
83 unsigned gs_output_prim;
84 unsigned gs_max_out_vertices;
85 unsigned gs_num_invocations;
86 /* size in bytes of a data item in the ring (single vertex data) */
87 unsigned ring_item_size;
88
89 unsigned indirect_files;
90 unsigned max_arrays;
91 unsigned num_arrays;
92 unsigned vs_as_es;
93 unsigned vs_as_gs_a;
94 unsigned ps_prim_id_input;
95 struct r600_shader_array * arrays;
96 };
97
98 union r600_shader_key {
99 struct {
100 unsigned nr_cbufs:4;
101 unsigned color_two_side:1;
102 unsigned alpha_to_one:1;
103 } ps;
104 struct {
105 unsigned prim_id_out:8;
106 unsigned as_es:1; /* export shader */
107 unsigned as_gs_a:1;
108 } vs;
109 };
110
111 struct r600_shader_array {
112 unsigned gpr_start;
113 unsigned gpr_count;
114 unsigned comp_mask;
115 };
116
117 struct r600_pipe_shader {
118 struct r600_pipe_shader_selector *selector;
119 struct r600_pipe_shader *next_variant;
120 /* for GS - corresponding copy shader (installed as VS) */
121 struct r600_pipe_shader *gs_copy_shader;
122 struct r600_shader shader;
123 struct r600_command_buffer command_buffer; /* register writes */
124 struct r600_resource *bo;
125 unsigned sprite_coord_enable;
126 unsigned flatshade;
127 unsigned pa_cl_vs_out_cntl;
128 unsigned nr_ps_color_outputs;
129 union r600_shader_key key;
130 unsigned db_shader_control;
131 unsigned ps_depth_export;
132 unsigned enabled_stream_buffers_mask;
133 };
134
135 /* return the table index 0-5 for TGSI_INTERPOLATE_LINEAR/PERSPECTIVE and
136 TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */
137 int eg_get_interpolator_index(unsigned interpolate, unsigned location);
138
139
140 #ifdef __cplusplus
141 } // extern "C"
142 #endif
143
144
145 #endif