gallium: Use pipe_buffer_* inlines as much as possible.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 4 Sep 2008 00:32:54 +0000 (09:32 +0900)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 4 Sep 2008 00:38:23 +0000 (09:38 +0900)
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_draw_quad.c
src/gallium/auxiliary/util/u_gen_mipmap.c

index 05399f9885e7b60f961f1f2a1b6956c5ef9bea1a..9adf72944e6d2938eb835fc8089baabbe2e9531b 100644 (file)
@@ -138,10 +138,10 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
    /* fragment shader */
    ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
 
-   ctx->vbuf = pipe->winsys->buffer_create(pipe->winsys,
-                                           32,
-                                           PIPE_BUFFER_USAGE_VERTEX,
-                                           sizeof(ctx->vertices));
+   ctx->vbuf = pipe_buffer_create(pipe->screen,
+                                  32,
+                                  PIPE_BUFFER_USAGE_VERTEX,
+                                  sizeof(ctx->vertices));
    if (!ctx->vbuf) {
       FREE(ctx);
       ctx->pipe->delete_fs_state(ctx->pipe, ctx->fs);
@@ -174,7 +174,7 @@ util_destroy_blit(struct blit_state *ctx)
    FREE((void*) ctx->vert_shader.tokens);
    FREE((void*) ctx->frag_shader.tokens);
 
-   pipe->winsys->buffer_destroy(pipe->winsys, ctx->vbuf);
+   pipe_buffer_reference(pipe->screen, &ctx->vbuf, NULL);
 
    FREE(ctx);
 }
@@ -214,12 +214,12 @@ setup_vertex_data(struct blit_state *ctx,
    ctx->vertices[3][1][0] = 0.0f;
    ctx->vertices[3][1][1] = 1.0f;
 
-   buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
-                                       PIPE_BUFFER_USAGE_CPU_WRITE);
+   buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
    memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
 
-   ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+   pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
 }
 
 
@@ -259,12 +259,12 @@ setup_vertex_data_tex(struct blit_state *ctx,
    ctx->vertices[3][1][0] = s0;
    ctx->vertices[3][1][1] = t1;
 
-   buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
-                                       PIPE_BUFFER_USAGE_CPU_WRITE);
+   buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
    memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
 
-   ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+   pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
 }
 /**
  * Copy pixel block from src surface to dst surface.
index d643ee9ab75fdcb1383c70c11a99803ec2c2bb09..8ecae71b641db79c2a514bf30b41b5590b4eac80 100644 (file)
@@ -86,11 +86,11 @@ util_draw_texquad(struct pipe_context *pipe,
    vertexBytes = 4 * (4 * numAttribs * sizeof(float));
 
    /* XXX create one-time */
