pb_buffer.h revision aef455c4a7bbd7df97a6444ae332cb5fb976e627
15c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/************************************************************************** 25c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 35c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 45c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * All Rights Reserved. 55c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 65c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Permission is hereby granted, free of charge, to any person obtaining a 75c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * copy of this software and associated documentation files (the 85c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * "Software"), to deal in the Software without restriction, including 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * without limitation the rights to use, copy, modify, merge, publish, 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * distribute, sub license, and/or sell copies of the Software, and to 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * permit persons to whom the Software is furnished to do so, subject to 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * the following conditions: 13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * 145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * The above copyright notice and this permission notice (including the 155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * next paragraph) shall be included in all copies or substantial portions 165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * of the Software. 175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * 185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 235c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 245c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 255c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) **************************************************************************/ 275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/** 291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * \file 301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * Generic code for buffers. 311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * 325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Behind a pipe buffle handle there can be DMA buffers, client (or user) 335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * buffers, regular malloced buffers, etc. This file provides an abstract base 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * buffer handle that allows the driver to cope with all those kinds of buffers 355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * in a more flexible way. 365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * There is no obligation of a winsys driver to use this library. And a pipe 386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * driver should be completly agnostic about it. 395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * \author Jos� Fonseca <jrfonseca@tungstengraphics.com> 415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */ 425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 430de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)#ifndef PB_BUFFER_H_ 445c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#define PB_BUFFER_H_ 455c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 465c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 475c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "pipe/p_compiler.h" 485c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "pipe/p_debug.h" 495c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "pipe/p_state.h" 505c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "pipe/p_inlines.h" 515c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 525c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 535c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#ifdef __cplusplus 545c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuextern "C" { 550de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)#endif 560de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) 570de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) 586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)struct pb_vtbl; 596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)/** 616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * Buffer description. 625c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * 63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Used when allocating the buffer. 64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 65cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)struct pb_desc 66cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles){ 67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch unsigned alignment; 68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch unsigned usage; 69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}; 70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch/** 73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Base class for all pb_* buffers. 74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */ 75116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstruct pb_buffer 76116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{ 77116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch struct pipe_buffer base; 78116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 79116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch /** 80116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Pointer to the virtual function table. 81116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * 825c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Avoid accessing this table directly. Use the inline functions below 835c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * instead to avoid mistakes. 84cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 85cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const struct pb_vtbl *vtbl; 86cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 87cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 88cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 89cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)/** 90cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Virtual function table for the buffer storage operations. 916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * 926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * Note that creation is not done through this table. 93cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 94cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)struct pb_vtbl 95cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles){ 965c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu void (*destroy)( struct pb_buffer *buf ); 975c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 98cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) /** 99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Map the entire data store of a buffer object into the client's address. 100cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE. 101cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 1026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void *(*map)( struct pb_buffer *buf, 1036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) unsigned flags ); 1046d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1056d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) void (*unmap)( struct pb_buffer *buf ); 1066d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1076d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) /** 1086d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * Get the base buffer and the offset. 1096d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * 110cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * A buffer can be subdivided in smaller buffers. This method should return 111cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * the underlaying buffer, and the relative offset. 1126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * 1136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * Buffers without an underlaying base buffer should return themselves, with 1146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * a zero offset. 1156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * 116cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Note that this will increase the reference count of the base buffer. 1176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) */ 118cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) void (*get_base_buffer)( struct pb_buffer *buf, 119cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) struct pb_buffer **base_buf, 120cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) unsigned *offset ); 121cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 122cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 123cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 124cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)static INLINE struct pipe_buffer * 1255c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liupb_pipe_buffer( struct pb_buffer *pbuf ) 1265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu{ 127cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) assert(pbuf); 1285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return &pbuf->base; 1295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 1305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 131cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 132cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)static INLINE struct pb_buffer * 133cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)pb_buffer( struct pipe_buffer *buf ) 134cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles){ 135116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch assert(buf); 136116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch /* Could add a magic cookie check on debug builds. 137116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */ 138116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return (struct pb_buffer *)buf; 139cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 140cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 141cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 142cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)/* Accessor functions for pb->vtbl: 143116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */ 144cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)static INLINE void * 145cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)pb_map(struct pb_buffer *buf, 146116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch unsigned flags) 147116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{ 148116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch assert(buf); 149cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if(!buf) 150cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return NULL; 151cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return buf->vtbl->map(buf, flags); 152cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 153cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 154116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 1551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistatic INLINE void 156116680a4aac90f2aa7413d9095a592090648e557Ben Murdochpb_unmap(struct pb_buffer *buf) 157116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{ 158116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch assert(buf); 159116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch if(!buf) 160116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return; 161116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch buf->vtbl->unmap(buf); 162116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 163116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 164116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 165116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstatic INLINE void 166116680a4aac90f2aa7413d9095a592090648e557Ben Murdochpb_get_base_buffer( struct pb_buffer *buf, 167cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) struct pb_buffer **base_buf, 168cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) unsigned *offset ) 169116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{ 170116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch assert(buf); 171cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if(!buf) { 172116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch base_buf = NULL; 173cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) offset = 0; 1745c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return; 1755c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu } 1765c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu buf->vtbl->get_base_buffer(buf, base_buf, offset); 1775c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 178f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 179116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 180116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstatic INLINE void 181f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)pb_destroy(struct pb_buffer *buf) 182116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch{ 183f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) assert(buf); 1845c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu if(!buf) 185cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return; 186cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) buf->vtbl->destroy(buf); 1875c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 188116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 189116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 190116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch/* XXX: thread safety issues! 191116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */ 1925c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liustatic INLINE void 1935c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liupb_reference(struct pb_buffer **dst, 1945c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu struct pb_buffer *src) 1955c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu{ 1965c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu if (src) 197cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) src->base.refcount++; 198cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 1995c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu if (*dst && --(*dst)->base.refcount == 0) 2005c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu pb_destroy( *dst ); 2015c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 2025c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu *dst = src; 2035c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 2045c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 205cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 206116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch/** 207116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Utility function to check whether the provided alignment is consistent with 2085c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * the requested or not. 2095c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */ 2105c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liustatic INLINE boolean 2115c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liupb_check_alignment(size_t requested, size_t provided) 2125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu{ 2135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return requested <= provided && (provided % requested) == 0 ? TRUE : FALSE; 2145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 2155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 2165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 2175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/** 2185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Utility function to check whether the provided alignment is consistent with 2195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * the requested or not. 2205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */ 2215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liustatic INLINE boolean 2225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liupb_check_usage(unsigned requested, unsigned provided) 2235c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu{ 2245c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return (requested & provided) == requested ? TRUE : FALSE; 2256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 2266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)/** 2296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * Malloc-based buffer to store data that can't be used by the graphics 2306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) * hardware. 2316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) */ 2325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liustruct pb_buffer * 2336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)pb_malloc_buffer_create(size_t size, 2346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const struct pb_desc *desc); 2356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 237116680a4aac90f2aa7413d9095a592090648e557Ben Murdochvoid 238116680a4aac90f2aa7413d9095a592090648e557Ben Murdochpb_init_winsys(struct pipe_winsys *winsys); 239116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 240116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 241116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifdef __cplusplus 242116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 2436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#endif 2445c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 2455c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#endif /*PB_BUFFER_H_*/ 2465c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu