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