radeon-gallium: Add surface_buffer_create callback.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 20:21:17 +0000 (13:21 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 20:21:17 +0000 (13:21 -0700)
src/gallium/winsys/drm/radeon/core/radeon_buffer.c

index a15487352b22dbce33c8125bb3c6430b4ac664fb..0d0fdc5bd86e17db44d4b6446ac2070e4cb2f007 100644 (file)
@@ -93,6 +93,29 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
     return &radeon_buffer->base;
 }
 
+static struct pipe_buffer *radeon_surface_buffer_create(struct pipe_winsys *ws,
+                                                        unsigned width,
+                                                        unsigned height,
+                                                        enum pipe_format format,
+                                                        unsigned usage,
+                                                        unsigned *stride)
+{
+    struct pipe_format_block block;
+    unsigned nblocksx, nblocksy, size;
+
+    pf_get_block(format, &block);
+
+    nblocksx = pf_get_nblocksx(&block, width);
+    nblocksy = pf_get_nblocksy(&block, height);
+
+    /* Radeons enjoy things in multiples of 32. */
+    /* XXX this can be 32 when POT */
+    *stride = (nblocksx * block.size + 63) & ~63;
+    size = *stride * nblocksy;
+
+    return radeon_buffer_create(ws, 64, usage, size);
+}
+
 static void radeon_buffer_del(struct pipe_buffer *buffer)
 {
     struct radeon_pipe_buffer *radeon_buffer =
@@ -180,10 +203,11 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
     radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
 
     radeon_ws->base.buffer_create = radeon_buffer_create;
-    radeon_ws->base.buffer_destroy = radeon_buffer_del;
     radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
+    radeon_ws->base.surface_buffer_create = radeon_surface_buffer_create;
     radeon_ws->base.buffer_map = radeon_buffer_map;
     radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
+    radeon_ws->base.buffer_destroy = radeon_buffer_del;
 
     radeon_ws->base.fence_reference = radeon_fence_reference;
     radeon_ws->base.fence_signalled = radeon_fence_signalled;