2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keithw@vmware.com>
34 #include "brw_context.h"
35 #include "brw_state.h"
36 #include "drivers/common/meta.h"
37 #include "intel_batchbuffer.h"
38 #include "intel_buffers.h"
40 #include "brw_ff_gs.h"
44 static const struct brw_tracked_state
*gen4_atoms
[] =
46 &brw_interpolation_map
,
48 &brw_clip_prog
, /* must do before state base address */
49 &brw_sf_prog
, /* must do before state base address */
51 /* Once all the programs are done, we know how large urb entry
52 * sizes need to be and can decide if we need to change the urb
56 &brw_recalculate_urb_fence
,
61 /* Surface state setup. Must come before the VS/WM unit. The binding
62 * table upload must be last.
64 &brw_vs_pull_constants
,
65 &brw_wm_pull_constants
,
66 &brw_renderbuffer_surfaces
,
67 &brw_texture_surfaces
,
68 &brw_vs_binding_table
,
69 &brw_wm_binding_table
,
74 /* These set up state for brw_psp_urb_cbs */
78 &brw_vs_unit
, /* always required, enabled or not */
85 &brw_state_base_address
,
87 &brw_binding_table_pointers
,
88 &brw_blend_constant_color
,
93 &brw_polygon_stipple_offset
,
96 &brw_aa_line_parameters
,
101 &brw_indices
, /* must come before brw_vertices */
108 static const struct brw_tracked_state
*gen6_atoms
[] =
113 /* Command packets: */
115 /* must do before binding table pointers, cc state ptrs */
116 &brw_state_base_address
,
119 &gen6_viewport_state
, /* must do after *_vp stages */
122 &gen6_blend_state
, /* must do before cc unit */
123 &gen6_color_calc_state
, /* must do before cc unit */
124 &gen6_depth_stencil_state
, /* must do before cc unit */
126 &gen6_vs_push_constants
, /* Before vs_state */
127 &gen6_gs_push_constants
, /* Before gs_state */
128 &gen6_wm_push_constants
, /* Before wm_state */
130 /* Surface state setup. Must come before the VS/WM unit. The binding
131 * table upload must be last.
133 &brw_vs_pull_constants
,
134 &brw_vs_ubo_surfaces
,
135 &brw_gs_pull_constants
,
136 &brw_gs_ubo_surfaces
,
137 &brw_wm_pull_constants
,
138 &brw_wm_ubo_surfaces
,
139 &gen6_renderbuffer_surfaces
,
140 &brw_texture_surfaces
,
142 &brw_vs_binding_table
,
143 &gen6_gs_binding_table
,
144 &brw_wm_binding_table
,
150 &gen6_multisample_state
,
160 &gen6_binding_table_pointers
,
164 &brw_polygon_stipple
,
165 &brw_polygon_stipple_offset
,
168 &brw_aa_line_parameters
,
172 &brw_indices
, /* must come before brw_vertices */
177 static const struct brw_tracked_state
*gen7_render_atoms
[] =
179 /* Command packets: */
181 /* must do before binding table pointers, cc state ptrs */
182 &brw_state_base_address
,
185 &gen7_sf_clip_viewport
,
187 &gen7_push_constant_space
,
189 &gen6_blend_state
, /* must do before cc unit */
190 &gen6_color_calc_state
, /* must do before cc unit */
191 &gen6_depth_stencil_state
, /* must do before cc unit */
193 &gen6_vs_push_constants
, /* Before vs_state */
194 &gen6_gs_push_constants
, /* Before gs_state */
195 &gen6_wm_push_constants
, /* Before wm_surfaces and constant_buffer */
197 /* Surface state setup. Must come before the VS/WM unit. The binding
198 * table upload must be last.
200 &brw_vs_pull_constants
,
201 &brw_vs_ubo_surfaces
,
202 &brw_vs_abo_surfaces
,
203 &brw_gs_pull_constants
,
204 &brw_gs_ubo_surfaces
,
205 &brw_gs_abo_surfaces
,
206 &brw_wm_pull_constants
,
207 &brw_wm_ubo_surfaces
,
208 &brw_wm_abo_surfaces
,
209 &gen6_renderbuffer_surfaces
,
210 &brw_texture_surfaces
,
211 &brw_vs_binding_table
,
212 &brw_gs_binding_table
,
213 &brw_wm_binding_table
,
218 &gen6_multisample_state
,
220 &gen7_disable_stages
,
234 &brw_polygon_stipple
,
235 &brw_polygon_stipple_offset
,
238 &brw_aa_line_parameters
,
242 &brw_indices
, /* must come before brw_vertices */
249 static const struct brw_tracked_state
*gen7_compute_atoms
[] =
253 static const struct brw_tracked_state
*gen8_render_atoms
[] =
255 /* Command packets: */
256 &gen8_state_base_address
,
259 &gen8_sf_clip_viewport
,
261 &gen7_push_constant_space
,
264 &gen6_color_calc_state
,
266 &gen6_vs_push_constants
, /* Before vs_state */
267 &gen6_gs_push_constants
, /* Before gs_state */
268 &gen6_wm_push_constants
, /* Before wm_surfaces and constant_buffer */
270 /* Surface state setup. Must come before the VS/WM unit. The binding
271 * table upload must be last.
273 &brw_vs_pull_constants
,
274 &brw_vs_ubo_surfaces
,
275 &brw_vs_abo_surfaces
,
276 &brw_gs_pull_constants
,
277 &brw_gs_ubo_surfaces
,
278 &brw_gs_abo_surfaces
,
279 &brw_wm_pull_constants
,
280 &brw_wm_ubo_surfaces
,
281 &brw_wm_abo_surfaces
,
282 &gen6_renderbuffer_surfaces
,
283 &brw_texture_surfaces
,
284 &brw_vs_binding_table
,
285 &brw_gs_binding_table
,
286 &brw_wm_binding_table
,
291 &gen8_multisample_state
,
293 &gen8_disable_stages
,
304 &gen8_wm_depth_stencil
,
311 &brw_polygon_stipple
,
312 &brw_polygon_stipple_offset
,
315 &brw_aa_line_parameters
,
329 static const struct brw_tracked_state
*gen8_compute_atoms
[] =
334 brw_upload_initial_gpu_state(struct brw_context
*brw
)
336 /* On platforms with hardware contexts, we can set our initial GPU state
337 * right away rather than doing it via state atoms. This saves a small
338 * amount of overhead on every draw call.
344 intel_emit_post_sync_nonzero_flush(brw
);
346 brw_upload_invariant_state(brw
);
348 /* Recommended optimization for Victim Cache eviction in pixel backend. */
351 OUT_BATCH(MI_LOAD_REGISTER_IMM
| (3 - 2));
352 OUT_BATCH(GEN7_CACHE_MODE_1
);
353 OUT_BATCH((GEN9_PARTIAL_RESOLVE_DISABLE_IN_VC
<< 16) |
354 GEN9_PARTIAL_RESOLVE_DISABLE_IN_VC
);
359 gen8_emit_3dstate_sample_pattern(brw
);
363 static inline const struct brw_tracked_state
*
364 brw_get_pipeline_atoms(struct brw_context
*brw
,
365 enum brw_pipeline pipeline
)
368 case BRW_RENDER_PIPELINE
:
369 return brw
->render_atoms
;
370 case BRW_COMPUTE_PIPELINE
:
371 return brw
->compute_atoms
;
373 STATIC_ASSERT(BRW_NUM_PIPELINES
== 2);
374 unreachable("Unsupported pipeline");
380 brw_copy_pipeline_atoms(struct brw_context
*brw
,
381 enum brw_pipeline pipeline
,
382 const struct brw_tracked_state
**atoms
,
385 /* This is to work around brw_context::atoms being declared const. We want
386 * it to be const, but it needs to be initialized somehow!
388 struct brw_tracked_state
*context_atoms
=
389 (struct brw_tracked_state
*) brw_get_pipeline_atoms(brw
, pipeline
);
391 for (int i
= 0; i
< num_atoms
; i
++) {
392 context_atoms
[i
] = *atoms
[i
];
393 assert(context_atoms
[i
].dirty
.mesa
| context_atoms
[i
].dirty
.brw
);
394 assert(context_atoms
[i
].emit
);
397 brw
->num_atoms
[pipeline
] = num_atoms
;
400 void brw_init_state( struct brw_context
*brw
)
402 struct gl_context
*ctx
= &brw
->ctx
;
404 STATIC_ASSERT(ARRAY_SIZE(gen4_atoms
) <= ARRAY_SIZE(brw
->render_atoms
));
405 STATIC_ASSERT(ARRAY_SIZE(gen6_atoms
) <= ARRAY_SIZE(brw
->render_atoms
));
406 STATIC_ASSERT(ARRAY_SIZE(gen7_render_atoms
) <=
407 ARRAY_SIZE(brw
->render_atoms
));
408 STATIC_ASSERT(ARRAY_SIZE(gen8_render_atoms
) <=
409 ARRAY_SIZE(brw
->render_atoms
));
410 STATIC_ASSERT(ARRAY_SIZE(gen7_compute_atoms
) <=
411 ARRAY_SIZE(brw
->compute_atoms
));
412 STATIC_ASSERT(ARRAY_SIZE(gen8_compute_atoms
) <=
413 ARRAY_SIZE(brw
->compute_atoms
));
415 brw_init_caches(brw
);
418 brw_copy_pipeline_atoms(brw
, BRW_RENDER_PIPELINE
,
420 ARRAY_SIZE(gen8_render_atoms
));
421 brw_copy_pipeline_atoms(brw
, BRW_COMPUTE_PIPELINE
,
423 ARRAY_SIZE(gen8_compute_atoms
));
424 } else if (brw
->gen
== 7) {
425 brw_copy_pipeline_atoms(brw
, BRW_RENDER_PIPELINE
,
427 ARRAY_SIZE(gen7_render_atoms
));
428 brw_copy_pipeline_atoms(brw
, BRW_COMPUTE_PIPELINE
,
430 ARRAY_SIZE(gen7_compute_atoms
));
431 } else if (brw
->gen
== 6) {
432 brw_copy_pipeline_atoms(brw
, BRW_RENDER_PIPELINE
,
433 gen6_atoms
, ARRAY_SIZE(gen6_atoms
));
435 brw_copy_pipeline_atoms(brw
, BRW_RENDER_PIPELINE
,
436 gen4_atoms
, ARRAY_SIZE(gen4_atoms
));
439 brw_upload_initial_gpu_state(brw
);
441 brw
->NewGLState
= ~0;
442 brw
->ctx
.NewDriverState
= ~0ull;
444 /* ~0 is a nonsensical value which won't match anything we program, so
445 * the programming will take effect on the first time around.
447 brw
->pma_stall_bits
= ~0;
449 /* Make sure that brw->ctx.NewDriverState has enough bits to hold all possible
452 STATIC_ASSERT(BRW_NUM_STATE_BITS
<= 8 * sizeof(brw
->ctx
.NewDriverState
));
454 ctx
->DriverFlags
.NewTransformFeedback
= BRW_NEW_TRANSFORM_FEEDBACK
;
455 ctx
->DriverFlags
.NewTransformFeedbackProg
= BRW_NEW_TRANSFORM_FEEDBACK
;
456 ctx
->DriverFlags
.NewRasterizerDiscard
= BRW_NEW_RASTERIZER_DISCARD
;
457 ctx
->DriverFlags
.NewUniformBuffer
= BRW_NEW_UNIFORM_BUFFER
;
458 ctx
->DriverFlags
.NewTextureBuffer
= BRW_NEW_TEXTURE_BUFFER
;
459 ctx
->DriverFlags
.NewAtomicBuffer
= BRW_NEW_ATOMIC_BUFFER
;
463 void brw_destroy_state( struct brw_context
*brw
)
465 brw_destroy_caches(brw
);
468 /***********************************************************************
472 check_state(const struct brw_state_flags
*a
, const struct brw_state_flags
*b
)
474 return ((a
->mesa
& b
->mesa
) | (a
->brw
& b
->brw
)) != 0;
477 static void accumulate_state( struct brw_state_flags
*a
,
478 const struct brw_state_flags
*b
)
485 static void xor_states( struct brw_state_flags
*result
,
486 const struct brw_state_flags
*a
,
487 const struct brw_state_flags
*b
)
489 result
->mesa
= a
->mesa
^ b
->mesa
;
490 result
->brw
= a
->brw
^ b
->brw
;
493 struct dirty_bit_map
{
499 #define DEFINE_BIT(name) {name, #name, 0}
501 static struct dirty_bit_map mesa_bits
[] = {
502 DEFINE_BIT(_NEW_MODELVIEW
),
503 DEFINE_BIT(_NEW_PROJECTION
),
504 DEFINE_BIT(_NEW_TEXTURE_MATRIX
),
505 DEFINE_BIT(_NEW_COLOR
),
506 DEFINE_BIT(_NEW_DEPTH
),
507 DEFINE_BIT(_NEW_EVAL
),
508 DEFINE_BIT(_NEW_FOG
),
509 DEFINE_BIT(_NEW_HINT
),
510 DEFINE_BIT(_NEW_LIGHT
),
511 DEFINE_BIT(_NEW_LINE
),
512 DEFINE_BIT(_NEW_PIXEL
),
513 DEFINE_BIT(_NEW_POINT
),
514 DEFINE_BIT(_NEW_POLYGON
),
515 DEFINE_BIT(_NEW_POLYGONSTIPPLE
),
516 DEFINE_BIT(_NEW_SCISSOR
),
517 DEFINE_BIT(_NEW_STENCIL
),
518 DEFINE_BIT(_NEW_TEXTURE
),
519 DEFINE_BIT(_NEW_TRANSFORM
),
520 DEFINE_BIT(_NEW_VIEWPORT
),
521 DEFINE_BIT(_NEW_ARRAY
),
522 DEFINE_BIT(_NEW_RENDERMODE
),
523 DEFINE_BIT(_NEW_BUFFERS
),
524 DEFINE_BIT(_NEW_CURRENT_ATTRIB
),
525 DEFINE_BIT(_NEW_MULTISAMPLE
),
526 DEFINE_BIT(_NEW_TRACK_MATRIX
),
527 DEFINE_BIT(_NEW_PROGRAM
),
528 DEFINE_BIT(_NEW_PROGRAM_CONSTANTS
),
529 DEFINE_BIT(_NEW_BUFFER_OBJECT
),
530 DEFINE_BIT(_NEW_FRAG_CLAMP
),
531 /* Avoid sign extension problems. */
532 {(unsigned) _NEW_VARYING_VP_INPUTS
, "_NEW_VARYING_VP_INPUTS", 0},
536 static struct dirty_bit_map brw_bits
[] = {
537 DEFINE_BIT(BRW_NEW_FS_PROG_DATA
),
538 DEFINE_BIT(BRW_NEW_BLORP_BLIT_PROG_DATA
),
539 DEFINE_BIT(BRW_NEW_SF_PROG_DATA
),
540 DEFINE_BIT(BRW_NEW_VS_PROG_DATA
),
541 DEFINE_BIT(BRW_NEW_FF_GS_PROG_DATA
),
542 DEFINE_BIT(BRW_NEW_GS_PROG_DATA
),
543 DEFINE_BIT(BRW_NEW_CLIP_PROG_DATA
),
544 DEFINE_BIT(BRW_NEW_URB_FENCE
),
545 DEFINE_BIT(BRW_NEW_FRAGMENT_PROGRAM
),
546 DEFINE_BIT(BRW_NEW_GEOMETRY_PROGRAM
),
547 DEFINE_BIT(BRW_NEW_VERTEX_PROGRAM
),
548 DEFINE_BIT(BRW_NEW_CURBE_OFFSETS
),
549 DEFINE_BIT(BRW_NEW_REDUCED_PRIMITIVE
),
550 DEFINE_BIT(BRW_NEW_PRIMITIVE
),
551 DEFINE_BIT(BRW_NEW_CONTEXT
),
552 DEFINE_BIT(BRW_NEW_PSP
),
553 DEFINE_BIT(BRW_NEW_SURFACES
),
554 DEFINE_BIT(BRW_NEW_VS_BINDING_TABLE
),
555 DEFINE_BIT(BRW_NEW_GS_BINDING_TABLE
),
556 DEFINE_BIT(BRW_NEW_PS_BINDING_TABLE
),
557 DEFINE_BIT(BRW_NEW_INDICES
),
558 DEFINE_BIT(BRW_NEW_VERTICES
),
559 DEFINE_BIT(BRW_NEW_BATCH
),
560 DEFINE_BIT(BRW_NEW_INDEX_BUFFER
),
561 DEFINE_BIT(BRW_NEW_VS_CONSTBUF
),
562 DEFINE_BIT(BRW_NEW_GS_CONSTBUF
),
563 DEFINE_BIT(BRW_NEW_PROGRAM_CACHE
),
564 DEFINE_BIT(BRW_NEW_STATE_BASE_ADDRESS
),
565 DEFINE_BIT(BRW_NEW_VUE_MAP_VS
),
566 DEFINE_BIT(BRW_NEW_VUE_MAP_GEOM_OUT
),
567 DEFINE_BIT(BRW_NEW_TRANSFORM_FEEDBACK
),
568 DEFINE_BIT(BRW_NEW_RASTERIZER_DISCARD
),
569 DEFINE_BIT(BRW_NEW_STATS_WM
),
570 DEFINE_BIT(BRW_NEW_UNIFORM_BUFFER
),
571 DEFINE_BIT(BRW_NEW_ATOMIC_BUFFER
),
572 DEFINE_BIT(BRW_NEW_META_IN_PROGRESS
),
573 DEFINE_BIT(BRW_NEW_INTERPOLATION_MAP
),
574 DEFINE_BIT(BRW_NEW_PUSH_CONSTANT_ALLOCATION
),
575 DEFINE_BIT(BRW_NEW_NUM_SAMPLES
),
576 DEFINE_BIT(BRW_NEW_TEXTURE_BUFFER
),
577 DEFINE_BIT(BRW_NEW_GEN4_UNIT_STATE
),
578 DEFINE_BIT(BRW_NEW_CC_VP
),
579 DEFINE_BIT(BRW_NEW_SF_VP
),
580 DEFINE_BIT(BRW_NEW_CLIP_VP
),
581 DEFINE_BIT(BRW_NEW_SAMPLER_STATE_TABLE
),
582 DEFINE_BIT(BRW_NEW_VS_ATTRIB_WORKAROUNDS
),
587 brw_update_dirty_count(struct dirty_bit_map
*bit_map
, uint64_t bits
)
589 for (int i
= 0; bit_map
[i
].bit
!= 0; i
++) {
590 if (bit_map
[i
].bit
& bits
)
596 brw_print_dirty_count(struct dirty_bit_map
*bit_map
)
598 for (int i
= 0; bit_map
[i
].bit
!= 0; i
++) {
599 if (bit_map
[i
].count
> 1) {
600 fprintf(stderr
, "0x%016lx: %12d (%s)\n",
601 bit_map
[i
].bit
, bit_map
[i
].count
, bit_map
[i
].name
);
607 brw_upload_programs(struct brw_context
*brw
,
608 enum brw_pipeline pipeline
)
610 if (pipeline
== BRW_RENDER_PIPELINE
) {
611 brw_upload_vs_prog(brw
);
614 brw_upload_ff_gs_prog(brw
);
616 brw_upload_gs_prog(brw
);
618 brw_upload_wm_prog(brw
);
623 merge_ctx_state(struct brw_context
*brw
,
624 struct brw_state_flags
*state
)
626 state
->mesa
|= brw
->NewGLState
;
627 assert(brw
->state
.dirty
.mesa
== 0);
628 state
->brw
|= brw
->ctx
.NewDriverState
;
629 assert(brw
->state
.dirty
.brw
== 0ull);
633 check_and_emit_atom(struct brw_context
*brw
,
634 struct brw_state_flags
*state
,
635 const struct brw_tracked_state
*atom
)
637 if (check_state(state
, &atom
->dirty
)) {
639 merge_ctx_state(brw
, state
);
644 brw_upload_pipeline_state(struct brw_context
*brw
,
645 enum brw_pipeline pipeline
)
647 struct gl_context
*ctx
= &brw
->ctx
;
648 struct brw_state_flags
*brw_state
= &brw
->state
.dirty
;
650 static int dirty_count
= 0;
651 struct brw_state_flags state
= brw
->state
.pipelines
[pipeline
];
654 /* Always re-emit all state. */
655 brw
->NewGLState
= ~0;
656 ctx
->NewDriverState
= ~0ull;
659 if (pipeline
== BRW_RENDER_PIPELINE
) {
660 if (brw
->fragment_program
!= ctx
->FragmentProgram
._Current
) {
661 brw
->fragment_program
= ctx
->FragmentProgram
._Current
;
662 brw
->ctx
.NewDriverState
|= BRW_NEW_FRAGMENT_PROGRAM
;
665 if (brw
->geometry_program
!= ctx
->GeometryProgram
._Current
) {
666 brw
->geometry_program
= ctx
->GeometryProgram
._Current
;
667 brw
->ctx
.NewDriverState
|= BRW_NEW_GEOMETRY_PROGRAM
;
670 if (brw
->vertex_program
!= ctx
->VertexProgram
._Current
) {
671 brw
->vertex_program
= ctx
->VertexProgram
._Current
;
672 brw
->ctx
.NewDriverState
|= BRW_NEW_VERTEX_PROGRAM
;
676 if (brw
->meta_in_progress
!= _mesa_meta_in_progress(ctx
)) {
677 brw
->meta_in_progress
= _mesa_meta_in_progress(ctx
);
678 brw
->ctx
.NewDriverState
|= BRW_NEW_META_IN_PROGRESS
;
681 if (brw
->num_samples
!= ctx
->DrawBuffer
->Visual
.samples
) {
682 brw
->num_samples
= ctx
->DrawBuffer
->Visual
.samples
;
683 brw
->ctx
.NewDriverState
|= BRW_NEW_NUM_SAMPLES
;
686 /* Exit early if no state is flagged as dirty */
687 merge_ctx_state(brw
, &state
);
688 if ((state
.mesa
| state
.brw
) == 0)
691 /* Emit Sandybridge workaround flushes on every primitive, for safety. */
693 intel_emit_post_sync_nonzero_flush(brw
);
695 brw_upload_programs(brw
, pipeline
);
696 merge_ctx_state(brw
, &state
);
698 const struct brw_tracked_state
*atoms
=
699 brw_get_pipeline_atoms(brw
, pipeline
);
700 const int num_atoms
= brw
->num_atoms
[pipeline
];
702 if (unlikely(INTEL_DEBUG
)) {
703 /* Debug version which enforces various sanity checks on the
704 * state flags which are generated and checked to help ensure
705 * state atoms are ordered correctly in the list.
707 struct brw_state_flags examined
, prev
;
708 memset(&examined
, 0, sizeof(examined
));
711 for (i
= 0; i
< num_atoms
; i
++) {
712 const struct brw_tracked_state
*atom
= &atoms
[i
];
713 struct brw_state_flags generated
;
715 check_and_emit_atom(brw
, &state
, atom
);
717 accumulate_state(&examined
, &atom
->dirty
);
719 /* generated = (prev ^ state)
720 * if (examined & generated)
723 xor_states(&generated
, &prev
, &state
);
724 assert(!check_state(&examined
, &generated
));
729 for (i
= 0; i
< num_atoms
; i
++) {
730 const struct brw_tracked_state
*atom
= &atoms
[i
];
732 check_and_emit_atom(brw
, &state
, atom
);
736 if (unlikely(INTEL_DEBUG
& DEBUG_STATE
)) {
737 STATIC_ASSERT(ARRAY_SIZE(brw_bits
) == BRW_NUM_STATE_BITS
+ 1);
739 brw_update_dirty_count(mesa_bits
, state
.mesa
);
740 brw_update_dirty_count(brw_bits
, state
.brw
);
741 if (dirty_count
++ % 1000 == 0) {
742 brw_print_dirty_count(mesa_bits
);
743 brw_print_dirty_count(brw_bits
);
744 fprintf(stderr
, "\n");
749 /***********************************************************************
752 void brw_upload_render_state(struct brw_context
*brw
)
754 brw_upload_pipeline_state(brw
, BRW_RENDER_PIPELINE
);
758 brw_pipeline_state_finished(struct brw_context
*brw
,
759 enum brw_pipeline pipeline
)
761 struct brw_state_flags
*state
= &brw
->state
.dirty
;
763 /* Save all dirty state into the other pipelines */
764 for (int i
= 0; i
< BRW_NUM_PIPELINES
; i
++) {
766 brw
->state
.pipelines
[i
].mesa
|= brw
->NewGLState
;
767 brw
->state
.pipelines
[i
].brw
|= brw
->ctx
.NewDriverState
;
769 memset(&brw
->state
.pipelines
[i
], 0, sizeof(struct brw_state_flags
));
774 brw
->ctx
.NewDriverState
= 0ull;
775 memset(state
, 0, sizeof(*state
));
779 * Clear dirty bits to account for the fact that the state emitted by
780 * brw_upload_render_state() has been committed to the hardware. This is a
781 * separate call from brw_upload_render_state() because it's possible that
782 * after the call to brw_upload_render_state(), we will discover that we've
783 * run out of aperture space, and need to rewind the batch buffer to the state
784 * it had before the brw_upload_render_state() call.
787 brw_render_state_finished(struct brw_context
*brw
)
789 brw_pipeline_state_finished(brw
, BRW_RENDER_PIPELINE
);
793 brw_upload_compute_state(struct brw_context
*brw
)
795 brw_upload_pipeline_state(brw
, BRW_COMPUTE_PIPELINE
);
799 brw_compute_state_finished(struct brw_context
*brw
)
801 brw_pipeline_state_finished(brw
, BRW_COMPUTE_PIPELINE
);