gallium/graw: stop using user_buffer_create
authorMarek Olšák <maraeo@gmail.com>
Sat, 12 May 2012 10:56:19 +0000 (12:56 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 12 May 2012 21:13:45 +0000 (23:13 +0200)
This is compile-tested.

16 files changed:
src/gallium/auxiliary/util/u_inlines.h
src/gallium/tests/graw/fs-fragcoord.c
src/gallium/tests/graw/fs-frontface.c
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/fs-write-z.c
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/occlusion-query.c
src/gallium/tests/graw/quad-sample.c
src/gallium/tests/graw/quad-tex.c
src/gallium/tests/graw/shader-leak.c
src/gallium/tests/graw/tex-srgb.c
src/gallium/tests/graw/tex-swizzle.c
src/gallium/tests/graw/tri-gs.c
src/gallium/tests/graw/tri-instanced.c
src/gallium/tests/graw/tri.c
src/gallium/tests/graw/vs-test.c

index b0ba585b9bf9bde7a8e016762871453b7eb96660..2ec1ccfe9d3204cf85aeb0f80118ee18037d0c2d 100644 (file)
@@ -376,6 +376,19 @@ pipe_buffer_write_nooverlap(struct pipe_context *pipe,
                                0, 0);
 }
 
+static INLINE struct pipe_resource *
+pipe_buffer_create_with_data(struct pipe_context *pipe,
+                             unsigned bind,
+                             unsigned usage,
+                             unsigned size,
+                             void *ptr)
+{
+   struct pipe_resource *res = pipe_buffer_create(pipe->screen,
+                                                  bind, usage, size);
+   pipe_buffer_write_nooverlap(pipe, res, 0, size, ptr);
+   return res;
+}
+
 static INLINE void
 pipe_buffer_read(struct pipe_context *pipe,
                  struct pipe_resource *buf,
index 471acbb363926bf3bb71738c1924172480f43f3b..893170fe597e48c9de50d8cd13e9a6f0f645c20e 100644 (file)
@@ -67,10 +67,11 @@ set_vertices(void)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index e725255181580638338edf2fe796815f399339f7..d46ce5540695ab82eba96d4b5ac6b9f55e017281 100644 (file)
@@ -89,10 +89,11 @@ set_vertices(void)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                                 vertices,
-                                                 sizeof(vertices),
-                                                 PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index b42a86cfc8ed85c4bc98887f4ffe5a7fa5e92840..1c0d514667a35eca11f681b1a28130fb392522e0 100644 (file)
@@ -216,10 +216,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }
index 186e3ec5034a5dd5b5f7b437a5264613adb87e78..3eee2b2ab4ee03e131e5d8f3c627d85687e39c36 100644 (file)
@@ -93,10 +93,11 @@ set_vertices(void)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                                 vertices,
-                                                 sizeof(vertices),
-                                                 PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index a471abd9a3d1e2e07dfac6669f4714ae9a09792d..52eb60079768e33542a634678e26e70eef5dd478 100644 (file)
@@ -251,15 +251,17 @@ static void set_vertices( void )
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
    if (draw_strip) {
-      vbuf.buffer = screen->user_buffer_create(screen,
-                                               vertices_strip,
-                                               sizeof(vertices_strip),
-                                               PIPE_BIND_VERTEX_BUFFER);
+      vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                                 PIPE_BIND_VERTEX_BUFFER,
+                                                 PIPE_USAGE_STATIC,
+                                                 sizeof(vertices_strip),
+                                                 vertices_strip);
    } else {
-      vbuf.buffer = screen->user_buffer_create(screen,
-                                               vertices,
-                                               sizeof(vertices),
-                                               PIPE_BIND_VERTEX_BUFFER);
+      vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                                 PIPE_BIND_VERTEX_BUFFER,
+                                                 PIPE_USAGE_STATIC,
+                                                 sizeof(vertices),
+                                                 vertices);
    }
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
index 5c4bc8cf47982f25eecc17c9574eb6a8bd3c4b79..cfaba34285d52449cbe6a304e2d05bf85bce0d03 100644 (file)
@@ -94,10 +94,11 @@ set_vertices(struct vertex *vertices, unsigned bytes)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                            vertices,
-                                            bytes,
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              bytes,
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index 712ff515befdd7f7ddbf049c3cc1ff5d8270b47f..4703b83db0ea1a4eb30d275e54081e4b8b9ed412 100644 (file)
@@ -100,10 +100,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }
index 9f81ad593ae06a7194e5acb0f5eca41732cdc0bb..dc3a73796e7ea68d3e67ccf93faa50f5bef08488 100644 (file)
@@ -56,10 +56,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index 103aa6d3f3a97d1dc2fac91deb2f2dd64cf79bba..f24490e349f915202848c1e09429296ffff429c2 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
 
 
 static int num_iters = 100;
