radeonsi: rename definitions of shader limits
[mesa.git] / src / gallium / drivers / radeonsi / si_pipe.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 * Authors:
24 * Jerome Glisse
25 */
26 #ifndef SI_PIPE_H
27 #define SI_PIPE_H
28
29 #include "si_state.h"
30
31 #ifdef PIPE_ARCH_BIG_ENDIAN
32 #define SI_BIG_ENDIAN 1
33 #else
34 #define SI_BIG_ENDIAN 0
35 #endif
36
37 #define SI_TRACE_CS 0
38 #define SI_TRACE_CS_DWORDS 6
39
40 #define SI_MAX_DRAW_CS_DWORDS 18
41
42 #define LLVM_SUPPORTS_GEOM_SHADERS \
43 ((HAVE_LLVM >= 0x0305) || \
44 (HAVE_LLVM == 0x0304 && LLVM_VERSION_PATCH >= 1))
45
46 struct si_pipe_compute;
47
48 struct si_screen {
49 struct r600_common_screen b;
50 };
51
52 struct si_pipe_sampler_view {
53 struct pipe_sampler_view base;
54 struct r600_resource *resource;
55 uint32_t state[8];
56 uint32_t fmask_state[8];
57 };
58
59 struct si_pipe_sampler_state {
60 uint32_t val[4];
61 uint32_t border_color[4];
62 };
63
64 struct si_cs_shader_state {
65 struct si_pipe_compute *program;
66 };
67
68 struct si_textures_info {
69 struct si_sampler_views views;
70 struct si_pipe_sampler_state *samplers[SI_NUM_USER_SAMPLERS];
71 unsigned n_views;
72 uint32_t depth_texture_mask; /* which textures are depth */
73 uint32_t compressed_colortex_mask;
74 unsigned n_samplers;
75 };
76
77 struct si_framebuffer {
78 struct r600_atom atom;
79 struct pipe_framebuffer_state state;
80 unsigned nr_samples;
81 unsigned log_samples;
82 unsigned cb0_is_integer;
83 unsigned compressed_cb_mask;
84 unsigned export_16bpc;
85 };
86
87 #define SI_NUM_ATOMS(sctx) (sizeof((sctx)->atoms)/sizeof((sctx)->atoms.array[0]))
88
89 #define SI_NUM_SHADERS (PIPE_SHADER_GEOMETRY+1)
90
91 struct si_context {
92 struct r600_common_context b;
93 struct blitter_context *blitter;
94 void *custom_dsa_flush_depth_stencil[8];
95 void *custom_dsa_flush_depth[8];
96 void *custom_dsa_flush_stencil[8];
97 void *custom_dsa_flush_inplace;
98 void *custom_blend_resolve;
99 void *custom_blend_decompress;
100 void *custom_blend_fastclear;
101 struct si_screen *screen;
102
103 union {
104 struct {
105 /* The order matters. */
106 struct r600_atom *const_buffers[SI_NUM_SHADERS];
107 struct r600_atom *rw_buffers[SI_NUM_SHADERS];
108 struct r600_atom *sampler_views[SI_NUM_SHADERS];
109 /* Caches must be flushed after resource descriptors are
110 * updated in memory. */
111 struct r600_atom *cache_flush;
112 struct r600_atom *streamout_begin;
113 struct r600_atom *streamout_enable; /* must be after streamout_begin */
114 struct r600_atom *framebuffer;
115 struct r600_atom *msaa_config;
116 } s;
117 struct r600_atom *array[0];
118 } atoms;
119
120 struct si_framebuffer framebuffer;
121 struct si_vertex_element *vertex_elements;
122 unsigned pa_sc_line_stipple;
123 unsigned pa_su_sc_mode_cntl;
124 /* for saving when using blitter */
125 struct pipe_stencil_ref stencil_ref;
126 struct si_pipe_shader_selector *ps_shader;
127 struct si_pipe_shader_selector *gs_shader;
128 struct si_pipe_shader_selector *vs_shader;
129 struct si_cs_shader_state cs_shader_state;
130 /* shader information */
131 unsigned sprite_coord_enable;
132 struct si_buffer_resources const_buffers[SI_NUM_SHADERS];
133 struct si_buffer_resources rw_buffers[SI_NUM_SHADERS];
134 struct si_textures_info samplers[SI_NUM_SHADERS];
135 struct r600_resource *border_color_table;
136 unsigned border_color_offset;
137
138 struct r600_atom msaa_config;
139 int ps_iter_samples;
140
141 unsigned default_ps_gprs, default_vs_gprs;
142
143 /* Below are variables from the old r600_context.
144 */
145 unsigned pm4_dirty_cdwords;
146
147 /* Vertex and index buffers. */
148 bool vertex_buffers_dirty;
149 struct pipe_index_buffer index_buffer;
150 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
151 unsigned nr_vertex_buffers;
152
153 /* With rasterizer discard, there doesn't have to be a pixel shader.
154 * In that case, we bind this one: */
155 void *dummy_pixel_shader;
156 struct si_pm4_state *gs_on;
157 struct si_pm4_state *gs_off;
158 struct si_pm4_state *gs_rings;
159 struct r600_atom cache_flush;
160 struct pipe_constant_buffer null_const_buf; /* used for set_constant_buffer(NULL) on CIK */
161 struct pipe_constant_buffer esgs_ring;
162 struct pipe_constant_buffer gsvs_ring;
163
164 /* SI state handling */
165 union si_state queued;
166 union si_state emitted;
167 };
168
169 /* si_blit.c */
170 void si_init_blit_functions(struct si_context *sctx);
171 void si_flush_depth_textures(struct si_context *sctx,
172 struct si_textures_info *textures);
173 void si_decompress_color_textures(struct si_context *sctx,
174 struct si_textures_info *textures);
175
176 /* si_dma.c */
177 void si_dma_copy(struct pipe_context *ctx,
178 struct pipe_resource *dst,
179 unsigned dst_level,
180 unsigned dstx, unsigned dsty, unsigned dstz,
181 struct pipe_resource *src,
182 unsigned src_level,
183 const struct pipe_box *src_box);
184
185 /* si_hw_context.c */
186 void si_context_gfx_flush(void *context, unsigned flags,
187 struct pipe_fence_handle **fence);
188 void si_begin_new_cs(struct si_context *ctx);
189 void si_need_cs_space(struct si_context *ctx, unsigned num_dw, boolean count_draw_in);
190
191 #if SI_TRACE_CS
192 void si_trace_emit(struct si_context *sctx);
193 #endif
194
195 /* si_compute.c */
196 void si_init_compute_functions(struct si_context *sctx);
197
198 /* si_uvd.c */
199 struct pipe_video_codec *si_uvd_create_decoder(struct pipe_context *context,
200 const struct pipe_video_codec *templ);
201
202 struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
203 const struct pipe_video_buffer *tmpl);
204
205 /*
206 * common helpers
207 */
208
209 static INLINE struct r600_resource *
210 si_resource_create_custom(struct pipe_screen *screen,
211 unsigned usage, unsigned size)
212 {
213 assert(size);
214 return r600_resource(pipe_buffer_create(screen,
215 PIPE_BIND_CUSTOM, usage, size));
216 }
217
218 #endif