1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2003 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#ifndef I915_CONTEXT_H
29bf215546Sopenharmony_ci#define I915_CONTEXT_H
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "pipe/p_context.h"
32bf215546Sopenharmony_ci#include "pipe/p_defines.h"
33bf215546Sopenharmony_ci#include "pipe/p_state.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#include "draw/draw_vertex.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci#include "tgsi/tgsi_scan.h"
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci#include "util/log.h"
40bf215546Sopenharmony_ci#include "util/slab.h"
41bf215546Sopenharmony_ci#include "util/u_blitter.h"
42bf215546Sopenharmony_ci#include "i915_reg.h"
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_cistruct i915_winsys;
45bf215546Sopenharmony_cistruct i915_winsys_buffer;
46bf215546Sopenharmony_cistruct i915_winsys_batchbuffer;
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci#define I915_TEX_UNITS 8
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci#define I915_DYNAMIC_MODES4       0
51bf215546Sopenharmony_ci#define I915_DYNAMIC_DEPTHSCALE_0 1 /* just the header */
52bf215546Sopenharmony_ci#define I915_DYNAMIC_DEPTHSCALE_1 2
53bf215546Sopenharmony_ci#define I915_DYNAMIC_IAB          3
54bf215546Sopenharmony_ci#define I915_DYNAMIC_BC_0         4 /* just the header */
55bf215546Sopenharmony_ci#define I915_DYNAMIC_BC_1         5
56bf215546Sopenharmony_ci#define I915_DYNAMIC_BFO_0        6
57bf215546Sopenharmony_ci#define I915_DYNAMIC_BFO_1        7
58bf215546Sopenharmony_ci#define I915_DYNAMIC_STP_0        8
59bf215546Sopenharmony_ci#define I915_DYNAMIC_STP_1        9
60bf215546Sopenharmony_ci#define I915_DYNAMIC_SC_ENA_0     10
61bf215546Sopenharmony_ci#define I915_DYNAMIC_SC_RECT_0    11
62bf215546Sopenharmony_ci#define I915_DYNAMIC_SC_RECT_1    12
63bf215546Sopenharmony_ci#define I915_DYNAMIC_SC_RECT_2    13
64bf215546Sopenharmony_ci#define I915_MAX_DYNAMIC          14
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci#define I915_IMMEDIATE_S0  0
67bf215546Sopenharmony_ci#define I915_IMMEDIATE_S1  1
68bf215546Sopenharmony_ci#define I915_IMMEDIATE_S2  2
69bf215546Sopenharmony_ci#define I915_IMMEDIATE_S3  3
70bf215546Sopenharmony_ci#define I915_IMMEDIATE_S4  4
71bf215546Sopenharmony_ci#define I915_IMMEDIATE_S5  5
72bf215546Sopenharmony_ci#define I915_IMMEDIATE_S6  6
73bf215546Sopenharmony_ci#define I915_IMMEDIATE_S7  7
74bf215546Sopenharmony_ci#define I915_MAX_IMMEDIATE 8
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci/* These must mach the order of LI0_STATE_* bits, as they will be used
77bf215546Sopenharmony_ci * to generate hardware packets:
78bf215546Sopenharmony_ci */
79bf215546Sopenharmony_ci#define I915_CACHE_STATIC    0
80bf215546Sopenharmony_ci#define I915_CACHE_DYNAMIC   1 /* handled specially */
81bf215546Sopenharmony_ci#define I915_CACHE_SAMPLER   2
82bf215546Sopenharmony_ci#define I915_CACHE_MAP       3
83bf215546Sopenharmony_ci#define I915_CACHE_PROGRAM   4
84bf215546Sopenharmony_ci#define I915_CACHE_CONSTANTS 5
85bf215546Sopenharmony_ci#define I915_MAX_CACHE       6
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci#define I915_MAX_CONSTANT 32
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci/** See constant_flags[] below */
90bf215546Sopenharmony_ci#define I915_CONSTFLAG_USER 0x1f
91bf215546Sopenharmony_ci
92bf215546Sopenharmony_ci/**
93bf215546Sopenharmony_ci * Subclass of pipe_shader_state
94bf215546Sopenharmony_ci */
95bf215546Sopenharmony_cistruct i915_fragment_shader {
96bf215546Sopenharmony_ci   struct pipe_shader_state state;
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci   struct tgsi_shader_info info;
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_ci   struct draw_fragment_shader *draw_data;
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci   uint32_t *program;
103bf215546Sopenharmony_ci   uint32_t program_len;
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci   /**
106bf215546Sopenharmony_ci    * constants introduced during translation.
107bf215546Sopenharmony_ci    * These are placed at the end of the constant buffer and grow toward
108bf215546Sopenharmony_ci    * the beginning (eg: slot 31, 30 29, ...)
109bf215546Sopenharmony_ci    * User-provided constants start at 0.
110bf215546Sopenharmony_ci    * This allows both types of constants to co-exist (until there's too many)
111bf215546Sopenharmony_ci    * and doesn't require regenerating/changing the fragment program to
112bf215546Sopenharmony_ci    * shuffle constants around.
113bf215546Sopenharmony_ci    */
114bf215546Sopenharmony_ci   uint32_t num_constants;
115bf215546Sopenharmony_ci   float constants[I915_MAX_CONSTANT][4];
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci   /**
118bf215546Sopenharmony_ci    * Status of each constant
119bf215546Sopenharmony_ci    * if I915_CONSTFLAG_PARAM, the value must be taken from the corresponding
120bf215546Sopenharmony_ci    * slot of the user's constant buffer. (set by pipe->set_constant_buffer())
121bf215546Sopenharmony_ci    * Else, the bitmask indicates which components are occupied by immediates.
122bf215546Sopenharmony_ci    */
123bf215546Sopenharmony_ci   ubyte constant_flags[I915_MAX_CONSTANT];
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_ci   /**
126bf215546Sopenharmony_ci    * The mapping between TGSI inputs and hw texture coords.
127bf215546Sopenharmony_ci    * We need to share this between the vertex and fragment stages.
128bf215546Sopenharmony_ci    **/
129bf215546Sopenharmony_ci   struct {
130bf215546Sopenharmony_ci      enum tgsi_semantic semantic;
131bf215546Sopenharmony_ci      int index;
132bf215546Sopenharmony_ci   } texcoords[I915_TEX_UNITS];
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci   bool reads_pntc;
135bf215546Sopenharmony_ci};
136bf215546Sopenharmony_ci
137bf215546Sopenharmony_cistruct i915_cache_context;
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci/* Use to calculate differences between state emitted to hardware and
140bf215546Sopenharmony_ci * current driver-calculated state.
141bf215546Sopenharmony_ci */
142bf215546Sopenharmony_cistruct i915_state {
143bf215546Sopenharmony_ci   unsigned immediate[I915_MAX_IMMEDIATE];
144bf215546Sopenharmony_ci   unsigned dynamic[I915_MAX_DYNAMIC];
145bf215546Sopenharmony_ci
146bf215546Sopenharmony_ci   /** number of constants passed in through a constant buffer */
147bf215546Sopenharmony_ci   uint32_t num_user_constants[PIPE_SHADER_TYPES];
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci   /* texture sampler state */
150bf215546Sopenharmony_ci   unsigned sampler[I915_TEX_UNITS][3];
151bf215546Sopenharmony_ci   unsigned sampler_enable_flags;
152bf215546Sopenharmony_ci   unsigned sampler_enable_nr;
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci   /* texture image buffers */
155bf215546Sopenharmony_ci   unsigned texbuffer[I915_TEX_UNITS][3];
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ci   /** Describes the current hardware vertex layout */
158bf215546Sopenharmony_ci   struct vertex_info vertex_info;
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci   /* static state (dst/depth buffer state) */
161bf215546Sopenharmony_ci   struct i915_winsys_buffer *cbuf_bo;
162bf215546Sopenharmony_ci   unsigned cbuf_flags;
163bf215546Sopenharmony_ci   struct i915_winsys_buffer *depth_bo;
164bf215546Sopenharmony_ci   unsigned depth_flags;
165bf215546Sopenharmony_ci   unsigned dst_buf_vars;
166bf215546Sopenharmony_ci   uint32_t draw_offset;
167bf215546Sopenharmony_ci   uint32_t draw_size;
168bf215546Sopenharmony_ci
169bf215546Sopenharmony_ci   /* Reswizzle for OC writes in PIXEL_SHADER_PROGRAM, or 0 if unnecessary. */
170bf215546Sopenharmony_ci   uint32_t fixup_swizzle;
171bf215546Sopenharmony_ci   /* Mapping from color buffer dst channels in HW to gallium API src channels.
172bf215546Sopenharmony_ci    */
173bf215546Sopenharmony_ci   uint8_t color_swizzle[4];
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci   unsigned id; /* track lost context events */
176bf215546Sopenharmony_ci};
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_cistruct i915_blend_state {
179bf215546Sopenharmony_ci   unsigned iab;
180bf215546Sopenharmony_ci   unsigned iab_alpha_in_g;
181bf215546Sopenharmony_ci   unsigned iab_alpha_is_x;
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ci   unsigned modes4;
184bf215546Sopenharmony_ci   unsigned LIS5;
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci   unsigned LIS6;
187bf215546Sopenharmony_ci   unsigned LIS6_alpha_in_g;
188bf215546Sopenharmony_ci   unsigned LIS6_alpha_is_x;
189bf215546Sopenharmony_ci};
190bf215546Sopenharmony_ci
191bf215546Sopenharmony_cistruct i915_depth_stencil_state {
192bf215546Sopenharmony_ci   unsigned stencil_modes4_cw;
193bf215546Sopenharmony_ci   unsigned stencil_modes4_ccw;
194bf215546Sopenharmony_ci   unsigned bfo_cw[2];
195bf215546Sopenharmony_ci   unsigned bfo_ccw[2];
196bf215546Sopenharmony_ci   unsigned stencil_LIS5_cw;
197bf215546Sopenharmony_ci   unsigned stencil_LIS5_ccw;
198bf215546Sopenharmony_ci   unsigned depth_LIS6;
199bf215546Sopenharmony_ci};
200bf215546Sopenharmony_ci
201bf215546Sopenharmony_cistruct i915_rasterizer_state {
202bf215546Sopenharmony_ci   struct pipe_rasterizer_state templ;
203bf215546Sopenharmony_ci
204bf215546Sopenharmony_ci   unsigned light_twoside : 1;
205bf215546Sopenharmony_ci   unsigned st;
206bf215546Sopenharmony_ci
207bf215546Sopenharmony_ci   unsigned LIS4;
208bf215546Sopenharmony_ci   unsigned LIS6;
209bf215546Sopenharmony_ci   unsigned LIS7;
210bf215546Sopenharmony_ci   unsigned sc[1];
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci   union {
213bf215546Sopenharmony_ci      float f;
214bf215546Sopenharmony_ci      unsigned u;
215bf215546Sopenharmony_ci   } ds[2];
216bf215546Sopenharmony_ci};
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_cistruct i915_sampler_state {
219bf215546Sopenharmony_ci   struct pipe_sampler_state templ;
220bf215546Sopenharmony_ci   unsigned state[3];
221bf215546Sopenharmony_ci   unsigned minlod;
222bf215546Sopenharmony_ci   unsigned maxlod;
223bf215546Sopenharmony_ci};
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_cistruct i915_surface {
226bf215546Sopenharmony_ci   struct pipe_surface templ;
227bf215546Sopenharmony_ci   uint32_t buf_info; /* _3DSTATE_BUF_INFO_CMD flags */
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci   /* PIXEL_SHADER_PROGRAM swizzle for OC buffer to handle the cbuf format (or 0
230bf215546Sopenharmony_ci    * if none). */
231bf215546Sopenharmony_ci   uint32_t oc_swizzle;
232bf215546Sopenharmony_ci   /* cbuf swizzle from dst r/g/b/a channels in memory to channels of gallium
233bf215546Sopenharmony_ci    * API. */
234bf215546Sopenharmony_ci   uint8_t color_swizzle[4];
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci   bool alpha_in_g : 1;
237bf215546Sopenharmony_ci   bool alpha_is_x : 1;
238bf215546Sopenharmony_ci};
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_cistruct i915_velems_state {
241bf215546Sopenharmony_ci   unsigned count;
242bf215546Sopenharmony_ci   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
243bf215546Sopenharmony_ci};
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_cistruct i915_context {
246bf215546Sopenharmony_ci   struct pipe_context base;
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   struct i915_winsys *iws;
249bf215546Sopenharmony_ci
250bf215546Sopenharmony_ci   struct draw_context *draw;
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci   /* The most recent drawing state as set by the driver:
253bf215546Sopenharmony_ci    */
254bf215546Sopenharmony_ci   const struct i915_blend_state *blend;
255bf215546Sopenharmony_ci   const struct i915_sampler_state *fragment_sampler[PIPE_MAX_SAMPLERS];
256bf215546Sopenharmony_ci   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_SAMPLERS];
257bf215546Sopenharmony_ci   const struct i915_depth_stencil_state *depth_stencil;
258bf215546Sopenharmony_ci   const struct i915_rasterizer_state *rasterizer;
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci   struct i915_fragment_shader *fs;
261bf215546Sopenharmony_ci
262bf215546Sopenharmony_ci   void *vs;
263bf215546Sopenharmony_ci
264bf215546Sopenharmony_ci   struct i915_velems_state *velems;
265bf215546Sopenharmony_ci   unsigned nr_vertex_buffers;
266bf215546Sopenharmony_ci   struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
267bf215546Sopenharmony_ci
268bf215546Sopenharmony_ci   struct pipe_blend_color blend_color;
269bf215546Sopenharmony_ci   struct pipe_stencil_ref stencil_ref;
270bf215546Sopenharmony_ci   struct pipe_clip_state clip;
271bf215546Sopenharmony_ci   struct pipe_resource *constants[PIPE_SHADER_TYPES];
272bf215546Sopenharmony_ci   struct pipe_framebuffer_state framebuffer;
273bf215546Sopenharmony_ci   struct pipe_poly_stipple poly_stipple;
274bf215546Sopenharmony_ci   struct pipe_scissor_state scissor;
275bf215546Sopenharmony_ci   struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
276bf215546Sopenharmony_ci   struct pipe_viewport_state viewport;
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ci   unsigned dirty;
279bf215546Sopenharmony_ci
280bf215546Sopenharmony_ci   unsigned num_samplers;
281bf215546Sopenharmony_ci   unsigned num_fragment_sampler_views;
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_ci   struct i915_winsys_batchbuffer *batch;
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci   /** Vertex buffer */
286bf215546Sopenharmony_ci   struct i915_winsys_buffer *vbo;
287bf215546Sopenharmony_ci   size_t vbo_offset;
288bf215546Sopenharmony_ci   unsigned vbo_flushed;
289bf215546Sopenharmony_ci
290bf215546Sopenharmony_ci   struct i915_state current;
291bf215546Sopenharmony_ci   unsigned hardware_dirty;
292bf215546Sopenharmony_ci   unsigned immediate_dirty : I915_MAX_IMMEDIATE;
293bf215546Sopenharmony_ci   unsigned dynamic_dirty : I915_MAX_DYNAMIC;
294bf215546Sopenharmony_ci   unsigned static_dirty : 4;
295bf215546Sopenharmony_ci   unsigned flush_dirty : 2;
296bf215546Sopenharmony_ci
297bf215546Sopenharmony_ci   struct i915_winsys_buffer *validation_buffers[2 + 1 + I915_TEX_UNITS];
298bf215546Sopenharmony_ci   int num_validation_buffers;
299bf215546Sopenharmony_ci
300bf215546Sopenharmony_ci   struct slab_mempool transfer_pool;
301bf215546Sopenharmony_ci   struct slab_mempool texture_transfer_pool;
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_ci   /* state for tracking flushes */
304bf215546Sopenharmony_ci   int last_fired_vertices;
305bf215546Sopenharmony_ci   int fired_vertices;
306bf215546Sopenharmony_ci   int queued_vertices;
307bf215546Sopenharmony_ci
308bf215546Sopenharmony_ci   bool no_log_program_errors;
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_ci   /** blitter/hw-clear */
311bf215546Sopenharmony_ci   struct blitter_context *blitter;
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ci   struct util_debug_callback debug;
314bf215546Sopenharmony_ci};
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci/* A flag for each frontend state object:
317bf215546Sopenharmony_ci */
318bf215546Sopenharmony_ci#define I915_NEW_VIEWPORT      0x1
319bf215546Sopenharmony_ci#define I915_NEW_RASTERIZER    0x2
320bf215546Sopenharmony_ci#define I915_NEW_FS            0x4
321bf215546Sopenharmony_ci#define I915_NEW_BLEND         0x8
322bf215546Sopenharmony_ci#define I915_NEW_CLIP          0x10
323bf215546Sopenharmony_ci#define I915_NEW_SCISSOR       0x20
324bf215546Sopenharmony_ci#define I915_NEW_STIPPLE       0x40
325bf215546Sopenharmony_ci#define I915_NEW_FRAMEBUFFER   0x80
326bf215546Sopenharmony_ci#define I915_NEW_ALPHA_TEST    0x100
327bf215546Sopenharmony_ci#define I915_NEW_DEPTH_STENCIL 0x200
328bf215546Sopenharmony_ci#define I915_NEW_SAMPLER       0x400
329bf215546Sopenharmony_ci#define I915_NEW_SAMPLER_VIEW  0x800
330bf215546Sopenharmony_ci#define I915_NEW_VS_CONSTANTS  0x1000
331bf215546Sopenharmony_ci#define I915_NEW_FS_CONSTANTS  0x2000
332bf215546Sopenharmony_ci#define I915_NEW_GS_CONSTANTS  0x4000
333bf215546Sopenharmony_ci#define I915_NEW_VBO           0x8000
334bf215546Sopenharmony_ci#define I915_NEW_VS            0x10000
335bf215546Sopenharmony_ci#define I915_NEW_COLOR_SWIZZLE 0x20000
336bf215546Sopenharmony_ci
337bf215546Sopenharmony_ci/* Driver's internally generated state flags:
338bf215546Sopenharmony_ci */
339bf215546Sopenharmony_ci#define I915_NEW_VERTEX_FORMAT 0x10000
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_ci/* Dirty flags for hardware emit
342bf215546Sopenharmony_ci */
343bf215546Sopenharmony_ci#define I915_HW_STATIC    (1 << I915_CACHE_STATIC)
344bf215546Sopenharmony_ci#define I915_HW_DYNAMIC   (1 << I915_CACHE_DYNAMIC)
345bf215546Sopenharmony_ci#define I915_HW_SAMPLER   (1 << I915_CACHE_SAMPLER)
346bf215546Sopenharmony_ci#define I915_HW_MAP       (1 << I915_CACHE_MAP)
347bf215546Sopenharmony_ci#define I915_HW_PROGRAM   (1 << I915_CACHE_PROGRAM)
348bf215546Sopenharmony_ci#define I915_HW_CONSTANTS (1 << I915_CACHE_CONSTANTS)
349bf215546Sopenharmony_ci#define I915_HW_IMMEDIATE (1 << (I915_MAX_CACHE + 0))
350bf215546Sopenharmony_ci#define I915_HW_INVARIANT (1 << (I915_MAX_CACHE + 1))
351bf215546Sopenharmony_ci#define I915_HW_FLUSH     (1 << (I915_MAX_CACHE + 1))
352bf215546Sopenharmony_ci
353bf215546Sopenharmony_ci/* hw flush handling */
354bf215546Sopenharmony_ci#define I915_FLUSH_CACHE    1
355bf215546Sopenharmony_ci#define I915_PIPELINE_FLUSH 2
356bf215546Sopenharmony_ci
357bf215546Sopenharmony_ci/* split up static state */
358bf215546Sopenharmony_ci#define I915_DST_BUF_COLOR 1
359bf215546Sopenharmony_ci#define I915_DST_BUF_DEPTH 2
360bf215546Sopenharmony_ci#define I915_DST_VARS      4
361bf215546Sopenharmony_ci#define I915_DST_RECT      8
362bf215546Sopenharmony_ci
363bf215546Sopenharmony_cistatic inline void
364bf215546Sopenharmony_cii915_set_flush_dirty(struct i915_context *i915, unsigned flush)
365bf215546Sopenharmony_ci{
366bf215546Sopenharmony_ci   i915->hardware_dirty |= I915_HW_FLUSH;
367bf215546Sopenharmony_ci   i915->flush_dirty |= flush;
368bf215546Sopenharmony_ci}
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_cistatic inline uint32_t
371bf215546Sopenharmony_cii915_stencil_ccw(struct i915_context *i915)
372bf215546Sopenharmony_ci{
373bf215546Sopenharmony_ci   /* If we're doing two sided stencil, then front_ccw means we need to reverse
374bf215546Sopenharmony_ci    * the state for the sides.
375bf215546Sopenharmony_ci    */
376bf215546Sopenharmony_ci   return i915->rasterizer->templ.front_ccw &&
377bf215546Sopenharmony_ci          (i915->depth_stencil->bfo_cw[0] & BFO_STENCIL_TWO_SIDE);
378bf215546Sopenharmony_ci}
379bf215546Sopenharmony_ci/***********************************************************************
380bf215546Sopenharmony_ci * i915_prim_emit.c:
381bf215546Sopenharmony_ci */
382bf215546Sopenharmony_cistruct draw_stage *i915_draw_render_stage(struct i915_context *i915);
383bf215546Sopenharmony_ci
384bf215546Sopenharmony_ci/***********************************************************************
385bf215546Sopenharmony_ci * i915_prim_vbuf.c:
386bf215546Sopenharmony_ci */
387bf215546Sopenharmony_cistruct draw_stage *i915_draw_vbuf_stage(struct i915_context *i915);
388bf215546Sopenharmony_ci
389bf215546Sopenharmony_ci/***********************************************************************
390bf215546Sopenharmony_ci * i915_state_emit.c:
391bf215546Sopenharmony_ci */
392bf215546Sopenharmony_civoid i915_emit_hardware_state(struct i915_context *i915);
393bf215546Sopenharmony_ci
394bf215546Sopenharmony_ci/***********************************************************************
395bf215546Sopenharmony_ci * i915_clear.c:
396bf215546Sopenharmony_ci */
397bf215546Sopenharmony_civoid i915_clear_blitter(struct pipe_context *pipe, unsigned buffers,
398bf215546Sopenharmony_ci                        const struct pipe_scissor_state *scissor_state,
399bf215546Sopenharmony_ci                        const union pipe_color_union *color, double depth,
400bf215546Sopenharmony_ci                        unsigned stencil);
401bf215546Sopenharmony_civoid i915_clear_render(struct pipe_context *pipe, unsigned buffers,
402bf215546Sopenharmony_ci                       const struct pipe_scissor_state *scissor_state,
403bf215546Sopenharmony_ci                       const union pipe_color_union *color, double depth,
404bf215546Sopenharmony_ci                       unsigned stencil);
405bf215546Sopenharmony_civoid i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
406bf215546Sopenharmony_ci                     const union pipe_color_union *color, double depth,
407bf215546Sopenharmony_ci                     unsigned stencil, unsigned destx, unsigned desty,
408bf215546Sopenharmony_ci                     unsigned width, unsigned height);
409bf215546Sopenharmony_ci
410bf215546Sopenharmony_ci/***********************************************************************
411bf215546Sopenharmony_ci *
412bf215546Sopenharmony_ci */
413bf215546Sopenharmony_civoid i915_init_state_functions(struct i915_context *i915);
414bf215546Sopenharmony_civoid i915_init_flush_functions(struct i915_context *i915);
415bf215546Sopenharmony_civoid i915_init_string_functions(struct i915_context *i915);
416bf215546Sopenharmony_ci
417bf215546Sopenharmony_ci/************************************************************************
418bf215546Sopenharmony_ci * i915_context.c
419bf215546Sopenharmony_ci */
420bf215546Sopenharmony_cistruct pipe_context *i915_create_context(struct pipe_screen *screen, void *priv,
421bf215546Sopenharmony_ci                                         unsigned flags);
422bf215546Sopenharmony_ci
423bf215546Sopenharmony_ci/***********************************************************************
424bf215546Sopenharmony_ci * Inline conversion functions.  These are better-typed than the
425bf215546Sopenharmony_ci * macros used previously:
426bf215546Sopenharmony_ci */
427bf215546Sopenharmony_cistatic inline struct i915_context *
428bf215546Sopenharmony_cii915_context(struct pipe_context *pipe)
429bf215546Sopenharmony_ci{
430bf215546Sopenharmony_ci   return (struct i915_context *)pipe;
431bf215546Sopenharmony_ci}
432bf215546Sopenharmony_ci
433bf215546Sopenharmony_cistatic inline struct i915_surface *
434bf215546Sopenharmony_cii915_surface(struct pipe_surface *pipe)
435bf215546Sopenharmony_ci{
436bf215546Sopenharmony_ci   return (struct i915_surface *)pipe;
437bf215546Sopenharmony_ci}
438bf215546Sopenharmony_ci
439bf215546Sopenharmony_ci#endif
440