intel_be_device.c File Reference

Include dependency graph for intel_be_device.c:

Go to the source code of this file.

Functions

static struct intel_be_deviceintel_be_device (struct pipe_winsys *winsys)
static void * intel_be_buffer_map (struct pipe_winsys *winsys, struct pipe_buffer *buf, unsigned flags)
static void intel_be_buffer_unmap (struct pipe_winsys *winsys, struct pipe_buffer *buf)
static void intel_be_buffer_destroy (struct pipe_winsys *winsys, struct pipe_buffer *buf)
static struct pipe_bufferintel_be_buffer_create (struct pipe_winsys *winsys, unsigned alignment, unsigned usage, unsigned size)
static struct pipe_bufferintel_be_user_buffer_create (struct pipe_winsys *winsys, void *ptr, unsigned bytes)
struct pipe_bufferintel_be_buffer_from_handle (struct intel_be_device *device, const char *name, unsigned handle)
 Create a be buffer from a drm bo handle.
static struct pipe_surfaceintel_i915_surface_alloc (struct pipe_winsys *winsys)
static int intel_i915_surface_alloc_storage (struct pipe_winsys *winsys, struct pipe_surface *surf, unsigned width, unsigned height, enum pipe_format format, unsigned flags, unsigned tex_usage)
static void intel_i915_surface_release (struct pipe_winsys *winsys, struct pipe_surface **s)
static void intel_be_fence_reference (struct pipe_winsys *sws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence)
static int intel_be_fence_signalled (struct pipe_winsys *sws, struct pipe_fence_handle *fence, unsigned flag)
static int intel_be_fence_finish (struct pipe_winsys *sws, struct pipe_fence_handle *fence, unsigned flag)
boolean intel_be_init_device (struct intel_be_device *dev, int fd, unsigned id)
void intel_be_destroy_device (struct intel_be_device *dev)


Function Documentation

static struct pipe_buffer* intel_be_buffer_create ( struct pipe_winsys winsys,
unsigned  alignment,
unsigned  usage,
unsigned  size 
) [static, read]

Definition at line 66 of file intel_be_device.c.

References pipe_buffer::alignment, intel_be_buffer::base, CALLOC_STRUCT, intel_be_buffer::driBO, driBOData(), driGenBuffers(), intel_be_device(), intel_be_device::mallocPool, PIPE_BUFFER_USAGE_CONSTANT, PIPE_BUFFER_USAGE_CUSTOM, PIPE_BUFFER_USAGE_GPU_READ, PIPE_BUFFER_USAGE_GPU_WRITE, PIPE_BUFFER_USAGE_VERTEX, intel_be_buffer::pool, pipe_buffer::refcount, intel_be_device::regionPool, pipe_buffer::size, pipe_buffer::usage, and intel_be_device::vertexPool.

00070 {
00071         struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
00072         struct intel_be_device *iws = intel_be_device(winsys);
00073         unsigned flags = 0;
00074         struct _DriBufferPool *pool;
00075 
00076         buffer->base.refcount = 1;
00077         buffer->base.alignment = alignment;
00078         buffer->base.usage = usage;
00079         buffer->base.size = size;
00080 
00081         if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
00082                 flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
00083                 pool = iws->mallocPool;
00084         } else if (usage & PIPE_BUFFER_USAGE_CUSTOM) {
00085                 /* For vertex buffers */
00086                 flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
00087                 pool = iws->vertexPool;
00088         } else {
00089                 flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
00090                 pool = iws->regionPool;
00091         }
00092 
00093         if (usage & PIPE_BUFFER_USAGE_GPU_READ)
00094                 flags |= DRM_BO_FLAG_READ;
00095 
00096         if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
00097                 flags |= DRM_BO_FLAG_WRITE;
00098 
00099         /* drm complains if we don't set any read/write flags.
00100          */
00101         if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
00102                 flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
00103 
00104         buffer->pool = pool;
00105         driGenBuffers( buffer->pool,
00106                 "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
00107 
00108         driBOData( buffer->driBO, size, NULL, buffer->pool, 0 );
00109 
00110         return &buffer->base;
00111 }

