2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
31 #ifdef PIPE_ARCH_BIG_ENDIAN
32 #define SI_BIG_ENDIAN 1
34 #define SI_BIG_ENDIAN 0
38 #define SI_TRACE_CS_DWORDS 6
40 #define SI_MAX_DRAW_CS_DWORDS 18
42 struct si_pipe_compute
;
45 struct r600_common_screen b
;
48 struct si_pipe_sampler_view
{
49 struct pipe_sampler_view base
;
50 struct r600_resource
*resource
;
52 uint32_t fmask_state
[8];
55 struct si_pipe_sampler_state
{
57 uint32_t border_color
[4];
60 struct si_cs_shader_state
{
61 struct si_pipe_compute
*program
;
64 struct si_textures_info
{
65 struct si_sampler_views views
;
66 struct si_pipe_sampler_state
*samplers
[NUM_TEX_UNITS
];
68 uint32_t depth_texture_mask
; /* which textures are depth */
69 uint32_t compressed_colortex_mask
;
74 struct pipe_surface base
;
77 #define SI_NUM_ATOMS(sctx) (sizeof((sctx)->atoms)/sizeof((sctx)->atoms.array[0]))
79 #define SI_SHADER_EXPORT (PIPE_SHADER_GEOMETRY+1)
80 #define SI_NUM_SHADERS (SI_SHADER_EXPORT+1)
83 struct r600_common_context b
;
84 struct blitter_context
*blitter
;
85 void *custom_dsa_flush_depth_stencil
[8];
86 void *custom_dsa_flush_depth
[8];
87 void *custom_dsa_flush_stencil
[8];
88 void *custom_dsa_flush_inplace
;
89 void *custom_blend_resolve
;
90 void *custom_blend_decompress
;
91 struct si_screen
*screen
;
95 /* The order matters. */
96 struct r600_atom
*const_buffers
[SI_NUM_SHADERS
];
97 struct r600_atom
*sampler_views
[SI_NUM_SHADERS
];
98 struct r600_atom
*streamout_buffers
;
99 /* Caches must be flushed after resource descriptors are
100 * updated in memory. */
101 struct r600_atom
*cache_flush
;
102 struct r600_atom
*streamout_begin
;
104 struct r600_atom
*array
[0];
107 struct si_vertex_element
*vertex_elements
;
108 struct pipe_framebuffer_state framebuffer
;
109 unsigned fb_log_samples
;
110 unsigned fb_cb0_is_integer
;
111 unsigned fb_compressed_cb_mask
;
112 unsigned pa_sc_line_stipple
;
113 unsigned pa_su_sc_mode_cntl
;
114 /* for saving when using blitter */
115 struct pipe_stencil_ref stencil_ref
;
116 struct si_pipe_shader_selector
*ps_shader
;
117 struct si_pipe_shader_selector
*gs_shader
;
118 struct si_pipe_shader_selector
*vs_shader
;
119 struct si_cs_shader_state cs_shader_state
;
120 /* shader information */
121 unsigned sprite_coord_enable
;
122 unsigned export_16bpc
;
123 struct si_buffer_resources const_buffers
[SI_NUM_SHADERS
];
124 struct si_buffer_resources streamout_buffers
;
125 struct si_textures_info samplers
[SI_NUM_SHADERS
];
126 struct r600_resource
*border_color_table
;
127 unsigned border_color_offset
;
129 unsigned default_ps_gprs
, default_vs_gprs
;
131 /* Below are variables from the old r600_context.
133 unsigned pm4_dirty_cdwords
;
135 /* Vertex and index buffers. */
136 bool vertex_buffers_dirty
;
137 struct pipe_index_buffer index_buffer
;
138 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
139 unsigned nr_vertex_buffers
;
141 /* With rasterizer discard, there doesn't have to be a pixel shader.
142 * In that case, we bind this one: */
143 void *dummy_pixel_shader
;
144 struct si_pm4_state
*gs_on
;
145 struct si_pm4_state
*gs_off
;
146 struct si_pm4_state
*gs_rings
;
147 struct r600_atom cache_flush
;
148 struct pipe_constant_buffer null_const_buf
; /* used for set_constant_buffer(NULL) on CIK */
149 struct pipe_constant_buffer esgs_ring
;
150 struct pipe_constant_buffer gsvs_ring
;
152 /* SI state handling */
153 union si_state queued
;
154 union si_state emitted
;
158 void si_init_blit_functions(struct si_context
*sctx
);
159 void si_flush_depth_textures(struct si_context
*sctx
,
160 struct si_textures_info
*textures
);
161 void si_decompress_color_textures(struct si_context
*sctx
,
162 struct si_textures_info
*textures
);
164 /* si_hw_context.c */
165 void si_context_flush(struct si_context
*ctx
, unsigned flags
);
166 void si_begin_new_cs(struct si_context
*ctx
);
167 void si_need_cs_space(struct si_context
*ctx
, unsigned num_dw
, boolean count_draw_in
);
170 void si_flush(struct pipe_context
*ctx
, struct pipe_fence_handle
**fence
,
174 void si_trace_emit(struct si_context
*sctx
);
178 void si_init_compute_functions(struct si_context
*sctx
);
181 struct pipe_video_codec
*si_uvd_create_decoder(struct pipe_context
*context
,
182 const struct pipe_video_codec
*templ
);
184 struct pipe_video_buffer
*si_video_buffer_create(struct pipe_context
*pipe
,
185 const struct pipe_video_buffer
*tmpl
);
191 static INLINE
struct r600_resource
*
192 si_resource_create_custom(struct pipe_screen
*screen
,
193 unsigned usage
, unsigned size
)
196 return r600_resource(pipe_buffer_create(screen
,
197 PIPE_BIND_CUSTOM
, usage
, size
));