1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
35 #include "pipe/p_debug.h"
36 #include "pipe/p_thread.h"
37 #include "ws_dri_bufpool.h"
38 #include "ws_dri_bufmgr.h"
41 pool_create(struct _DriBufferPool
*pool
,
42 unsigned long size
, uint64_t flags
, unsigned hint
,
45 unsigned long *private = malloc(size
+ 2*sizeof(unsigned long));
46 if ((flags
& DRM_BO_MASK_MEM
) != DRM_BO_FLAG_MEM_LOCAL
)
50 return (void *)private;
55 pool_destroy(struct _DriBufferPool
*pool
, void *private)
62 pool_waitIdle(struct _DriBufferPool
*pool
, void *private,
63 pipe_mutex
*mutex
, int lazy
)
69 pool_map(struct _DriBufferPool
*pool
, void *private, unsigned flags
,
70 int hint
, pipe_mutex
*mutex
, void **virtual)
72 *virtual = (void *)((unsigned long *)private + 2);
77 pool_unmap(struct _DriBufferPool
*pool
, void *private)
83 pool_offset(struct _DriBufferPool
*pool
, void *private)
93 pool_poolOffset(struct _DriBufferPool
*pool
, void *private)
102 pool_flags(struct _DriBufferPool
*pool
, void *private)
104 return DRM_BO_FLAG_MEM_LOCAL
| DRM_BO_FLAG_CACHED
;
108 pool_size(struct _DriBufferPool
*pool
, void *private)
110 return *(unsigned long *) private;
115 pool_fence(struct _DriBufferPool
*pool
, void *private,
116 struct _DriFenceObject
*fence
)
123 pool_kernel(struct _DriBufferPool
*pool
, void *private)
130 pool_takedown(struct _DriBufferPool
*pool
)
136 struct _DriBufferPool
*
137 driMallocPoolInit(void)
139 struct _DriBufferPool
*pool
;
141 pool
= (struct _DriBufferPool
*) malloc(sizeof(*pool
));
147 pool
->map
= &pool_map
;
148 pool
->unmap
= &pool_unmap
;
149 pool
->destroy
= &pool_destroy
;
150 pool
->offset
= &pool_offset
;
151 pool
->poolOffset
= &pool_poolOffset
;
152 pool
->flags
= &pool_flags
;
153 pool
->size
= &pool_size
;
154 pool
->create
= &pool_create
;
155 pool
->fence
= &pool_fence
;
156 pool
->kernel
= &pool_kernel
;
157 pool
->validate
= NULL
;
158 pool
->waitIdle
= &pool_waitIdle
;
159 pool
->takeDown
= &pool_takedown
;