static void intel_be_buffer_destroy ( struct pipe_winsys winsys,
struct pipe_buffer buf 
) [static]

Definition at line 58 of file intel_be_device.c.

References dri_bo(), driBOUnReference(), and FREE.

00060 {
00061         driBOUnReference( dri_bo(buf) );
00062         FREE(buf);
00063 }

struct pipe_buffer* intel_be_buffer_from_handle ( struct intel_be_device device,
const char *  name,
unsigned  handle 
) [read]

Create a be buffer from a drm bo handle.

Takes a reference

XXX TODO check error

Definition at line 129 of file intel_be_device.c.

References pipe_buffer::alignment, intel_be_buffer::base, intel_be_buffer::driBO, driBOSetReferenced(), driBOSize(), driGenBuffers(), pipe_buffer::refcount, pipe_buffer::size, intel_be_device::staticPool, and pipe_buffer::usage.

00131 {
00132         struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
00133         struct pipe_buffer *buffer;
00134 
00135         if (!be_buf)
00136                 goto err;
00137 
00138         memset(be_buf, 0, sizeof(*be_buf));
00139 
00140         driGenBuffers(device->staticPool, name, 1, &be_buf->driBO, 0, 0, 0);
00141     driBOSetReferenced(be_buf->driBO, handle);
00142 
00143         if (0) 
00144                 goto err_bo;
00145         
00146         buffer = &be_buf->base;
00147         buffer->refcount = 1;
00148         buffer->alignment = 0;
00149         buffer->usage = 0;
00150         buffer->size = driBOSize(be_buf->driBO);
00151 
00152         return buffer;
00153 err_bo:
00154         free(be_buf);
00155 err:
00156         return NULL;
00157 }

static void* intel_be_buffer_map ( struct pipe_winsys winsys,
struct pipe_buffer buf,
unsigned  flags 
) [static]

Definition at line 36 of file intel_be_device.c.

References dri_bo(), driBOMap(), PIPE_BUFFER_USAGE_CPU_READ, and PIPE_BUFFER_USAGE_CPU_WRITE.

00039 {
00040         unsigned drm_flags = 0;
00041         
00042         if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
00043                 drm_flags |= DRM_BO_FLAG_WRITE;
00044 
00045         if (flags & PIPE_BUFFER_USAGE_CPU_READ)
00046                 drm_flags |= DRM_BO_FLAG_READ;
00047 
00048         return driBOMap( dri_bo(buf), drm_flags, 0 );
00049 }

static void intel_be_buffer_unmap ( struct pipe_winsys winsys,
struct pipe_buffer buf 
) [static]

Definition at line 51 of file intel_be_device.c.

References dri_bo(), and driBOUnmap().

00053 {
00054         driBOUnmap( dri_bo(buf) );
00055 }

void intel_be_destroy_device ( struct intel_be_device dev  ) 

TODO takedown fenceMgr and fMan

Definition at line 299 of file intel_be_device.c.

References intel_be_device::batchPool, driPoolTakeDown(), intel_be_device::mallocPool, intel_be_device::regionPool, intel_be_device::staticPool, and intel_be_device::vertexPool.

00300 {
00301         driPoolTakeDown(dev->mallocPool);
00302         driPoolTakeDown(dev->staticPool);
00303         driPoolTakeDown(dev->regionPool);
00304         driPoolTakeDown(dev->vertexPool);
00305         driPoolTakeDown(dev->batchPool);
00306 
00308 }

static struct intel_be_device* intel_be_device ( struct pipe_winsys winsys  )  [static, read]

Definition at line 24 of file intel_be_device.c.

00025 {
00026         return (struct intel_be_device *)winsys;
00027 }

static int intel_be_fence_finish ( struct pipe_winsys sws,
struct pipe_fence_handle *  fence,
unsigned  flag 
) [static]

Definition at line 217 of file intel_be_device.c.

References driFenceFinish().

00220 {
00221         return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
00222 }

static void intel_be_fence_reference ( struct pipe_winsys sws,
struct pipe_fence_handle **  ptr,
struct pipe_fence_handle *  fence 
) [static]

Definition at line 197 of file intel_be_device.c.

References driFenceReference(), and driFenceUnReference().

00200 {
00201         if (*ptr)
00202                 driFenceUnReference((struct _DriFenceObject **)ptr);
00203 
00204         if (fence)
00205                 *ptr = (struct pipe_fence_handle *)driFenceReference((struct _DriFenceObject *)fence);
00206 }

static int intel_be_fence_signalled ( struct pipe_winsys sws,
struct pipe_fence_handle *  fence,
unsigned  flag 
) [static]

Definition at line 209 of file intel_be_device.c.

References driFenceSignaled().

00212 {
00213         return driFenceSignaled((struct _DriFenceObject *)fence, flag);
00214 }

boolean intel_be_init_device ( struct intel_be_device dev,
int  fd,
unsigned  id 
)

Definition at line 230 of file intel_be_device.c.

References intel_be_device::base, intel_be_device::batchPool, pipe_winsys::buffer_create, pipe_winsys::buffer_destroy, pipe_winsys::buffer_map, pipe_winsys::buffer_unmap, driDRMPoolInit(), driFenceMgrTTMInit(), driInitFreeSlabManager(), driMallocPoolInit(), driSlabPoolInit(), intel_be_device::fd, pipe_winsys::fence_finish, pipe_winsys::fence_reference, pipe_winsys::fence_signalled, intel_be_device::fenceMgr, pipe_winsys::flush_frontbuffer, intel_be_device::fMan, pipe_winsys::get_name, i915_create_screen(), intel_be_buffer_create(), intel_be_buffer_destroy(), intel_be_buffer_map(), intel_be_buffer_unmap(), intel_be_fence_finish(), intel_be_fence_reference(), intel_be_fence_signalled(), intel_be_user_buffer_create(), intel_flush_frontbuffer(), intel_get_name(), intel_i915_surface_alloc(), intel_i915_surface_alloc_storage(), intel_i915_surface_release(), intel_be_device::mallocPool, intel_be_device::max_batch_size, intel_be_device::max_vertex_size, intel_be_device::regionPool, intel_be_device::screen, intel_be_device::staticPool, pipe_winsys::surface_alloc, pipe_winsys::surface_alloc_storage, pipe_winsys::surface_release, pipe_winsys::user_buffer_create, and intel_be_device::vertexPool.

00231 {
00232         dev->fd = fd;
00233         dev->max_batch_size = 16 * 4096;
00234         dev->max_vertex_size = 128 * 4096;
00235 
00236         dev->base.buffer_create = intel_be_buffer_create;
00237         dev->base.user_buffer_create = intel_be_user_buffer_create;
00238         dev->base.buffer_map = intel_be_buffer_map;
00239         dev->base.buffer_unmap = intel_be_buffer_unmap;
00240         dev->base.buffer_destroy = intel_be_buffer_destroy;
00241         dev->base.surface_alloc = intel_i915_surface_alloc;
00242         dev->base.surface_alloc_storage = intel_i915_surface_alloc_storage;
00243         dev->base.surface_release = intel_i915_surface_release;
00244         dev->base.fence_reference = intel_be_fence_reference;
00245         dev->base.fence_signalled = intel_be_fence_signalled;
00246         dev->base.fence_finish = intel_be_fence_finish;
00247 
00248 #if 0 /* Set by the winsys */
00249         dev->base.flush_frontbuffer = intel_flush_frontbuffer;
00250         dev->base.get_name = intel_get_name;
00251 #endif
00252 
00253         dev->fMan = driInitFreeSlabManager(10, 10);
00254         dev->fenceMgr = driFenceMgrTTMInit(dev->fd);
00255 
00256         dev->mallocPool = driMallocPoolInit();
00257         dev->staticPool = driDRMPoolInit(dev->fd);
00258         /* Sizes: 64 128 256 512 1024 2048 4096 8192 16384 32768 */
00259         dev->regionPool = driSlabPoolInit(dev->fd,
00260                                           DRM_BO_FLAG_READ |
00261                                           DRM_BO_FLAG_WRITE |
00262                                           DRM_BO_FLAG_MEM_TT,
00263                                           DRM_BO_FLAG_READ |
00264                                           DRM_BO_FLAG_WRITE |
00265                                           DRM_BO_FLAG_MEM_TT,
00266                                           64,
00267                                           10, 120, 4096 * 64, 0,
00268                                           dev->fMan);
00269 
00270         dev->vertexPool = driSlabPoolInit(dev->fd,
00271                                           DRM_BO_FLAG_READ |
00272                                           DRM_BO_FLAG_WRITE |
00273                                           DRM_BO_FLAG_MEM_TT,
00274                                           DRM_BO_FLAG_READ |
00275                                           DRM_BO_FLAG_WRITE |
00276                                           DRM_BO_FLAG_MEM_TT,
00277                                           dev->max_vertex_size,
00278                                           1, 120, dev->max_vertex_size * 4, 0,
00279                                           dev->fMan);
00280 
00281         dev->batchPool = driSlabPoolInit(dev->fd,
00282                                          DRM_BO_FLAG_EXE |
00283                                          DRM_BO_FLAG_MEM_TT,
00284                                          DRM_BO_FLAG_EXE |
00285                                          DRM_BO_FLAG_MEM_TT,
00286                                          dev->max_batch_size,
00287                                          1, 40, dev->max_batch_size * 16, 0,
00288                                          dev->fMan);
00289 
00290         /* Fill in this struct with callbacks that i915simple will need to
00291          * communicate with the window system, buffer manager, etc.
00292          */
00293         dev->screen = i915_create_screen(&dev->base, id);
00294 
00295         return true;
00296 }

static struct pipe_buffer* intel_be_user_buffer_create ( struct pipe_winsys winsys,
void *  ptr,
unsigned  bytes 
) [static, read]

Definition at line 115 of file intel_be_device.c.

References intel_be_buffer::base, CALLOC_STRUCT, intel_be_buffer::driBO, driGenUserBuffer(), intel_be_device(), pipe_buffer::refcount, and intel_be_device::regionPool.

00116 {
00117         struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
00118         struct intel_be_device *iws = intel_be_device(winsys);
00119 
00120         driGenUserBuffer( iws->regionPool,
00121                           "pipe user buffer", &buffer->driBO, ptr, bytes );
00122 
00123         buffer->base.refcount = 1;
00124 
00125         return &buffer->base;
00126 }

static struct pipe_surface* intel_i915_surface_alloc ( struct pipe_winsys winsys  )  [static, read]

Definition at line 167 of file intel_be_device.c.

References assert.

00168 {
00169         assert((size_t)"intel_i915_surface_alloc is deprecated" & 0);
00170         return NULL;
00171 }

static int intel_i915_surface_alloc_storage ( struct pipe_winsys winsys,
struct pipe_surface surf,
unsigned  width,
unsigned  height,
enum pipe_format  format,
unsigned  flags,
unsigned  tex_usage 
) [static]

Definition at line 174 of file intel_be_device.c.

References assert.

00180 {
00181         assert((size_t)"intel_i915_surface_alloc_storage is deprecated" & 0);
00182         return -1;
00183 }

static void intel_i915_surface_release ( struct pipe_winsys winsys,
struct pipe_surface **  s 
) [static]

Definition at line 186 of file intel_be_device.c.

References assert.

00187 {
00188         assert((size_t)"intel_i915_surface_release is deprecated" & 0);
00189 }


Generated on Tue Sep 29 06:25:45 2009 for Gallium3D by  doxygen 1.5.4