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_framebuffer.h"
29 #include "util/u_helpers.h"
30 #include "util/u_upload_mgr.h"
32 #include "ilo_context.h"
33 #include "ilo_resource.h"
34 #include "ilo_shader.h"
35 #include "ilo_state.h"
38 finalize_shader_states(struct ilo_context
*ilo
)
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 (ilo
->dirty
& state
) {
70 ilo_shader_select_kernel(shader
, ilo
, ILO_DIRTY_ALL
);
72 else if (ilo_shader_select_kernel(shader
, ilo
, ilo
->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
&& ilo
->dirty
&
79 (state
| ILO_DIRTY_GS
| ILO_DIRTY_VS
| ILO_DIRTY_RASTERIZER
)) {
80 if (ilo_shader_select_kernel_routing(shader
,
81 (ilo
->gs
) ? ilo
->gs
: ilo
->vs
, ilo
->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
->dirty
|= ILO_DIRTY_CBUF
;
121 finalize_constant_buffers(struct ilo_context
*ilo
)
123 if (ilo
->dirty
& (ILO_DIRTY_CBUF
| ILO_DIRTY_VS
))
124 finalize_cbuf_state(ilo
, &ilo
->cbuf
[PIPE_SHADER_VERTEX
], ilo
->vs
);
126 if (ilo
->dirty
& (ILO_DIRTY_CBUF
| ILO_DIRTY_FS
))
127 finalize_cbuf_state(ilo
, &ilo
->cbuf
[PIPE_SHADER_FRAGMENT
], ilo
->fs
);
131 finalize_index_buffer(struct ilo_context
*ilo
)
133 const bool need_upload
= (ilo
->draw
->indexed
&&
134 (ilo
->ib
.user_buffer
|| ilo
->ib
.offset
% ilo
->ib
.index_size
));
135 struct pipe_resource
*current_hw_res
= NULL
;
137 if (!(ilo
->dirty
& ILO_DIRTY_IB
) && !need_upload
)
140 pipe_resource_reference(¤t_hw_res
, ilo
->ib
.hw_resource
);
143 const unsigned offset
= ilo
->ib
.index_size
* ilo
->draw
->start
;
144 const unsigned size
= ilo
->ib
.index_size
* ilo
->draw
->count
;
147 if (ilo
->ib
.user_buffer
) {
148 u_upload_data(ilo
->uploader
, 0, size
,
149 ilo
->ib
.user_buffer
+ offset
, &hw_offset
, &ilo
->ib
.hw_resource
);
152 u_upload_buffer(ilo
->uploader
, 0, ilo
->ib
.offset
+ offset
, size
,
153 ilo
->ib
.buffer
, &hw_offset
, &ilo
->ib
.hw_resource
);
156 /* the HW offset should be aligned */
157 assert(hw_offset
% ilo
->ib
.index_size
== 0);
158 ilo
->ib
.draw_start_offset
= hw_offset
/ ilo
->ib
.index_size
;
161 * INDEX[ilo->draw->start] in the original buffer is INDEX[0] in the HW
164 ilo
->ib
.draw_start_offset
-= ilo
->draw
->start
;
167 pipe_resource_reference(&ilo
->ib
.hw_resource
, ilo
->ib
.buffer
);
169 /* note that index size may be zero when the draw is not indexed */
170 if (ilo
->draw
->indexed
)
171 ilo
->ib
.draw_start_offset
= ilo
->ib
.offset
/ ilo
->ib
.index_size
;
173 ilo
->ib
.draw_start_offset
= 0;
176 /* treat the IB as clean if the HW states do not change */
177 if (ilo
->ib
.hw_resource
== current_hw_res
&&
178 ilo
->ib
.hw_index_size
== ilo
->ib
.index_size
)
179 ilo
->dirty
&= ~ILO_DIRTY_IB
;
181 ilo
->ib
.hw_index_size
= ilo
->ib
.index_size
;
183 pipe_resource_reference(¤t_hw_res
, NULL
);
187 * Finalize states. Some states depend on other states and are
188 * incomplete/invalid until finalized.
191 ilo_finalize_3d_states(struct ilo_context
*ilo
,
192 const struct pipe_draw_info
*draw
)
196 finalize_shader_states(ilo
);
197 finalize_constant_buffers(ilo
);
198 finalize_index_buffer(ilo
);
200 u_upload_unmap(ilo
->uploader
);
204 ilo_create_blend_state(struct pipe_context
*pipe
,
205 const struct pipe_blend_state
*state
)
207 struct ilo_context
*ilo
= ilo_context(pipe
);
208 struct ilo_blend_state
*blend
;
210 blend
= MALLOC_STRUCT(ilo_blend_state
);
213 ilo_gpe_init_blend(ilo
->dev
, state
, blend
);
219 ilo_bind_blend_state(struct pipe_context
*pipe
, void *state
)
221 struct ilo_context
*ilo
= ilo_context(pipe
);
225 ilo
->dirty
|= ILO_DIRTY_BLEND
;
229 ilo_delete_blend_state(struct pipe_context
*pipe
, void *state
)
235 ilo_create_sampler_state(struct pipe_context
*pipe
,
236 const struct pipe_sampler_state
*state
)
238 struct ilo_context
*ilo
= ilo_context(pipe
);
239 struct ilo_sampler_cso
*sampler
;
241 sampler
= MALLOC_STRUCT(ilo_sampler_cso
);
244 ilo_gpe_init_sampler_cso(ilo
->dev
, state
, sampler
);
250 ilo_bind_sampler_states(struct pipe_context
*pipe
, unsigned shader
,
251 unsigned start
, unsigned count
, void **samplers
)
253 struct ilo_context
*ilo
= ilo_context(pipe
);
254 struct ilo_sampler_state
*dst
= &ilo
->sampler
[shader
];
255 bool changed
= false;
258 assert(start
+ count
<= Elements(dst
->cso
));
261 for (i
= 0; i
< count
; i
++) {
262 if (dst
->cso
[start
+ i
] != samplers
[i
]) {
263 dst
->cso
[start
+ i
] = samplers
[i
];
266 * This function is sometimes called to reduce the number of bound
267 * samplers. Do not consider that as a state change (and create a
268 * new array of SAMPLER_STATE).
276 for (i
= 0; i
< count
; i
++)
277 dst
->cso
[start
+ i
] = NULL
;
280 if (dst
->count
<= start
+ count
) {
286 while (count
> 0 && !dst
->cso
[count
- 1])
294 case PIPE_SHADER_VERTEX
:
295 ilo
->dirty
|= ILO_DIRTY_SAMPLER_VS
;
297 case PIPE_SHADER_GEOMETRY
:
298 ilo
->dirty
|= ILO_DIRTY_SAMPLER_GS
;
300 case PIPE_SHADER_FRAGMENT
:
301 ilo
->dirty
|= ILO_DIRTY_SAMPLER_FS
;
303 case PIPE_SHADER_COMPUTE
:
304 ilo
->dirty
|= ILO_DIRTY_SAMPLER_CS
;
311 ilo_bind_fragment_sampler_states(struct pipe_context
*pipe
,
312 unsigned num_samplers
,
315 struct ilo_context
*ilo
= ilo_context(pipe
);
317 ilo_bind_sampler_states(pipe
, PIPE_SHADER_FRAGMENT
,
318 0, num_samplers
, samplers
);
320 if (ilo
->sampler
[PIPE_SHADER_FRAGMENT
].count
> num_samplers
) {
321 ilo_bind_sampler_states(pipe
, PIPE_SHADER_FRAGMENT
, num_samplers
,
322 ilo
->sampler
[PIPE_SHADER_FRAGMENT
].count
- num_samplers
, NULL
);
327 ilo_bind_vertex_sampler_states(struct pipe_context
*pipe
,
328 unsigned num_samplers
,
331 struct ilo_context
*ilo
= ilo_context(pipe
);
333 ilo_bind_sampler_states(pipe
, PIPE_SHADER_VERTEX
,
334 0, num_samplers
, samplers
);
336 if (ilo
->sampler
[PIPE_SHADER_VERTEX
].count
> num_samplers
) {
337 ilo_bind_sampler_states(pipe
, PIPE_SHADER_VERTEX
, num_samplers
,
338 ilo
->sampler
[PIPE_SHADER_VERTEX
].count
- num_samplers
, NULL
);
343 ilo_bind_geometry_sampler_states(struct pipe_context
*pipe
,
344 unsigned num_samplers
,
347 struct ilo_context
*ilo
= ilo_context(pipe
);
349 ilo_bind_sampler_states(pipe
, PIPE_SHADER_GEOMETRY
,
350 0, num_samplers
, samplers
);
352 if (ilo
->sampler
[PIPE_SHADER_GEOMETRY
].count
> num_samplers
) {
353 ilo_bind_sampler_states(pipe
, PIPE_SHADER_GEOMETRY
, num_samplers
,
354 ilo
->sampler
[PIPE_SHADER_GEOMETRY
].count
- num_samplers
, NULL
);
359 ilo_bind_compute_sampler_states(struct pipe_context
*pipe
,
361 unsigned num_samplers
,
364 ilo_bind_sampler_states(pipe
, PIPE_SHADER_COMPUTE
,
365 start_slot
, num_samplers
, samplers
);
369 ilo_bind_sampler_states2(struct pipe_context
*pipe
, unsigned shader
,
370 unsigned start
, unsigned count
, void **samplers
)
373 case PIPE_SHADER_VERTEX
:
374 ilo_bind_vertex_sampler_states(pipe
, count
, samplers
);
376 case PIPE_SHADER_GEOMETRY
:
377 ilo_bind_geometry_sampler_states(pipe
, count
, samplers
);
379 case PIPE_SHADER_FRAGMENT
:
380 ilo_bind_fragment_sampler_states(pipe
, count
, samplers
);
382 case PIPE_SHADER_COMPUTE
:
383 ilo_bind_compute_sampler_states(pipe
, start
, count
, samplers
);
389 ilo_delete_sampler_state(struct pipe_context
*pipe
, void *state
)
395 ilo_create_rasterizer_state(struct pipe_context
*pipe
,
396 const struct pipe_rasterizer_state
*state
)
398 struct ilo_context
*ilo
= ilo_context(pipe
);
399 struct ilo_rasterizer_state
*rast
;
401 rast
= MALLOC_STRUCT(ilo_rasterizer_state
);
404 rast
->state
= *state
;
405 ilo_gpe_init_rasterizer(ilo
->dev
, state
, rast
);
411 ilo_bind_rasterizer_state(struct pipe_context
*pipe
, void *state
)
413 struct ilo_context
*ilo
= ilo_context(pipe
);
415 ilo
->rasterizer
= state
;
417 ilo
->dirty
|= ILO_DIRTY_RASTERIZER
;
421 ilo_delete_rasterizer_state(struct pipe_context
*pipe
, void *state
)
427 ilo_create_depth_stencil_alpha_state(struct pipe_context
*pipe
,
428 const struct pipe_depth_stencil_alpha_state
*state
)
430 struct ilo_context
*ilo
= ilo_context(pipe
);
431 struct ilo_dsa_state
*dsa
;
433 dsa
= MALLOC_STRUCT(ilo_dsa_state
);
436 ilo_gpe_init_dsa(ilo
->dev
, state
, dsa
);
442 ilo_bind_depth_stencil_alpha_state(struct pipe_context
*pipe
, void *state
)
444 struct ilo_context
*ilo
= ilo_context(pipe
);
448 ilo
->dirty
|= ILO_DIRTY_DSA
;
452 ilo_delete_depth_stencil_alpha_state(struct pipe_context
*pipe
, void *state
)
458 ilo_create_fs_state(struct pipe_context
*pipe
,
459 const struct pipe_shader_state
*state
)
461 struct ilo_context
*ilo
= ilo_context(pipe
);
462 struct ilo_shader_state
*shader
;
464 shader
= ilo_shader_create_fs(ilo
->dev
, state
, ilo
);
467 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
473 ilo_bind_fs_state(struct pipe_context
*pipe
, void *state
)
475 struct ilo_context
*ilo
= ilo_context(pipe
);
479 ilo
->dirty
|= ILO_DIRTY_FS
;
483 ilo_delete_fs_state(struct pipe_context
*pipe
, void *state
)
485 struct ilo_context
*ilo
= ilo_context(pipe
);
486 struct ilo_shader_state
*fs
= (struct ilo_shader_state
*) state
;
488 ilo_shader_cache_remove(ilo
->shader_cache
, fs
);
489 ilo_shader_destroy(fs
);
493 ilo_create_vs_state(struct pipe_context
*pipe
,
494 const struct pipe_shader_state
*state
)
496 struct ilo_context
*ilo
= ilo_context(pipe
);
497 struct ilo_shader_state
*shader
;
499 shader
= ilo_shader_create_vs(ilo
->dev
, state
, ilo
);
502 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
508 ilo_bind_vs_state(struct pipe_context
*pipe
, void *state
)
510 struct ilo_context
*ilo
= ilo_context(pipe
);
514 ilo
->dirty
|= ILO_DIRTY_VS
;
518 ilo_delete_vs_state(struct pipe_context
*pipe
, void *state
)
520 struct ilo_context
*ilo
= ilo_context(pipe
);
521 struct ilo_shader_state
*vs
= (struct ilo_shader_state
*) state
;
523 ilo_shader_cache_remove(ilo
->shader_cache
, vs
);
524 ilo_shader_destroy(vs
);
528 ilo_create_gs_state(struct pipe_context
*pipe
,
529 const struct pipe_shader_state
*state
)
531 struct ilo_context
*ilo
= ilo_context(pipe
);
532 struct ilo_shader_state
*shader
;
534 shader
= ilo_shader_create_gs(ilo
->dev
, state
, ilo
);
537 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
543 ilo_bind_gs_state(struct pipe_context
*pipe
, void *state
)
545 struct ilo_context
*ilo
= ilo_context(pipe
);
547 /* util_blitter may set this unnecessarily */
548 if (ilo
->gs
== state
)
553 ilo
->dirty
|= ILO_DIRTY_GS
;
557 ilo_delete_gs_state(struct pipe_context
*pipe
, void *state
)
559 struct ilo_context
*ilo
= ilo_context(pipe
);
560 struct ilo_shader_state
*gs
= (struct ilo_shader_state
*) state
;
562 ilo_shader_cache_remove(ilo
->shader_cache
, gs
);
563 ilo_shader_destroy(gs
);
567 ilo_create_vertex_elements_state(struct pipe_context
*pipe
,
568 unsigned num_elements
,
569 const struct pipe_vertex_element
*elements
)
571 struct ilo_context
*ilo
= ilo_context(pipe
);
572 struct ilo_ve_state
*ve
;
574 ve
= MALLOC_STRUCT(ilo_ve_state
);
577 ilo_gpe_init_ve(ilo
->dev
, num_elements
, elements
, ve
);
583 ilo_bind_vertex_elements_state(struct pipe_context
*pipe
, void *state
)
585 struct ilo_context
*ilo
= ilo_context(pipe
);
589 ilo
->dirty
|= ILO_DIRTY_VE
;
593 ilo_delete_vertex_elements_state(struct pipe_context
*pipe
, void *state
)
595 struct ilo_ve_state
*ve
= state
;
601 ilo_set_blend_color(struct pipe_context
*pipe
,
602 const struct pipe_blend_color
*state
)
604 struct ilo_context
*ilo
= ilo_context(pipe
);
606 ilo
->blend_color
= *state
;
608 ilo
->dirty
|= ILO_DIRTY_BLEND_COLOR
;
612 ilo_set_stencil_ref(struct pipe_context
*pipe
,
613 const struct pipe_stencil_ref
*state
)
615 struct ilo_context
*ilo
= ilo_context(pipe
);
617 /* util_blitter may set this unnecessarily */
618 if (!memcmp(&ilo
->stencil_ref
, state
, sizeof(*state
)))
621 ilo
->stencil_ref
= *state
;
623 ilo
->dirty
|= ILO_DIRTY_STENCIL_REF
;
627 ilo_set_sample_mask(struct pipe_context
*pipe
,
628 unsigned sample_mask
)
630 struct ilo_context
*ilo
= ilo_context(pipe
);
632 /* util_blitter may set this unnecessarily */
633 if (ilo
->sample_mask
== sample_mask
)
636 ilo
->sample_mask
= sample_mask
;
638 ilo
->dirty
|= ILO_DIRTY_SAMPLE_MASK
;
642 ilo_set_clip_state(struct pipe_context
*pipe
,
643 const struct pipe_clip_state
*state
)
645 struct ilo_context
*ilo
= ilo_context(pipe
);
649 ilo
->dirty
|= ILO_DIRTY_CLIP
;
653 ilo_set_constant_buffer(struct pipe_context
*pipe
,
654 uint shader
, uint index
,
655 struct pipe_constant_buffer
*buf
)
657 struct ilo_context
*ilo
= ilo_context(pipe
);
658 struct ilo_cbuf_state
*cbuf
= &ilo
->cbuf
[shader
];
659 const unsigned count
= 1;
662 assert(shader
< Elements(ilo
->cbuf
));
663 assert(index
+ count
<= Elements(ilo
->cbuf
[shader
].cso
));
666 for (i
= 0; i
< count
; i
++) {
667 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
669 pipe_resource_reference(&cso
->resource
, buf
[i
].buffer
);
672 const enum pipe_format elem_format
=
673 PIPE_FORMAT_R32G32B32A32_FLOAT
;
675 ilo_gpe_init_view_surface_for_buffer(ilo
->dev
,
676 ilo_buffer(buf
[i
].buffer
),
677 buf
[i
].buffer_offset
, buf
[i
].buffer_size
,
678 util_format_get_blocksize(elem_format
), elem_format
,
679 false, false, &cso
->surface
);
681 cso
->user_buffer
= NULL
;
682 cso
->user_buffer_size
= 0;
684 cbuf
->enabled_mask
|= 1 << (index
+ i
);
686 else if (buf
[i
].user_buffer
) {
687 cso
->surface
.bo
= NULL
;
689 /* buffer_offset does not apply for user buffer */
690 cso
->user_buffer
= buf
[i
].user_buffer
;
691 cso
->user_buffer_size
= buf
[i
].buffer_size
;
693 cbuf
->enabled_mask
|= 1 << (index
+ i
);
696 cso
->surface
.bo
= NULL
;
697 cso
->user_buffer
= NULL
;
698 cso
->user_buffer_size
= 0;
700 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
705 for (i
= 0; i
< count
; i
++) {
706 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
708 pipe_resource_reference(&cso
->resource
, NULL
);
709 cso
->surface
.bo
= NULL
;
710 cso
->user_buffer
= NULL
;
711 cso
->user_buffer_size
= 0;
713 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
717 ilo
->dirty
|= ILO_DIRTY_CBUF
;
721 ilo_set_framebuffer_state(struct pipe_context
*pipe
,
722 const struct pipe_framebuffer_state
*state
)
724 struct ilo_context
*ilo
= ilo_context(pipe
);
726 util_copy_framebuffer_state(&ilo
->fb
.state
, state
);
729 ilo
->fb
.num_samples
= state
->cbufs
[0]->texture
->nr_samples
;
730 else if (state
->zsbuf
)
731 ilo
->fb
.num_samples
= state
->zsbuf
->texture
->nr_samples
;
733 ilo
->fb
.num_samples
= 1;
735 if (!ilo
->fb
.num_samples
)
736 ilo
->fb
.num_samples
= 1;
738 ilo
->dirty
|= ILO_DIRTY_FB
;
742 ilo_set_polygon_stipple(struct pipe_context
*pipe
,
743 const struct pipe_poly_stipple
*state
)
745 struct ilo_context
*ilo
= ilo_context(pipe
);
747 ilo
->poly_stipple
= *state
;
749 ilo
->dirty
|= ILO_DIRTY_POLY_STIPPLE
;
753 ilo_set_scissor_states(struct pipe_context
*pipe
,
755 unsigned num_scissors
,
756 const struct pipe_scissor_state
*scissors
)
758 struct ilo_context
*ilo
= ilo_context(pipe
);
760 ilo_gpe_set_scissor(ilo
->dev
, start_slot
, num_scissors
,
761 scissors
, &ilo
->scissor
);
763 ilo
->dirty
|= ILO_DIRTY_SCISSOR
;
767 ilo_set_viewport_states(struct pipe_context
*pipe
,
769 unsigned num_viewports
,
770 const struct pipe_viewport_state
*viewports
)
772 struct ilo_context
*ilo
= ilo_context(pipe
);
777 for (i
= 0; i
< num_viewports
; i
++) {
778 ilo_gpe_set_viewport_cso(ilo
->dev
, &viewports
[i
],
779 &ilo
->viewport
.cso
[start_slot
+ i
]);
782 if (ilo
->viewport
.count
< start_slot
+ num_viewports
)
783 ilo
->viewport
.count
= start_slot
+ num_viewports
;
785 /* need to save viewport 0 for util_blitter */
786 if (!start_slot
&& num_viewports
)
787 ilo
->viewport
.viewport0
= viewports
[0];
790 if (ilo
->viewport
.count
<= start_slot
+ num_viewports
&&
791 ilo
->viewport
.count
> start_slot
)
792 ilo
->viewport
.count
= start_slot
;
795 ilo
->dirty
|= ILO_DIRTY_VIEWPORT
;
799 ilo_set_sampler_views(struct pipe_context
*pipe
, unsigned shader
,
800 unsigned start
, unsigned count
,
801 struct pipe_sampler_view
**views
)
803 struct ilo_context
*ilo
= ilo_context(pipe
);
804 struct ilo_view_state
*dst
= &ilo
->view
[shader
];
807 assert(start
+ count
<= Elements(dst
->states
));
810 for (i
= 0; i
< count
; i
++)
811 pipe_sampler_view_reference(&dst
->states
[start
+ i
], views
[i
]);
814 for (i
= 0; i
< count
; i
++)
815 pipe_sampler_view_reference(&dst
->states
[start
+ i
], NULL
);
818 if (dst
->count
<= start
+ count
) {
824 while (count
> 0 && !dst
->states
[count
- 1])
832 ilo_set_fragment_sampler_views(struct pipe_context
*pipe
,
834 struct pipe_sampler_view
**views
)
836 struct ilo_context
*ilo
= ilo_context(pipe
);
838 ilo_set_sampler_views(pipe
, PIPE_SHADER_FRAGMENT
, 0, num_views
, views
);
840 if (ilo
->view
[PIPE_SHADER_FRAGMENT
].count
> num_views
) {
841 ilo_set_sampler_views(pipe
, PIPE_SHADER_FRAGMENT
, num_views
,
842 ilo
->view
[PIPE_SHADER_FRAGMENT
].count
- num_views
, NULL
);
845 ilo
->dirty
|= ILO_DIRTY_VIEW_FS
;
849 ilo_set_vertex_sampler_views(struct pipe_context
*pipe
,
851 struct pipe_sampler_view
**views
)
853 struct ilo_context
*ilo
= ilo_context(pipe
);
855 ilo_set_sampler_views(pipe
, PIPE_SHADER_VERTEX
, 0, num_views
, views
);
857 if (ilo
->view
[PIPE_SHADER_VERTEX
].count
> num_views
) {
858 ilo_set_sampler_views(pipe
, PIPE_SHADER_VERTEX
, num_views
,
859 ilo
->view
[PIPE_SHADER_VERTEX
].count
- num_views
, NULL
);
862 ilo
->dirty
|= ILO_DIRTY_VIEW_VS
;
866 ilo_set_geometry_sampler_views(struct pipe_context
*pipe
,
868 struct pipe_sampler_view
**views
)
870 struct ilo_context
*ilo
= ilo_context(pipe
);
872 ilo_set_sampler_views(pipe
, PIPE_SHADER_GEOMETRY
, 0, num_views
, views
);
874 if (ilo
->view
[PIPE_SHADER_GEOMETRY
].count
> num_views
) {
875 ilo_set_sampler_views(pipe
, PIPE_SHADER_GEOMETRY
, num_views
,
876 ilo
->view
[PIPE_SHADER_GEOMETRY
].count
- num_views
, NULL
);
879 ilo
->dirty
|= ILO_DIRTY_VIEW_GS
;
883 ilo_set_compute_sampler_views(struct pipe_context
*pipe
,
884 unsigned start_slot
, unsigned num_views
,
885 struct pipe_sampler_view
**views
)
887 struct ilo_context
*ilo
= ilo_context(pipe
);
889 ilo_set_sampler_views(pipe
, PIPE_SHADER_COMPUTE
,
890 start_slot
, num_views
, views
);
892 ilo
->dirty
|= ILO_DIRTY_VIEW_CS
;
896 ilo_set_shader_resources(struct pipe_context
*pipe
,
897 unsigned start
, unsigned count
,
898 struct pipe_surface
**surfaces
)
900 struct ilo_context
*ilo
= ilo_context(pipe
);
901 struct ilo_resource_state
*dst
= &ilo
->resource
;
904 assert(start
+ count
<= Elements(dst
->states
));
907 for (i
= 0; i
< count
; i
++)
908 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
911 for (i
= 0; i
< count
; i
++)
912 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
915 if (dst
->count
<= start
+ count
) {
921 while (count
> 0 && !dst
->states
[count
- 1])
927 ilo
->dirty
|= ILO_DIRTY_RESOURCE
;
931 ilo_set_vertex_buffers(struct pipe_context
*pipe
,
932 unsigned start_slot
, unsigned num_buffers
,
933 const struct pipe_vertex_buffer
*buffers
)
935 struct ilo_context
*ilo
= ilo_context(pipe
);
938 /* no PIPE_CAP_USER_VERTEX_BUFFERS */
940 for (i
= 0; i
< num_buffers
; i
++)
941 assert(!buffers
[i
].user_buffer
);
944 util_set_vertex_buffers_mask(ilo
->vb
.states
,
945 &ilo
->vb
.enabled_mask
, buffers
, start_slot
, num_buffers
);
947 ilo
->dirty
|= ILO_DIRTY_VB
;
951 ilo_set_index_buffer(struct pipe_context
*pipe
,
952 const struct pipe_index_buffer
*state
)
954 struct ilo_context
*ilo
= ilo_context(pipe
);
957 pipe_resource_reference(&ilo
->ib
.buffer
, state
->buffer
);
958 ilo
->ib
.user_buffer
= state
->user_buffer
;
959 ilo
->ib
.offset
= state
->offset
;
960 ilo
->ib
.index_size
= state
->index_size
;
963 pipe_resource_reference(&ilo
->ib
.buffer
, NULL
);
964 ilo
->ib
.user_buffer
= NULL
;
966 ilo
->ib
.index_size
= 0;
969 ilo
->dirty
|= ILO_DIRTY_IB
;
972 static struct pipe_stream_output_target
*
973 ilo_create_stream_output_target(struct pipe_context
*pipe
,
974 struct pipe_resource
*res
,
975 unsigned buffer_offset
,
976 unsigned buffer_size
)
978 struct pipe_stream_output_target
*target
;
980 target
= MALLOC_STRUCT(pipe_stream_output_target
);
983 pipe_reference_init(&target
->reference
, 1);
984 target
->buffer
= NULL
;
985 pipe_resource_reference(&target
->buffer
, res
);
986 target
->context
= pipe
;
987 target
->buffer_offset
= buffer_offset
;
988 target
->buffer_size
= buffer_size
;
994 ilo_set_stream_output_targets(struct pipe_context
*pipe
,
995 unsigned num_targets
,
996 struct pipe_stream_output_target
**targets
,
997 unsigned append_bitmask
)
999 struct ilo_context
*ilo
= ilo_context(pipe
);
1005 /* util_blitter may set this unnecessarily */
1006 if (!ilo
->so
.count
&& !num_targets
)
1009 for (i
= 0; i
< num_targets
; i
++)
1010 pipe_so_target_reference(&ilo
->so
.states
[i
], targets
[i
]);
1012 for (; i
< ilo
->so
.count
; i
++)
1013 pipe_so_target_reference(&ilo
->so
.states
[i
], NULL
);
1015 ilo
->so
.count
= num_targets
;
1016 ilo
->so
.append_bitmask
= append_bitmask
;
1018 ilo
->so
.enabled
= (ilo
->so
.count
> 0);
1020 ilo
->dirty
|= ILO_DIRTY_SO
;
1024 ilo_stream_output_target_destroy(struct pipe_context
*pipe
,
1025 struct pipe_stream_output_target
*target
)
1027 pipe_resource_reference(&target
->buffer
, NULL
);
1031 static struct pipe_sampler_view
*
1032 ilo_create_sampler_view(struct pipe_context
*pipe
,
1033 struct pipe_resource
*res
,
1034 const struct pipe_sampler_view
*templ
)
1036 struct ilo_context
*ilo
= ilo_context(pipe
);
1037 struct ilo_view_cso
*view
;
1039 view
= MALLOC_STRUCT(ilo_view_cso
);
1042 view
->base
= *templ
;
1043 pipe_reference_init(&view
->base
.reference
, 1);
1044 view
->base
.texture
= NULL
;
1045 pipe_resource_reference(&view
->base
.texture
, res
);
1046 view
->base
.context
= pipe
;
1048 if (res
->target
== PIPE_BUFFER
) {
1049 const unsigned elem_size
= util_format_get_blocksize(templ
->format
);
1050 const unsigned first_elem
= templ
->u
.buf
.first_element
;
1051 const unsigned num_elems
= templ
->u
.buf
.last_element
- first_elem
+ 1;
1053 ilo_gpe_init_view_surface_for_buffer(ilo
->dev
, ilo_buffer(res
),
1054 first_elem
* elem_size
, num_elems
* elem_size
,
1055 elem_size
, templ
->format
, false, false, &view
->surface
);
1058 struct ilo_texture
*tex
= ilo_texture(res
);
1060 /* warn about degraded performance because of a missing binding flag */
1061 if (tex
->tiling
== INTEL_TILING_NONE
&&
1062 !(tex
->base
.bind
& PIPE_BIND_SAMPLER_VIEW
)) {
1063 ilo_warn("creating sampler view for a resource "
1064 "not created for sampling\n");
1067 ilo_gpe_init_view_surface_for_texture(ilo
->dev
, tex
,
1069 templ
->u
.tex
.first_level
,
1070 templ
->u
.tex
.last_level
- templ
->u
.tex
.first_level
+ 1,
1071 templ
->u
.tex
.first_layer
,
1072 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1073 false, false, &view
->surface
);
1080 ilo_sampler_view_destroy(struct pipe_context
*pipe
,
1081 struct pipe_sampler_view
*view
)
1083 pipe_resource_reference(&view
->texture
, NULL
);
1087 static struct pipe_surface
*
1088 ilo_create_surface(struct pipe_context
*pipe
,
1089 struct pipe_resource
*res
,
1090 const struct pipe_surface
*templ
)
1092 struct ilo_context
*ilo
= ilo_context(pipe
);
1093 struct ilo_surface_cso
*surf
;
1095 surf
= MALLOC_STRUCT(ilo_surface_cso
);
1098 surf
->base
= *templ
;
1099 pipe_reference_init(&surf
->base
.reference
, 1);
1100 surf
->base
.texture
= NULL
;
1101 pipe_resource_reference(&surf
->base
.texture
, res
);
1103 surf
->base
.context
= pipe
;
1104 surf
->base
.width
= u_minify(res
->width0
, templ
->u
.tex
.level
);
1105 surf
->base
.height
= u_minify(res
->height0
, templ
->u
.tex
.level
);
1107 surf
->is_rt
= !util_format_is_depth_or_stencil(templ
->format
);
1111 assert(res
->target
!= PIPE_BUFFER
);
1114 * classic i965 sets render_cache_rw for constant buffers and sol
1115 * surfaces but not render buffers. Why?
1117 ilo_gpe_init_view_surface_for_texture(ilo
->dev
, ilo_texture(res
),
1118 templ
->format
, templ
->u
.tex
.level
, 1,
1119 templ
->u
.tex
.first_layer
,
1120 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1121 true, true, &surf
->u
.rt
);
1124 assert(res
->target
!= PIPE_BUFFER
);
1126 ilo_gpe_init_zs_surface(ilo
->dev
, ilo_texture(res
),
1127 templ
->format
, templ
->u
.tex
.level
,
1128 templ
->u
.tex
.first_layer
,
1129 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1137 ilo_surface_destroy(struct pipe_context
*pipe
,
1138 struct pipe_surface
*surface
)
1140 pipe_resource_reference(&surface
->texture
, NULL
);
1145 ilo_create_compute_state(struct pipe_context
*pipe
,
1146 const struct pipe_compute_state
*state
)
1148 struct ilo_context
*ilo
= ilo_context(pipe
);
1149 struct ilo_shader_state
*shader
;
1151 shader
= ilo_shader_create_cs(ilo
->dev
, state
, ilo
);
1154 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
1160 ilo_bind_compute_state(struct pipe_context
*pipe
, void *state
)
1162 struct ilo_context
*ilo
= ilo_context(pipe
);
1166 ilo
->dirty
|= ILO_DIRTY_CS
;
1170 ilo_delete_compute_state(struct pipe_context
*pipe
, void *state
)
1172 struct ilo_context
*ilo
= ilo_context(pipe
);
1173 struct ilo_shader_state
*cs
= (struct ilo_shader_state
*) state
;
1175 ilo_shader_cache_remove(ilo
->shader_cache
, cs
);
1176 ilo_shader_destroy(cs
);
1180 ilo_set_compute_resources(struct pipe_context
*pipe
,
1181 unsigned start
, unsigned count
,
1182 struct pipe_surface
**surfaces
)
1184 struct ilo_context
*ilo
= ilo_context(pipe
);
1185 struct ilo_resource_state
*dst
= &ilo
->cs_resource
;
1188 assert(start
+ count
<= Elements(dst
->states
));
1191 for (i
= 0; i
< count
; i
++)
1192 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
1195 for (i
= 0; i
< count
; i
++)
1196 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
1199 if (dst
->count
<= start
+ count
) {
1205 while (count
> 0 && !dst
->states
[count
- 1])
1211 ilo
->dirty
|= ILO_DIRTY_CS_RESOURCE
;
1215 ilo_set_global_binding(struct pipe_context
*pipe
,
1216 unsigned start
, unsigned count
,
1217 struct pipe_resource
**resources
,
1220 struct ilo_context
*ilo
= ilo_context(pipe
);
1221 struct ilo_global_binding
*dst
= &ilo
->global_binding
;
1224 assert(start
+ count
<= Elements(dst
->resources
));
1227 for (i
= 0; i
< count
; i
++)
1228 pipe_resource_reference(&dst
->resources
[start
+ i
], resources
[i
]);
1231 for (i
= 0; i
< count
; i
++)
1232 pipe_resource_reference(&dst
->resources
[start
+ i
], NULL
);
1235 if (dst
->count
<= start
+ count
) {
1241 while (count
> 0 && !dst
->resources
[count
- 1])
1247 ilo
->dirty
|= ILO_DIRTY_GLOBAL_BINDING
;
1251 * Initialize state-related functions.
1254 ilo_init_state_functions(struct ilo_context
*ilo
)
1256 STATIC_ASSERT(ILO_STATE_COUNT
<= 32);
1258 ilo
->base
.create_blend_state
= ilo_create_blend_state
;
1259 ilo
->base
.bind_blend_state
= ilo_bind_blend_state
;
1260 ilo
->base
.delete_blend_state
= ilo_delete_blend_state
;
1261 ilo
->base
.create_sampler_state
= ilo_create_sampler_state
;
1262 ilo
->base
.bind_sampler_states
= ilo_bind_sampler_states2
;
1263 ilo
->base
.delete_sampler_state
= ilo_delete_sampler_state
;
1264 ilo
->base
.create_rasterizer_state
= ilo_create_rasterizer_state
;
1265 ilo
->base
.bind_rasterizer_state
= ilo_bind_rasterizer_state
;
1266 ilo
->base
.delete_rasterizer_state
= ilo_delete_rasterizer_state
;
1267 ilo
->base
.create_depth_stencil_alpha_state
= ilo_create_depth_stencil_alpha_state
;
1268 ilo
->base
.bind_depth_stencil_alpha_state
= ilo_bind_depth_stencil_alpha_state
;
1269 ilo
->base
.delete_depth_stencil_alpha_state
= ilo_delete_depth_stencil_alpha_state
;
1270 ilo
->base
.create_fs_state
= ilo_create_fs_state
;
1271 ilo
->base
.bind_fs_state
= ilo_bind_fs_state
;
1272 ilo
->base
.delete_fs_state
= ilo_delete_fs_state
;
1273 ilo
->base
.create_vs_state
= ilo_create_vs_state
;
1274 ilo
->base
.bind_vs_state
= ilo_bind_vs_state
;
1275 ilo
->base
.delete_vs_state
= ilo_delete_vs_state
;
1276 ilo
->base
.create_gs_state
= ilo_create_gs_state
;
1277 ilo
->base
.bind_gs_state
= ilo_bind_gs_state
;
1278 ilo
->base
.delete_gs_state
= ilo_delete_gs_state
;
1279 ilo
->base
.create_vertex_elements_state
= ilo_create_vertex_elements_state
;
1280 ilo
->base
.bind_vertex_elements_state
= ilo_bind_vertex_elements_state
;
1281 ilo
->base
.delete_vertex_elements_state
= ilo_delete_vertex_elements_state
;
1283 ilo
->base
.set_blend_color
= ilo_set_blend_color
;
1284 ilo
->base
.set_stencil_ref
= ilo_set_stencil_ref
;
1285 ilo
->base
.set_sample_mask
= ilo_set_sample_mask
;
1286 ilo
->base
.set_clip_state
= ilo_set_clip_state
;
1287 ilo
->base
.set_constant_buffer
= ilo_set_constant_buffer
;
1288 ilo
->base
.set_framebuffer_state
= ilo_set_framebuffer_state
;
1289 ilo
->base
.set_polygon_stipple
= ilo_set_polygon_stipple
;
1290 ilo
->base
.set_scissor_states
= ilo_set_scissor_states
;
1291 ilo
->base
.set_viewport_states
= ilo_set_viewport_states
;
1292 ilo
->base
.set_fragment_sampler_views
= ilo_set_fragment_sampler_views
;
1293 ilo
->base
.set_vertex_sampler_views
= ilo_set_vertex_sampler_views
;
1294 ilo
->base
.set_geometry_sampler_views
= ilo_set_geometry_sampler_views
;
1295 ilo
->base
.set_compute_sampler_views
= ilo_set_compute_sampler_views
;
1296 ilo
->base
.set_shader_resources
= ilo_set_shader_resources
;
1297 ilo
->base
.set_vertex_buffers
= ilo_set_vertex_buffers
;
1298 ilo
->base
.set_index_buffer
= ilo_set_index_buffer
;
1300 ilo
->base
.create_stream_output_target
= ilo_create_stream_output_target
;
1301 ilo
->base
.stream_output_target_destroy
= ilo_stream_output_target_destroy
;
1302 ilo
->base
.set_stream_output_targets
= ilo_set_stream_output_targets
;
1304 ilo
->base
.create_sampler_view
= ilo_create_sampler_view
;
1305 ilo
->base
.sampler_view_destroy
= ilo_sampler_view_destroy
;
1307 ilo
->base
.create_surface
= ilo_create_surface
;
1308 ilo
->base
.surface_destroy
= ilo_surface_destroy
;
1310 ilo
->base
.create_compute_state
= ilo_create_compute_state
;
1311 ilo
->base
.bind_compute_state
= ilo_bind_compute_state
;
1312 ilo
->base
.delete_compute_state
= ilo_delete_compute_state
;
1313 ilo
->base
.set_compute_resources
= ilo_set_compute_resources
;
1314 ilo
->base
.set_global_binding
= ilo_set_global_binding
;
1318 ilo_init_states(struct ilo_context
*ilo
)
1320 ilo_gpe_set_scissor_null(ilo
->dev
, &ilo
->scissor
);
1322 ilo_gpe_init_zs_surface(ilo
->dev
, NULL
,
1323 PIPE_FORMAT_NONE
, 0, 0, 1, &ilo
->fb
.null_zs
);
1325 ilo
->dirty
= ILO_DIRTY_ALL
;
1329 ilo_cleanup_states(struct ilo_context
*ilo
)
1333 for (i
= 0; i
< Elements(ilo
->vb
.states
); i
++) {
1334 if (ilo
->vb
.enabled_mask
& (1 << i
))
1335 pipe_resource_reference(&ilo
->vb
.states
[i
].buffer
, NULL
);
1338 pipe_resource_reference(&ilo
->ib
.buffer
, NULL
);
1339 pipe_resource_reference(&ilo
->ib
.hw_resource
, NULL
);
1341 for (i
= 0; i
< ilo
->so
.count
; i
++)
1342 pipe_so_target_reference(&ilo
->so
.states
[i
], NULL
);
1344 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1345 for (i
= 0; i
< ilo
->view
[sh
].count
; i
++) {
1346 struct pipe_sampler_view
*view
= ilo
->view
[sh
].states
[i
];
1347 pipe_sampler_view_reference(&view
, NULL
);
1350 for (i
= 0; i
< Elements(ilo
->cbuf
[sh
].cso
); i
++) {
1351 struct ilo_cbuf_cso
*cbuf
= &ilo
->cbuf
[sh
].cso
[i
];
1352 pipe_resource_reference(&cbuf
->resource
, NULL
);
1356 for (i
= 0; i
< ilo
->resource
.count
; i
++)
1357 pipe_surface_reference(&ilo
->resource
.states
[i
], NULL
);
1359 for (i
= 0; i
< ilo
->fb
.state
.nr_cbufs
; i
++)
1360 pipe_surface_reference(&ilo
->fb
.state
.cbufs
[i
], NULL
);
1362 if (ilo
->fb
.state
.zsbuf
)
1363 pipe_surface_reference(&ilo
->fb
.state
.zsbuf
, NULL
);
1365 for (i
= 0; i
< ilo
->cs_resource
.count
; i
++)
1366 pipe_surface_reference(&ilo
->cs_resource
.states
[i
], NULL
);
1368 for (i
= 0; i
< ilo
->global_binding
.count
; i
++)
1369 pipe_resource_reference(&ilo
->global_binding
.resources
[i
], NULL
);
1373 * Mark all states that have the resource dirty.
1376 ilo_mark_states_with_resource_dirty(struct ilo_context
*ilo
,
1377 const struct pipe_resource
*res
)
1379 uint32_t states
= 0;
1382 if (res
->target
== PIPE_BUFFER
) {
1383 uint32_t vb_mask
= ilo
->vb
.enabled_mask
;
1386 const unsigned idx
= u_bit_scan(&vb_mask
);
1388 if (ilo
->vb
.states
[idx
].buffer
== res
) {
1389 states
|= ILO_DIRTY_VB
;
1394 if (ilo
->ib
.buffer
== res
) {
1395 states
|= ILO_DIRTY_IB
;
1398 * finalize_index_buffer() has an optimization that clears
1399 * ILO_DIRTY_IB when the HW states do not change. However, it fails
1400 * to flush the VF cache when the HW states do not change, but the
1401 * contents of the IB has changed. Here, we set the index size to an
1402 * invalid value to avoid the optimization.
1404 ilo
->ib
.hw_index_size
= 0;
1407 for (i
= 0; i
< ilo
->so
.count
; i
++) {
1408 if (ilo
->so
.states
[i
]->buffer
== res
) {
1409 states
|= ILO_DIRTY_SO
;
1415 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1416 for (i
= 0; i
< ilo
->view
[sh
].count
; i
++) {
1417 struct pipe_sampler_view
*view
= ilo
->view
[sh
].states
[i
];
1419 if (view
->texture
== res
) {
1420 static const unsigned view_dirty_bits
[PIPE_SHADER_TYPES
] = {
1421 [PIPE_SHADER_VERTEX
] = ILO_DIRTY_VIEW_VS
,
1422 [PIPE_SHADER_FRAGMENT
] = ILO_DIRTY_VIEW_FS
,
1423 [PIPE_SHADER_GEOMETRY
] = ILO_DIRTY_VIEW_GS
,
1424 [PIPE_SHADER_COMPUTE
] = ILO_DIRTY_VIEW_CS
,
1427 states
|= view_dirty_bits
[sh
];
1432 if (res
->target
== PIPE_BUFFER
) {
1433 for (i
= 0; i
< Elements(ilo
->cbuf
[sh
].cso
); i
++) {
1434 struct ilo_cbuf_cso
*cbuf
= &ilo
->cbuf
[sh
].cso
[i
];
1436 if (cbuf
->resource
== res
) {
1437 states
|= ILO_DIRTY_CBUF
;
1444 for (i
= 0; i
< ilo
->resource
.count
; i
++) {
1445 if (ilo
->resource
.states
[i
]->texture
== res
) {
1446 states
|= ILO_DIRTY_RESOURCE
;
1452 if (res
->target
!= PIPE_BUFFER
) {
1453 for (i
= 0; i
< ilo
->fb
.state
.nr_cbufs
; i
++) {
1454 if (ilo
->fb
.state
.cbufs
[i
]->texture
== res
) {
1455 states
|= ILO_DIRTY_FB
;
1460 if (ilo
->fb
.state
.zsbuf
&& ilo
->fb
.state
.zsbuf
->texture
== res
)
1461 states
|= ILO_DIRTY_FB
;
1464 for (i
= 0; i
< ilo
->cs_resource
.count
; i
++) {
1465 pipe_surface_reference(&ilo
->cs_resource
.states
[i
], NULL
);
1466 if (ilo
->cs_resource
.states
[i
]->texture
== res
) {
1467 states
|= ILO_DIRTY_CS_RESOURCE
;
1472 for (i
= 0; i
< ilo
->global_binding
.count
; i
++) {
1473 if (ilo
->global_binding
.resources
[i
] == res
) {
1474 states
|= ILO_DIRTY_GLOBAL_BINDING
;
1479 ilo
->dirty
|= states
;
1483 ilo_dump_dirty_flags(uint32_t dirty
)
1485 static const char *state_names
[ILO_STATE_COUNT
] = {
1486 [ILO_STATE_VB
] = "VB",
1487 [ILO_STATE_VE
] = "VE",
1488 [ILO_STATE_IB
] = "IB",
1489 [ILO_STATE_VS
] = "VS",
1490 [ILO_STATE_GS
] = "GS",
1491 [ILO_STATE_SO
] = "SO",
1492 [ILO_STATE_CLIP
] = "CLIP",
1493 [ILO_STATE_VIEWPORT
] = "VIEWPORT",
1494 [ILO_STATE_SCISSOR
] = "SCISSOR",
1495 [ILO_STATE_RASTERIZER
] = "RASTERIZER",
1496 [ILO_STATE_POLY_STIPPLE
] = "POLY_STIPPLE",
1497 [ILO_STATE_SAMPLE_MASK
] = "SAMPLE_MASK",
1498 [ILO_STATE_FS
] = "FS",
1499 [ILO_STATE_DSA
] = "DSA",
1500 [ILO_STATE_STENCIL_REF
] = "STENCIL_REF",
1501 [ILO_STATE_BLEND
] = "BLEND",
1502 [ILO_STATE_BLEND_COLOR
] = "BLEND_COLOR",
1503 [ILO_STATE_FB
] = "FB",
1504 [ILO_STATE_SAMPLER_VS
] = "SAMPLER_VS",
1505 [ILO_STATE_SAMPLER_GS
] = "SAMPLER_GS",
1506 [ILO_STATE_SAMPLER_FS
] = "SAMPLER_FS",
1507 [ILO_STATE_SAMPLER_CS
] = "SAMPLER_CS",
1508 [ILO_STATE_VIEW_VS
] = "VIEW_VS",
1509 [ILO_STATE_VIEW_GS
] = "VIEW_GS",
1510 [ILO_STATE_VIEW_FS
] = "VIEW_FS",
1511 [ILO_STATE_VIEW_CS
] = "VIEW_CS",
1512 [ILO_STATE_CBUF
] = "CBUF",
1513 [ILO_STATE_RESOURCE
] = "RESOURCE",
1514 [ILO_STATE_CS
] = "CS",
1515 [ILO_STATE_CS_RESOURCE
] = "CS_RESOURCE",
1516 [ILO_STATE_GLOBAL_BINDING
] = "GLOBAL_BINDING",
1520 ilo_printf("no state is dirty\n");
1524 dirty
&= (1U << ILO_STATE_COUNT
) - 1;
1526 ilo_printf("%2d states are dirty:", util_bitcount(dirty
));
1528 const enum ilo_state state
= u_bit_scan(&dirty
);
1529 ilo_printf(" %s", state_names
[state
]);