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])
296 ilo_bind_fragment_sampler_states(struct pipe_context
*pipe
,
297 unsigned num_samplers
,
300 struct ilo_context
*ilo
= ilo_context(pipe
);
302 if (ilo_bind_sampler_states(pipe
, PIPE_SHADER_FRAGMENT
,
303 0, num_samplers
, samplers
))
304 ilo
->dirty
|= ILO_DIRTY_SAMPLER_FS
;
306 if (ilo
->sampler
[PIPE_SHADER_FRAGMENT
].count
> num_samplers
) {
307 ilo_bind_sampler_states(pipe
, PIPE_SHADER_FRAGMENT
, num_samplers
,
308 ilo
->sampler
[PIPE_SHADER_FRAGMENT
].count
- num_samplers
, NULL
);
313 ilo_bind_vertex_sampler_states(struct pipe_context
*pipe
,
314 unsigned num_samplers
,
317 struct ilo_context
*ilo
= ilo_context(pipe
);
319 if (ilo_bind_sampler_states(pipe
, PIPE_SHADER_VERTEX
,
320 0, num_samplers
, samplers
))
321 ilo
->dirty
|= ILO_DIRTY_SAMPLER_VS
;
323 if (ilo
->sampler
[PIPE_SHADER_VERTEX
].count
> num_samplers
) {
324 ilo_bind_sampler_states(pipe
, PIPE_SHADER_VERTEX
, num_samplers
,
325 ilo
->sampler
[PIPE_SHADER_VERTEX
].count
- num_samplers
, NULL
);
330 ilo_bind_geometry_sampler_states(struct pipe_context
*pipe
,
331 unsigned num_samplers
,
334 struct ilo_context
*ilo
= ilo_context(pipe
);
336 if (ilo_bind_sampler_states(pipe
, PIPE_SHADER_GEOMETRY
,
337 0, num_samplers
, samplers
))
338 ilo
->dirty
|= ILO_DIRTY_SAMPLER_GS
;
340 if (ilo
->sampler
[PIPE_SHADER_GEOMETRY
].count
> num_samplers
) {
341 ilo_bind_sampler_states(pipe
, PIPE_SHADER_GEOMETRY
, num_samplers
,
342 ilo
->sampler
[PIPE_SHADER_GEOMETRY
].count
- num_samplers
, NULL
);
347 ilo_bind_compute_sampler_states(struct pipe_context
*pipe
,
349 unsigned num_samplers
,
352 struct ilo_context
*ilo
= ilo_context(pipe
);
354 if (ilo_bind_sampler_states(pipe
, PIPE_SHADER_COMPUTE
,
355 start_slot
, num_samplers
, samplers
))
356 ilo
->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 struct ilo_context
*ilo
= ilo_context(pipe
);
370 struct ilo_rasterizer_state
*rast
;
372 rast
= MALLOC_STRUCT(ilo_rasterizer_state
);
375 rast
->state
= *state
;
376 ilo_gpe_init_rasterizer(ilo
->dev
, state
, rast
);
382 ilo_bind_rasterizer_state(struct pipe_context
*pipe
, void *state
)
384 struct ilo_context
*ilo
= ilo_context(pipe
);
386 ilo
->rasterizer
= state
;
388 ilo
->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 struct ilo_context
*ilo
= ilo_context(pipe
);
402 struct ilo_dsa_state
*dsa
;
404 dsa
= MALLOC_STRUCT(ilo_dsa_state
);
407 ilo_gpe_init_dsa(ilo
->dev
, state
, dsa
);
413 ilo_bind_depth_stencil_alpha_state(struct pipe_context
*pipe
, void *state
)
415 struct ilo_context
*ilo
= ilo_context(pipe
);
419 ilo
->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
);
438 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
444 ilo_bind_fs_state(struct pipe_context
*pipe
, void *state
)
446 struct ilo_context
*ilo
= ilo_context(pipe
);
450 ilo
->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
);
473 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
479 ilo_bind_vs_state(struct pipe_context
*pipe
, void *state
)
481 struct ilo_context
*ilo
= ilo_context(pipe
);
485 ilo
->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
);
508 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
514 ilo_bind_gs_state(struct pipe_context
*pipe
, void *state
)
516 struct ilo_context
*ilo
= ilo_context(pipe
);
518 /* util_blitter may set this unnecessarily */
519 if (ilo
->gs
== state
)
524 ilo
->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 struct ilo_context
*ilo
= ilo_context(pipe
);
543 struct ilo_ve_state
*ve
;
545 ve
= MALLOC_STRUCT(ilo_ve_state
);
548 ilo_gpe_init_ve(ilo
->dev
, num_elements
, elements
, ve
);
554 ilo_bind_vertex_elements_state(struct pipe_context
*pipe
, void *state
)
556 struct ilo_context
*ilo
= ilo_context(pipe
);
560 ilo
->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_context
*ilo
= ilo_context(pipe
);
577 ilo
->blend_color
= *state
;
579 ilo
->dirty
|= ILO_DIRTY_BLEND_COLOR
;
583 ilo_set_stencil_ref(struct pipe_context
*pipe
,
584 const struct pipe_stencil_ref
*state
)
586 struct ilo_context
*ilo
= ilo_context(pipe
);
588 /* util_blitter may set this unnecessarily */
589 if (!memcmp(&ilo
->stencil_ref
, state
, sizeof(*state
)))
592 ilo
->stencil_ref
= *state
;
594 ilo
->dirty
|= ILO_DIRTY_STENCIL_REF
;
598 ilo_set_sample_mask(struct pipe_context
*pipe
,
599 unsigned sample_mask
)
601 struct ilo_context
*ilo
= ilo_context(pipe
);
603 /* util_blitter may set this unnecessarily */
604 if (ilo
->sample_mask
== sample_mask
)
607 ilo
->sample_mask
= sample_mask
;
609 ilo
->dirty
|= ILO_DIRTY_SAMPLE_MASK
;
613 ilo_set_clip_state(struct pipe_context
*pipe
,
614 const struct pipe_clip_state
*state
)
616 struct ilo_context
*ilo
= ilo_context(pipe
);
620 ilo
->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 struct ilo_context
*ilo
= ilo_context(pipe
);
629 struct ilo_cbuf_state
*cbuf
= &ilo
->cbuf
[shader
];
630 const unsigned count
= 1;
633 assert(shader
< Elements(ilo
->cbuf
));
634 assert(index
+ count
<= Elements(ilo
->cbuf
[shader
].cso
));
637 for (i
= 0; i
< count
; i
++) {
638 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
640 pipe_resource_reference(&cso
->resource
, buf
[i
].buffer
);
643 const enum pipe_format elem_format
=
644 PIPE_FORMAT_R32G32B32A32_FLOAT
;
646 ilo_gpe_init_view_surface_for_buffer(ilo
->dev
,
647 ilo_buffer(buf
[i
].buffer
),
648 buf
[i
].buffer_offset
, buf
[i
].buffer_size
,
649 util_format_get_blocksize(elem_format
), elem_format
,
650 false, false, &cso
->surface
);
652 cso
->user_buffer
= NULL
;
653 cso
->user_buffer_size
= 0;
655 cbuf
->enabled_mask
|= 1 << (index
+ i
);
657 else if (buf
[i
].user_buffer
) {
658 cso
->surface
.bo
= NULL
;
660 /* buffer_offset does not apply for user buffer */
661 cso
->user_buffer
= buf
[i
].user_buffer
;
662 cso
->user_buffer_size
= buf
[i
].buffer_size
;
664 cbuf
->enabled_mask
|= 1 << (index
+ i
);
667 cso
->surface
.bo
= NULL
;
668 cso
->user_buffer
= NULL
;
669 cso
->user_buffer_size
= 0;
671 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
676 for (i
= 0; i
< count
; i
++) {
677 struct ilo_cbuf_cso
*cso
= &cbuf
->cso
[index
+ i
];
679 pipe_resource_reference(&cso
->resource
, NULL
);
680 cso
->surface
.bo
= NULL
;
681 cso
->user_buffer
= NULL
;
682 cso
->user_buffer_size
= 0;
684 cbuf
->enabled_mask
&= ~(1 << (index
+ i
));
688 ilo
->dirty
|= ILO_DIRTY_CBUF
;
692 ilo_set_framebuffer_state(struct pipe_context
*pipe
,
693 const struct pipe_framebuffer_state
*state
)
695 struct ilo_context
*ilo
= ilo_context(pipe
);
697 util_copy_framebuffer_state(&ilo
->fb
.state
, state
);
700 ilo
->fb
.num_samples
= state
->cbufs
[0]->texture
->nr_samples
;
701 else if (state
->zsbuf
)
702 ilo
->fb
.num_samples
= state
->zsbuf
->texture
->nr_samples
;
704 ilo
->fb
.num_samples
= 1;
706 if (!ilo
->fb
.num_samples
)
707 ilo
->fb
.num_samples
= 1;
709 ilo
->dirty
|= ILO_DIRTY_FB
;
713 ilo_set_polygon_stipple(struct pipe_context
*pipe
,
714 const struct pipe_poly_stipple
*state
)
716 struct ilo_context
*ilo
= ilo_context(pipe
);
718 ilo
->poly_stipple
= *state
;
720 ilo
->dirty
|= ILO_DIRTY_POLY_STIPPLE
;
724 ilo_set_scissor_states(struct pipe_context
*pipe
,
726 unsigned num_scissors
,
727 const struct pipe_scissor_state
*scissors
)
729 struct ilo_context
*ilo
= ilo_context(pipe
);
731 ilo_gpe_set_scissor(ilo
->dev
, start_slot
, num_scissors
,
732 scissors
, &ilo
->scissor
);
734 ilo
->dirty
|= ILO_DIRTY_SCISSOR
;
738 ilo_set_viewport_states(struct pipe_context
*pipe
,
740 unsigned num_viewports
,
741 const struct pipe_viewport_state
*viewports
)
743 struct ilo_context
*ilo
= ilo_context(pipe
);
748 for (i
= 0; i
< num_viewports
; i
++) {
749 ilo_gpe_set_viewport_cso(ilo
->dev
, &viewports
[i
],
750 &ilo
->viewport
.cso
[start_slot
+ i
]);
753 if (ilo
->viewport
.count
< start_slot
+ num_viewports
)
754 ilo
->viewport
.count
= start_slot
+ num_viewports
;
756 /* need to save viewport 0 for util_blitter */
757 if (!start_slot
&& num_viewports
)
758 ilo
->viewport
.viewport0
= viewports
[0];
761 if (ilo
->viewport
.count
<= start_slot
+ num_viewports
&&
762 ilo
->viewport
.count
> start_slot
)
763 ilo
->viewport
.count
= start_slot
;
766 ilo
->dirty
|= ILO_DIRTY_VIEWPORT
;
770 ilo_set_sampler_views(struct pipe_context
*pipe
, unsigned shader
,
771 unsigned start
, unsigned count
,
772 struct pipe_sampler_view
**views
)
774 struct ilo_context
*ilo
= ilo_context(pipe
);
775 struct ilo_view_state
*dst
= &ilo
->view
[shader
];
778 assert(start
+ count
<= Elements(dst
->states
));
781 for (i
= 0; i
< count
; i
++)
782 pipe_sampler_view_reference(&dst
->states
[start
+ i
], views
[i
]);
785 for (i
= 0; i
< count
; i
++)
786 pipe_sampler_view_reference(&dst
->states
[start
+ i
], NULL
);
789 if (dst
->count
<= start
+ count
) {
795 while (count
> 0 && !dst
->states
[count
- 1])
803 ilo_set_fragment_sampler_views(struct pipe_context
*pipe
,
805 struct pipe_sampler_view
**views
)
807 struct ilo_context
*ilo
= ilo_context(pipe
);
809 ilo_set_sampler_views(pipe
, PIPE_SHADER_FRAGMENT
, 0, num_views
, views
);
811 if (ilo
->view
[PIPE_SHADER_FRAGMENT
].count
> num_views
) {
812 ilo_set_sampler_views(pipe
, PIPE_SHADER_FRAGMENT
, num_views
,
813 ilo
->view
[PIPE_SHADER_FRAGMENT
].count
- num_views
, NULL
);
816 ilo
->dirty
|= ILO_DIRTY_VIEW_FS
;
820 ilo_set_vertex_sampler_views(struct pipe_context
*pipe
,
822 struct pipe_sampler_view
**views
)
824 struct ilo_context
*ilo
= ilo_context(pipe
);
826 ilo_set_sampler_views(pipe
, PIPE_SHADER_VERTEX
, 0, num_views
, views
);
828 if (ilo
->view
[PIPE_SHADER_VERTEX
].count
> num_views
) {
829 ilo_set_sampler_views(pipe
, PIPE_SHADER_VERTEX
, num_views
,
830 ilo
->view
[PIPE_SHADER_VERTEX
].count
- num_views
, NULL
);
833 ilo
->dirty
|= ILO_DIRTY_VIEW_VS
;
837 ilo_set_geometry_sampler_views(struct pipe_context
*pipe
,
839 struct pipe_sampler_view
**views
)
841 struct ilo_context
*ilo
= ilo_context(pipe
);
843 ilo_set_sampler_views(pipe
, PIPE_SHADER_GEOMETRY
, 0, num_views
, views
);
845 if (ilo
->view
[PIPE_SHADER_GEOMETRY
].count
> num_views
) {
846 ilo_set_sampler_views(pipe
, PIPE_SHADER_GEOMETRY
, num_views
,
847 ilo
->view
[PIPE_SHADER_GEOMETRY
].count
- num_views
, NULL
);
850 ilo
->dirty
|= ILO_DIRTY_VIEW_GS
;
854 ilo_set_compute_sampler_views(struct pipe_context
*pipe
,
855 unsigned start_slot
, unsigned num_views
,
856 struct pipe_sampler_view
**views
)
858 struct ilo_context
*ilo
= ilo_context(pipe
);
860 ilo_set_sampler_views(pipe
, PIPE_SHADER_COMPUTE
,
861 start_slot
, num_views
, views
);
863 ilo
->dirty
|= ILO_DIRTY_VIEW_CS
;
867 ilo_set_shader_resources(struct pipe_context
*pipe
,
868 unsigned start
, unsigned count
,
869 struct pipe_surface
**surfaces
)
871 struct ilo_context
*ilo
= ilo_context(pipe
);
872 struct ilo_resource_state
*dst
= &ilo
->resource
;
875 assert(start
+ count
<= Elements(dst
->states
));
878 for (i
= 0; i
< count
; i
++)
879 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
882 for (i
= 0; i
< count
; i
++)
883 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
886 if (dst
->count
<= start
+ count
) {
892 while (count
> 0 && !dst
->states
[count
- 1])
898 ilo
->dirty
|= ILO_DIRTY_RESOURCE
;
902 ilo_set_vertex_buffers(struct pipe_context
*pipe
,
903 unsigned start_slot
, unsigned num_buffers
,
904 const struct pipe_vertex_buffer
*buffers
)
906 struct ilo_context
*ilo
= ilo_context(pipe
);
909 /* no PIPE_CAP_USER_VERTEX_BUFFERS */
911 for (i
= 0; i
< num_buffers
; i
++)
912 assert(!buffers
[i
].user_buffer
);
915 util_set_vertex_buffers_mask(ilo
->vb
.states
,
916 &ilo
->vb
.enabled_mask
, buffers
, start_slot
, num_buffers
);
918 ilo
->dirty
|= ILO_DIRTY_VB
;
922 ilo_set_index_buffer(struct pipe_context
*pipe
,
923 const struct pipe_index_buffer
*state
)
925 struct ilo_context
*ilo
= ilo_context(pipe
);
928 pipe_resource_reference(&ilo
->ib
.buffer
, state
->buffer
);
929 ilo
->ib
.user_buffer
= state
->user_buffer
;
930 ilo
->ib
.offset
= state
->offset
;
931 ilo
->ib
.index_size
= state
->index_size
;
934 pipe_resource_reference(&ilo
->ib
.buffer
, NULL
);
935 ilo
->ib
.user_buffer
= NULL
;
937 ilo
->ib
.index_size
= 0;
940 ilo
->dirty
|= ILO_DIRTY_IB
;
943 static struct pipe_stream_output_target
*
944 ilo_create_stream_output_target(struct pipe_context
*pipe
,
945 struct pipe_resource
*res
,
946 unsigned buffer_offset
,
947 unsigned buffer_size
)
949 struct pipe_stream_output_target
*target
;
951 target
= MALLOC_STRUCT(pipe_stream_output_target
);
954 pipe_reference_init(&target
->reference
, 1);
955 target
->buffer
= NULL
;
956 pipe_resource_reference(&target
->buffer
, res
);
957 target
->context
= pipe
;
958 target
->buffer_offset
= buffer_offset
;
959 target
->buffer_size
= buffer_size
;
965 ilo_set_stream_output_targets(struct pipe_context
*pipe
,
966 unsigned num_targets
,
967 struct pipe_stream_output_target
**targets
,
968 unsigned append_bitmask
)
970 struct ilo_context
*ilo
= ilo_context(pipe
);
976 /* util_blitter may set this unnecessarily */
977 if (!ilo
->so
.count
&& !num_targets
)
980 for (i
= 0; i
< num_targets
; i
++)
981 pipe_so_target_reference(&ilo
->so
.states
[i
], targets
[i
]);
983 for (; i
< ilo
->so
.count
; i
++)
984 pipe_so_target_reference(&ilo
->so
.states
[i
], NULL
);
986 ilo
->so
.count
= num_targets
;
987 ilo
->so
.append_bitmask
= append_bitmask
;
989 ilo
->so
.enabled
= (ilo
->so
.count
> 0);
991 ilo
->dirty
|= ILO_DIRTY_SO
;
995 ilo_stream_output_target_destroy(struct pipe_context
*pipe
,
996 struct pipe_stream_output_target
*target
)
998 pipe_resource_reference(&target
->buffer
, NULL
);
1002 static struct pipe_sampler_view
*
1003 ilo_create_sampler_view(struct pipe_context
*pipe
,
1004 struct pipe_resource
*res
,
1005 const struct pipe_sampler_view
*templ
)
1007 struct ilo_context
*ilo
= ilo_context(pipe
);
1008 struct ilo_view_cso
*view
;
1010 view
= MALLOC_STRUCT(ilo_view_cso
);
1013 view
->base
= *templ
;
1014 pipe_reference_init(&view
->base
.reference
, 1);
1015 view
->base
.texture
= NULL
;
1016 pipe_resource_reference(&view
->base
.texture
, res
);
1017 view
->base
.context
= pipe
;
1019 if (res
->target
== PIPE_BUFFER
) {
1020 const unsigned elem_size
= util_format_get_blocksize(templ
->format
);
1021 const unsigned first_elem
= templ
->u
.buf
.first_element
;
1022 const unsigned num_elems
= templ
->u
.buf
.last_element
- first_elem
+ 1;
1024 ilo_gpe_init_view_surface_for_buffer(ilo
->dev
, ilo_buffer(res
),
1025 first_elem
* elem_size
, num_elems
* elem_size
,
1026 elem_size
, templ
->format
, false, false, &view
->surface
);
1029 struct ilo_texture
*tex
= ilo_texture(res
);
1031 /* warn about degraded performance because of a missing binding flag */
1032 if (tex
->tiling
== INTEL_TILING_NONE
&&
1033 !(tex
->base
.bind
& PIPE_BIND_SAMPLER_VIEW
)) {
1034 ilo_warn("creating sampler view for a resource "
1035 "not created for sampling\n");
1038 ilo_gpe_init_view_surface_for_texture(ilo
->dev
, tex
,
1040 templ
->u
.tex
.first_level
,
1041 templ
->u
.tex
.last_level
- templ
->u
.tex
.first_level
+ 1,
1042 templ
->u
.tex
.first_layer
,
1043 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1044 false, false, &view
->surface
);
1051 ilo_sampler_view_destroy(struct pipe_context
*pipe
,
1052 struct pipe_sampler_view
*view
)
1054 pipe_resource_reference(&view
->texture
, NULL
);
1058 static struct pipe_surface
*
1059 ilo_create_surface(struct pipe_context
*pipe
,
1060 struct pipe_resource
*res
,
1061 const struct pipe_surface
*templ
)
1063 struct ilo_context
*ilo
= ilo_context(pipe
);
1064 struct ilo_surface_cso
*surf
;
1066 surf
= MALLOC_STRUCT(ilo_surface_cso
);
1069 surf
->base
= *templ
;
1070 pipe_reference_init(&surf
->base
.reference
, 1);
1071 surf
->base
.texture
= NULL
;
1072 pipe_resource_reference(&surf
->base
.texture
, res
);
1074 surf
->base
.context
= pipe
;
1075 surf
->base
.width
= u_minify(res
->width0
, templ
->u
.tex
.level
);
1076 surf
->base
.height
= u_minify(res
->height0
, templ
->u
.tex
.level
);
1078 surf
->is_rt
= !util_format_is_depth_or_stencil(templ
->format
);
1082 assert(res
->target
!= PIPE_BUFFER
);
1085 * classic i965 sets render_cache_rw for constant buffers and sol
1086 * surfaces but not render buffers. Why?
1088 ilo_gpe_init_view_surface_for_texture(ilo
->dev
, ilo_texture(res
),
1089 templ
->format
, templ
->u
.tex
.level
, 1,
1090 templ
->u
.tex
.first_layer
,
1091 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1092 true, true, &surf
->u
.rt
);
1095 assert(res
->target
!= PIPE_BUFFER
);
1097 ilo_gpe_init_zs_surface(ilo
->dev
, ilo_texture(res
),
1098 templ
->format
, templ
->u
.tex
.level
,
1099 templ
->u
.tex
.first_layer
,
1100 templ
->u
.tex
.last_layer
- templ
->u
.tex
.first_layer
+ 1,
1108 ilo_surface_destroy(struct pipe_context
*pipe
,
1109 struct pipe_surface
*surface
)
1111 pipe_resource_reference(&surface
->texture
, NULL
);
1116 ilo_create_compute_state(struct pipe_context
*pipe
,
1117 const struct pipe_compute_state
*state
)
1119 struct ilo_context
*ilo
= ilo_context(pipe
);
1120 struct ilo_shader_state
*shader
;
1122 shader
= ilo_shader_create_cs(ilo
->dev
, state
, ilo
);
1125 ilo_shader_cache_add(ilo
->shader_cache
, shader
);
1131 ilo_bind_compute_state(struct pipe_context
*pipe
, void *state
)
1133 struct ilo_context
*ilo
= ilo_context(pipe
);
1137 ilo
->dirty
|= ILO_DIRTY_CS
;
1141 ilo_delete_compute_state(struct pipe_context
*pipe
, void *state
)
1143 struct ilo_context
*ilo
= ilo_context(pipe
);
1144 struct ilo_shader_state
*cs
= (struct ilo_shader_state
*) state
;
1146 ilo_shader_cache_remove(ilo
->shader_cache
, cs
);
1147 ilo_shader_destroy(cs
);
1151 ilo_set_compute_resources(struct pipe_context
*pipe
,
1152 unsigned start
, unsigned count
,
1153 struct pipe_surface
**surfaces
)
1155 struct ilo_context
*ilo
= ilo_context(pipe
);
1156 struct ilo_resource_state
*dst
= &ilo
->cs_resource
;
1159 assert(start
+ count
<= Elements(dst
->states
));
1162 for (i
= 0; i
< count
; i
++)
1163 pipe_surface_reference(&dst
->states
[start
+ i
], surfaces
[i
]);
1166 for (i
= 0; i
< count
; i
++)
1167 pipe_surface_reference(&dst
->states
[start
+ i
], NULL
);
1170 if (dst
->count
<= start
+ count
) {
1176 while (count
> 0 && !dst
->states
[count
- 1])
1182 ilo
->dirty
|= ILO_DIRTY_CS_RESOURCE
;
1186 ilo_set_global_binding(struct pipe_context
*pipe
,
1187 unsigned start
, unsigned count
,
1188 struct pipe_resource
**resources
,
1191 struct ilo_context
*ilo
= ilo_context(pipe
);
1192 struct ilo_global_binding
*dst
= &ilo
->global_binding
;
1195 assert(start
+ count
<= Elements(dst
->resources
));
1198 for (i
= 0; i
< count
; i
++)
1199 pipe_resource_reference(&dst
->resources
[start
+ i
], resources
[i
]);
1202 for (i
= 0; i
< count
; i
++)
1203 pipe_resource_reference(&dst
->resources
[start
+ i
], NULL
);
1206 if (dst
->count
<= start
+ count
) {
1212 while (count
> 0 && !dst
->resources
[count
- 1])
1218 ilo
->dirty
|= ILO_DIRTY_GLOBAL_BINDING
;
1222 * Initialize state-related functions.
1225 ilo_init_state_functions(struct ilo_context
*ilo
)
1227 STATIC_ASSERT(ILO_STATE_COUNT
<= 32);
1229 ilo
->base
.create_blend_state
= ilo_create_blend_state
;
1230 ilo
->base
.bind_blend_state
= ilo_bind_blend_state
;
1231 ilo
->base
.delete_blend_state
= ilo_delete_blend_state
;
1232 ilo
->base
.create_sampler_state
= ilo_create_sampler_state
;
1233 ilo
->base
.bind_fragment_sampler_states
= ilo_bind_fragment_sampler_states
;
1234 ilo
->base
.bind_vertex_sampler_states
= ilo_bind_vertex_sampler_states
;
1235 ilo
->base
.bind_geometry_sampler_states
= ilo_bind_geometry_sampler_states
;
1236 ilo
->base
.bind_compute_sampler_states
= ilo_bind_compute_sampler_states
;
1237 ilo
->base
.delete_sampler_state
= ilo_delete_sampler_state
;
1238 ilo
->base
.create_rasterizer_state
= ilo_create_rasterizer_state
;
1239 ilo
->base
.bind_rasterizer_state
= ilo_bind_rasterizer_state
;
1240 ilo
->base
.delete_rasterizer_state
= ilo_delete_rasterizer_state
;
1241 ilo
->base
.create_depth_stencil_alpha_state
= ilo_create_depth_stencil_alpha_state
;
1242 ilo
->base
.bind_depth_stencil_alpha_state
= ilo_bind_depth_stencil_alpha_state
;
1243 ilo
->base
.delete_depth_stencil_alpha_state
= ilo_delete_depth_stencil_alpha_state
;
1244 ilo
->base
.create_fs_state
= ilo_create_fs_state
;
1245 ilo
->base
.bind_fs_state
= ilo_bind_fs_state
;
1246 ilo
->base
.delete_fs_state
= ilo_delete_fs_state
;
1247 ilo
->base
.create_vs_state
= ilo_create_vs_state
;
1248 ilo
->base
.bind_vs_state
= ilo_bind_vs_state
;
1249 ilo
->base
.delete_vs_state
= ilo_delete_vs_state
;
1250 ilo
->base
.create_gs_state
= ilo_create_gs_state
;
1251 ilo
->base
.bind_gs_state
= ilo_bind_gs_state
;
1252 ilo
->base
.delete_gs_state
= ilo_delete_gs_state
;
1253 ilo
->base
.create_vertex_elements_state
= ilo_create_vertex_elements_state
;
1254 ilo
->base
.bind_vertex_elements_state
= ilo_bind_vertex_elements_state
;
1255 ilo
->base
.delete_vertex_elements_state
= ilo_delete_vertex_elements_state
;
1257 ilo
->base
.set_blend_color
= ilo_set_blend_color
;
1258 ilo
->base
.set_stencil_ref
= ilo_set_stencil_ref
;
1259 ilo
->base
.set_sample_mask
= ilo_set_sample_mask
;
1260 ilo
->base
.set_clip_state
= ilo_set_clip_state
;
1261 ilo
->base
.set_constant_buffer
= ilo_set_constant_buffer
;
1262 ilo
->base
.set_framebuffer_state
= ilo_set_framebuffer_state
;
1263 ilo
->base
.set_polygon_stipple
= ilo_set_polygon_stipple
;
1264 ilo
->base
.set_scissor_states
= ilo_set_scissor_states
;
1265 ilo
->base
.set_viewport_states
= ilo_set_viewport_states
;
1266 ilo
->base
.set_fragment_sampler_views
= ilo_set_fragment_sampler_views
;
1267 ilo
->base
.set_vertex_sampler_views
= ilo_set_vertex_sampler_views
;
1268 ilo
->base
.set_geometry_sampler_views
= ilo_set_geometry_sampler_views
;
1269 ilo
->base
.set_compute_sampler_views
= ilo_set_compute_sampler_views
;
1270 ilo
->base
.set_shader_resources
= ilo_set_shader_resources
;
1271 ilo
->base
.set_vertex_buffers
= ilo_set_vertex_buffers
;
1272 ilo
->base
.set_index_buffer
= ilo_set_index_buffer
;
1274 ilo
->base
.create_stream_output_target
= ilo_create_stream_output_target
;
1275 ilo
->base
.stream_output_target_destroy
= ilo_stream_output_target_destroy
;
1276 ilo
->base
.set_stream_output_targets
= ilo_set_stream_output_targets
;
1278 ilo
->base
.create_sampler_view
= ilo_create_sampler_view
;
1279 ilo
->base
.sampler_view_destroy
= ilo_sampler_view_destroy
;
1281 ilo
->base
.create_surface
= ilo_create_surface
;
1282 ilo
->base
.surface_destroy
= ilo_surface_destroy
;
1284 ilo
->base
.create_compute_state
= ilo_create_compute_state
;
1285 ilo
->base
.bind_compute_state
= ilo_bind_compute_state
;
1286 ilo
->base
.delete_compute_state
= ilo_delete_compute_state
;
1287 ilo
->base
.set_compute_resources
= ilo_set_compute_resources
;
1288 ilo
->base
.set_global_binding
= ilo_set_global_binding
;
1292 ilo_init_states(struct ilo_context
*ilo
)
1294 ilo_gpe_set_scissor_null(ilo
->dev
, &ilo
->scissor
);
1296 ilo_gpe_init_zs_surface(ilo
->dev
, NULL
,
1297 PIPE_FORMAT_NONE
, 0, 0, 1, &ilo
->fb
.null_zs
);
1299 ilo
->dirty
= ILO_DIRTY_ALL
;
1303 ilo_cleanup_states(struct ilo_context
*ilo
)
1307 for (i
= 0; i
< Elements(ilo
->vb
.states
); i
++) {
1308 if (ilo
->vb
.enabled_mask
& (1 << i
))
1309 pipe_resource_reference(&ilo
->vb
.states
[i
].buffer
, NULL
);
1312 pipe_resource_reference(&ilo
->ib
.buffer
, NULL
);
1313 pipe_resource_reference(&ilo
->ib
.hw_resource
, NULL
);
1315 for (i
= 0; i
< ilo
->so
.count
; i
++)
1316 pipe_so_target_reference(&ilo
->so
.states
[i
], NULL
);
1318 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1319 for (i
= 0; i
< ilo
->view
[sh
].count
; i
++) {
1320 struct pipe_sampler_view
*view
= ilo
->view
[sh
].states
[i
];
1321 pipe_sampler_view_reference(&view
, NULL
);
1324 for (i
= 0; i
< Elements(ilo
->cbuf
[sh
].cso
); i
++) {
1325 struct ilo_cbuf_cso
*cbuf
= &ilo
->cbuf
[sh
].cso
[i
];
1326 pipe_resource_reference(&cbuf
->resource
, NULL
);
1330 for (i
= 0; i
< ilo
->resource
.count
; i
++)
1331 pipe_surface_reference(&ilo
->resource
.states
[i
], NULL
);
1333 for (i
= 0; i
< ilo
->fb
.state
.nr_cbufs
; i
++)
1334 pipe_surface_reference(&ilo
->fb
.state
.cbufs
[i
], NULL
);
1336 if (ilo
->fb
.state
.zsbuf
)
1337 pipe_surface_reference(&ilo
->fb
.state
.zsbuf
, NULL
);
1339 for (i
= 0; i
< ilo
->cs_resource
.count
; i
++)
1340 pipe_surface_reference(&ilo
->cs_resource
.states
[i
], NULL
);
1342 for (i
= 0; i
< ilo
->global_binding
.count
; i
++)
1343 pipe_resource_reference(&ilo
->global_binding
.resources
[i
], NULL
);
1347 * Mark all states that have the resource dirty.
1350 ilo_mark_states_with_resource_dirty(struct ilo_context
*ilo
,
1351 const struct pipe_resource
*res
)
1353 uint32_t states
= 0;
1356 if (res
->target
== PIPE_BUFFER
) {
1357 uint32_t vb_mask
= ilo
->vb
.enabled_mask
;
1360 const unsigned idx
= u_bit_scan(&vb_mask
);
1362 if (ilo
->vb
.states
[idx
].buffer
== res
) {
1363 states
|= ILO_DIRTY_VB
;
1368 if (ilo
->ib
.buffer
== res
) {
1369 states
|= ILO_DIRTY_IB
;
1372 * finalize_index_buffer() has an optimization that clears
1373 * ILO_DIRTY_IB when the HW states do not change. However, it fails
1374 * to flush the VF cache when the HW states do not change, but the
1375 * contents of the IB has changed. Here, we set the index size to an
1376 * invalid value to avoid the optimization.
1378 ilo
->ib
.hw_index_size
= 0;
1381 for (i
= 0; i
< ilo
->so
.count
; i
++) {
1382 if (ilo
->so
.states
[i
]->buffer
== res
) {
1383 states
|= ILO_DIRTY_SO
;
1389 for (sh
= 0; sh
< PIPE_SHADER_TYPES
; sh
++) {
1390 for (i
= 0; i
< ilo
->view
[sh
].count
; i
++) {
1391 struct pipe_sampler_view
*view
= ilo
->view
[sh
].states
[i
];
1393 if (view
->texture
== res
) {
1394 static const unsigned view_dirty_bits
[PIPE_SHADER_TYPES
] = {
1395 [PIPE_SHADER_VERTEX
] = ILO_DIRTY_VIEW_VS
,
1396 [PIPE_SHADER_FRAGMENT
] = ILO_DIRTY_VIEW_FS
,
1397 [PIPE_SHADER_GEOMETRY
] = ILO_DIRTY_VIEW_GS
,
1398 [PIPE_SHADER_COMPUTE
] = ILO_DIRTY_VIEW_CS
,
1401 states
|= view_dirty_bits
[sh
];
1406 if (res
->target
== PIPE_BUFFER
) {
1407 for (i
= 0; i
< Elements(ilo
->cbuf
[sh
].cso
); i
++) {
1408 struct ilo_cbuf_cso
*cbuf
= &ilo
->cbuf
[sh
].cso
[i
];
1410 if (cbuf
->resource
== res
) {
1411 states
|= ILO_DIRTY_CBUF
;
1418 for (i
= 0; i
< ilo
->resource
.count
; i
++) {
1419 if (ilo
->resource
.states
[i
]->texture
== res
) {
1420 states
|= ILO_DIRTY_RESOURCE
;
1426 if (res
->target
!= PIPE_BUFFER
) {
1427 for (i
= 0; i
< ilo
->fb
.state
.nr_cbufs
; i
++) {
1428 if (ilo
->fb
.state
.cbufs
[i
]->texture
== res
) {
1429 states
|= ILO_DIRTY_FB
;
1434 if (ilo
->fb
.state
.zsbuf
&& ilo
->fb
.state
.zsbuf
->texture
== res
)
1435 states
|= ILO_DIRTY_FB
;
1438 for (i
= 0; i
< ilo
->cs_resource
.count
; i
++) {
1439 pipe_surface_reference(&ilo
->cs_resource
.states
[i
], NULL
);
1440 if (ilo
->cs_resource
.states
[i
]->texture
== res
) {
1441 states
|= ILO_DIRTY_CS_RESOURCE
;
1446 for (i
= 0; i
< ilo
->global_binding
.count
; i
++) {
1447 if (ilo
->global_binding
.resources
[i
] == res
) {
1448 states
|= ILO_DIRTY_GLOBAL_BINDING
;
1453 ilo
->dirty
|= states
;