i915g: Add buffer write callback
authorJakob Bornecrantz <wallbraker@gmail.com>
Tue, 8 Sep 2009 23:38:04 +0000 (00:38 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Tue, 8 Sep 2009 23:43:36 +0000 (00:43 +0100)
src/gallium/drivers/i915simple/intel_winsys.h
src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c

index f949f52a9ced8331af17c5d6acf9c8a5a79e3506..42c5e7470ec4700c1b9c83561c73e5989eacf265 100644 (file)
@@ -150,6 +150,17 @@ struct intel_winsys {
    void (*buffer_unmap)(struct intel_winsys *iws,
                         struct intel_buffer *buffer);
 
+   /**
+    * Write to a buffer.
+    *
+    * Arguments follows pwrite(2)
+    */
+   int (*buffer_write)(struct intel_winsys *iws,
+                       struct intel_buffer *dst,
+                       const void *src,
+                       size_t size,
+                       size_t offset);
+
    void (*buffer_destroy)(struct intel_winsys *iws,
                           struct intel_buffer *buffer);
    /*@}*/
index e932f71e42ca7e9e99b91d354ce890f9e6083ccc..0030f915a367282d139d60bf5b4236ec888c5241 100644 (file)
@@ -110,6 +110,18 @@ intel_drm_buffer_unmap(struct intel_winsys *iws,
       drm_intel_bo_unmap(intel_bo(buffer));
 }
 
+static int
+intel_drm_buffer_write(struct intel_winsys *iws,
+                       struct intel_buffer *buffer,
+                       const void *data,
+                       size_t size,
+                       size_t offset)
+{
+   struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
+
+   return drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
+}
+
 static void
 intel_drm_buffer_destroy(struct intel_winsys *iws,
                          struct intel_buffer *buffer)
@@ -131,5 +143,6 @@ intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws)
    idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg;
    idws->base.buffer_map = intel_drm_buffer_map;
    idws->base.buffer_unmap = intel_drm_buffer_unmap;
+   idws->base.buffer_write = intel_drm_buffer_write;
    idws->base.buffer_destroy = intel_drm_buffer_destroy;
 }