1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub
8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom
9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_ci#ifndef _NINE_STATE_H_
24bf215546Sopenharmony_ci#define _NINE_STATE_H_
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "d3d9.h"
27bf215546Sopenharmony_ci#include "iunknown.h"
28bf215546Sopenharmony_ci#include "nine_defines.h"
29bf215546Sopenharmony_ci#include "pipe/p_state.h"
30bf215546Sopenharmony_ci#include "util/list.h"
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#define NINED3DSAMP_MINLOD (D3DSAMP_DMAPOFFSET + 1)
33bf215546Sopenharmony_ci#define NINED3DSAMP_SHADOW (D3DSAMP_DMAPOFFSET + 2)
34bf215546Sopenharmony_ci#define NINED3DSAMP_CUBETEX (D3DSAMP_DMAPOFFSET + 3)
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1)
37bf215546Sopenharmony_ci#define NINED3DRS_RTMASK      (D3DRS_BLENDOPALPHA + 2)
38bf215546Sopenharmony_ci/* ALPHACOVERAGE:
39bf215546Sopenharmony_ci * bit 0: enable alpha coverage
40bf215546Sopenharmony_ci * bit 1: ATOC is on
41bf215546Sopenharmony_ci */
42bf215546Sopenharmony_ci#define NINED3DRS_ALPHACOVERAGE  (D3DRS_BLENDOPALPHA + 3)
43bf215546Sopenharmony_ci#define NINED3DRS_MULTISAMPLE  (D3DRS_BLENDOPALPHA + 4)
44bf215546Sopenharmony_ci#define NINED3DRS_FETCH4  (D3DRS_BLENDOPALPHA + 5)
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci#define D3DRS_LAST       D3DRS_BLENDOPALPHA
47bf215546Sopenharmony_ci#define D3DSAMP_LAST     D3DSAMP_DMAPOFFSET
48bf215546Sopenharmony_ci#define NINED3DRS_LAST   NINED3DRS_FETCH4 /* 215 */
49bf215546Sopenharmony_ci#define NINED3DSAMP_LAST NINED3DSAMP_CUBETEX /* 16 */
50bf215546Sopenharmony_ci#define NINED3DTSS_LAST  D3DTSS_CONSTANT
51bf215546Sopenharmony_ci#define NINED3DTS_LAST   D3DTS_WORLDMATRIX(255)
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci#define D3DRS_COUNT       (D3DRS_LAST + 1)
54bf215546Sopenharmony_ci#define D3DSAMP_COUNT     (D3DSAMP_LAST + 1)
55bf215546Sopenharmony_ci#define NINED3DRS_COUNT   (NINED3DRS_LAST + 1)
56bf215546Sopenharmony_ci#define NINED3DSAMP_COUNT (NINED3DSAMP_LAST + 1)
57bf215546Sopenharmony_ci#define NINED3DTSS_COUNT  (NINED3DTSS_LAST + 1)
58bf215546Sopenharmony_ci#define NINED3DTS_COUNT   (NINED3DTS_LAST + 1)
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci#define NINE_STATE_FB          (1 <<  0)
61bf215546Sopenharmony_ci#define NINE_STATE_VIEWPORT    (1 <<  1)
62bf215546Sopenharmony_ci#define NINE_STATE_SCISSOR     (1 <<  2)
63bf215546Sopenharmony_ci#define NINE_STATE_RASTERIZER  (1 <<  3)
64bf215546Sopenharmony_ci#define NINE_STATE_BLEND       (1 <<  4)
65bf215546Sopenharmony_ci#define NINE_STATE_DSA         (1 <<  5)
66bf215546Sopenharmony_ci#define NINE_STATE_VS          (1 <<  6)
67bf215546Sopenharmony_ci#define NINE_STATE_VS_CONST    (1 <<  7)
68bf215546Sopenharmony_ci#define NINE_STATE_PS          (1 <<  8)
69bf215546Sopenharmony_ci#define NINE_STATE_PS_CONST    (1 <<  9)
70bf215546Sopenharmony_ci#define NINE_STATE_TEXTURE     (1 << 10)
71bf215546Sopenharmony_ci#define NINE_STATE_SAMPLER     (1 << 11)
72bf215546Sopenharmony_ci#define NINE_STATE_VDECL       (1 << 12)
73bf215546Sopenharmony_ci#define NINE_STATE_IDXBUF      (1 << 13)
74bf215546Sopenharmony_ci#define NINE_STATE_STREAMFREQ  (1 << 14)
75bf215546Sopenharmony_ci#define NINE_STATE_BLEND_COLOR (1 << 17)
76bf215546Sopenharmony_ci#define NINE_STATE_STENCIL_REF (1 << 18)
77bf215546Sopenharmony_ci#define NINE_STATE_SAMPLE_MASK (1 << 19)
78bf215546Sopenharmony_ci#define NINE_STATE_FF          (0x1f << 20)
79bf215546Sopenharmony_ci#define NINE_STATE_FF_VS       (0x17 << 20)
80bf215546Sopenharmony_ci#define NINE_STATE_FF_PS       (0x08 << 20)
81bf215546Sopenharmony_ci#define NINE_STATE_FF_LIGHTING (1 << 20)
82bf215546Sopenharmony_ci#define NINE_STATE_FF_MATERIAL (1 << 21)
83bf215546Sopenharmony_ci#define NINE_STATE_FF_VSTRANSF (1 << 22)
84bf215546Sopenharmony_ci#define NINE_STATE_FF_PS_CONSTS (1 << 23)
85bf215546Sopenharmony_ci#define NINE_STATE_FF_VS_OTHER  (1 << 24)
86bf215546Sopenharmony_ci#define NINE_STATE_VS_PARAMS_MISC  (1 << 25)
87bf215546Sopenharmony_ci#define NINE_STATE_PS_PARAMS_MISC (1 << 26)
88bf215546Sopenharmony_ci#define NINE_STATE_MULTISAMPLE (1 << 27)
89bf215546Sopenharmony_ci#define NINE_STATE_SWVP        (1 << 28)
90bf215546Sopenharmony_ci#define NINE_STATE_ALL          0x1fffffff
91bf215546Sopenharmony_ci#define NINE_STATE_UNHANDLED   (1 << 29)
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ci/* These states affect the ff shader key,
94bf215546Sopenharmony_ci * which we recompute everytime. */
95bf215546Sopenharmony_ci#define NINE_STATE_FF_SHADER    0
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_DSA  (1 << 0)
98bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_RASTERIZER (1 << 1)
99bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_BLEND (1 << 2)
100bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_CONST_VS (1 << 3)
101bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_CONST_PS (1 << 4)
102bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_VS (1 << 5)
103bf215546Sopenharmony_ci#define NINE_STATE_COMMIT_PS (1 << 6)
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci#define NINE_MAX_SIMULTANEOUS_RENDERTARGETS 4
107bf215546Sopenharmony_ci#define NINE_MAX_CONST_F_PS3 224
108bf215546Sopenharmony_ci#define NINE_MAX_CONST_F   256
109bf215546Sopenharmony_ci#define NINE_MAX_CONST_I   16
110bf215546Sopenharmony_ci#define NINE_MAX_CONST_B   16
111bf215546Sopenharmony_ci#define NINE_MAX_CONST_F_SWVP   8192
112bf215546Sopenharmony_ci#define NINE_MAX_CONST_I_SWVP   2048
113bf215546Sopenharmony_ci#define NINE_MAX_CONST_B_SWVP   2048
114bf215546Sopenharmony_ci#define NINE_MAX_CONST_ALL 276 /* B consts count only 1/4 th */
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_ci#define NINE_CONST_I_BASE(nconstf) \
117bf215546Sopenharmony_ci    ((nconstf)        * 4 * sizeof(float))
118bf215546Sopenharmony_ci#define NINE_CONST_B_BASE(nconstf) \
119bf215546Sopenharmony_ci    ((nconstf)        * 4 * sizeof(float) + \
120bf215546Sopenharmony_ci     NINE_MAX_CONST_I * 4 * sizeof(int))
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci#define VS_CONST_F_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_F_SWVP * sizeof(float[4])) : (NINE_MAX_CONST_F * sizeof(float[4])))
123bf215546Sopenharmony_ci#define VS_CONST_I_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_I_SWVP * sizeof(int[4])) : (NINE_MAX_CONST_I * sizeof(int[4])))
124bf215546Sopenharmony_ci#define VS_CONST_B_SIZE(device) (device->may_swvp ? (NINE_MAX_CONST_B_SWVP * sizeof(BOOL)) : (NINE_MAX_CONST_B * sizeof(BOOL)))
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci#define NINE_MAX_TEXTURE_STAGES 8
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci#define NINE_MAX_LIGHTS        65536
130bf215546Sopenharmony_ci#define NINE_MAX_LIGHTS_ACTIVE 8
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci#define NINED3DLIGHT_INVALID (D3DLIGHT_DIRECTIONAL + 1)
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci#define NINE_MAX_SAMPLERS_PS 16
135bf215546Sopenharmony_ci#define NINE_MAX_SAMPLERS_VS  4
136bf215546Sopenharmony_ci#define NINE_MAX_SAMPLERS    21 /* PS + DMAP + VS */
137bf215546Sopenharmony_ci#define NINE_SAMPLER_PS(s)  ( 0 + (s))
138bf215546Sopenharmony_ci#define NINE_SAMPLER_DMAP    16
139bf215546Sopenharmony_ci#define NINE_SAMPLER_VS(s)  (17 + (s))
140bf215546Sopenharmony_ci#define NINE_PS_SAMPLERS_MASK 0x00ffff
141bf215546Sopenharmony_ci#define NINE_VS_SAMPLERS_MASK 0x1e0000
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_cistruct nine_ff_state {
144bf215546Sopenharmony_ci    struct {
145bf215546Sopenharmony_ci        uint32_t tex_stage[NINE_MAX_TEXTURE_STAGES][(NINED3DTSS_COUNT + 31) / 32]; /* stateblocks only */
146bf215546Sopenharmony_ci        uint32_t transform[(NINED3DTS_COUNT + 31) / 32];
147bf215546Sopenharmony_ci    } changed;
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci    D3DMATRIX *transform; /* access only via nine_state_access_transform */
150bf215546Sopenharmony_ci    unsigned num_transforms;
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci    /* XXX: Do state blocks just change the set of active lights or do we
153bf215546Sopenharmony_ci     * have to store which lights have been disabled, too ?
154bf215546Sopenharmony_ci     */
155bf215546Sopenharmony_ci    D3DLIGHT9 *light;
156bf215546Sopenharmony_ci    uint16_t active_light[NINE_MAX_LIGHTS_ACTIVE]; /* 8 */
157bf215546Sopenharmony_ci    unsigned num_lights;
158bf215546Sopenharmony_ci    unsigned num_lights_active;
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci    D3DMATERIAL9 material;
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci    DWORD tex_stage[NINE_MAX_TEXTURE_STAGES][NINED3DTSS_COUNT];
163bf215546Sopenharmony_ci};
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_cistruct nine_state
166bf215546Sopenharmony_ci{
167bf215546Sopenharmony_ci    struct {
168bf215546Sopenharmony_ci        uint32_t group;
169bf215546Sopenharmony_ci        uint32_t rs[(NINED3DRS_COUNT + 31) / 32];
170bf215546Sopenharmony_ci        uint32_t vtxbuf;
171bf215546Sopenharmony_ci        uint32_t stream_freq;
172bf215546Sopenharmony_ci        uint32_t texture;
173bf215546Sopenharmony_ci        uint16_t sampler[NINE_MAX_SAMPLERS];
174bf215546Sopenharmony_ci        struct nine_range *vs_const_f;
175bf215546Sopenharmony_ci        struct nine_range *ps_const_f;
176bf215546Sopenharmony_ci        struct nine_range *vs_const_i;
177bf215546Sopenharmony_ci        uint16_t ps_const_i; /* NINE_MAX_CONST_I == 16 */
178bf215546Sopenharmony_ci        struct nine_range *vs_const_b;
179bf215546Sopenharmony_ci        uint16_t ps_const_b; /* NINE_MAX_CONST_B == 16 */
180bf215546Sopenharmony_ci        uint8_t ucp;
181bf215546Sopenharmony_ci    } changed; /* stateblocks only */
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ci    struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
184bf215546Sopenharmony_ci    struct NineSurface9 *ds;
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci    D3DVIEWPORT9 viewport;
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ci    struct pipe_scissor_state scissor;
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_ci    /* NOTE: vs, ps will be NULL for FF and are set in device->ff.vs,ps instead
191bf215546Sopenharmony_ci     *  (XXX: or is it better to reference FF shaders here, too ?)
192bf215546Sopenharmony_ci     * NOTE: const_f contains extra space for const_i,b to use as user constbuf
193bf215546Sopenharmony_ci     */
194bf215546Sopenharmony_ci    struct NineVertexShader9 *vs;
195bf215546Sopenharmony_ci    float *vs_const_f;
196bf215546Sopenharmony_ci    int   *vs_const_i;
197bf215546Sopenharmony_ci    BOOL  *vs_const_b;
198bf215546Sopenharmony_ci    float *vs_lconstf_temp; /* ProcessVertices */
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ci    struct NinePixelShader9 *ps;
201bf215546Sopenharmony_ci    float *ps_const_f;
202bf215546Sopenharmony_ci    int    ps_const_i[NINE_MAX_CONST_I][4];
203bf215546Sopenharmony_ci    BOOL   ps_const_b[NINE_MAX_CONST_B];
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ci    struct NineVertexDeclaration9 *vdecl;
206bf215546Sopenharmony_ci
207bf215546Sopenharmony_ci    struct NineIndexBuffer9   *idxbuf;
208bf215546Sopenharmony_ci    struct NineVertexBuffer9  *stream[PIPE_MAX_ATTRIBS];
209bf215546Sopenharmony_ci    struct pipe_vertex_buffer  vtxbuf[PIPE_MAX_ATTRIBS]; /* vtxbuf.buffer unused */
210bf215546Sopenharmony_ci    UINT stream_freq[PIPE_MAX_ATTRIBS];
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_ci    struct pipe_clip_state clip;
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci    DWORD rs_advertised[NINED3DRS_COUNT]; /* the ones apps get with GetRenderState */
215bf215546Sopenharmony_ci
216bf215546Sopenharmony_ci    struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS]; /* PS, DMAP, VS */
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci    DWORD samp_advertised[NINE_MAX_SAMPLERS][D3DSAMP_COUNT];
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci    struct nine_ff_state ff;
221bf215546Sopenharmony_ci};
222bf215546Sopenharmony_ci
223bf215546Sopenharmony_cistruct nine_context {
224bf215546Sopenharmony_ci    struct {
225bf215546Sopenharmony_ci        uint32_t group;
226bf215546Sopenharmony_ci        uint16_t sampler[NINE_MAX_SAMPLERS];
227bf215546Sopenharmony_ci        uint32_t vtxbuf;
228bf215546Sopenharmony_ci        BOOL vs_const_f;
229bf215546Sopenharmony_ci        BOOL vs_const_i;
230bf215546Sopenharmony_ci        BOOL vs_const_b;
231bf215546Sopenharmony_ci        BOOL ps_const_f;
232bf215546Sopenharmony_ci        BOOL ps_const_i;
233bf215546Sopenharmony_ci        BOOL ps_const_b;
234bf215546Sopenharmony_ci        BOOL ucp;
235bf215546Sopenharmony_ci    } changed;
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci    uint32_t bumpmap_vars[6 * NINE_MAX_TEXTURE_STAGES];
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci    struct NineSurface9 *rt[NINE_MAX_SIMULTANEOUS_RENDERTARGETS];
240bf215546Sopenharmony_ci    struct NineSurface9 *ds;
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_ci    struct {
243bf215546Sopenharmony_ci        void *vs;
244bf215546Sopenharmony_ci        unsigned *vs_const_ranges;
245bf215546Sopenharmony_ci        unsigned vs_const_used_size;
246bf215546Sopenharmony_ci        void *ps;
247bf215546Sopenharmony_ci        unsigned *ps_const_ranges;
248bf215546Sopenharmony_ci        unsigned ps_const_used_size;
249bf215546Sopenharmony_ci    } cso_shader;
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ci    struct pipe_context *pipe;
252bf215546Sopenharmony_ci    struct cso_context *cso;
253bf215546Sopenharmony_ci
254bf215546Sopenharmony_ci    uint8_t rt_mask;
255bf215546Sopenharmony_ci
256bf215546Sopenharmony_ci    D3DVIEWPORT9 viewport;
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_ci    struct pipe_scissor_state scissor;
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci    struct NineVertexShader9 *vs;
261bf215546Sopenharmony_ci    BOOL programmable_vs;
262bf215546Sopenharmony_ci    float *vs_const_f;
263bf215546Sopenharmony_ci    float *vs_const_f_swvp;
264bf215546Sopenharmony_ci    int   *vs_const_i;
265bf215546Sopenharmony_ci    BOOL  *vs_const_b;
266bf215546Sopenharmony_ci    float *vs_lconstf_temp;
267bf215546Sopenharmony_ci
268bf215546Sopenharmony_ci    struct NinePixelShader9 *ps;
269bf215546Sopenharmony_ci    float *ps_const_f;
270bf215546Sopenharmony_ci    int    ps_const_i[NINE_MAX_CONST_I][4];
271bf215546Sopenharmony_ci    BOOL   ps_const_b[NINE_MAX_CONST_B];
272bf215546Sopenharmony_ci    float *ps_lconstf_temp;
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ci    struct NineVertexDeclaration9 *vdecl;
275bf215546Sopenharmony_ci
276bf215546Sopenharmony_ci    struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
277bf215546Sopenharmony_ci    UINT stream_freq[PIPE_MAX_ATTRIBS];
278bf215546Sopenharmony_ci    uint32_t stream_instancedata_mask; /* derived from stream_freq */
279bf215546Sopenharmony_ci    uint32_t stream_usage_mask; /* derived from VS and vdecl */
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci    struct pipe_resource *idxbuf;
282bf215546Sopenharmony_ci    unsigned index_offset;
283bf215546Sopenharmony_ci    unsigned index_size;
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci    struct pipe_clip_state clip;
286bf215546Sopenharmony_ci
287bf215546Sopenharmony_ci    DWORD rs[NINED3DRS_COUNT];
288bf215546Sopenharmony_ci
289bf215546Sopenharmony_ci    struct {
290bf215546Sopenharmony_ci        BOOL enabled;
291bf215546Sopenharmony_ci        BOOL shadow;
292bf215546Sopenharmony_ci        DWORD lod;
293bf215546Sopenharmony_ci        D3DRESOURCETYPE type;
294bf215546Sopenharmony_ci        struct pipe_resource *resource;
295bf215546Sopenharmony_ci        struct pipe_sampler_view *view[2];
296bf215546Sopenharmony_ci        uint8_t pstype;
297bf215546Sopenharmony_ci    } texture[NINE_MAX_SAMPLERS];
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci    DWORD samp[NINE_MAX_SAMPLERS][NINED3DSAMP_COUNT];
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_ci    uint32_t samplers_shadow;
302bf215546Sopenharmony_ci    uint32_t samplers_fetch4;
303bf215546Sopenharmony_ci
304bf215546Sopenharmony_ci    uint8_t bound_samplers_mask_vs;
305bf215546Sopenharmony_ci    uint8_t enabled_samplers_mask_vs;
306bf215546Sopenharmony_ci    uint8_t enabled_sampler_count_vs;
307bf215546Sopenharmony_ci    uint8_t enabled_sampler_count_ps;
308bf215546Sopenharmony_ci    uint16_t bound_samplers_mask_ps;
309bf215546Sopenharmony_ci    uint16_t enabled_samplers_mask_ps;
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ci    int dummy_vbo_bound_at; /* -1 = not bound , >= 0 = bound index */
312bf215546Sopenharmony_ci    boolean vbo_bound_done;
313bf215546Sopenharmony_ci
314bf215546Sopenharmony_ci    boolean inline_constants;
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci    struct nine_ff_state ff;
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_ci    /* software vertex processing */
319bf215546Sopenharmony_ci    boolean swvp;
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ci    uint32_t commit;
322bf215546Sopenharmony_ci    struct {
323bf215546Sopenharmony_ci        struct pipe_framebuffer_state fb;
324bf215546Sopenharmony_ci        struct pipe_depth_stencil_alpha_state dsa;
325bf215546Sopenharmony_ci        struct pipe_rasterizer_state rast;
326bf215546Sopenharmony_ci        struct pipe_blend_state blend;
327bf215546Sopenharmony_ci        struct pipe_constant_buffer cb_vs;
328bf215546Sopenharmony_ci        struct pipe_constant_buffer cb0_swvp;
329bf215546Sopenharmony_ci        struct pipe_constant_buffer cb1_swvp;
330bf215546Sopenharmony_ci        struct pipe_constant_buffer cb2_swvp;
331bf215546Sopenharmony_ci        struct pipe_constant_buffer cb3_swvp;
332bf215546Sopenharmony_ci        struct pipe_constant_buffer cb_ps;
333bf215546Sopenharmony_ci        struct pipe_constant_buffer cb_vs_ff;
334bf215546Sopenharmony_ci        struct pipe_constant_buffer cb_ps_ff;
335bf215546Sopenharmony_ci    } pipe_data;
336bf215546Sopenharmony_ci};
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_cistruct nine_state_sw_internal {
339bf215546Sopenharmony_ci    struct pipe_transfer *transfers_so[4];
340bf215546Sopenharmony_ci};
341bf215546Sopenharmony_ci
342bf215546Sopenharmony_cistruct nine_clipplane {
343bf215546Sopenharmony_ci    float plane[4];
344bf215546Sopenharmony_ci};
345bf215546Sopenharmony_ci/* map D3DRS -> NINE_STATE_x
346bf215546Sopenharmony_ci */
347bf215546Sopenharmony_ciextern const uint32_t nine_render_state_group[NINED3DRS_COUNT];
348bf215546Sopenharmony_ci
349bf215546Sopenharmony_ci/* for D3DSBT_PIXEL/VERTEX:
350bf215546Sopenharmony_ci */
351bf215546Sopenharmony_ciextern const uint32_t nine_render_states_pixel[(NINED3DRS_COUNT + 31) / 32];
352bf215546Sopenharmony_ciextern const uint32_t nine_render_states_vertex[(NINED3DRS_COUNT + 31) / 32];
353bf215546Sopenharmony_ci
354bf215546Sopenharmony_cistruct NineDevice9;
355bf215546Sopenharmony_ci
356bf215546Sopenharmony_ci/* Internal multithreading: When enabled, the nine_context functions
357bf215546Sopenharmony_ci * will append work to a worker thread when possible. Only the worker
358bf215546Sopenharmony_ci * thread can access struct nine_context. */
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_civoid
361bf215546Sopenharmony_cinine_context_set_stream_source_apply(struct NineDevice9 *device,
362bf215546Sopenharmony_ci                                    UINT StreamNumber,
363bf215546Sopenharmony_ci                                    struct pipe_resource *res,
364bf215546Sopenharmony_ci                                    UINT OffsetInBytes,
365bf215546Sopenharmony_ci                                    UINT Stride);
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_civoid
368bf215546Sopenharmony_cinine_context_set_indices_apply(struct NineDevice9 *device,
369bf215546Sopenharmony_ci                               struct pipe_resource *res,
370bf215546Sopenharmony_ci                               UINT IndexSize,
371bf215546Sopenharmony_ci                               UINT OffsetInBytes);
372bf215546Sopenharmony_ci
373bf215546Sopenharmony_civoid
374bf215546Sopenharmony_cinine_context_set_render_state(struct NineDevice9 *device,
375bf215546Sopenharmony_ci                              D3DRENDERSTATETYPE State,
376bf215546Sopenharmony_ci                              DWORD Value);
377bf215546Sopenharmony_ci
378bf215546Sopenharmony_civoid
379bf215546Sopenharmony_cinine_context_set_texture(struct NineDevice9 *device,
380bf215546Sopenharmony_ci                         DWORD Stage,
381bf215546Sopenharmony_ci                         struct NineBaseTexture9 *tex);
382bf215546Sopenharmony_ci
383bf215546Sopenharmony_civoid
384bf215546Sopenharmony_cinine_context_set_sampler_state(struct NineDevice9 *device,
385bf215546Sopenharmony_ci                               DWORD Sampler,
386bf215546Sopenharmony_ci                               D3DSAMPLERSTATETYPE Type,
387bf215546Sopenharmony_ci                               DWORD Value);
388bf215546Sopenharmony_ci
389bf215546Sopenharmony_civoid
390bf215546Sopenharmony_cinine_context_set_stream_source(struct NineDevice9 *device,
391bf215546Sopenharmony_ci                               UINT StreamNumber,
392bf215546Sopenharmony_ci                               struct NineVertexBuffer9 *pVBuf9,
393bf215546Sopenharmony_ci                               UINT OffsetInBytes,
394bf215546Sopenharmony_ci                               UINT Stride);
395bf215546Sopenharmony_ci
396bf215546Sopenharmony_civoid
397bf215546Sopenharmony_cinine_context_set_stream_source_freq(struct NineDevice9 *device,
398bf215546Sopenharmony_ci                                    UINT StreamNumber,
399bf215546Sopenharmony_ci                                    UINT Setting);
400bf215546Sopenharmony_ci
401bf215546Sopenharmony_civoid
402bf215546Sopenharmony_cinine_context_set_indices(struct NineDevice9 *device,
403bf215546Sopenharmony_ci                         struct NineIndexBuffer9 *idxbuf);
404bf215546Sopenharmony_ci
405bf215546Sopenharmony_civoid
406bf215546Sopenharmony_cinine_context_set_vertex_declaration(struct NineDevice9 *device,
407bf215546Sopenharmony_ci                                    struct NineVertexDeclaration9 *vdecl);
408bf215546Sopenharmony_ci
409bf215546Sopenharmony_civoid
410bf215546Sopenharmony_cinine_context_set_vertex_shader(struct NineDevice9 *device,
411bf215546Sopenharmony_ci                               struct NineVertexShader9 *pShader);
412bf215546Sopenharmony_ci
413bf215546Sopenharmony_civoid
414bf215546Sopenharmony_cinine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
415bf215546Sopenharmony_ci                                          UINT StartRegister,
416bf215546Sopenharmony_ci                                          const float *pConstantData,
417bf215546Sopenharmony_ci                                          const unsigned pConstantData_size,
418bf215546Sopenharmony_ci                                          UINT Vector4fCount);
419bf215546Sopenharmony_ci
420bf215546Sopenharmony_civoid
421bf215546Sopenharmony_cinine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
422bf215546Sopenharmony_ci                                          UINT StartRegister,
423bf215546Sopenharmony_ci                                          const int *pConstantData,
424bf215546Sopenharmony_ci                                          const unsigned pConstantData_size,
425bf215546Sopenharmony_ci                                          UINT Vector4iCount);
426bf215546Sopenharmony_ci
427bf215546Sopenharmony_civoid
428bf215546Sopenharmony_cinine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
429bf215546Sopenharmony_ci                                          UINT StartRegister,
430bf215546Sopenharmony_ci                                          const BOOL *pConstantData,
431bf215546Sopenharmony_ci                                          const unsigned pConstantData_size,
432bf215546Sopenharmony_ci                                          UINT BoolCount);
433bf215546Sopenharmony_ci
434bf215546Sopenharmony_civoid
435bf215546Sopenharmony_cinine_context_set_pixel_shader(struct NineDevice9 *device,
436bf215546Sopenharmony_ci                              struct NinePixelShader9* ps);
437bf215546Sopenharmony_ci
438bf215546Sopenharmony_civoid
439bf215546Sopenharmony_cinine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
440bf215546Sopenharmony_ci                                        UINT StartRegister,
441bf215546Sopenharmony_ci                                        const float *pConstantData,
442bf215546Sopenharmony_ci                                        const unsigned pConstantData_size,
443bf215546Sopenharmony_ci                                        UINT Vector4fCount);
444bf215546Sopenharmony_ci
445bf215546Sopenharmony_civoid
446bf215546Sopenharmony_cinine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
447bf215546Sopenharmony_ci                                         UINT StartRegister,
448bf215546Sopenharmony_ci                                         const int *pConstantData,
449bf215546Sopenharmony_ci                                         const unsigned pConstantData_size,
450bf215546Sopenharmony_ci                                         UINT Vector4iCount);
451bf215546Sopenharmony_ci
452bf215546Sopenharmony_civoid
453bf215546Sopenharmony_cinine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
454bf215546Sopenharmony_ci                                         UINT StartRegister,
455bf215546Sopenharmony_ci                                         const BOOL *pConstantData,
456bf215546Sopenharmony_ci                                         const unsigned pConstantData_size,
457bf215546Sopenharmony_ci                                         UINT BoolCount);
458bf215546Sopenharmony_ci
459bf215546Sopenharmony_civoid
460bf215546Sopenharmony_cinine_context_set_viewport(struct NineDevice9 *device,
461bf215546Sopenharmony_ci                          const D3DVIEWPORT9 *viewport);
462bf215546Sopenharmony_ci
463bf215546Sopenharmony_civoid
464bf215546Sopenharmony_cinine_context_set_scissor(struct NineDevice9 *device,
465bf215546Sopenharmony_ci                         const struct pipe_scissor_state *scissor);
466bf215546Sopenharmony_ci
467bf215546Sopenharmony_civoid
468bf215546Sopenharmony_cinine_context_set_transform(struct NineDevice9 *device,
469bf215546Sopenharmony_ci                           D3DTRANSFORMSTATETYPE State,
470bf215546Sopenharmony_ci                           const D3DMATRIX *pMatrix);
471bf215546Sopenharmony_ci
472bf215546Sopenharmony_civoid
473bf215546Sopenharmony_cinine_context_set_material(struct NineDevice9 *device,
474bf215546Sopenharmony_ci                          const D3DMATERIAL9 *pMaterial);
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_civoid
477bf215546Sopenharmony_cinine_context_set_light(struct NineDevice9 *device,
478bf215546Sopenharmony_ci                       DWORD Index,
479bf215546Sopenharmony_ci                       const D3DLIGHT9 *pLight);
480bf215546Sopenharmony_ci
481bf215546Sopenharmony_civoid
482bf215546Sopenharmony_cinine_context_light_enable(struct NineDevice9 *device,
483bf215546Sopenharmony_ci                          DWORD Index,
484bf215546Sopenharmony_ci                          BOOL Enable);
485bf215546Sopenharmony_ci
486bf215546Sopenharmony_civoid
487bf215546Sopenharmony_cinine_context_set_texture_stage_state(struct NineDevice9 *device,
488bf215546Sopenharmony_ci                                     DWORD Stage,
489bf215546Sopenharmony_ci                                     D3DTEXTURESTAGESTATETYPE Type,
490bf215546Sopenharmony_ci                                     DWORD Value);
491bf215546Sopenharmony_ci
492bf215546Sopenharmony_civoid
493bf215546Sopenharmony_cinine_context_set_render_target(struct NineDevice9 *device,
494bf215546Sopenharmony_ci                               DWORD RenderTargetIndex,
495bf215546Sopenharmony_ci                               struct NineSurface9 *rt);
496bf215546Sopenharmony_ci
497bf215546Sopenharmony_civoid
498bf215546Sopenharmony_cinine_context_set_depth_stencil(struct NineDevice9 *device,
499bf215546Sopenharmony_ci                               struct NineSurface9 *ds);
500bf215546Sopenharmony_ci
501bf215546Sopenharmony_civoid
502bf215546Sopenharmony_cinine_context_set_clip_plane(struct NineDevice9 *device,
503bf215546Sopenharmony_ci                            DWORD Index,
504bf215546Sopenharmony_ci                            const struct nine_clipplane *pPlane);
505bf215546Sopenharmony_ci
506bf215546Sopenharmony_civoid
507bf215546Sopenharmony_cinine_context_set_swvp(struct NineDevice9 *device,
508bf215546Sopenharmony_ci                      boolean swvp);
509bf215546Sopenharmony_ci
510bf215546Sopenharmony_civoid
511bf215546Sopenharmony_cinine_context_apply_stateblock(struct NineDevice9 *device,
512bf215546Sopenharmony_ci                              const struct nine_state *src);
513bf215546Sopenharmony_ci
514bf215546Sopenharmony_civoid
515bf215546Sopenharmony_cinine_context_clear_fb(struct NineDevice9 *device, DWORD Count,
516bf215546Sopenharmony_ci                      const D3DRECT *pRects, DWORD Flags,
517bf215546Sopenharmony_ci                      D3DCOLOR Color, float Z, DWORD Stencil);
518bf215546Sopenharmony_ci
519bf215546Sopenharmony_civoid
520bf215546Sopenharmony_cinine_context_draw_primitive(struct NineDevice9 *device,
521bf215546Sopenharmony_ci                            D3DPRIMITIVETYPE PrimitiveType,
522bf215546Sopenharmony_ci                            UINT StartVertex,
523bf215546Sopenharmony_ci                            UINT PrimitiveCount);
524bf215546Sopenharmony_ci
525bf215546Sopenharmony_civoid
526bf215546Sopenharmony_cinine_context_draw_indexed_primitive(struct NineDevice9 *device,
527bf215546Sopenharmony_ci                                    D3DPRIMITIVETYPE PrimitiveType,
528bf215546Sopenharmony_ci                                    INT BaseVertexIndex,
529bf215546Sopenharmony_ci                                    UINT MinVertexIndex,
530bf215546Sopenharmony_ci                                    UINT NumVertices,
531bf215546Sopenharmony_ci                                    UINT StartIndex,
532bf215546Sopenharmony_ci                                    UINT PrimitiveCount);
533bf215546Sopenharmony_ci
534bf215546Sopenharmony_civoid
535bf215546Sopenharmony_cinine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *device,
536bf215546Sopenharmony_ci                                                       D3DPRIMITIVETYPE PrimitiveType,
537bf215546Sopenharmony_ci                                                       UINT MinVertexIndex,
538bf215546Sopenharmony_ci                                                       UINT NumVertices,
539bf215546Sopenharmony_ci                                                       UINT PrimitiveCount,
540bf215546Sopenharmony_ci                                                       struct pipe_vertex_buffer *vbuf,
541bf215546Sopenharmony_ci                                                       struct pipe_resource *ibuf,
542bf215546Sopenharmony_ci                                                       void *user_ibuf,
543bf215546Sopenharmony_ci                                                       unsigned index_offset,
544bf215546Sopenharmony_ci						       unsigned index_size);
545bf215546Sopenharmony_ci
546bf215546Sopenharmony_civoid
547bf215546Sopenharmony_cinine_context_resource_copy_region(struct NineDevice9 *device,
548bf215546Sopenharmony_ci                                  struct NineUnknown *dst,
549bf215546Sopenharmony_ci                                  struct NineUnknown *src,
550bf215546Sopenharmony_ci                                  struct pipe_resource* dst_res,
551bf215546Sopenharmony_ci                                  unsigned dst_level,
552bf215546Sopenharmony_ci                                  const struct pipe_box *dst_box,
553bf215546Sopenharmony_ci                                  struct pipe_resource* src_res,
554bf215546Sopenharmony_ci                                  unsigned src_level,
555bf215546Sopenharmony_ci                                  const struct pipe_box *src_box);
556bf215546Sopenharmony_ci
557bf215546Sopenharmony_civoid
558bf215546Sopenharmony_cinine_context_blit(struct NineDevice9 *device,
559bf215546Sopenharmony_ci                  struct NineUnknown *dst,
560bf215546Sopenharmony_ci                  struct NineUnknown *src,
561bf215546Sopenharmony_ci                  struct pipe_blit_info *blit);
562bf215546Sopenharmony_ci
563bf215546Sopenharmony_civoid
564bf215546Sopenharmony_cinine_context_clear_render_target(struct NineDevice9 *device,
565bf215546Sopenharmony_ci                                 struct NineSurface9 *surface,
566bf215546Sopenharmony_ci                                 D3DCOLOR color,
567bf215546Sopenharmony_ci                                 UINT x,
568bf215546Sopenharmony_ci                                 UINT y,
569bf215546Sopenharmony_ci                                 UINT width,
570bf215546Sopenharmony_ci                                 UINT height);
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_civoid
573bf215546Sopenharmony_cinine_context_gen_mipmap(struct NineDevice9 *device,
574bf215546Sopenharmony_ci                        struct NineUnknown *dst,
575bf215546Sopenharmony_ci                        struct pipe_resource *res,
576bf215546Sopenharmony_ci                        UINT base_level, UINT last_level,
577bf215546Sopenharmony_ci                        UINT first_layer, UINT last_layer,
578bf215546Sopenharmony_ci                        UINT filter);
579bf215546Sopenharmony_ci
580bf215546Sopenharmony_civoid
581bf215546Sopenharmony_cinine_context_range_upload(struct NineDevice9 *device,
582bf215546Sopenharmony_ci                          unsigned *counter,
583bf215546Sopenharmony_ci                          struct NineUnknown *src_ref,
584bf215546Sopenharmony_ci                          struct pipe_resource *res,
585bf215546Sopenharmony_ci                          unsigned offset,
586bf215546Sopenharmony_ci                          unsigned size,
587bf215546Sopenharmony_ci                          unsigned usage,
588bf215546Sopenharmony_ci                          const void *data);
589bf215546Sopenharmony_ci
590bf215546Sopenharmony_civoid
591bf215546Sopenharmony_cinine_context_box_upload(struct NineDevice9 *device,
592bf215546Sopenharmony_ci                        unsigned *counter,
593bf215546Sopenharmony_ci                        struct NineUnknown *src_ref,
594bf215546Sopenharmony_ci                        struct pipe_resource *res,
595bf215546Sopenharmony_ci                        unsigned level,
596bf215546Sopenharmony_ci                        const struct pipe_box *dst_box,
597bf215546Sopenharmony_ci                        enum pipe_format src_format,
598bf215546Sopenharmony_ci                        const void *src, unsigned src_stride,
599bf215546Sopenharmony_ci                        unsigned src_layer_stride,
600bf215546Sopenharmony_ci                        const struct pipe_box *src_box);
601bf215546Sopenharmony_ci
602bf215546Sopenharmony_cistruct pipe_query *
603bf215546Sopenharmony_cinine_context_create_query(struct NineDevice9 *device, unsigned query_type);
604bf215546Sopenharmony_ci
605bf215546Sopenharmony_civoid
606bf215546Sopenharmony_cinine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query);
607bf215546Sopenharmony_ci
608bf215546Sopenharmony_civoid
609bf215546Sopenharmony_cinine_context_begin_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
610bf215546Sopenharmony_ci
611bf215546Sopenharmony_civoid
612bf215546Sopenharmony_cinine_context_end_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
613bf215546Sopenharmony_ci
614bf215546Sopenharmony_ciboolean
615bf215546Sopenharmony_cinine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
616bf215546Sopenharmony_ci                              unsigned *counter, boolean flush, boolean wait,
617bf215546Sopenharmony_ci                              union pipe_query_result *result);
618bf215546Sopenharmony_ci
619bf215546Sopenharmony_civoid
620bf215546Sopenharmony_cinine_context_pipe_flush(struct NineDevice9 *device);
621bf215546Sopenharmony_ci
622bf215546Sopenharmony_civoid nine_state_restore_non_cso(struct NineDevice9 *device);
623bf215546Sopenharmony_civoid nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
624bf215546Sopenharmony_ci                             boolean is_reset);
625bf215546Sopenharmony_civoid nine_device_state_clear(struct NineDevice9 *);
626bf215546Sopenharmony_civoid nine_context_clear(struct NineDevice9 *);
627bf215546Sopenharmony_civoid nine_context_update_state(struct NineDevice9 *);
628bf215546Sopenharmony_ci
629bf215546Sopenharmony_civoid nine_state_init_sw(struct NineDevice9 *device);
630bf215546Sopenharmony_civoid nine_state_prepare_draw_sw(struct NineDevice9 *device,
631bf215546Sopenharmony_ci                                struct NineVertexDeclaration9 *vdecl_out,
632bf215546Sopenharmony_ci                                int start_vertice,
633bf215546Sopenharmony_ci                                int num_vertices,
634bf215546Sopenharmony_ci                                struct pipe_stream_output_info *so);
635bf215546Sopenharmony_civoid nine_state_after_draw_sw(struct NineDevice9 *device);
636bf215546Sopenharmony_civoid nine_state_destroy_sw(struct NineDevice9 *device);
637bf215546Sopenharmony_ci
638bf215546Sopenharmony_civoid
639bf215546Sopenharmony_cinine_state_resize_transform(struct nine_ff_state *ff_state, unsigned N);
640bf215546Sopenharmony_ci
641bf215546Sopenharmony_ci/* If @alloc is FALSE, the return value may be a const identity matrix.
642bf215546Sopenharmony_ci * Therefore, do not modify if you set alloc to FALSE !
643bf215546Sopenharmony_ci */
644bf215546Sopenharmony_ciD3DMATRIX *
645bf215546Sopenharmony_cinine_state_access_transform(struct nine_ff_state *, D3DTRANSFORMSTATETYPE,
646bf215546Sopenharmony_ci                            boolean alloc);
647bf215546Sopenharmony_ci
648bf215546Sopenharmony_ciHRESULT
649bf215546Sopenharmony_cinine_state_set_light(struct nine_ff_state *, DWORD, const D3DLIGHT9 *);
650bf215546Sopenharmony_ci
651bf215546Sopenharmony_ciHRESULT
652bf215546Sopenharmony_cinine_state_light_enable(struct nine_ff_state *,
653bf215546Sopenharmony_ci                        DWORD, BOOL);
654bf215546Sopenharmony_ci
655bf215546Sopenharmony_ciconst char *nine_d3drs_to_string(DWORD State);
656bf215546Sopenharmony_ci
657bf215546Sopenharmony_ci/* CSMT functions */
658bf215546Sopenharmony_cistruct csmt_context;
659bf215546Sopenharmony_ci
660bf215546Sopenharmony_cistruct csmt_context *
661bf215546Sopenharmony_cinine_csmt_create( struct NineDevice9 *This );
662bf215546Sopenharmony_ci
663bf215546Sopenharmony_civoid
664bf215546Sopenharmony_cinine_csmt_destroy( struct NineDevice9 *This, struct csmt_context *ctx );
665bf215546Sopenharmony_ci
666bf215546Sopenharmony_ci/* Flushes and waits everything is executed */
667bf215546Sopenharmony_civoid
668bf215546Sopenharmony_cinine_csmt_process( struct NineDevice9 *This );
669bf215546Sopenharmony_ci
670bf215546Sopenharmony_ci/* Flushes and doesn't wait */
671bf215546Sopenharmony_civoid
672bf215546Sopenharmony_cinine_csmt_flush( struct NineDevice9 *This );
673bf215546Sopenharmony_ci
674bf215546Sopenharmony_ci/* Get the pipe_context (should not be called from the worker thread).
675bf215546Sopenharmony_ci * All the work in the worker thread is finished before returning. */
676bf215546Sopenharmony_cistruct pipe_context *
677bf215546Sopenharmony_cinine_context_get_pipe( struct NineDevice9 *device );
678bf215546Sopenharmony_ci
679bf215546Sopenharmony_ci/* Can be called from all threads */
680bf215546Sopenharmony_cistruct pipe_context *
681bf215546Sopenharmony_cinine_context_get_pipe_multithread( struct NineDevice9 *device );
682bf215546Sopenharmony_ci
683bf215546Sopenharmony_ci
684bf215546Sopenharmony_ci/* Get the pipe_context (should not be called from the worker thread).
685bf215546Sopenharmony_ci * All the work in the worker thread is paused before returning.
686bf215546Sopenharmony_ci * It is neccessary to release in order to restart the thread.
687bf215546Sopenharmony_ci * This is intended for use of the nine_context pipe_context that don't
688bf215546Sopenharmony_ci * need the worker thread to finish all queued job. */
689bf215546Sopenharmony_cistruct pipe_context *
690bf215546Sopenharmony_cinine_context_get_pipe_acquire( struct NineDevice9 *device );
691bf215546Sopenharmony_ci
692bf215546Sopenharmony_civoid
693bf215546Sopenharmony_cinine_context_get_pipe_release( struct NineDevice9 *device );
694bf215546Sopenharmony_ci
695bf215546Sopenharmony_cibool
696bf215546Sopenharmony_cinine_context_is_worker( struct NineDevice9 *device );
697bf215546Sopenharmony_ci
698bf215546Sopenharmony_ci#endif /* _NINE_STATE_H_ */
699