1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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 VMWARE 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 **************************************************************************/
30 * Scene queue. We'll use two queues. One contains "full" scenes which
31 * are produced by the "setup" code. The other contains "empty" scenes
32 * which are produced by the "rast" code when it finishes rendering a scene.
35 #include "util/u_ringbuffer.h"
36 #include "util/u_memory.h"
37 #include "lp_scene_queue.h"
41 #define MAX_SCENE_QUEUE 4
44 struct util_packet header
;
45 struct lp_scene
*scene
;
53 struct util_ringbuffer
*ring
;
58 /** Allocate a new scene queue */
59 struct lp_scene_queue
*
60 lp_scene_queue_create(void)
62 struct lp_scene_queue
*queue
= CALLOC_STRUCT(lp_scene_queue
);
66 queue
->ring
= util_ringbuffer_create( MAX_SCENE_QUEUE
*
67 sizeof( struct scene_packet
) / 4);
68 if (queue
->ring
== NULL
)
79 /** Delete a scene queue */
81 lp_scene_queue_destroy(struct lp_scene_queue
*queue
)
83 util_ringbuffer_destroy(queue
->ring
);
88 /** Remove first lp_scene from head of queue */
90 lp_scene_dequeue(struct lp_scene_queue
*queue
, boolean wait
)
92 struct scene_packet packet
;
97 ret
= util_ringbuffer_dequeue(queue
->ring
,
108 /** Add an lp_scene to tail of queue */
110 lp_scene_enqueue(struct lp_scene_queue
*queue
, struct lp_scene
*scene
)
112 struct scene_packet packet
;
114 packet
.header
.dwords
= sizeof packet
/ 4;
115 packet
.header
.data24
= 0;
116 packet
.scene
= scene
;
118 util_ringbuffer_enqueue(queue
->ring
, &packet
.header
);