radeon/r200/r300: cleanup some of the renderbuffer code
[mesa.git] / src / gallium / winsys / drm / intel / common / ws_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 _PSB_BUFPOOL_H_
33 #define _PSB_BUFPOOL_H_
34
35 #include <xf86drm.h>
36 #include "pipe/p_thread.h"
37 struct _DriFenceObject;
38
39 typedef struct _DriBufferPool
40 {
41 int fd;
42 int (*map) (struct _DriBufferPool * pool, void *private,
43 unsigned flags, int hint, pipe_mutex *mutex,
44 void **virtual);
45 int (*unmap) (struct _DriBufferPool * pool, void *private);
46 int (*destroy) (struct _DriBufferPool * pool, void *private);
47 unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
48 unsigned long (*poolOffset) (struct _DriBufferPool * pool, void *private);
49 uint64_t (*flags) (struct _DriBufferPool * pool, void *private);
50 unsigned long (*size) (struct _DriBufferPool * pool, void *private);
51 void *(*create) (struct _DriBufferPool * pool, unsigned long size,
52 uint64_t flags, unsigned hint, unsigned alignment);
53 void *(*reference) (struct _DriBufferPool * pool, unsigned handle);
54 int (*unreference) (struct _DriBufferPool * pool, void *private);
55 int (*fence) (struct _DriBufferPool * pool, void *private,
56 struct _DriFenceObject * fence);
57 drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
58 int (*validate) (struct _DriBufferPool * pool, void *private, pipe_mutex *mutex);
59 int (*waitIdle) (struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
60 int lazy);
61 int (*setStatus) (struct _DriBufferPool *pool, void *private,
62 uint64_t flag_diff, uint64_t old_flags);
63 void (*takeDown) (struct _DriBufferPool * pool);
64 void *data;
65 } DriBufferPool;
66
67 extern void bmError(int val, const char *file, const char *function,
68 int line);
69 #define BM_CKFATAL(val) \
70 do{ \
71 int tstVal = (val); \
72 if (tstVal) \
73 bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
74 } while(0);
75
76
77 /*
78 * Builtin pools.
79 */
80
81 /*
82 * Kernel buffer objects. Size in multiples of page size. Page size aligned.
83 */
84
85 extern struct _DriBufferPool *driDRMPoolInit(int fd);
86 extern struct _DriBufferPool *driMallocPoolInit(void);
87
88 struct _DriFreeSlabManager;
89 extern struct _DriBufferPool * driSlabPoolInit(int fd, uint64_t flags,
90 uint64_t validMask,
91 uint32_t smallestSize,
92 uint32_t numSizes,
93 uint32_t desiredNumBuffers,
94 uint32_t maxSlabSize,
95 uint32_t pageAlignment,
96 struct _DriFreeSlabManager *fMan);
97 extern void driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan);
98 extern struct _DriFreeSlabManager *
99 driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec);
100
101
102 #endif