targets/dri: update scons build to handle __driDriverGetExtensions_vmwgfx
[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[NUM_TEX_UNITS];
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 #define SI_RW_SO 2 /* Streamout buffer descriptors after ring buffers */
92
93 struct si_context {
94 struct r600_common_context b;
95 struct blitter_context *blitter;
96 void *custom_dsa_flush_depth_stencil[8];
97 void *custom_dsa_flush_depth[8];
98 void *custom_dsa_flush_stencil[8];
99 void *custom_dsa_flush_inplace;
100 void *custom_blend_resolve;
101 void *custom_blend_decompress;
102 void *custom_blend_fastclear;
103 struct si_screen *screen;
104
105 union {
106 struct {
107 /* The order matters. */
108 struct r600_atom *const_buffers[SI_NUM_SHADERS];
109 struct r600_atom *rw_buffers[SI_NUM_SHADERS];
110 struct r600_atom *sampler_views[SI_NUM_SHADERS];
111 /* Caches must be flushed after resource descriptors are
112 * updated in memory. */
113 struct r600_atom *cache_flush;
114 struct r600_atom *streamout_begin;
115 struct r600_atom *streamout_enable; /* must be after streamout_begin */
116 struct r600_atom *framebuffer;
117 struct r600_atom *msaa_config;
118 } s;
119 struct r600_atom *array[0];
120 } atoms;
121
122 struct si_framebuffer framebuffer;
123 struct si_vertex_element *vertex_elements;
124 unsigned pa_sc_line_stipple;
125 unsigned pa_su_sc_mode_cntl;
126 /* for saving when using blitter */
127 struct pipe_stencil_ref stencil_ref;
128 struct si_pipe_shader_selector *ps_shader;
129 struct si_pipe_shader_selector *gs_shader;
130 struct si_pipe_shader_selector *vs_shader;
131 struct si_cs_shader_state cs_shader_state;
132 /* shader information */
133 unsigned sprite_coord_enable;
134 struct si_buffer_resources const_buffers[SI_NUM_SHADERS];
135 struct si_buffer_resources rw_buffers[SI_NUM_SHADERS];
136 struct si_textures_info samplers[SI_NUM_SHADERS];
137 struct r600_resource *border_color_table;
138 unsigned border_color_offset;
139
140 struct r600_atom msaa_config;
141 int ps_iter_samples;
142
143 unsigned default_ps_gprs, default_vs_gprs;
144
145 /* Below are variables from the old r600_context.
146 */
147 unsigned pm4_dirty_cdwords;
148
149 /* Vertex and index buffers. */
150 bool vertex_buffers_dirty;
151 struct pipe_index_buffer index_buffer;
152 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
153 unsigned nr_vertex_buffers;
154
155 /* With rasterizer discard, there doesn't have to be a pixel shader.
156 * In that case, we bind this one: */
157 void *dummy_pixel_shader;
158 struct si_pm4_state *gs_on;
159 struct si_pm4_state *gs_off;
160 struct si_pm4_state *gs_rings;
161 struct r600_atom cache_flush;
162 struct pipe_constant_buffer null_const_buf; /* used for set_constant_buffer(NULL) on CIK */
163 struct pipe_constant_buffer esgs_ring;
164 struct pipe_constant_buffer gsvs_ring;
165
166 /* SI state handling */
167 union si_state queued;
168 union si_state emitted;
169 };
170
171 /* si_blit.c */
172 void si_init_blit_functions(struct si_context *sctx);
173 void si_flush_depth_textures(struct si_context *sctx,
174 struct si_textures_info *textures);
175 void si_decompress_color_textures(struct si_context *sctx,
176 struct si_textures_info *textures);
177
178 /* si_dma.c */
179 void si_dma_copy(struct pipe_context *ctx,
180 struct pipe_resource *dst,
181 unsigned dst_level,
182 unsigned dstx, unsigned dsty, unsigned dstz,
183 struct pipe_resource *src,
184 unsigned src_level,
185 const struct pipe_box *src_box);
186
187 /* si_hw_context.c */
188 void si_context_gfx_flush(void *context, unsigned flags,
189 struct pipe_fence_handle **fence);
190 void si_begin_new_cs(struct si_context *ctx);
191 void si_need_cs_space(struct si_context *ctx, unsigned num_dw, boolean count_draw_in);
192
193 #if SI_TRACE_CS
194 void si_trace_emit(struct si_context *sctx);
195 #endif
196
197 /* si_compute.c */
198 void si_init_compute_functions(struct si_context *sctx);
199
200 /* si_uvd.c */
201 struct pipe_video_codec *si_uvd_create_decoder(struct pipe_context *context,
202 const struct pipe_video_codec *templ);
203
204 struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
205 const struct pipe_video_buffer *tmpl);
206
207 /*
208 * common helpers
209 */
210
211 static INLINE struct r600_resource *
212 si_resource_create_custom(struct pipe_screen *screen,
213 unsigned usage, unsigned size)
214 {
215 assert(size);
216 return r600_resource(pipe_buffer_create(screen,
217 PIPE_BIND_CUSTOM, usage, size));
218 }
219
220 #endif