Merge texmem-0-3-branch.
[mesa.git] / src / mesa / drivers / dri / common / dri_bufpool.h
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
4 * All Rights Reserved.
5 *
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:
13 *
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.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 *
27 **************************************************************************/
28 /*
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
30 */
31
32 #ifndef _DRI_BUFPOOL_H_
33 #define _DRI_BUFPOOL_H_
34
35 #include <xf86drm.h>
36 struct _DriFenceObject;
37
38 typedef struct _DriBufferPool
39 {
40 int fd;
41 int (*map) (struct _DriBufferPool * pool, void *private,
42 unsigned flags, int hint, void **virtual);
43 int (*unmap) (struct _DriBufferPool * pool, void *private);
44 int (*destroy) (struct _DriBufferPool * pool, void *private);
45 unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
46 unsigned (*flags) (struct _DriBufferPool * pool, void *private);
47 unsigned long (*size) (struct _DriBufferPool * pool, void *private);
48 void *(*create) (struct _DriBufferPool * pool, unsigned long size,
49 unsigned flags, unsigned hint, unsigned alignment);
50 int (*fence) (struct _DriBufferPool * pool, void *private,
51 struct _DriFenceObject * fence);
52 drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
53 int (*validate) (struct _DriBufferPool * pool, void *private);
54 void *(*setstatic) (struct _DriBufferPool * pool, unsigned long offset,
55 unsigned long size, void *virtual, unsigned flags);
56 int (*waitIdle) (struct _DriBufferPool *pool, void *private,
57 int lazy);
58 void (*takeDown) (struct _DriBufferPool * pool);
59 void *data;
60 } DriBufferPool;
61
62 extern void bmError(int val, const char *file, const char *function,
63 int line);
64 #define BM_CKFATAL(val) \
65 do{ \
66 int tstVal = (val); \
67 if (tstVal) \
68 bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
69 } while(0);
70
71
72
73
74
75 /*
76 * Builtin pools.
77 */
78
79 /*
80 * Kernel buffer objects. Size in multiples of page size. Page size aligned.
81 */
82
83 extern struct _DriBufferPool *driDRMPoolInit(int fd);
84 extern struct _DriBufferPool *driDRMStaticPoolInit(int fd);
85
86 #endif