2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
28 #include "util/u_helpers.h"
29 #include "util/u_upload_mgr.h"
31 #include "ilo_context.h"
32 #include "ilo_resource.h"
33 #include "ilo_shader.h"
34 #include "ilo_state.h"
35 #include "ilo_state_gen.h"
38 finalize_shader_states(struct ilo_state_vector
*vec
)
42 for (type
= 0; type
< PIPE_SHADER_TYPES
; type
++) {
43 struct ilo_shader_state
*shader
;
47 case PIPE_SHADER_VERTEX
:
51 case PIPE_SHADER_GEOMETRY
:
55 case PIPE_SHADER_FRAGMENT
:
68 /* compile if the shader or the states it depends on changed */
69 if (vec
->dirty
& state
) {
70 ilo_shader_select_kernel(shader
, vec
, ILO_DIRTY_ALL
);
72 else if (ilo_shader_select_kernel(shader
, vec
, vec
->dirty
)) {
73 /* mark the state dirty if a new kernel is selected */
77 /* need to setup SBE for FS */
78 if (type
== PIPE_SHADER_FRAGMENT
&& vec
->dirty
&
79 (state
| ILO_DIRTY_GS
| ILO_DIRTY_VS
| ILO_DIRTY_RASTERIZER
)) {
80 if (ilo_shader_select_kernel_routing(shader
,
81 (vec
->gs
) ? vec
->gs
: vec
->vs
, vec
->rasterizer
))
88 finalize_cbuf_state(struct ilo_context
*ilo
,
89 struct ilo_cbuf_state
*cbuf
,
90 const struct ilo_shader_state
*sh
)
92 uint32_t upload_mask
= cbuf
->enabled_mask
;
94 /* skip CBUF0 if the kernel does not need it */
96 ~ilo_shader_get_kernel_param(sh
, ILO_KERNEL_SKIP_CBUF0_UPLOAD
);
99 const enum pipe_format elem_format
= PIPE_FORMAT_R32G32B32A32_FLOAT
;
102 i
= u_bit_scan(&upload_mask
);
103 /* no need to upload */
104 if (cbuf
->cso
[i
].resource
)
107 u_upload_data(ilo
->uploader
, 0, cbuf
->cso
[i
].user_buffer_size
,
108 cbuf
->cso
[i
].user_buffer
, &offset
, &cbuf
->cso
[i
].resource
);
110 ilo_gpe_init_view_surface_for_buffer(ilo
->dev
,
111 ilo_buffer(cbuf
->cso
[i
].resource
),
112 offset
, cbuf
->cso
[i
].user_buffer_size
,
113 util_format_get_blocksize(elem_format
), elem_format
,
114 false, false, &cbuf
->cso
[i
].surface
);
116 ilo
->state_vector
.dirty
|= ILO_DIRTY_CBUF
;
121 finalize_constant_buffers(struct ilo_context
*ilo
)
123 struct ilo_state_vector
*vec
= &ilo
->state_vector
;
125 if (vec
->dirty
& (ILO_DIRTY_CBUF
| ILO_DIRTY_VS
))
126 finalize_cbuf_state(ilo
, &vec
->cbuf
[PIPE_SHADER_VERTEX
], vec
->vs
);
128 if (ilo
->state_vector
.dirty
& (ILO_DIRTY_CBUF
| ILO_DIRTY_FS
))
129 finalize_cbuf_state(ilo
, &vec
->cbuf
[PIPE_SHADER_FRAGMENT
], vec
->fs
);
133 finalize_index_buffer(struct ilo_context
*ilo
)
135 struct ilo_state_vector
*vec
= &ilo
->state_vector
;
136 const bool need_upload
= (vec
->draw
->indexed
&&
137 (vec
->ib
.user_buffer
|| vec
->ib
.offset
% vec
->ib
.index_size
));
138 struct pipe_resource
*current_hw_res
= NULL
;
140 if (!(vec
->dirty
& ILO_DIRTY_IB
) && !need_upload
)
143 pipe_resource_reference(¤t_hw_res
, vec
->ib
.hw_resource
);
146 const unsigned offset
= vec
->ib
.index_size
* vec
->draw
->start
;
147 const unsigned size
= vec
->ib
.index_size
* vec
->draw
->count
;
150 if (vec
->ib
.user_buffer
) {
151 u_upload_data(ilo
->uploader
, 0, size
,
152 vec
->ib
.user_buffer
+ offset
, &hw_offset
, &vec
->ib
.hw_resource
);
155 u_upload_buffer(ilo
->uploader
, 0, vec
->ib
.offset
+ offset
, size
,
156 vec
->ib
.buffer
, &hw_offset
, &vec
->ib
.hw_resource
);
159 /* the HW offset should be aligned */
160 assert(hw_offset
% vec
->ib
.index_size
== 0);
161 vec
->ib
.draw_start_offset
= hw_offset
/ vec
->ib
.index_size
;
164 * INDEX[vec->draw->start] in the original buffer is INDEX[0] in the HW
167 vec
->ib
.draw_start_offset
-= vec
->draw
->start
;
170 pipe_resource_reference(&vec
->ib
.hw_resource
, vec
->ib
.buffer
);
172 /* note that index size may be zero when the draw is not indexed */
173 if (vec
->draw
->indexed
)
174 vec
->ib
.draw_start_offset
= vec
->ib
.offset
/ vec
->ib
.index_size
;
176 vec
->ib
.draw_start_offset
= 0;
179 /* treat the IB as clean if the HW states do not change */
180 if (vec
->ib
.hw_resource
== current_hw_res
&&
181 vec
->ib
.hw_index_size
== vec
->ib
.index_size
)
182 vec
->dirty
&= ~ILO_DIRTY_IB
;
184 vec
->ib
.hw_index_size
= vec
->ib
.index_size
;
186 pipe_resource_reference(¤t_hw_res
, NULL
);
190 finalize_vertex_elements(struct ilo_context
*ilo
)
192 struct ilo_state_vector
*vec
= &ilo
->state_vector
;
194 if (!(vec
->dirty
& (ILO_DIRTY_VE
| ILO_DIRTY_VS
)))
197 vec
->dirty
|= ILO_DIRTY_VE
;
199 vec
->ve
->last_cso_edgeflag
= false;
200 if (vec
->ve
->count
&& vec
->vs
&&
201 ilo_shader_get_kernel_param(vec
->vs
, ILO_KERNEL_VS_INPUT_EDGEFLAG
)) {
202 vec
->ve
->edgeflag_cso
= vec
->ve
->cso
[vec
->ve
->count
- 1];
203 ilo_gpe_set_ve_edgeflag(ilo
->dev
, &vec
->ve
->edgeflag_cso
);
204 vec
->ve
->last_cso_edgeflag
= true;
207 vec
->ve
->prepend_nosrc_cso
= false;
209 (ilo_shader_get_kernel_param(vec
->vs
,
210 ILO_KERNEL_VS_INPUT_INSTANCEID
) ||
211 ilo_shader_get_kernel_param(vec
->vs
,
212 ILO_KERNEL_VS_INPUT_VERTEXID
))) {
213 ilo_gpe_init_ve_nosrc(ilo
->dev
,
214 GEN6_VFCOMP_STORE_VID
,
215 GEN6_VFCOMP_STORE_IID
,
218 &vec
->ve
->nosrc_cso
);
219 vec
->ve
->prepend_nosrc_cso
= true;
220 } else if (!vec
->vs
) {
221 /* generate VUE header */
222 ilo_gpe_init_ve_nosrc(ilo
->dev
,
223 GEN6_VFCOMP_STORE_0
, /* Reserved */
224 GEN6_VFCOMP_STORE_0
, /* Render Target Array Index */
225 GEN6_VFCOMP_STORE_0
, /* Viewport Index */
226 GEN6_VFCOMP_STORE_0
, /* Point Width */
227 &vec
->ve
->nosrc_cso
);
228 vec
->ve
->prepend_nosrc_cso
= true;
229 } else if (!vec
->ve
->count
) {
231 * From the Sandy Bridge PRM, volume 2 part 1, page 92:
233 * "SW must ensure that at least one vertex element is defined prior
234 * to issuing a 3DPRIMTIVE command, or operation is UNDEFINED."
236 ilo_gpe_init_ve_nosrc(ilo
->dev
,
240 GEN6_VFCOMP_STORE_1_FP
,
241 &vec
->ve
->nosrc_cso
);
242 vec
->ve
->prepend_nosrc_cso
= true;
247 * Finalize states. Some states depend on other states and are
248 * incomplete/invalid until finalized.
251 ilo_finalize_3d_states(struct ilo_context
*ilo
,
252 const struct pipe_draw_info
*draw
)
254 ilo
->state_vector
.draw
= draw
;
256 finalize_shader_states(&ilo
->state_vector
);
257 finalize_constant_buffers(ilo
);
258 finalize_index_buffer(ilo
);
259 finalize_vertex_elements(ilo
);
261 u_upload_unmap(ilo
->uploader
);
265 ilo_create_blend_state(struct pipe_context
*pipe
,
266 const struct pipe_blend_state
*state
)
268 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
269 struct ilo_blend_state
*blend
;
271 blend
= MALLOC_STRUCT(ilo_blend_state
);
274 ilo_gpe_init_blend(dev
, state
, blend
);
280 ilo_bind_blend_state(struct pipe_context
*pipe
, void *state
)
282 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
286 vec
->dirty
|= ILO_DIRTY_BLEND
;
290 ilo_delete_blend_state(struct pipe_context
*pipe
, void *state
)
296 ilo_create_sampler_state(struct pipe_context
*pipe
,
297 const struct pipe_sampler_state
*state
)
299 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
300 struct ilo_sampler_cso
*sampler
;
302 sampler
= MALLOC_STRUCT(ilo_sampler_cso
);
305 ilo_gpe_init_sampler_cso(dev
, state
, sampler
);
311 ilo_bind_sampler_states(struct pipe_context
*pipe
, unsigned shader
,
312 unsigned start
, unsigned count
, void **samplers
)
314 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
315 struct ilo_sampler_state
*dst
= &vec
->sampler
[shader
];
316 bool changed
= false;
319 assert(start
+ count
<= Elements(dst
->cso
));
322 for (i
= 0; i
< count
; i
++) {
323 if (dst
->cso
[start
+ i
] != samplers
[i
]) {
324 dst
->cso
[start
+ i
] = samplers
[i
];
327 * This function is sometimes called to reduce the number of bound
328 * samplers. Do not consider that as a state change (and create a
329 * new array of SAMPLER_STATE).
337 for (i
= 0; i
< count
; i
++)
338 dst
->cso
[start
+ i
] = NULL
;
343 case PIPE_SHADER_VERTEX
:
344 vec
->dirty
|= ILO_DIRTY_SAMPLER_VS
;
346 case PIPE_SHADER_GEOMETRY
:
347 vec
->dirty
|= ILO_DIRTY_SAMPLER_GS
;
349 case PIPE_SHADER_FRAGMENT
:
350 vec
->dirty
|= ILO_DIRTY_SAMPLER_FS
;
352 case PIPE_SHADER_COMPUTE
:
353 vec
->dirty
|= ILO_DIRTY_SAMPLER_CS
;
360 ilo_delete_sampler_state(struct pipe_context
*pipe
, void *state
)
366 ilo_create_rasterizer_state(struct pipe_context
*pipe
,
367 const struct pipe_rasterizer_state
*state
)
369 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
370 struct ilo_rasterizer_state
*rast
;
372 rast
= MALLOC_STRUCT(ilo_rasterizer_state
);
375 rast
->state
= *state
;
376 ilo_gpe_init_rasterizer(dev
, state
, rast
);
382 ilo_bind_rasterizer_state(struct pipe_context
*pipe
, void *state
)
384 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
386 vec
->rasterizer
= state
;
388 vec
->dirty
|= ILO_DIRTY_RASTERIZER
;
392 ilo_delete_rasterizer_state(struct pipe_context
*pipe
, void *state
)
398 ilo_create_depth_stencil_alpha_state(struct pipe_context
*pipe
,
399 const struct pipe_depth_stencil_alpha_state
*state
)
401 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
402 struct ilo_dsa_state
*dsa
;
404 dsa
= MALLOC_STRUCT(ilo_dsa_state
);
407 ilo_gpe_init_dsa(dev
, state
, dsa
);
413 ilo_bind_depth_stencil_alpha_state(struct pipe_context
*pipe
, void *state
)
415 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
419 vec
->dirty
|= ILO_DIRTY_DSA
;
423 ilo_delete_depth_stencil_alpha_state(struct pipe_context
*pipe
, void *state
)
429 ilo_create_fs_state(struct pipe_context
*pipe
,
430 const struct pipe_shader_state
*state
)
432 struct ilo_context
*ilo
= ilo_context(pipe
);
433 struct ilo_shader_state
*shader
;
435 shader
= ilo_shader_create_fs(ilo
->dev
, state
, &ilo
->state_vector
);
438 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
444 ilo_bind_fs_state(struct pipe_context
*pipe
, void *state
)
446 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
450 vec
->dirty
|= ILO_DIRTY_FS
;
454 ilo_delete_fs_state(struct pipe_context
*pipe
, void *state
)
456 struct ilo_context
*ilo
= ilo_context(pipe
);
457 struct ilo_shader_state
*fs
= (struct ilo_shader_state
*) state
;
459 ilo_shader_cache_remove(ilo
->shader_cache
, fs
);
460 ilo_shader_destroy(fs
);
464 ilo_create_vs_state(struct pipe_context
*pipe
,
465 const struct pipe_shader_state
*state
)
467 struct ilo_context
*ilo
= ilo_context(pipe
);
468 struct ilo_shader_state
*shader
;
470 shader
= ilo_shader_create_vs(ilo
->dev
, state
, &ilo
->state_vector
);
473 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
479 ilo_bind_vs_state(struct pipe_context
*pipe
, void *state
)
481 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
485 vec
->dirty
|= ILO_DIRTY_VS
;
489 ilo_delete_vs_state(struct pipe_context
*pipe
, void *state
)
491 struct ilo_context
*ilo
= ilo_context(pipe
);
492 struct ilo_shader_state
*vs
= (struct ilo_shader_state
*) state
;
494 ilo_shader_cache_remove(ilo
->shader_cache
, vs
);
495 ilo_shader_destroy(vs
);
499 ilo_create_gs_state(struct pipe_context
*pipe
,
500 const struct pipe_shader_state
*state
)
502 struct ilo_context
*ilo
= ilo_context(pipe
);
503 struct ilo_shader_state
*shader
;
505 shader
= ilo_shader_create_gs(ilo
->dev
, state
, &ilo
->state_vector
);
508 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
514 ilo_bind_gs_state(struct pipe_context
*pipe
, void *state
)
516 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
518 /* util_blitter may set this unnecessarily */
519 if (vec
->gs
== state
)
524 vec
->dirty
|= ILO_DIRTY_GS
;
528 ilo_delete_gs_state(struct pipe_context
*pipe
, void *state
)
530 struct ilo_context
*ilo
= ilo_context(pipe
);
531 struct ilo_shader_state
*gs
= (struct ilo_shader_state
*) state
;
533 ilo_shader_cache_remove(ilo
->shader_cache
, gs
);
534 ilo_shader_destroy(gs
);
538 ilo_create_vertex_elements_state(struct pipe_context
*pipe
,
539 unsigned num_elements
,
540 const struct pipe_vertex_element
*elements
)
542 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
543 struct ilo_ve_state
*ve
;
545 ve
= MALLOC_STRUCT(ilo_ve_state
);
548 ilo_gpe_init_ve(dev
, num_elements
, elements
, ve
);
554 ilo_bind_vertex_elements_state(struct pipe_context
*pipe
, void *state
)
556 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
560 vec
->dirty
|= ILO_DIRTY_VE
;
564 ilo_delete_vertex_elements_state(struct pipe_context
*pipe
, void *state
)
566 struct ilo_ve_state
*ve
= state
;
572 ilo_set_blend_color(struct pipe_context
*pipe
,
573 const struct pipe_blend_color
*state
)
575 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
577 vec
->blend_color
= *state
;
579 vec
->dirty
|= ILO_DIRTY_BLEND_COLOR
;
583 ilo_set_stencil_ref(struct pipe_context
*pipe
,
584 const struct pipe_stencil_ref
*state
)
586 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
588 /* util_blitter may set this unnecessarily */
589 if (!memcmp(&vec
->stencil_ref
, state
, sizeof(*state
)))
592 vec
->stencil_ref
= *state
;
594 vec
->dirty
|= ILO_DIRTY_STENCIL_REF
;
598 ilo_set_sample_mask(struct pipe_context
*pipe
,
599 unsigned sample_mask
)
601 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
603 /* util_blitter may set this unnecessarily */
604 if (vec
->sample_mask
== sample_mask
)
607 vec
->sample_mask
= sample_mask
;
609 vec
->dirty
|= ILO_DIRTY_SAMPLE_MASK
;
613 ilo_set_clip_state(struct pipe_context
*pipe
,
614 const struct pipe_clip_state
*state
)
616 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
620 vec
->dirty
|= ILO_DIRTY_CLIP
;
624 ilo_set_constant_buffer(struct pipe_context
*pipe
,
625 uint shader
, uint index
,
626 struct pipe_constant_buffer
*buf
)
628 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
629 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
630 struct ilo_cbuf_state
*cbuf
= &vec
->cbuf
[shader
];
631 const unsigned count
= 1;
634 assert(shader
< Elements(vec
->cbuf
));
635 assert(index
+ count
<= Elements(vec
->cbuf
[shader
].cso
));
638 for (i
= 0; i
< count
; i
++) {
639 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
641 pipe_resource_reference(&cso
->resource
, buf
[i
].buffer
);
644 const enum pipe_format elem_format
=
645 PIPE_FORMAT_R32G32B32A32_FLOAT
;
647 ilo_gpe_init_view_surface_for_buffer(dev
,
648 ilo_buffer(buf
[i
].buffer
),
649 buf
[i
].buffer_offset
, buf
[i
].buffer_size
,
650 util_format_get_blocksize(elem_format
), elem_format
,
651 false, false, &cso
->surface
);
653 cso
->user_buffer
= NULL
;
654 cso
->user_buffer_size
= 0;
656 cbuf
->enabled_mask
|= 1 << (index
+ i
);
658 else if (buf
[i
].user_buffer
) {
659 cso
->surface
.bo
= NULL
;
661 /* buffer_offset does not apply for user buffer */
662 cso
->user_buffer
= buf
[i
].user_buffer
;
663 cso
->user_buffer_size
= buf
[i
].buffer_size
;
665 cbuf
->enabled_mask
|= 1 << (index
+ i
);
668 cso
->surface
.bo
= NULL
;
669 cso
->user_buffer
= NULL
;
670 cso
->user_buffer_size
= 0;
672 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
677 for (i
= 0; i
< count
; i
++) {
678 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
680 pipe_resource_reference(&cso
->resource
, NULL
);
681 cso
->surface
.bo
= NULL
;
682 cso
->user_buffer
= NULL
;
683 cso
->user_buffer_size
= 0;
685 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
689 vec
->dirty
|= ILO_DIRTY_CBUF
;
693 ilo_set_framebuffer_state(struct pipe_context
*pipe
,
694 const struct pipe_framebuffer_state
*state
)
696 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
697 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
699 ilo_gpe_set_fb(dev
, state
, &vec
->fb
);
701 vec
->dirty
|= ILO_DIRTY_FB
;
705 ilo_set_polygon_stipple(struct pipe_context
*pipe
,
706 const struct pipe_poly_stipple
*state
)
708 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
710 vec
->poly_stipple
= *state
;
712 vec
->dirty
|= ILO_DIRTY_POLY_STIPPLE
;
716 ilo_set_scissor_states(struct pipe_context
*pipe
,
718 unsigned num_scissors
,
719 const struct pipe_scissor_state
*scissors
)
721 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
722 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
724 ilo_gpe_set_scissor(dev
, start_slot
, num_scissors
,
725 scissors
, &vec
->scissor
);
727 vec
->dirty
|= ILO_DIRTY_SCISSOR
;
731 ilo_set_viewport_states(struct pipe_context
*pipe
,
733 unsigned num_viewports
,
734 const struct pipe_viewport_state
*viewports
)
736 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
737 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
742 for (i
= 0; i
< num_viewports
; i
++) {
743 ilo_gpe_set_viewport_cso(dev
, &viewports
[i
],
744 &vec
->viewport
.cso
[start_slot
+ i
]);
747 if (vec
->viewport
.count
< start_slot
+ num_viewports
)
748 vec
->viewport
.count
= start_slot
+ num_viewports
;
750 /* need to save viewport 0 for util_blitter */
751 if (!start_slot
&& num_viewports
)
752 vec
->viewport
.viewport0
= viewports
[0];
755 if (vec
->viewport
.count
<= start_slot
+ num_viewports
&&
756 vec
->viewport
.count
> start_slot
)
757 vec
->viewport
.count
= start_slot
;
760 vec
->dirty
|= ILO_DIRTY_VIEWPORT
;
764 ilo_set_sampler_views(struct pipe_context
*pipe
, unsigned shader
,
765 unsigned start
, unsigned count
,
766 struct pipe_sampler_view
**views
)
768 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
769 struct ilo_view_state
*dst
= &vec
->view
[shader
];
772 assert(start
+ count
<= Elements(dst
->states
));
775 for (i
= 0; i
< count
; i
++)
776 pipe_sampler_view_reference(&dst
->states
[start
+ i
], views
[i
]);
779 for (i
= 0; i
< count
; i
++)
780 pipe_sampler_view_reference(&dst
->states
[start
+ i
], NULL
);
783 if (dst
->count
<= start
+ count
) {
789 while (count
> 0 && !dst
->states
[count
- 1])
796 case PIPE_SHADER_VERTEX
:
797 vec
->dirty
|= ILO_DIRTY_VIEW_VS
;
799 case PIPE_SHADER_GEOMETRY
:
800 vec
->dirty
|= ILO_DIRTY_VIEW_GS
;
802 case PIPE_SHADER_FRAGMENT
:
803 vec
->dirty
|= ILO_DIRTY_VIEW_FS
;
805 case PIPE_SHADER_COMPUTE
:
806 vec
->dirty
|= ILO_DIRTY_VIEW_CS
;
812 ilo_set_shader_resources(struct pipe_context
*pipe
,
813 unsigned start
, unsigned count
,
814 struct pipe_surface
**surfaces
)
816 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
817 struct ilo_resource_state
*dst
= &vec
->resource
;
820 assert(start
+ count
<= Elements(dst
->states
));
823 for (i
= 0; i
< count
; i
++)
824 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
827 for (i
= 0; i
< count
; i
++)
828 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
831 if (dst
->count
<= start
+ count
) {
837 while (count
> 0 && !dst
->states
[count
- 1])
843 vec
->dirty
|= ILO_DIRTY_RESOURCE
;
847 ilo_set_vertex_buffers(struct pipe_context
*pipe
,
848 unsigned start_slot
, unsigned num_buffers
,
849 const struct pipe_vertex_buffer
*buffers
)
851 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
854 /* no PIPE_CAP_USER_VERTEX_BUFFERS */
856 for (i
= 0; i
< num_buffers
; i
++)
857 assert(!buffers
[i
].user_buffer
);
860 util_set_vertex_buffers_mask(vec
->vb
.states
,
861 &vec
->vb
.enabled_mask
, buffers
, start_slot
, num_buffers
);
863 vec
->dirty
|= ILO_DIRTY_VB
;
867 ilo_set_index_buffer(struct pipe_context
*pipe
,
868 const struct pipe_index_buffer
*state
)
870 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
873 pipe_resource_reference(&vec
->ib
.buffer
, state
->buffer
);
874 vec
->ib
.user_buffer
= state
->user_buffer
;
875 vec
->ib
.offset
= state
->offset
;
876 vec
->ib
.index_size
= state
->index_size
;
879 pipe_resource_reference(&vec
->ib
.buffer
, NULL
);
880 vec
->ib
.user_buffer
= NULL
;
882 vec
->ib
.index_size
= 0;
885 vec
->dirty
|= ILO_DIRTY_IB
;
888 static struct pipe_stream_output_target
*
889 ilo_create_stream_output_target(struct pipe_context
*pipe
,
890 struct pipe_resource
*res
,
891 unsigned buffer_offset
,
892 unsigned buffer_size
)
894 struct pipe_stream_output_target
*target
;
896 target
= MALLOC_STRUCT(pipe_stream_output_target
);
899 pipe_reference_init(&target
->reference
, 1);
900 target
->buffer
= NULL
;
901 pipe_resource_reference(&target
->buffer
, res
);
902 target
->context
= pipe
;
903 target
->buffer_offset
= buffer_offset
;
904 target
->buffer_size
= buffer_size
;
910 ilo_set_stream_output_targets(struct pipe_context
*pipe
,
911 unsigned num_targets
,
912 struct pipe_stream_output_target
**targets
,
913 const unsigned *offset
)
915 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
917 unsigned append_bitmask
= 0;
922 /* util_blitter may set this unnecessarily */
923 if (!vec
->so
.count
&& !num_targets
)
926 for (i
= 0; i
< num_targets
; i
++) {
927 pipe_so_target_reference(&vec
->so
.states
[i
], targets
[i
]);
928 if (offset
[i
] == (unsigned)-1)
929 append_bitmask
|= 1 << i
;
932 for (; i
< vec
->so
.count
; i
++)
933 pipe_so_target_reference(&vec
->so
.states
[i
], NULL
);
935 vec
->so
.count
= num_targets
;
936 vec
->so
.append_bitmask
= append_bitmask
;
938 vec
->so
.enabled
= (vec
->so
.count
> 0);
940 vec
->dirty
|= ILO_DIRTY_SO
;
944 ilo_stream_output_target_destroy(struct pipe_context
*pipe
,
945 struct pipe_stream_output_target
*target
)
947 pipe_resource_reference(&target
->buffer
, NULL
);
951 static struct pipe_sampler_view
*
952 ilo_create_sampler_view(struct pipe_context
*pipe
,
953 struct pipe_resource
*res
,
954 const struct pipe_sampler_view
*templ
)
956 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
957 struct ilo_view_cso
*view
;
959 view
= MALLOC_STRUCT(ilo_view_cso
);
963 pipe_reference_init(&view
->base
.reference
, 1);
964 view
->base
.texture
= NULL
;
965 pipe_resource_reference(&view
->base
.texture
, res
);
966 view
->base
.context
= pipe
;
968 if (res
->target
== PIPE_BUFFER
) {
969 const unsigned elem_size
= util_format_get_blocksize(templ
->format
);
970 const unsigned first_elem
= templ
->u
.buf
.first_element
;
971 const unsigned num_elems
= templ
->u
.buf
.last_element
- first_elem
+ 1;
973 ilo_gpe_init_view_surface_for_buffer(dev
, ilo_buffer(res
),
974 first_elem
* elem_size
, num_elems
* elem_size
,
975 elem_size
, templ
->format
, false, false, &view
->surface
);
978 struct ilo_texture
*tex
= ilo_texture(res
);
980 /* warn about degraded performance because of a missing binding flag */
981 if (tex
->layout
.tiling
== INTEL_TILING_NONE
&&
982 !(tex
->base
.bind
& PIPE_BIND_SAMPLER_VIEW
)) {
983 ilo_warn("creating sampler view for a resource "
984 "not created for sampling\n");
987 ilo_gpe_init_view_surface_for_texture(dev
, tex
,
989 templ
->u
.tex
.first_level
,
990 templ
->u
.tex
.last_level
- templ
->u
.tex
.first_level
+ 1,
991 templ
->u
.tex
.first_layer
,
992 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
993 false, &view
->surface
);
1000 ilo_sampler_view_destroy(struct pipe_context
*pipe
,
1001 struct pipe_sampler_view
*view
)
1003 pipe_resource_reference(&view
->texture
, NULL
);
1007 static struct pipe_surface
*
1008 ilo_create_surface(struct pipe_context
*pipe
,
1009 struct pipe_resource
*res
,
1010 const struct pipe_surface
*templ
)
1012 const struct ilo_dev_info
*dev
= ilo_context(pipe
)->dev
;
1013 struct ilo_surface_cso
*surf
;
1015 surf
= MALLOC_STRUCT(ilo_surface_cso
);
1018 surf
->base
= *templ
;
1019 pipe_reference_init(&surf
->base
.reference
, 1);
1020 surf
->base
.texture
= NULL
;
1021 pipe_resource_reference(&surf
->base
.texture
, res
);
1023 surf
->base
.context
= pipe
;
1024 surf
->base
.width
= u_minify(res
->width0
, templ
->u
.tex
.level
);
1025 surf
->base
.height
= u_minify(res
->height0
, templ
->u
.tex
.level
);
1027 surf
->is_rt
= !util_format_is_depth_or_stencil(templ
->format
);
1031 assert(res
->target
!= PIPE_BUFFER
);
1034 * classic i965 sets render_cache_rw for constant buffers and sol
1035 * surfaces but not render buffers. Why?
1037 ilo_gpe_init_view_surface_for_texture(dev
, ilo_texture(res
),
1038 templ
->format
, templ
->u
.tex
.level
, 1,
1039 templ
->u
.tex
.first_layer
,
1040 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1044 assert(res
->target
!= PIPE_BUFFER
);
1046 ilo_gpe_init_zs_surface(dev
, ilo_texture(res
),
1047 templ
->format
, templ
->u
.tex
.level
,
1048 templ
->u
.tex
.first_layer
,
1049 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1057 ilo_surface_destroy(struct pipe_context
*pipe
,
1058 struct pipe_surface
*surface
)
1060 pipe_resource_reference(&surface
->texture
, NULL
);
1065 ilo_create_compute_state(struct pipe_context
*pipe
,
1066 const struct pipe_compute_state
*state
)
1068 struct ilo_context
*ilo
= ilo_context(pipe
);
1069 struct ilo_shader_state
*shader
;
1071 shader
= ilo_shader_create_cs(ilo
->dev
, state
, &ilo
->state_vector
);
1074 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
1080 ilo_bind_compute_state(struct pipe_context
*pipe
, void *state
)
1082 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
1086 vec
->dirty
|= ILO_DIRTY_CS
;
1090 ilo_delete_compute_state(struct pipe_context
*pipe
, void *state
)
1092 struct ilo_context
*ilo
= ilo_context(pipe
);
1093 struct ilo_shader_state
*cs
= (struct ilo_shader_state
*) state
;
1095 ilo_shader_cache_remove(ilo
->shader_cache
, cs
);
1096 ilo_shader_destroy(cs
);
1100 ilo_set_compute_resources(struct pipe_context
*pipe
,
1101 unsigned start
, unsigned count
,
1102 struct pipe_surface
**surfaces
)
1104 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
1105 struct ilo_resource_state
*dst
= &vec
->cs_resource
;
1108 assert(start
+ count
<= Elements(dst
->states
));
1111 for (i
= 0; i
< count
; i
++)
1112 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
1115 for (i
= 0; i
< count
; i
++)
1116 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
1119 if (dst
->count
<= start
+ count
) {
1125 while (count
> 0 && !dst
->states
[count
- 1])
1131 vec
->dirty
|= ILO_DIRTY_CS_RESOURCE
;
1135 ilo_set_global_binding(struct pipe_context
*pipe
,
1136 unsigned start
, unsigned count
,
1137 struct pipe_resource
**resources
,
1140 struct ilo_state_vector
*vec
= &ilo_context(pipe
)->state_vector
;
1141 struct ilo_global_binding
*dst
= &vec
->global_binding
;
1144 assert(start
+ count
<= Elements(dst
->resources
));
1147 for (i
= 0; i
< count
; i
++)
1148 pipe_resource_reference(&dst
->resources
[start
+ i
], resources
[i
]);
1151 for (i
= 0; i
< count
; i
++)
1152 pipe_resource_reference(&dst
->resources
[start
+ i
], NULL
);
1155 if (dst
->count
<= start
+ count
) {
1161 while (count
> 0 && !dst
->resources
[count
- 1])
1167 vec
->dirty
|= ILO_DIRTY_GLOBAL_BINDING
;
1171 * Initialize state-related functions.
1174 ilo_init_state_functions(struct ilo_context
*ilo
)
1176 STATIC_ASSERT(ILO_STATE_COUNT
<= 32);
1178 ilo
->base
.create_blend_state
= ilo_create_blend_state
;
1179 ilo
->base
.bind_blend_state
= ilo_bind_blend_state
;
1180 ilo
->base
.delete_blend_state
= ilo_delete_blend_state
;
1181 ilo
->base
.create_sampler_state
= ilo_create_sampler_state
;
1182 ilo
->base
.bind_sampler_states
= ilo_bind_sampler_states
;
1183 ilo
->base
.delete_sampler_state
= ilo_delete_sampler_state
;
1184 ilo
->base
.create_rasterizer_state
= ilo_create_rasterizer_state
;
1185 ilo
->base
.bind_rasterizer_state
= ilo_bind_rasterizer_state
;
1186 ilo
->base
.delete_rasterizer_state
= ilo_delete_rasterizer_state
;
1187 ilo
->base
.create_depth_stencil_alpha_state
= ilo_create_depth_stencil_alpha_state
;
1188 ilo
->base
.bind_depth_stencil_alpha_state
= ilo_bind_depth_stencil_alpha_state
;
1189 ilo
->base
.delete_depth_stencil_alpha_state
= ilo_delete_depth_stencil_alpha_state
;
1190 ilo
->base
.create_fs_state
= ilo_create_fs_state
;
1191 ilo
->base
.bind_fs_state
= ilo_bind_fs_state
;
1192 ilo
->base
.delete_fs_state
= ilo_delete_fs_state
;
1193 ilo
->base
.create_vs_state
= ilo_create_vs_state
;
1194 ilo
->base
.bind_vs_state
= ilo_bind_vs_state
;
1195 ilo
->base
.delete_vs_state
= ilo_delete_vs_state
;
1196 ilo
->base
.create_gs_state
= ilo_create_gs_state
;
1197 ilo
->base
.bind_gs_state
= ilo_bind_gs_state
;
1198 ilo
->base
.delete_gs_state
= ilo_delete_gs_state
;
1199 ilo
->base
.create_vertex_elements_state
= ilo_create_vertex_elements_state
;
1200 ilo
->base
.bind_vertex_elements_state
= ilo_bind_vertex_elements_state
;
1201 ilo
->base
.delete_vertex_elements_state
= ilo_delete_vertex_elements_state
;
1203 ilo
->base
.set_blend_color
= ilo_set_blend_color
;
1204 ilo
->base
.set_stencil_ref
= ilo_set_stencil_ref
;
1205 ilo
->base
.set_sample_mask
= ilo_set_sample_mask
;
1206 ilo
->base
.set_clip_state
= ilo_set_clip_state
;
1207 ilo
->base
.set_constant_buffer
= ilo_set_constant_buffer
;
1208 ilo
->base
.set_framebuffer_state
= ilo_set_framebuffer_state
;
1209 ilo
->base
.set_polygon_stipple
= ilo_set_polygon_stipple
;
1210 ilo
->base
.set_scissor_states
= ilo_set_scissor_states
;
1211 ilo
->base
.set_viewport_states
= ilo_set_viewport_states
;
1212 ilo
->base
.set_sampler_views
= ilo_set_sampler_views
;
1213 ilo
->base
.set_shader_resources
= ilo_set_shader_resources
;
1214 ilo
->base
.set_vertex_buffers
= ilo_set_vertex_buffers
;
1215 ilo
->base
.set_index_buffer
= ilo_set_index_buffer
;
1217 ilo
->base
.create_stream_output_target
= ilo_create_stream_output_target
;
1218 ilo
->base
.stream_output_target_destroy
= ilo_stream_output_target_destroy
;
1219 ilo
->base
.set_stream_output_targets
= ilo_set_stream_output_targets
;
1221 ilo
->base
.create_sampler_view
= ilo_create_sampler_view
;
1222 ilo
->base
.sampler_view_destroy
= ilo_sampler_view_destroy
;
1224 ilo
->base
.create_surface
= ilo_create_surface
;
1225 ilo
->base
.surface_destroy
= ilo_surface_destroy
;
1227 ilo
->base
.create_compute_state
= ilo_create_compute_state
;
1228 ilo
->base
.bind_compute_state
= ilo_bind_compute_state
;
1229 ilo
->base
.delete_compute_state
= ilo_delete_compute_state
;
1230 ilo
->base
.set_compute_resources
= ilo_set_compute_resources
;
1231 ilo
->base
.set_global_binding
= ilo_set_global_binding
;
1235 ilo_state_vector_init(const struct ilo_dev_info
*dev
,
1236 struct ilo_state_vector
*vec
)
1238 ilo_gpe_set_scissor_null(dev
, &vec
->scissor
);
1240 ilo_gpe_init_zs_surface(dev
, NULL
, PIPE_FORMAT_NONE
,
1241 0, 0, 1, &vec
->fb
.null_zs
);
1243 vec
->dirty
= ILO_DIRTY_ALL
;
1247 ilo_state_vector_cleanup(struct ilo_state_vector
*vec
)
1251 for (i
= 0; i
< Elements(vec
->vb
.states
); i
++) {
1252 if (vec
->vb
.enabled_mask
& (1 << i
))
1253 pipe_resource_reference(&vec
->vb
.states
[i
].buffer
, NULL
);
1256 pipe_resource_reference(&vec
->ib
.buffer
, NULL
);
1257 pipe_resource_reference(&vec
->ib
.hw_resource
, NULL
);
1259 for (i
= 0; i
< vec
->so
.count
; i
++)
1260 pipe_so_target_reference(&vec
->so
.states
[i
], NULL
);
1262 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1263 for (i
= 0; i
< vec
->view
[sh
].count
; i
++) {
1264 struct pipe_sampler_view
*view
= vec
->view
[sh
].states
[i
];
1265 pipe_sampler_view_reference(&view
, NULL
);
1268 for (i
= 0; i
< Elements(vec
->cbuf
[sh
].cso
); i
++) {
1269 struct ilo_cbuf_cso
*cbuf
= &vec
->cbuf
[sh
].cso
[i
];
1270 pipe_resource_reference(&cbuf
->resource
, NULL
);
1274 for (i
= 0; i
< vec
->resource
.count
; i
++)
1275 pipe_surface_reference(&vec
->resource
.states
[i
], NULL
);
1277 for (i
= 0; i
< vec
->fb
.state
.nr_cbufs
; i
++)
1278 pipe_surface_reference(&vec
->fb
.state
.cbufs
[i
], NULL
);
1280 if (vec
->fb
.state
.zsbuf
)
1281 pipe_surface_reference(&vec
->fb
.state
.zsbuf
, NULL
);
1283 for (i
= 0; i
< vec
->cs_resource
.count
; i
++)
1284 pipe_surface_reference(&vec
->cs_resource
.states
[i
], NULL
);
1286 for (i
= 0; i
< vec
->global_binding
.count
; i
++)
1287 pipe_resource_reference(&vec
->global_binding
.resources
[i
], NULL
);
1291 * Mark all states that have the resource dirty.
1294 ilo_state_vector_resource_renamed(struct ilo_state_vector
*vec
,
1295 struct pipe_resource
*res
)
1297 struct intel_bo
*bo
= ilo_resource_get_bo(res
);
1298 uint32_t states
= 0;
1301 if (res
->target
== PIPE_BUFFER
) {
1302 uint32_t vb_mask
= vec
->vb
.enabled_mask
;
1305 const unsigned idx
= u_bit_scan(&vb_mask
);
1307 if (vec
->vb
.states
[idx
].buffer
== res
) {
1308 states
|= ILO_DIRTY_VB
;
1313 if (vec
->ib
.buffer
== res
) {
1314 states
|= ILO_DIRTY_IB
;
1317 * finalize_index_buffer() has an optimization that clears
1318 * ILO_DIRTY_IB when the HW states do not change. However, it fails
1319 * to flush the VF cache when the HW states do not change, but the
1320 * contents of the IB has changed. Here, we set the index size to an
1321 * invalid value to avoid the optimization.
1323 vec
->ib
.hw_index_size
= 0;
1326 for (i
= 0; i
< vec
->so
.count
; i
++) {
1327 if (vec
->so
.states
[i
]->buffer
== res
) {
1328 states
|= ILO_DIRTY_SO
;
1334 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1335 for (i
= 0; i
< vec
->view
[sh
].count
; i
++) {
1336 struct ilo_view_cso
*cso
= (struct ilo_view_cso
*) vec
->view
[sh
].states
[i
];
1338 if (cso
->base
.texture
== res
) {
1339 static const unsigned view_dirty_bits
[PIPE_SHADER_TYPES
] = {
1340 [PIPE_SHADER_VERTEX
] = ILO_DIRTY_VIEW_VS
,
1341 [PIPE_SHADER_FRAGMENT
] = ILO_DIRTY_VIEW_FS
,
1342 [PIPE_SHADER_GEOMETRY
] = ILO_DIRTY_VIEW_GS
,
1343 [PIPE_SHADER_COMPUTE
] = ILO_DIRTY_VIEW_CS
,
1345 cso
->surface
.bo
= bo
;
1347 states
|= view_dirty_bits
[sh
];
1352 if (res
->target
== PIPE_BUFFER
) {
1353 for (i
= 0; i
< Elements(vec
->cbuf
[sh
].cso
); i
++) {
1354 struct ilo_cbuf_cso
*cbuf
= &vec
->cbuf
[sh
].cso
[i
];
1356 if (cbuf
->resource
== res
) {
1357 cbuf
->surface
.bo
= bo
;
1358 states
|= ILO_DIRTY_CBUF
;
1365 for (i
= 0; i
< vec
->resource
.count
; i
++) {
1366 struct ilo_surface_cso
*cso
=
1367 (struct ilo_surface_cso
*) vec
->resource
.states
[i
];
1369 if (cso
->base
.texture
== res
) {
1371 states
|= ILO_DIRTY_RESOURCE
;
1377 if (res
->target
!= PIPE_BUFFER
) {
1378 for (i
= 0; i
< vec
->fb
.state
.nr_cbufs
; i
++) {
1379 struct ilo_surface_cso
*cso
=
1380 (struct ilo_surface_cso
*) vec
->fb
.state
.cbufs
[i
];
1381 if (cso
&& cso
->base
.texture
== res
) {
1383 states
|= ILO_DIRTY_FB
;
1388 if (vec
->fb
.state
.zsbuf
&& vec
->fb
.state
.zsbuf
->texture
== res
) {
1389 struct ilo_surface_cso
*cso
=
1390 (struct ilo_surface_cso
*) vec
->fb
.state
.zsbuf
;
1393 states
|= ILO_DIRTY_FB
;
1397 for (i
= 0; i
< vec
->cs_resource
.count
; i
++) {
1398 struct ilo_surface_cso
*cso
=
1399 (struct ilo_surface_cso
*) vec
->cs_resource
.states
[i
];
1400 if (cso
->base
.texture
== res
) {
1402 states
|= ILO_DIRTY_CS_RESOURCE
;
1407 for (i
= 0; i
< vec
->global_binding
.count
; i
++) {
1408 if (vec
->global_binding
.resources
[i
] == res
) {
1409 states
|= ILO_DIRTY_GLOBAL_BINDING
;
1414 vec
->dirty
|= states
;
1418 ilo_state_vector_dump_dirty(const struct ilo_state_vector
*vec
)
1420 static const char *state_names
[ILO_STATE_COUNT
] = {
1421 [ILO_STATE_VB
] = "VB",
1422 [ILO_STATE_VE
] = "VE",
1423 [ILO_STATE_IB
] = "IB",
1424 [ILO_STATE_VS
] = "VS",
1425 [ILO_STATE_GS
] = "GS",
1426 [ILO_STATE_SO
] = "SO",
1427 [ILO_STATE_CLIP
] = "CLIP",
1428 [ILO_STATE_VIEWPORT
] = "VIEWPORT",
1429 [ILO_STATE_SCISSOR
] = "SCISSOR",
1430 [ILO_STATE_RASTERIZER
] = "RASTERIZER",
1431 [ILO_STATE_POLY_STIPPLE
] = "POLY_STIPPLE",
1432 [ILO_STATE_SAMPLE_MASK
] = "SAMPLE_MASK",
1433 [ILO_STATE_FS
] = "FS",
1434 [ILO_STATE_DSA
] = "DSA",
1435 [ILO_STATE_STENCIL_REF
] = "STENCIL_REF",
1436 [ILO_STATE_BLEND
] = "BLEND",
1437 [ILO_STATE_BLEND_COLOR
] = "BLEND_COLOR",
1438 [ILO_STATE_FB
] = "FB",
1439 [ILO_STATE_SAMPLER_VS
] = "SAMPLER_VS",
1440 [ILO_STATE_SAMPLER_GS
] = "SAMPLER_GS",
1441 [ILO_STATE_SAMPLER_FS
] = "SAMPLER_FS",
1442 [ILO_STATE_SAMPLER_CS
] = "SAMPLER_CS",
1443 [ILO_STATE_VIEW_VS
] = "VIEW_VS",
1444 [ILO_STATE_VIEW_GS
] = "VIEW_GS",
1445 [ILO_STATE_VIEW_FS
] = "VIEW_FS",
1446 [ILO_STATE_VIEW_CS
] = "VIEW_CS",
1447 [ILO_STATE_CBUF
] = "CBUF",
1448 [ILO_STATE_RESOURCE
] = "RESOURCE",
1449 [ILO_STATE_CS
] = "CS",
1450 [ILO_STATE_CS_RESOURCE
] = "CS_RESOURCE",
1451 [ILO_STATE_GLOBAL_BINDING
] = "GLOBAL_BINDING",
1453 uint32_t dirty
= vec
->dirty
;
1456 ilo_printf("no state is dirty\n");
1460 dirty
&= (1U << ILO_STATE_COUNT
) - 1;
1462 ilo_printf("%2d states are dirty:", util_bitcount(dirty
));
1464 const enum ilo_state state
= u_bit_scan(&dirty
);
1465 ilo_printf(" %s", state_names
[state
]);