@@ -89,10 +90,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }
index 8eaf0bd1ec765bf479608466f37bde16c28892e5..ea07b8d692d63ac25e5278a5bcfbae005bf903ed 100644 (file)
@@ -72,10 +72,11 @@ set_vertices(struct vertex *verts, unsigned num_verts)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                                 verts,
-                                                 num_verts *sizeof(struct vertex),
-                                                 PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              num_verts * sizeof(struct vertex),
+                                              verts);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index 80a96087e78d4108fd96ad7747230bf1789c6d83..0709447f33e1d1a82bbf85e11a1279e6c913ab22 100644 (file)
@@ -54,10 +54,11 @@ static void set_vertices(void)
 
    vbuf.stride = sizeof(struct vertex);
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index 733263133ca4e4450703bf4d871f0e963d5644d8..7406fbc8956c3a64a865edba6534c73b8412b5b4 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
 
 enum pipe_format formats[] = {
    PIPE_FORMAT_R8G8B8A8_UNORM,
@@ -90,10 +91,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }
index 837381592c26648acdaf974a8b2c6e3aa9c6805a..d3de15c32c0e858e4afe4cbc63a52f924f674f31 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "util/u_memory.h"      /* Offset() */
 #include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
 
 
 enum pipe_format formats[] = {
@@ -133,27 +134,29 @@ static void set_vertices( void )
    /* vertex data */
    vbuf[0].stride = sizeof( struct vertex );
    vbuf[0].buffer_offset = 0;
-   vbuf[0].buffer = screen->user_buffer_create(screen,
-                                               vertices,
-                                               sizeof(vertices),
-                                               PIPE_BIND_VERTEX_BUFFER);
+   vbuf[0].buffer = pipe_buffer_create_with_data(ctx,
+                                                 PIPE_BIND_VERTEX_BUFFER,
+                                                 PIPE_USAGE_STATIC,
+                                                 sizeof(vertices),
+                                                 vertices);
 
    /* instance data */
    vbuf[1].stride = sizeof( inst_data[0] );
    vbuf[1].buffer_offset = 0;
-   vbuf[1].buffer = screen->user_buffer_create(screen,
-                                               inst_data,
-                                               sizeof(inst_data),
-                                               PIPE_BIND_VERTEX_BUFFER);
-
+   vbuf[1].buffer = pipe_buffer_create_with_data(ctx,
+                                                 PIPE_BIND_VERTEX_BUFFER,
+                                                 PIPE_USAGE_STATIC,
+                                                 sizeof(inst_data),
+                                                 inst_data);
 
    ctx->set_vertex_buffers(ctx, 2, vbuf);
 
    /* index data */
-   ibuf.buffer = screen->user_buffer_create(screen,
-                                            indices,
-                                            sizeof(indices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   ibuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_INDEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(indices),
+                                              indices);
    ibuf.offset = 0;
    ibuf.index_size = 2;
 
index 75fa88cae9e5c98f0748c26655df9a34b1d9e3f9..f6b2aa96c9de763e6ba18d0af9f4d790110f700e 100644 (file)
@@ -55,10 +55,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = info.screen->user_buffer_create(info.screen,
-                                                 vertices,
-                                                 sizeof(vertices),
-                                                 PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
 }
index 23b7ada98ad49799232cc41d9740f33055c73efc..ad524c46537e206d2927e858a4888b7e8764fa2c 100644 (file)
@@ -172,10 +172,11 @@ static void set_vertices( void )
 
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   vbuf.buffer = pipe_buffer_create_with_data(ctx,
+                                              PIPE_BIND_VERTEX_BUFFER,
+                                              PIPE_USAGE_STATIC,
+                                              sizeof(vertices),
+                                              vertices);
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }