i965g: Build winsys again
authorJakob Bornecrantz <jakob@vmware.com>
Fri, 6 Nov 2009 00:09:28 +0000 (00:09 +0000)
committerJakob Bornecrantz <wallbraker@gmail.com>
Fri, 6 Nov 2009 15:55:06 +0000 (15:55 +0000)
src/gallium/winsys/drm/i965/dri/Makefile
src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c

index badd486b5150e40d6f1de79b918e7e14d4617fba..f7e81eed87b0bab5144eccac73980a93b49bc4e2 100644 (file)
@@ -5,7 +5,7 @@ LIBNAME = i965_dri.so
 
 PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
-       $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
+       $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
        $(TOP)/src/gallium/drivers/identity/libidentity.a \
index 61717d2942d7acdb9784877a13d10d5b2d3237d0..431bedbaffef76f39251c9a067c876582e09ffd7 100644 (file)
@@ -17,18 +17,19 @@ const char *names[BRW_BUFFER_TYPE_MAX] = {
    "state_cache",
 };
 
-static struct brw_winsys_buffer *
-i965_libdrm_bo_alloc( struct brw_winsys_screen *sws,
-                     enum brw_buffer_type type,
-                     unsigned size,
-                     unsigned alignment )
+static enum pipe_error 
+i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
+                     enum brw_buffer_type type,
+                     unsigned size,
+                     unsigned alignment,
+                     struct brw_winsys_buffer **bo_out)
 {
    struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
    struct i965_libdrm_buffer *buf;
 
    buf = CALLOC_STRUCT(i965_libdrm_buffer);
    if (!buf)
-      return NULL;
+      return PIPE_ERROR_OUT_OF_MEMORY;
 
    switch (type) {
    case BRW_BUFFER_TYPE_TEXTURE:
@@ -51,47 +52,27 @@ i965_libdrm_bo_alloc( struct brw_winsys_screen *sws,
    if (!buf->bo)
       goto err;
 
-   buf->base.offset = &buf->bo->offset;
    buf->base.size = size;
 
-   return &buf->base;
+   *bo_out = &buf->base;
+   return PIPE_OK;
 
 err:
    assert(0);
    FREE(buf);
-   return NULL;
+   return PIPE_ERROR_OUT_OF_MEMORY;
 }
 
-
-
-
-/* Reference and unreference buffers:
- */
 static void 
-i965_libdrm_bo_reference( struct brw_winsys_buffer *buffer )
+i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
 {
    struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
 
-   /* I think we have to refcount ourselves and then just pass through
-    * the final dereference to the bo on destruction.
-    */
-   buf->cheesy_refcount++;
+   drm_intel_bo_unreference(buf->bo);
+   FREE(buffer);
 }
 
-static void 
-i965_libdrm_bo_unreference( struct brw_winsys_buffer *buffer )
-{
-   struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
-   if (--buf->cheesy_refcount == 0) {
-      drm_intel_bo_unreference(buf->bo);
-      FREE(buffer);
-   }
-}
-
-   /* XXX: parameter names!!
-    */
-static int 
+static enum pipe_error
 i965_libdrm_bo_emit_reloc( struct brw_winsys_buffer *buffer,
                           enum brw_buffer_usage usage,
                           unsigned delta,
@@ -144,7 +125,7 @@ i965_libdrm_bo_emit_reloc( struct brw_winsys_buffer *buffer,
    return 0;
 }
 
-static int 
+static enum pipe_error 
 i965_libdrm_bo_exec( struct brw_winsys_buffer *buffer,
                     unsigned bytes_used )
 {
@@ -153,29 +134,38 @@ i965_libdrm_bo_exec( struct brw_winsys_buffer *buffer,
 
    ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
    if (ret)
-      return -1;
+      return PIPE_ERROR;
 
-   return 0;
+   return PIPE_OK;
 }
 
-static int
+static enum pipe_error
 i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
-                      size_t offset,
-                      size_t size,
-                      const void *data)
+                       enum brw_buffer_data_type data_type,
+                       size_t offset,
+                       size_t size,
+                       const void *data,
+                       const struct brw_winsys_reloc *reloc,
+                       unsigned nr_reloc)
 {
    struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-   int ret;
+   int ret, i;
+
+   (void)data_type;
 
    /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
     */
    ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
    if (ret)
-      return -1;
-   
-   return 0;
-}
+      return PIPE_ERROR;
+  
+   for (i = 0; i < nr_reloc; i++) {
+      i965_libdrm_bo_emit_reloc(buffer, reloc[i].usage, reloc[i].delta,
+                                reloc[i].offset, reloc[i].bo);
+   }
 
+   return PIPE_OK;
+}
 
 static boolean 
 i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
@@ -200,7 +190,7 @@ i965_libdrm_bo_references(struct brw_winsys_buffer *a,
 /* XXX: couldn't this be handled by returning true/false on
  * bo_emit_reloc?
  */
-static boolean 
+static enum pipe_error
 i965_libdrm_check_aperture_space( struct brw_winsys_screen *iws,
                                  struct brw_winsys_buffer **buffers,
                                  unsigned count )
@@ -219,12 +209,14 @@ i965_libdrm_check_aperture_space( struct brw_winsys_screen *iws,
    return dri_bufmgr_check_aperture_space(bos, count);
 }
 
-/**
- * Map a buffer.
- */
 static void *
 i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
-                  boolean write)
+                   enum brw_buffer_data_type data_type,
+                   unsigned offset,
+                   unsigned length,
+                   boolean write,
+                   boolean discard,
+                   boolean flush_explicit)
 {
    struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
    int ret;
@@ -246,9 +238,14 @@ i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
    return buf->bo->virtual;
 }
 
-/**
- * Unmap a buffer.
- */
+static void
+i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
+                           unsigned offset,
+                           unsigned length)
+{
+
+}
+
 static void 
 i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
 {
@@ -263,13 +260,11 @@ i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
       drm_intel_bo_unmap(buf->bo);
 }
 
-
 void
 i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
 {
    idws->base.bo_alloc             = i965_libdrm_bo_alloc;
-   idws->base.bo_reference         = i965_libdrm_bo_reference;
-   idws->base.bo_unreference       = i965_libdrm_bo_unreference;
+   idws->base.bo_destroy           = i965_libdrm_bo_destroy;
    idws->base.bo_emit_reloc        = i965_libdrm_bo_emit_reloc;
    idws->base.bo_exec              = i965_libdrm_bo_exec;
    idws->base.bo_subdata           = i965_libdrm_bo_subdata;
@@ -277,5 +272,6 @@ i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
    idws->base.bo_references        = i965_libdrm_bo_references;
    idws->base.check_aperture_space = i965_libdrm_check_aperture_space;
    idws->base.bo_map               = i965_libdrm_bo_map;
+   idws->base.bo_flush_range       = i965_libdrm_bo_flush_range;
    idws->base.bo_unmap             = i965_libdrm_bo_unmap;
 }