-   vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
-                                      PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
+   vbuf = pipe_buffer_create(pipe->screen, 32,
+                             PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
    if (vbuf) {
-      float *v = (float *) pipe->winsys->buffer_map(pipe->winsys, vbuf,
-                                             PIPE_BUFFER_USAGE_CPU_WRITE);
+      float *v = (float *) pipe_buffer_map(pipe->screen, vbuf,
+                                           PIPE_BUFFER_USAGE_CPU_WRITE);
       if (v) {
          /*
           * Load vertex buffer
@@ -123,7 +123,7 @@ util_draw_texquad(struct pipe_context *pipe,
          v[28] = 0.0;
          v[29] = 1.0;
 
-         pipe->winsys->buffer_unmap(pipe->winsys, vbuf);
+         pipe_buffer_unmap(pipe->screen, vbuf);
          util_draw_vertex_buffer(pipe, vbuf, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
       }
 
index c1e2c19f8772c61f10d02b13c381fc83deb5cf96..8c983da309e2510d5069212f93143de84244606d 100644 (file)
@@ -595,19 +595,19 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcMap = ((ubyte *) winsys->buffer_map(winsys, srcSurf->buffer,
-                                            PIPE_BUFFER_USAGE_CPU_READ)
+      srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
+                                          PIPE_BUFFER_USAGE_CPU_READ)
                 + srcSurf->offset);
-      dstMap = ((ubyte *) winsys->buffer_map(winsys, dstSurf->buffer,
-                                            PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
+                                          PIPE_BUFFER_USAGE_CPU_WRITE)
                 + dstSurf->offset);
 
       reduce_1d(pt->format,
                 srcSurf->width, srcMap,
                 dstSurf->width, dstMap);
 
-      winsys->buffer_unmap(winsys, srcSurf->buffer);
-      winsys->buffer_unmap(winsys, dstSurf->buffer);
+      pipe_buffer_unmap(screen, srcSurf->buffer);
+      pipe_buffer_unmap(screen, dstSurf->buffer);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);
@@ -639,11 +639,11 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
       dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
                                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
-      srcMap = ((ubyte *) winsys->buffer_map(winsys, srcSurf->buffer,
-                                            PIPE_BUFFER_USAGE_CPU_READ)
+      srcMap = ((ubyte *) pipe_buffer_map(screen, srcSurf->buffer,
+                                          PIPE_BUFFER_USAGE_CPU_READ)
                 + srcSurf->offset);
-      dstMap = ((ubyte *) winsys->buffer_map(winsys, dstSurf->buffer,
-                                            PIPE_BUFFER_USAGE_CPU_WRITE)
+      dstMap = ((ubyte *) pipe_buffer_map(screen, dstSurf->buffer,
+                                          PIPE_BUFFER_USAGE_CPU_WRITE)
                 + dstSurf->offset);
 
       reduce_2d(pt->format,
@@ -652,8 +652,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
                 dstSurf->width, dstSurf->height,
                 dstSurf->stride, dstMap);
 
-      winsys->buffer_unmap(winsys, srcSurf->buffer);
-      winsys->buffer_unmap(winsys, dstSurf->buffer);
+      pipe_buffer_unmap(screen, srcSurf->buffer);
+      pipe_buffer_unmap(screen, dstSurf->buffer);
 
       pipe_surface_reference(&srcSurf, NULL);
       pipe_surface_reference(&dstSurf, NULL);
@@ -759,10 +759,10 @@ util_create_gen_mipmap(struct pipe_context *pipe,
    /* fragment shader */
    ctx->fs = util_make_fragment_tex_shader(pipe, &ctx->frag_shader);
 
-   ctx->vbuf = pipe->winsys->buffer_create(pipe->winsys,
-                                           32,
-                                           PIPE_BUFFER_USAGE_VERTEX,
-                                           sizeof(ctx->vertices));
+   ctx->vbuf = pipe_buffer_create(pipe->screen,
+                                  32,
+                                  PIPE_BUFFER_USAGE_VERTEX,
+                                  sizeof(ctx->vertices));
    if (!ctx->vbuf) {
       FREE(ctx);
       return NULL;
@@ -805,12 +805,12 @@ set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
    ctx->vertices[3][1][0] = 0.0f;
    ctx->vertices[3][1][1] = 1.0f;
 
-   buf = ctx->pipe->winsys->buffer_map(ctx->pipe->winsys, ctx->vbuf,
-                                       PIPE_BUFFER_USAGE_CPU_WRITE);
+   buf = pipe_buffer_map(ctx->pipe->screen, ctx->vbuf,
+                         PIPE_BUFFER_USAGE_CPU_WRITE);
 
    memcpy(buf, ctx->vertices, sizeof(ctx->vertices));
 
-   ctx->pipe->winsys->buffer_unmap(ctx->pipe->winsys, ctx->vbuf);
+   pipe_buffer_unmap(ctx->pipe->screen, ctx->vbuf);
 }
 
 
@@ -829,7 +829,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
    FREE((void*) ctx->vert_shader.tokens);
    FREE((void*) ctx->frag_shader.tokens);
 
-   pipe->winsys->buffer_destroy(pipe->winsys, ctx->vbuf);
+   pipe_buffer_reference(pipe->winsys, &ctx->vbuf, NULL);
 
    FREE(ctx);
 }