2 #include "util/u_math.h"
4 #include "nvc0_context.h"
8 nvc0_validate_zcull(struct nvc0_context
*nvc0
)
10 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
11 struct pipe_framebuffer_state
*fb
= &nvc0
->framebuffer
;
12 struct nv50_surface
*sf
= nv50_surface(fb
->zsbuf
);
13 struct nv50_miptree
*mt
= nv50_miptree(sf
->base
.texture
);
14 struct nouveau_bo
*bo
= mt
->base
.bo
;
16 uint32_t offset
= align(mt
->total_size
, 1 << 17);
17 unsigned width
, height
;
19 assert(mt
->base
.base
.depth0
== 1 && mt
->base
.base
.array_size
< 2);
21 size
= mt
->total_size
* 2;
23 height
= align(fb
->height
, 32);
24 width
= fb
->width
% 224;
26 width
= fb
->width
+ (224 - width
);
30 BEGIN_NVC0(push
, NVC0_3D(ZCULL_REGION
), 1);
32 BEGIN_NVC0(push
, NVC0_3D(ZCULL_ADDRESS_HIGH
), 2);
33 PUSH_DATAh(push
, bo
->offset
+ offset
);
34 PUSH_DATA (push
, bo
->offset
+ offset
);
36 BEGIN_NVC0(push
, NVC0_3D(ZCULL_LIMIT_HIGH
), 2);
37 PUSH_DATAh(push
, bo
->offset
+ offset
);
38 PUSH_DATA (push
, bo
->offset
+ offset
);
39 BEGIN_NVC0(push
, SUBC_3D(0x07e0), 2);
40 PUSH_DATA (push
, size
);
41 PUSH_DATA (push
, size
>> 16);
42 BEGIN_NVC0(push
, SUBC_3D(0x15c8), 1); /* bits 0x3 */
44 BEGIN_NVC0(push
, NVC0_3D(ZCULL_WIDTH
), 4);
45 PUSH_DATA (push
, width
);
46 PUSH_DATA (push
, height
);
49 BEGIN_NVC0(push
, NVC0_3D(ZCULL_WINDOW_OFFSET_X
), 2);
52 BEGIN_NVC0(push
, NVC0_3D(ZCULL_INVALIDATE
), 1);
58 nvc0_validate_fb(struct nvc0_context
*nvc0
)
60 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
61 struct pipe_framebuffer_state
*fb
= &nvc0
->framebuffer
;
63 unsigned ms_mode
= NVC0_3D_MULTISAMPLE_MODE_MS1
;
64 boolean serialize
= FALSE
;
66 nouveau_bufctx_reset(nvc0
->bufctx_3d
, NVC0_BIND_FB
);
68 BEGIN_NVC0(push
, NVC0_3D(RT_CONTROL
), 1);
69 PUSH_DATA (push
, (076543210 << 4) | fb
->nr_cbufs
);
70 BEGIN_NVC0(push
, NVC0_3D(SCREEN_SCISSOR_HORIZ
), 2);
71 PUSH_DATA (push
, fb
->width
<< 16);
72 PUSH_DATA (push
, fb
->height
<< 16);
74 for (i
= 0; i
< fb
->nr_cbufs
; ++i
) {
75 struct nv50_surface
*sf
= nv50_surface(fb
->cbufs
[i
]);
76 struct nv04_resource
*res
= nv04_resource(sf
->base
.texture
);
77 struct nouveau_bo
*bo
= res
->bo
;
79 BEGIN_NVC0(push
, NVC0_3D(RT_ADDRESS_HIGH(i
)), 9);
80 PUSH_DATAh(push
, res
->address
+ sf
->offset
);
81 PUSH_DATA (push
, res
->address
+ sf
->offset
);
82 if (likely(nouveau_bo_memtype(bo
))) {
83 struct nv50_miptree
*mt
= nv50_miptree(sf
->base
.texture
);
85 assert(sf
->base
.texture
->target
!= PIPE_BUFFER
);
87 PUSH_DATA(push
, sf
->width
);
88 PUSH_DATA(push
, sf
->height
);
89 PUSH_DATA(push
, nvc0_format_table
[sf
->base
.format
].rt
);
90 PUSH_DATA(push
, (mt
->layout_3d
<< 16) |
91 mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
92 PUSH_DATA(push
, sf
->base
.u
.tex
.first_layer
+ sf
->depth
);
93 PUSH_DATA(push
, mt
->layer_stride
>> 2);
94 PUSH_DATA(push
, sf
->base
.u
.tex
.first_layer
);
96 ms_mode
= mt
->ms_mode
;
98 if (res
->base
.target
== PIPE_BUFFER
) {
99 PUSH_DATA(push
, 262144);
102 PUSH_DATA(push
, nv50_miptree(sf
->base
.texture
)->level
[0].pitch
);
103 PUSH_DATA(push
, sf
->height
);
105 PUSH_DATA(push
, nvc0_format_table
[sf
->base
.format
].rt
);
106 PUSH_DATA(push
, 1 << 12);
111 nvc0_resource_fence(res
, NOUVEAU_BO_WR
);
116 if (res
->status
& NOUVEAU_BUFFER_STATUS_GPU_READING
)
118 res
->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
;
119 res
->status
&= ~NOUVEAU_BUFFER_STATUS_GPU_READING
;
121 /* only register for writing, otherwise we'd always serialize here */
122 BCTX_REFN(nvc0
->bufctx_3d
, FB
, res
, WR
);
126 struct nv50_miptree
*mt
= nv50_miptree(fb
->zsbuf
->texture
);
127 struct nv50_surface
*sf
= nv50_surface(fb
->zsbuf
);
128 int unk
= mt
->base
.base
.target
== PIPE_TEXTURE_2D
;
130 BEGIN_NVC0(push
, NVC0_3D(ZETA_ADDRESS_HIGH
), 5);
131 PUSH_DATAh(push
, mt
->base
.address
+ sf
->offset
);
132 PUSH_DATA (push
, mt
->base
.address
+ sf
->offset
);
133 PUSH_DATA (push
, nvc0_format_table
[fb
->zsbuf
->format
].rt
);
134 PUSH_DATA (push
, mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
135 PUSH_DATA (push
, mt
->layer_stride
>> 2);
136 BEGIN_NVC0(push
, NVC0_3D(ZETA_ENABLE
), 1);
138 BEGIN_NVC0(push
, NVC0_3D(ZETA_HORIZ
), 3);
139 PUSH_DATA (push
, sf
->width
);
140 PUSH_DATA (push
, sf
->height
);
141 PUSH_DATA (push
, (unk
<< 16) |
142 (sf
->base
.u
.tex
.first_layer
+ sf
->depth
));
143 BEGIN_NVC0(push
, NVC0_3D(ZETA_BASE_LAYER
), 1);
144 PUSH_DATA (push
, sf
->base
.u
.tex
.first_layer
);
146 ms_mode
= mt
->ms_mode
;
148 if (mt
->base
.status
& NOUVEAU_BUFFER_STATUS_GPU_READING
)
150 mt
->base
.status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
;
151 mt
->base
.status
&= ~NOUVEAU_BUFFER_STATUS_GPU_READING
;
153 BCTX_REFN(nvc0
->bufctx_3d
, FB
, &mt
->base
, WR
);
155 BEGIN_NVC0(push
, NVC0_3D(ZETA_ENABLE
), 1);
159 IMMED_NVC0(push
, NVC0_3D(MULTISAMPLE_MODE
), ms_mode
);
162 IMMED_NVC0(push
, NVC0_3D(SERIALIZE
), 0);
166 nvc0_validate_blend_colour(struct nvc0_context
*nvc0
)
168 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
170 BEGIN_NVC0(push
, NVC0_3D(BLEND_COLOR(0)), 4);
171 PUSH_DATAf(push
, nvc0
->blend_colour
.color
[0]);
172 PUSH_DATAf(push
, nvc0
->blend_colour
.color
[1]);
173 PUSH_DATAf(push
, nvc0
->blend_colour
.color
[2]);
174 PUSH_DATAf(push
, nvc0
->blend_colour
.color
[3]);
178 nvc0_validate_stencil_ref(struct nvc0_context
*nvc0
)
180 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
181 const ubyte
*ref
= &nvc0
->stencil_ref
.ref_value
[0];
183 IMMED_NVC0(push
, NVC0_3D(STENCIL_FRONT_FUNC_REF
), ref
[0]);
184 IMMED_NVC0(push
, NVC0_3D(STENCIL_BACK_FUNC_REF
), ref
[1]);
188 nvc0_validate_stipple(struct nvc0_context
*nvc0
)
190 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
193 BEGIN_NVC0(push
, NVC0_3D(POLYGON_STIPPLE_PATTERN(0)), 32);
194 for (i
= 0; i
< 32; ++i
)
195 PUSH_DATA(push
, util_bswap32(nvc0
->stipple
.stipple
[i
]));
199 nvc0_validate_scissor(struct nvc0_context
*nvc0
)
201 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
202 struct pipe_scissor_state
*s
= &nvc0
->scissor
;
204 if (!(nvc0
->dirty
& NVC0_NEW_SCISSOR
) &&
205 nvc0
->rast
->pipe
.scissor
== nvc0
->state
.scissor
)
207 nvc0
->state
.scissor
= nvc0
->rast
->pipe
.scissor
;
209 BEGIN_NVC0(push
, NVC0_3D(SCISSOR_HORIZ(0)), 2);
210 if (nvc0
->rast
->pipe
.scissor
) {
211 PUSH_DATA(push
, (s
->maxx
<< 16) | s
->minx
);
212 PUSH_DATA(push
, (s
->maxy
<< 16) | s
->miny
);
214 PUSH_DATA(push
, (0xffff << 16) | 0);
215 PUSH_DATA(push
, (0xffff << 16) | 0);
220 nvc0_validate_viewport(struct nvc0_context
*nvc0
)
222 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
223 struct pipe_viewport_state
*vp
= &nvc0
->viewport
;
227 BEGIN_NVC0(push
, NVC0_3D(VIEWPORT_TRANSLATE_X(0)), 3);
228 PUSH_DATAf(push
, vp
->translate
[0]);
229 PUSH_DATAf(push
, vp
->translate
[1]);
230 PUSH_DATAf(push
, vp
->translate
[2]);
231 BEGIN_NVC0(push
, NVC0_3D(VIEWPORT_SCALE_X(0)), 3);
232 PUSH_DATAf(push
, vp
->scale
[0]);
233 PUSH_DATAf(push
, vp
->scale
[1]);
234 PUSH_DATAf(push
, vp
->scale
[2]);
236 /* now set the viewport rectangle to viewport dimensions for clipping */
238 x
= util_iround(MAX2(0.0f
, vp
->translate
[0] - fabsf(vp
->scale
[0])));
239 y
= util_iround(MAX2(0.0f
, vp
->translate
[1] - fabsf(vp
->scale
[1])));
240 w
= util_iround(vp
->translate
[0] + fabsf(vp
->scale
[0])) - x
;
241 h
= util_iround(vp
->translate
[1] + fabsf(vp
->scale
[1])) - y
;
243 zmin
= vp
->translate
[2] - fabsf(vp
->scale
[2]);
244 zmax
= vp
->translate
[2] + fabsf(vp
->scale
[2]);
246 BEGIN_NVC0(push
, NVC0_3D(VIEWPORT_HORIZ(0)), 2);
247 PUSH_DATA (push
, (w
<< 16) | x
);
248 PUSH_DATA (push
, (h
<< 16) | y
);
249 BEGIN_NVC0(push
, NVC0_3D(DEPTH_RANGE_NEAR(0)), 2);
250 PUSH_DATAf(push
, zmin
);
251 PUSH_DATAf(push
, zmax
);
255 nvc0_upload_uclip_planes(struct nvc0_context
*nvc0
, unsigned s
)
257 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
258 struct nouveau_bo
*bo
= nvc0
->screen
->uniform_bo
;
260 BEGIN_NVC0(push
, NVC0_3D(CB_SIZE
), 3);
261 PUSH_DATA (push
, 512);
262 PUSH_DATAh(push
, bo
->offset
+ (5 << 16) + (s
<< 9));
263 PUSH_DATA (push
, bo
->offset
+ (5 << 16) + (s
<< 9));
264 BEGIN_1IC0(push
, NVC0_3D(CB_POS
), PIPE_MAX_CLIP_PLANES
* 4 + 1);
265 PUSH_DATA (push
, 256);
266 PUSH_DATAp(push
, &nvc0
->clip
.ucp
[0][0], PIPE_MAX_CLIP_PLANES
* 4);
270 nvc0_check_program_ucps(struct nvc0_context
*nvc0
,
271 struct nvc0_program
*vp
, uint8_t mask
)
273 const unsigned n
= util_logbase2(mask
) + 1;
275 if (vp
->vp
.num_ucps
>= n
)
277 nvc0_program_destroy(nvc0
, vp
);
280 if (likely(vp
== nvc0
->vertprog
))
281 nvc0_vertprog_validate(nvc0
);
283 if (likely(vp
== nvc0
->gmtyprog
))
284 nvc0_vertprog_validate(nvc0
);
286 nvc0_tevlprog_validate(nvc0
);
290 nvc0_validate_clip(struct nvc0_context
*nvc0
)
292 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
293 struct nvc0_program
*vp
;
295 uint8_t clip_enable
= nvc0
->rast
->pipe
.clip_plane_enable
;
297 if (nvc0
->gmtyprog
) {
301 if (nvc0
->tevlprog
) {
309 if (clip_enable
&& vp
->vp
.num_ucps
< PIPE_MAX_CLIP_PLANES
)
310 nvc0_check_program_ucps(nvc0
, vp
, clip_enable
);
312 if (nvc0
->dirty
& (NVC0_NEW_CLIP
| (NVC0_NEW_VERTPROG
<< stage
)))
313 if (vp
->vp
.num_ucps
> 0 && vp
->vp
.num_ucps
<= PIPE_MAX_CLIP_PLANES
)
314 nvc0_upload_uclip_planes(nvc0
, stage
);
316 clip_enable
&= vp
->vp
.clip_enable
;
318 if (nvc0
->state
.clip_enable
!= clip_enable
) {
319 nvc0
->state
.clip_enable
= clip_enable
;
320 IMMED_NVC0(push
, NVC0_3D(CLIP_DISTANCE_ENABLE
), clip_enable
);
322 if (nvc0
->state
.clip_mode
!= vp
->vp
.clip_mode
) {
323 nvc0
->state
.clip_mode
= vp
->vp
.clip_mode
;
324 BEGIN_NVC0(push
, NVC0_3D(CLIP_DISTANCE_MODE
), 1);
325 PUSH_DATA (push
, vp
->vp
.clip_mode
);
330 nvc0_validate_blend(struct nvc0_context
*nvc0
)
332 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
334 PUSH_SPACE(push
, nvc0
->blend
->size
);
335 PUSH_DATAp(push
, nvc0
->blend
->state
, nvc0
->blend
->size
);
339 nvc0_validate_zsa(struct nvc0_context
*nvc0
)
341 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
343 PUSH_SPACE(push
, nvc0
->zsa
->size
);
344 PUSH_DATAp(push
, nvc0
->zsa
->state
, nvc0
->zsa
->size
);
348 nvc0_validate_rasterizer(struct nvc0_context
*nvc0
)
350 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
352 PUSH_SPACE(push
, nvc0
->rast
->size
);
353 PUSH_DATAp(push
, nvc0
->rast
->state
, nvc0
->rast
->size
);
357 nvc0_constbufs_validate(struct nvc0_context
*nvc0
)
359 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
362 for (s
= 0; s
< 5; ++s
) {
363 while (nvc0
->constbuf_dirty
[s
]) {
364 int i
= ffs(nvc0
->constbuf_dirty
[s
]) - 1;
365 nvc0
->constbuf_dirty
[s
] &= ~(1 << i
);
367 if (nvc0
->constbuf
[s
][i
].user
) {
368 struct nouveau_bo
*bo
= nvc0
->screen
->uniform_bo
;
369 const unsigned base
= s
<< 16;
370 const unsigned size
= nvc0
->constbuf
[s
][0].size
;
371 assert(i
== 0); /* we really only want OpenGL uniforms here */
372 assert(nvc0
->constbuf
[s
][0].u
.data
);
374 if (nvc0
->state
.uniform_buffer_bound
[s
] < size
) {
375 nvc0
->state
.uniform_buffer_bound
[s
] = align(size
, 0x100);
377 BEGIN_NVC0(push
, NVC0_3D(CB_SIZE
), 3);
378 PUSH_DATA (push
, nvc0
->state
.uniform_buffer_bound
[s
]);
379 PUSH_DATAh(push
, bo
->offset
+ base
);
380 PUSH_DATA (push
, bo
->offset
+ base
);
381 BEGIN_NVC0(push
, NVC0_3D(CB_BIND(s
)), 1);
382 PUSH_DATA (push
, (0 << 4) | 1);
384 nvc0_cb_push(&nvc0
->base
, bo
, NOUVEAU_BO_VRAM
,
385 base
, nvc0
->state
.uniform_buffer_bound
[s
],
387 nvc0
->constbuf
[s
][0].u
.data
);
389 struct nv04_resource
*res
=
390 nv04_resource(nvc0
->constbuf
[s
][i
].u
.buf
);
392 BEGIN_NVC0(push
, NVC0_3D(CB_SIZE
), 3);
393 PUSH_DATA (push
, nvc0
->constbuf
[s
][i
].size
);
394 PUSH_DATAh(push
, res
->address
+ nvc0
->constbuf
[s
][i
].offset
);
395 PUSH_DATA (push
, res
->address
+ nvc0
->constbuf
[s
][i
].offset
);
396 BEGIN_NVC0(push
, NVC0_3D(CB_BIND(s
)), 1);
397 PUSH_DATA (push
, (i
<< 4) | 1);
399 BCTX_REFN(nvc0
->bufctx_3d
, CB(s
, i
), res
, RD
);
401 BEGIN_NVC0(push
, NVC0_3D(CB_BIND(s
)), 1);
402 PUSH_DATA (push
, (i
<< 4) | 0);
405 nvc0
->state
.uniform_buffer_bound
[s
] = 0;
412 nvc0_validate_sample_mask(struct nvc0_context
*nvc0
)
414 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
418 nvc0
->sample_mask
& 0xffff,
419 nvc0
->sample_mask
& 0xffff,
420 nvc0
->sample_mask
& 0xffff,
421 nvc0
->sample_mask
& 0xffff
424 BEGIN_NVC0(push
, NVC0_3D(MSAA_MASK(0)), 4);
425 PUSH_DATA (push
, mask
[0]);
426 PUSH_DATA (push
, mask
[1]);
427 PUSH_DATA (push
, mask
[2]);
428 PUSH_DATA (push
, mask
[3]);
429 BEGIN_NVC0(push
, NVC0_3D(SAMPLE_SHADING
), 1);
430 PUSH_DATA (push
, 0x01);
434 nvc0_validate_global_residents(struct nvc0_context
*nvc0
,
435 struct nouveau_bufctx
*bctx
, int bin
)
439 for (i
= 0; i
< nvc0
->global_residents
.size
/ sizeof(struct pipe_resource
*);
441 struct pipe_resource
*res
= *util_dynarray_element(
442 &nvc0
->global_residents
, struct pipe_resource
*, i
);
444 nvc0_add_resident(bctx
, bin
, nv04_resource(res
), NOUVEAU_BO_RDWR
);
449 nvc0_validate_derived_1(struct nvc0_context
*nvc0
)
451 struct nouveau_pushbuf
*push
= nvc0
->base
.pushbuf
;
452 boolean rasterizer_discard
;
454 if (nvc0
->rast
&& nvc0
->rast
->pipe
.rasterizer_discard
) {
455 rasterizer_discard
= TRUE
;
457 boolean zs
= nvc0
->zsa
&&
458 (nvc0
->zsa
->pipe
.depth
.enabled
|| nvc0
->zsa
->pipe
.stencil
[0].enabled
);
459 rasterizer_discard
= !zs
&&
460 (!nvc0
->fragprog
|| !nvc0
->fragprog
->hdr
[18]);
463 if (rasterizer_discard
!= nvc0
->state
.rasterizer_discard
) {
464 nvc0
->state
.rasterizer_discard
= rasterizer_discard
;
465 IMMED_NVC0(push
, NVC0_3D(RASTERIZE_ENABLE
), !rasterizer_discard
);
470 nvc0_switch_pipe_context(struct nvc0_context
*ctx_to
)
472 struct nvc0_context
*ctx_from
= ctx_to
->screen
->cur_ctx
;
476 ctx_to
->state
= ctx_from
->state
;
480 for (s
= 0; s
< 5; ++s
) {
481 ctx_to
->samplers_dirty
[s
] = ~0;
482 ctx_to
->textures_dirty
[s
] = ~0;
486 ctx_to
->dirty
&= ~(NVC0_NEW_VERTEX
| NVC0_NEW_ARRAYS
);
487 if (!ctx_to
->idxbuf
.buffer
)
488 ctx_to
->dirty
&= ~NVC0_NEW_IDXBUF
;
490 if (!ctx_to
->vertprog
)
491 ctx_to
->dirty
&= ~NVC0_NEW_VERTPROG
;
492 if (!ctx_to
->fragprog
)
493 ctx_to
->dirty
&= ~NVC0_NEW_FRAGPROG
;
496 ctx_to
->dirty
&= ~NVC0_NEW_BLEND
;
498 ctx_to
->dirty
&= ~(NVC0_NEW_RASTERIZER
| NVC0_NEW_SCISSOR
);
500 ctx_to
->dirty
&= ~NVC0_NEW_ZSA
;
502 ctx_to
->screen
->cur_ctx
= ctx_to
;
505 static struct state_validate
{
506 void (*func
)(struct nvc0_context
*);
508 } validate_list
[] = {
509 { nvc0_validate_fb
, NVC0_NEW_FRAMEBUFFER
},
510 { nvc0_validate_blend
, NVC0_NEW_BLEND
},
511 { nvc0_validate_zsa
, NVC0_NEW_ZSA
},
512 { nvc0_validate_sample_mask
, NVC0_NEW_SAMPLE_MASK
},
513 { nvc0_validate_rasterizer
, NVC0_NEW_RASTERIZER
},
514 { nvc0_validate_blend_colour
, NVC0_NEW_BLEND_COLOUR
},
515 { nvc0_validate_stencil_ref
, NVC0_NEW_STENCIL_REF
},
516 { nvc0_validate_stipple
, NVC0_NEW_STIPPLE
},
517 { nvc0_validate_scissor
, NVC0_NEW_SCISSOR
| NVC0_NEW_RASTERIZER
},
518 { nvc0_validate_viewport
, NVC0_NEW_VIEWPORT
},
519 { nvc0_vertprog_validate
, NVC0_NEW_VERTPROG
},
520 { nvc0_tctlprog_validate
, NVC0_NEW_TCTLPROG
},
521 { nvc0_tevlprog_validate
, NVC0_NEW_TEVLPROG
},
522 { nvc0_gmtyprog_validate
, NVC0_NEW_GMTYPROG
},
523 { nvc0_fragprog_validate
, NVC0_NEW_FRAGPROG
},
524 { nvc0_validate_derived_1
, NVC0_NEW_FRAGPROG
| NVC0_NEW_ZSA
|
525 NVC0_NEW_RASTERIZER
},
526 { nvc0_validate_clip
, NVC0_NEW_CLIP
| NVC0_NEW_RASTERIZER
|
530 { nvc0_constbufs_validate
, NVC0_NEW_CONSTBUF
},
531 { nvc0_validate_textures
, NVC0_NEW_TEXTURES
},
532 { nvc0_validate_samplers
, NVC0_NEW_SAMPLERS
},
533 { nve4_set_tex_handles
, NVC0_NEW_TEXTURES
| NVC0_NEW_SAMPLERS
},
534 { nvc0_vertex_arrays_validate
, NVC0_NEW_VERTEX
| NVC0_NEW_ARRAYS
},
535 { nvc0_validate_surfaces
, NVC0_NEW_SURFACES
},
536 { nvc0_idxbuf_validate
, NVC0_NEW_IDXBUF
},
537 { nvc0_tfb_validate
, NVC0_NEW_TFB_TARGETS
| NVC0_NEW_GMTYPROG
}
539 #define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0]))
542 nvc0_state_validate(struct nvc0_context
*nvc0
, uint32_t mask
, unsigned words
)
548 if (nvc0
->screen
->cur_ctx
!= nvc0
)
549 nvc0_switch_pipe_context(nvc0
);
551 state_mask
= nvc0
->dirty
& mask
;
554 for (i
= 0; i
< validate_list_len
; ++i
) {
555 struct state_validate
*validate
= &validate_list
[i
];
557 if (state_mask
& validate
->states
)
558 validate
->func(nvc0
);
560 nvc0
->dirty
&= ~state_mask
;
562 nvc0_bufctx_fence(nvc0
, nvc0
->bufctx_3d
, FALSE
);
565 nouveau_pushbuf_bufctx(nvc0
->base
.pushbuf
, nvc0
->bufctx_3d
);
566 ret
= nouveau_pushbuf_validate(nvc0
->base
.pushbuf
);
570 if (unlikely(nvc0
->state
.flushed
))
571 nvc0_bufctx_fence(nvc0
, nvc0
->bufctx_3d
, TRUE
);