1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * 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, sub license, 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 portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
31 * Builds per-tile display lists and executes them on calls to
37 #include "pipe/p_defines.h"
38 #include "util/u_framebuffer.h"
39 #include "util/u_inlines.h"
40 #include "util/u_memory.h"
41 #include "util/u_pack_color.h"
42 #include "lp_context.h"
44 #include "lp_scene_queue.h"
45 #include "lp_texture.h"
50 #include "lp_setup_context.h"
51 #include "lp_screen.h"
53 #include "state_tracker/sw_winsys.h"
54 #include "lp_rast_priv.h"
56 #include "draw/draw_context.h"
57 #include "draw/draw_vbuf.h"
60 static void set_scene_state( struct lp_setup_context
*, enum setup_state
);
64 lp_setup_get_current_scene(struct lp_setup_context
*setup
)
68 /* wait for a free/empty scene
70 setup
->scene
= lp_scene_dequeue(setup
->empty_scenes
, TRUE
);
72 assert(lp_scene_is_empty(setup
->scene
));
74 lp_scene_begin_binning(setup
->scene
,
82 * Check if the size of the current scene has exceeded the limit.
83 * If so, flush/render it.
86 setup_check_scene_size_and_flush(struct lp_setup_context
*setup
)
89 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
90 unsigned size
= lp_scene_get_size(scene
);
92 if (size
> LP_MAX_SCENE_SIZE
) {
93 /*printf("LLVMPIPE: scene size = %u, flushing.\n", size);*/
94 set_scene_state( setup
, SETUP_FLUSHED
);
95 /*assert(lp_scene_get_size(scene) == 0);*/
102 first_triangle( struct lp_setup_context
*setup
,
103 const float (*v0
)[4],
104 const float (*v1
)[4],
105 const float (*v2
)[4])
107 set_scene_state( setup
, SETUP_ACTIVE
);
108 lp_setup_choose_triangle( setup
);
109 setup
->triangle( setup
, v0
, v1
, v2
);
113 first_line( struct lp_setup_context
*setup
,
114 const float (*v0
)[4],
115 const float (*v1
)[4])
117 set_scene_state( setup
, SETUP_ACTIVE
);
118 lp_setup_choose_line( setup
);
119 setup
->line( setup
, v0
, v1
);
123 first_point( struct lp_setup_context
*setup
,
124 const float (*v0
)[4])
126 set_scene_state( setup
, SETUP_ACTIVE
);
127 lp_setup_choose_point( setup
);
128 setup
->point( setup
, v0
);
131 static void reset_context( struct lp_setup_context
*setup
)
133 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
135 /* Reset derived state */
136 setup
->constants
.stored_size
= 0;
137 setup
->constants
.stored_data
= NULL
;
138 setup
->fs
.stored
= NULL
;
146 setup
->clear
.flags
= 0;
148 /* Have an explicit "start-binning" call and get rid of this
151 setup
->line
= first_line
;
152 setup
->point
= first_point
;
153 setup
->triangle
= first_triangle
;
157 /** Rasterize all scene's bins */
159 lp_setup_rasterize_scene( struct lp_setup_context
*setup
)
161 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
163 lp_scene_rasterize(scene
, setup
->rast
);
165 reset_context( setup
);
167 LP_DBG(DEBUG_SETUP
, "%s done \n", __FUNCTION__
);
173 begin_binning( struct lp_setup_context
*setup
)
175 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
177 LP_DBG(DEBUG_SETUP
, "%s color: %s depth: %s\n", __FUNCTION__
,
178 (setup
->clear
.flags
& PIPE_CLEAR_COLOR
) ? "clear": "load",
179 (setup
->clear
.flags
& PIPE_CLEAR_DEPTHSTENCIL
) ? "clear": "load");
181 if (setup
->fb
.nr_cbufs
) {
182 if (setup
->clear
.flags
& PIPE_CLEAR_COLOR
) {
183 lp_scene_bin_everywhere( scene
,
185 setup
->clear
.color
);
186 scene
->has_color_clear
= TRUE
;
190 if (setup
->fb
.zsbuf
) {
191 if (setup
->clear
.flags
& PIPE_CLEAR_DEPTHSTENCIL
) {
192 lp_scene_bin_everywhere( scene
,
193 lp_rast_clear_zstencil
,
194 setup
->clear
.zstencil
);
195 scene
->has_depth_clear
= TRUE
;
199 LP_DBG(DEBUG_SETUP
, "%s done\n", __FUNCTION__
);
203 /* This basically bins and then flushes any outstanding full-screen
206 * TODO: fast path for fullscreen clears and no triangles.
209 execute_clears( struct lp_setup_context
*setup
)
211 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
213 begin_binning( setup
);
214 lp_setup_rasterize_scene( setup
);
219 set_scene_state( struct lp_setup_context
*setup
,
220 enum setup_state new_state
)
222 unsigned old_state
= setup
->state
;
224 if (old_state
== new_state
)
227 LP_DBG(DEBUG_SETUP
, "%s old %d new %d\n", __FUNCTION__
, old_state
, new_state
);
231 begin_binning( setup
);
235 if (old_state
== SETUP_ACTIVE
) {
242 if (old_state
== SETUP_CLEARED
)
243 execute_clears( setup
);
245 lp_setup_rasterize_scene( setup
);
249 assert(0 && "invalid setup state mode");
252 setup
->state
= new_state
;
257 * \param flags bitmask of PIPE_FLUSH_x flags
260 lp_setup_flush( struct lp_setup_context
*setup
,
263 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
266 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
267 union lp_rast_cmd_arg dummy
= {0};
269 if (flags
& (PIPE_FLUSH_SWAPBUFFERS
|
271 /* Store colors in the linear color buffer(s).
272 * If we don't do this here, we'll end up converting the tiled
273 * data to linear in the texture_unmap() function, which will
274 * not be a parallel/threaded operation as here.
276 lp_scene_bin_everywhere(scene
, lp_rast_store_color
, dummy
);
280 set_scene_state( setup
, SETUP_FLUSHED
);
285 lp_setup_bind_framebuffer( struct lp_setup_context
*setup
,
286 const struct pipe_framebuffer_state
*fb
)
288 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
290 /* Flush any old scene.
292 set_scene_state( setup
, SETUP_FLUSHED
);
294 /* Set new state. This will be picked up later when we next need a
297 util_copy_framebuffer_state(&setup
->fb
, fb
);
302 lp_setup_clear( struct lp_setup_context
*setup
,
308 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
311 LP_DBG(DEBUG_SETUP
, "%s state %d\n", __FUNCTION__
, setup
->state
);
314 if (flags
& PIPE_CLEAR_COLOR
) {
315 for (i
= 0; i
< 4; ++i
)
316 setup
->clear
.color
.clear_color
[i
] = float_to_ubyte(color
[i
]);
319 if (flags
& PIPE_CLEAR_DEPTHSTENCIL
) {
320 setup
->clear
.zstencil
.clear_zstencil
=
321 util_pack_z_stencil(setup
->fb
.zsbuf
->format
,
326 if (setup
->state
== SETUP_ACTIVE
) {
327 /* Add the clear to existing scene. In the unusual case where
328 * both color and depth-stencil are being cleared when there's
329 * already been some rendering, we could discard the currently
330 * binned scene and start again, but I don't see that as being
333 if (flags
& PIPE_CLEAR_COLOR
) {
334 lp_scene_bin_everywhere( scene
,
336 setup
->clear
.color
);
337 scene
->has_color_clear
= TRUE
;
340 if (setup
->clear
.flags
& PIPE_CLEAR_DEPTHSTENCIL
) {
341 lp_scene_bin_everywhere( scene
,
342 lp_rast_clear_zstencil
,
343 setup
->clear
.zstencil
);
344 scene
->has_depth_clear
= TRUE
;
349 /* Put ourselves into the 'pre-clear' state, specifically to try
350 * and accumulate multiple clears to color and depth_stencil
351 * buffers which the app or state-tracker might issue
354 set_scene_state( setup
, SETUP_CLEARED
);
356 setup
->clear
.flags
|= flags
;
364 struct pipe_fence_handle
*
365 lp_setup_fence( struct lp_setup_context
*setup
)
367 if (setup
->num_threads
== 0) {
371 struct lp_scene
*scene
= lp_setup_get_current_scene(setup
);
372 const unsigned rank
= lp_scene_get_num_bins( scene
); /* xxx */
373 struct lp_fence
*fence
= lp_fence_create(rank
);
375 LP_DBG(DEBUG_SETUP
, "%s rank %u\n", __FUNCTION__
, rank
);
377 set_scene_state( setup
, SETUP_ACTIVE
);
379 /* insert the fence into all command bins */
380 lp_scene_bin_everywhere( scene
,
382 lp_rast_arg_fence(fence
) );
384 return (struct pipe_fence_handle
*) fence
;
390 lp_setup_set_triangle_state( struct lp_setup_context
*setup
,
392 boolean ccw_is_frontface
,
394 boolean gl_rasterization_rules
)
396 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
398 setup
->ccw_is_frontface
= ccw_is_frontface
;
399 setup
->cullmode
= cull_mode
;
400 setup
->triangle
= first_triangle
;
401 setup
->scissor_test
= scissor
;
402 setup
->pixel_offset
= gl_rasterization_rules
? 0.5f
: 0.0f
;
408 lp_setup_set_fs_inputs( struct lp_setup_context
*setup
,
409 const struct lp_shader_input
*input
,
412 LP_DBG(DEBUG_SETUP
, "%s %p %u\n", __FUNCTION__
, (void *) input
, nr
);
414 memcpy( setup
->fs
.input
, input
, nr
* sizeof input
[0] );
415 setup
->fs
.nr_inputs
= nr
;
419 lp_setup_set_fs_functions( struct lp_setup_context
*setup
,
420 lp_jit_frag_func jit_function0
,
421 lp_jit_frag_func jit_function1
,
424 LP_DBG(DEBUG_SETUP
, "%s %p\n", __FUNCTION__
, (void *) jit_function0
);
425 /* FIXME: reference count */
427 setup
->fs
.current
.jit_function
[0] = jit_function0
;
428 setup
->fs
.current
.jit_function
[1] = jit_function1
;
429 setup
->fs
.current
.opaque
= opaque
;
430 setup
->dirty
|= LP_SETUP_NEW_FS
;
434 lp_setup_set_fs_constants(struct lp_setup_context
*setup
,
435 struct pipe_resource
*buffer
)
437 LP_DBG(DEBUG_SETUP
, "%s %p\n", __FUNCTION__
, (void *) buffer
);
439 pipe_resource_reference(&setup
->constants
.current
, buffer
);
441 setup
->dirty
|= LP_SETUP_NEW_CONSTANTS
;
446 lp_setup_set_alpha_ref_value( struct lp_setup_context
*setup
,
447 float alpha_ref_value
)
449 LP_DBG(DEBUG_SETUP
, "%s %f\n", __FUNCTION__
, alpha_ref_value
);
451 if(setup
->fs
.current
.jit_context
.alpha_ref_value
!= alpha_ref_value
) {
452 setup
->fs
.current
.jit_context
.alpha_ref_value
= alpha_ref_value
;
453 setup
->dirty
|= LP_SETUP_NEW_FS
;
458 lp_setup_set_stencil_ref_values( struct lp_setup_context
*setup
,
459 const ubyte refs
[2] )
461 LP_DBG(DEBUG_SETUP
, "%s %d %d\n", __FUNCTION__
, refs
[0], refs
[1]);
463 if (setup
->fs
.current
.jit_context
.stencil_ref_front
!= refs
[0] ||
464 setup
->fs
.current
.jit_context
.stencil_ref_back
!= refs
[1]) {
465 setup
->fs
.current
.jit_context
.stencil_ref_front
= refs
[0];
466 setup
->fs
.current
.jit_context
.stencil_ref_back
= refs
[1];
467 setup
->dirty
|= LP_SETUP_NEW_FS
;
472 lp_setup_set_blend_color( struct lp_setup_context
*setup
,
473 const struct pipe_blend_color
*blend_color
)
475 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
479 if(memcmp(&setup
->blend_color
.current
, blend_color
, sizeof *blend_color
) != 0) {
480 memcpy(&setup
->blend_color
.current
, blend_color
, sizeof *blend_color
);
481 setup
->dirty
|= LP_SETUP_NEW_BLEND_COLOR
;
487 lp_setup_set_scissor( struct lp_setup_context
*setup
,
488 const struct pipe_scissor_state
*scissor
)
490 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
494 if (memcmp(&setup
->scissor
.current
, scissor
, sizeof(*scissor
)) != 0) {
495 setup
->scissor
.current
= *scissor
; /* struct copy */
496 setup
->dirty
|= LP_SETUP_NEW_SCISSOR
;
502 lp_setup_set_flatshade_first( struct lp_setup_context
*setup
,
503 boolean flatshade_first
)
505 setup
->flatshade_first
= flatshade_first
;
510 lp_setup_set_vertex_info( struct lp_setup_context
*setup
,
511 struct vertex_info
*vertex_info
)
513 /* XXX: just silently holding onto the pointer:
515 setup
->vertex_info
= vertex_info
;
520 * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
523 lp_setup_set_fragment_sampler_views(struct lp_setup_context
*setup
,
525 struct pipe_sampler_view
**views
)
529 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
531 assert(num
<= PIPE_MAX_SAMPLERS
);
533 for (i
= 0; i
< PIPE_MAX_SAMPLERS
; i
++) {
534 struct pipe_sampler_view
*view
= i
< num
? views
[i
] : NULL
;
537 struct pipe_resource
*tex
= view
->texture
;
538 struct llvmpipe_resource
*lp_tex
= llvmpipe_resource(tex
);
539 struct lp_jit_texture
*jit_tex
;
540 jit_tex
= &setup
->fs
.current
.jit_context
.textures
[i
];
541 jit_tex
->width
= tex
->width0
;
542 jit_tex
->height
= tex
->height0
;
543 jit_tex
->depth
= tex
->depth0
;
544 jit_tex
->last_level
= tex
->last_level
;
546 /* We're referencing the texture's internal data, so save a
549 pipe_resource_reference(&setup
->fs
.current_tex
[i
], tex
);
552 /* regular texture - setup array of mipmap level pointers */
554 for (j
= 0; j
<= tex
->last_level
; j
++) {
556 llvmpipe_get_texture_image_all(lp_tex
, j
, LP_TEX_USAGE_READ
,
557 LP_TEX_LAYOUT_LINEAR
);
558 jit_tex
->row_stride
[j
] = lp_tex
->row_stride
[j
];
559 jit_tex
->img_stride
[j
] = lp_tex
->img_stride
[j
];
563 /* display target texture/surface */
565 * XXX: Where should this be unmapped?
568 struct llvmpipe_screen
*screen
= llvmpipe_screen(tex
->screen
);
569 struct sw_winsys
*winsys
= screen
->winsys
;
570 jit_tex
->data
[0] = winsys
->displaytarget_map(winsys
, lp_tex
->dt
,
572 jit_tex
->row_stride
[0] = lp_tex
->row_stride
[0];
573 jit_tex
->img_stride
[0] = lp_tex
->img_stride
[0];
574 assert(jit_tex
->data
[0]);
579 setup
->dirty
|= LP_SETUP_NEW_FS
;
584 * Is the given texture referenced by any scene?
585 * Note: we have to check all scenes including any scenes currently
586 * being rendered and the current scene being built.
589 lp_setup_is_resource_referenced( const struct lp_setup_context
*setup
,
590 const struct pipe_resource
*texture
)
594 /* check the render targets */
595 for (i
= 0; i
< setup
->fb
.nr_cbufs
; i
++) {
596 if (setup
->fb
.cbufs
[i
]->texture
== texture
)
597 return PIPE_REFERENCED_FOR_READ
| PIPE_REFERENCED_FOR_WRITE
;
599 if (setup
->fb
.zsbuf
&& setup
->fb
.zsbuf
->texture
== texture
) {
600 return PIPE_REFERENCED_FOR_READ
| PIPE_REFERENCED_FOR_WRITE
;
603 /* check textures referenced by the scene */
604 for (i
= 0; i
< Elements(setup
->scenes
); i
++) {
605 if (lp_scene_is_resource_referenced(setup
->scenes
[i
], texture
)) {
606 return PIPE_REFERENCED_FOR_READ
;
610 return PIPE_UNREFERENCED
;
615 * Called by vbuf code when we're about to draw something.
618 lp_setup_update_state( struct lp_setup_context
*setup
)
620 struct lp_scene
*scene
;
622 LP_DBG(DEBUG_SETUP
, "%s\n", __FUNCTION__
);
624 setup_check_scene_size_and_flush(setup
);
626 scene
= lp_setup_get_current_scene(setup
);
628 assert(setup
->fs
.current
.jit_function
);
630 /* Some of the 'draw' pipeline stages may have changed some driver state.
631 * Make sure we've processed those state changes before anything else.
633 * XXX this is the only place where llvmpipe_context is used in the
634 * setup code. This may get refactored/changed...
637 struct llvmpipe_context
*lp
= llvmpipe_context(scene
->pipe
);
639 llvmpipe_update_derived(lp
);
641 assert(lp
->dirty
== 0);
644 if(setup
->dirty
& LP_SETUP_NEW_BLEND_COLOR
) {
648 stored
= lp_scene_alloc_aligned(scene
, 4 * 16, 16);
651 /* smear each blend color component across 16 ubyte elements */
652 for (i
= 0; i
< 4; ++i
) {
653 uint8_t c
= float_to_ubyte(setup
->blend_color
.current
.color
[i
]);
654 for (j
= 0; j
< 16; ++j
)
655 stored
[i
*16 + j
] = c
;
658 setup
->blend_color
.stored
= stored
;
660 setup
->fs
.current
.jit_context
.blend_color
= setup
->blend_color
.stored
;
663 setup
->dirty
|= LP_SETUP_NEW_FS
;
666 if (setup
->dirty
& LP_SETUP_NEW_SCISSOR
) {
669 stored
= lp_scene_alloc_aligned(scene
, 4 * sizeof(int32_t), 16);
672 stored
[0] = (float) setup
->scissor
.current
.minx
;
673 stored
[1] = (float) setup
->scissor
.current
.miny
;
674 stored
[2] = (float) setup
->scissor
.current
.maxx
;
675 stored
[3] = (float) setup
->scissor
.current
.maxy
;
677 setup
->scissor
.stored
= stored
;
679 setup
->fs
.current
.jit_context
.scissor_xmin
= stored
[0];
680 setup
->fs
.current
.jit_context
.scissor_ymin
= stored
[1];
681 setup
->fs
.current
.jit_context
.scissor_xmax
= stored
[2];
682 setup
->fs
.current
.jit_context
.scissor_ymax
= stored
[3];
685 setup
->dirty
|= LP_SETUP_NEW_FS
;
688 if(setup
->dirty
& LP_SETUP_NEW_CONSTANTS
) {
689 struct pipe_resource
*buffer
= setup
->constants
.current
;
692 unsigned current_size
= buffer
->width0
;
693 const void *current_data
= llvmpipe_resource_data(buffer
);
695 /* TODO: copy only the actually used constants? */
697 if(setup
->constants
.stored_size
!= current_size
||
698 !setup
->constants
.stored_data
||
699 memcmp(setup
->constants
.stored_data
,
701 current_size
) != 0) {
704 stored
= lp_scene_alloc(scene
, current_size
);
709 setup
->constants
.stored_size
= current_size
;
710 setup
->constants
.stored_data
= stored
;
715 setup
->constants
.stored_size
= 0;
716 setup
->constants
.stored_data
= NULL
;
719 setup
->fs
.current
.jit_context
.constants
= setup
->constants
.stored_data
;
720 setup
->dirty
|= LP_SETUP_NEW_FS
;
724 if(setup
->dirty
& LP_SETUP_NEW_FS
) {
725 if(!setup
->fs
.stored
||
726 memcmp(setup
->fs
.stored
,
728 sizeof setup
->fs
.current
) != 0) {
729 /* The fs state that's been stored in the scene is different from
730 * the new, current state. So allocate a new lp_rast_state object
731 * and append it to the bin's setup data buffer.
734 struct lp_rast_state
*stored
=
735 (struct lp_rast_state
*) lp_scene_alloc(scene
, sizeof *stored
);
739 sizeof setup
->fs
.current
);
740 setup
->fs
.stored
= stored
;
742 /* put the state-set command into all bins */
743 lp_scene_bin_state_command( scene
,
745 lp_rast_arg_state(setup
->fs
.stored
) );
748 /* The scene now references the textures in the rasterization
749 * state record. Note that now.
751 for (i
= 0; i
< Elements(setup
->fs
.current_tex
); i
++) {
752 if (setup
->fs
.current_tex
[i
])
753 lp_scene_add_resource_reference(scene
, setup
->fs
.current_tex
[i
]);
760 assert(setup
->fs
.stored
);
765 /* Only caller is lp_setup_vbuf_destroy()
768 lp_setup_destroy( struct lp_setup_context
*setup
)
772 reset_context( setup
);
774 util_unreference_framebuffer_state(&setup
->fb
);
776 for (i
= 0; i
< Elements(setup
->fs
.current_tex
); i
++) {
777 pipe_resource_reference(&setup
->fs
.current_tex
[i
], NULL
);
780 pipe_resource_reference(&setup
->constants
.current
, NULL
);
782 /* free the scenes in the 'empty' queue */
784 struct lp_scene
*scene
= lp_scene_dequeue(setup
->empty_scenes
, FALSE
);
787 lp_scene_destroy(scene
);
790 lp_scene_queue_destroy(setup
->empty_scenes
);
792 lp_rast_destroy( setup
->rast
);
799 * Create a new primitive tiling engine. Plug it into the backend of
800 * the draw module. Currently also creates a rasterizer to use with
803 struct lp_setup_context
*
804 lp_setup_create( struct pipe_context
*pipe
,
805 struct draw_context
*draw
)
807 struct llvmpipe_screen
*screen
= llvmpipe_screen(pipe
->screen
);
808 struct lp_setup_context
*setup
= CALLOC_STRUCT(lp_setup_context
);
814 lp_setup_init_vbuf(setup
);
816 setup
->empty_scenes
= lp_scene_queue_create();
817 if (!setup
->empty_scenes
)
820 /* XXX: move this to the screen and share between contexts:
822 setup
->num_threads
= screen
->num_threads
;
823 setup
->rast
= lp_rast_create(screen
->num_threads
);
827 setup
->vbuf
= draw_vbuf_stage(draw
, &setup
->base
);
831 draw_set_rasterize_stage(draw
, setup
->vbuf
);
832 draw_set_render(draw
, &setup
->base
);
834 /* create some empty scenes */
835 for (i
= 0; i
< MAX_SCENES
; i
++) {
836 setup
->scenes
[i
] = lp_scene_create( pipe
, setup
->empty_scenes
);
838 lp_scene_enqueue(setup
->empty_scenes
, setup
->scenes
[i
]);
841 setup
->triangle
= first_triangle
;
842 setup
->line
= first_line
;
843 setup
->point
= first_point
;
851 lp_rast_destroy( setup
->rast
);
856 if (setup
->empty_scenes
)
857 lp_scene_queue_destroy(setup
->empty_scenes
);
865 * Put a BeginQuery command into all bins.
868 lp_setup_begin_query(struct lp_setup_context
*setup
,
869 struct llvmpipe_query
*pq
)
871 struct lp_scene
* scene
= lp_setup_get_current_scene(setup
);
872 union lp_rast_cmd_arg cmd_arg
;
874 /* init the query to its beginning state */
877 pq
->num_tiles
= scene
->tiles_x
* scene
->tiles_y
;
878 assert(pq
->num_tiles
> 0);
880 memset(pq
->count
, 0, sizeof(pq
->count
)); /* reset all counters */
882 cmd_arg
.query_obj
= pq
;
883 lp_scene_bin_everywhere(scene
, lp_rast_begin_query
, cmd_arg
);
889 * Put an EndQuery command into all bins.
892 lp_setup_end_query(struct lp_setup_context
*setup
, struct llvmpipe_query
*pq
)
894 struct lp_scene
* scene
= lp_setup_get_current_scene(setup
);
895 union lp_rast_cmd_arg cmd_arg
;
897 cmd_arg
.query_obj
= pq
;
898 lp_scene_bin_everywhere(scene
, lp_rast_end_query
, cmd_arg
);