OSDN Git Service

st/mesa: use the common uploader (v2)
authorMarek Olšák <marek.olsak@amd.com>
Fri, 27 Jan 2017 01:20:04 +0000 (02:20 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 14 Feb 2017 20:46:16 +0000 (21:46 +0100)
v2: use const_uploader

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> (v1)
Tested-by: Charmaine Lee <charmainel@vmware.com>
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_drawtex.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_pbo.c

index 6ab4ca9..d16f92e 100644 (file)
@@ -100,13 +100,13 @@ void st_upload_constants( struct st_context *st,
        * avoid gratuitous rendering synchronization.
        * Let's use a user buffer to avoid an unnecessary copy.
        */
-      if (st->constbuf_uploader) {
+      if (!st->has_user_constbuf) {
          cb.buffer = NULL;
          cb.user_buffer = NULL;
-         u_upload_data(st->constbuf_uploader, 0, paramBytes,
+         u_upload_data(st->pipe->const_uploader, 0, paramBytes,
                        st->ctx->Const.UniformBufferOffsetAlignment,
                        params->ParameterValues, &cb.buffer_offset, &cb.buffer);
-         u_upload_unmap(st->constbuf_uploader);
+         u_upload_unmap(st->pipe->const_uploader);
       } else {
          cb.buffer = NULL;
          cb.user_buffer = params->ParameterValues;
index 457c416..b2e2608 100644 (file)
@@ -717,7 +717,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
 
    vb.stride = sizeof(struct st_util_vertex);
 
-   u_upload_alloc(st->uploader, 0, num_vert_bytes, 4,
+   u_upload_alloc(pipe->stream_uploader, 0, num_vert_bytes, 4,
                   &vb.buffer_offset, &vb.buffer, (void **) &verts);
 
    /* build quads vertex data */
@@ -789,7 +789,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
       ctx->Current.RasterPos[1] += ymove;
    }
 
-   u_upload_unmap(st->uploader);
+   u_upload_unmap(pipe->stream_uploader);
 
    cso_set_vertex_buffers(st->cso_context,
                           cso_get_aux_vertex_buffer_slot(st->cso_context),
index 85f9a53..01c5757 100644 (file)
@@ -156,7 +156,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
       GLfloat *vbuf = NULL;
       GLuint tex_attr;
 
-      u_upload_alloc(st->uploader, 0,
+      u_upload_alloc(pipe->stream_uploader, 0,
                      numAttribs * 4 * 4 * sizeof(GLfloat), 4,
                      &offset, &vbuffer, (void **) &vbuf);
       if (!vbuffer) {
@@ -228,7 +228,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
          }
       }
 
-      u_upload_unmap(st->uploader);
+      u_upload_unmap(pipe->stream_uploader);
 
 #undef SET_ATTRIB
    }
index 5523734..3d0455f 100644 (file)
@@ -298,14 +298,6 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
       }
    }
 
-   u_upload_destroy(st->uploader);
-   if (st->indexbuf_uploader) {
-      u_upload_destroy(st->indexbuf_uploader);
-   }
-   if (st->constbuf_uploader) {
-      u_upload_destroy(st->constbuf_uploader);
-   }
-
    /* free glDrawPixels cache data */
    free(st->drawpix_cache.image);
    pipe_resource_reference(&st->drawpix_cache.texture, NULL);
@@ -345,22 +337,10 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
 
    st->dirty = ST_ALL_STATES_MASK;
 
-   /* Create upload manager for vertex data for glBitmap, glDrawPixels,
-    * glClear, etc.
-    */
-   st->uploader = u_upload_create(pipe, 65536, PIPE_BIND_VERTEX_BUFFER,
-                                  PIPE_USAGE_STREAM);
-
-   if (!screen->get_param(screen, PIPE_CAP_USER_INDEX_BUFFERS)) {
-      st->indexbuf_uploader = u_upload_create(pipe, 128 * 1024,
-                                              PIPE_BIND_INDEX_BUFFER,
-                                              PIPE_USAGE_STREAM);
-   }
-
-   if (!screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS))
-      st->constbuf_uploader = u_upload_create(pipe, 128 * 1024,
-                                              PIPE_BIND_CONSTANT_BUFFER,
-                                              PIPE_USAGE_STREAM);
+   st->has_user_indexbuf =
+      screen->get_param(screen, PIPE_CAP_USER_INDEX_BUFFERS);
+   st->has_user_constbuf =
+      screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS);
 
    st->cso_context = cso_create_context(pipe);
 
index b3478ea..942fdd7 100644 (file)
@@ -68,8 +68,6 @@ struct st_context
 
    struct pipe_context *pipe;
 
-   struct u_upload_mgr *uploader, *indexbuf_uploader, *constbuf_uploader;
-
    struct draw_context *draw;  /**< For selection/feedback/rastpos only */
    struct draw_stage *feedback_stage;  /**< For GL_FEEDBACK rendermode */
    struct draw_stage *selection_stage;  /**< For GL_SELECT rendermode */
@@ -86,6 +84,8 @@ struct st_context
    boolean has_shareable_shaders;
    boolean has_half_float_packing;
    boolean has_multi_draw_indirect;
+   boolean has_user_constbuf;
+   boolean has_user_indexbuf;
 
    /**
     * If a shader can be created when we get its source.
index c1a1d2d..8d54732 100644 (file)
@@ -105,16 +105,16 @@ setup_index_buffer(struct st_context *st,
       ibuffer->buffer = st_buffer_object(bufobj)->buffer;
       ibuffer->offset = pointer_to_offset(ib->ptr);
    }
-   else if (st->indexbuf_uploader) {
+   else if (!st->has_user_indexbuf) {
       /* upload indexes from user memory into a real buffer */
-      u_upload_data(st->indexbuf_uploader, 0,
+      u_upload_data(st->pipe->stream_uploader, 0,
                     ib->count * ibuffer->index_size, 4, ib->ptr,
                     &ibuffer->offset, &ibuffer->buffer);
       if (!ibuffer->buffer) {
          /* out of memory */
          return FALSE;
       }
-      u_upload_unmap(st->indexbuf_uploader);
+      u_upload_unmap(st->pipe->stream_uploader);
    }
    else {
       /* indices are in user space memory */
@@ -277,7 +277,7 @@ st_draw_vbo(struct gl_context *ctx,
       }
    }
 
-   if (ib && st->indexbuf_uploader && !_mesa_is_bufferobj(ib->obj)) {
+   if (ib && !st->has_user_indexbuf && !_mesa_is_bufferobj(ib->obj)) {
       pipe_resource_reference(&ibuffer.buffer, NULL);
    }
 }
@@ -418,7 +418,8 @@ st_draw_quad(struct st_context *st,
 
    vb.stride = sizeof(struct st_util_vertex);
 
-   u_upload_alloc(st->uploader, 0, 4 * sizeof(struct st_util_vertex), 4,
+   u_upload_alloc(st->pipe->stream_uploader, 0,
+                  4 * sizeof(struct st_util_vertex), 4,
                   &vb.buffer_offset, &vb.buffer, (void **) &verts);
    if (!vb.buffer) {
       return false;
@@ -468,7 +469,7 @@ st_draw_quad(struct st_context *st,
    verts[3].s = s0;
    verts[3].t = t1;
 
-   u_upload_unmap(st->uploader);
+   u_upload_unmap(st->pipe->stream_uploader);
 
    /* At the time of writing, cso_get_aux_vertex_buffer_slot() always returns
     * zero.  If that ever changes we need to audit the calls to that function
index a9ea6ea..2c63c09 100644 (file)
@@ -229,7 +229,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
       vbo.buffer = NULL;
       vbo.stride = 2 * sizeof(float);
 
-      u_upload_alloc(st->uploader, 0, 8 * sizeof(float), 4,
+      u_upload_alloc(st->pipe->stream_uploader, 0, 8 * sizeof(float), 4,
                      &vbo.buffer_offset, &vbo.buffer, (void **) &verts);
       if (!verts)
          return false;
@@ -243,7 +243,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
       verts[6] = x1;
       verts[7] = y1;
 
-      u_upload_unmap(st->uploader);
+      u_upload_unmap(st->pipe->stream_uploader);
 
       velem.src_offset = 0;
       velem.instance_divisor = 0;
@@ -261,16 +261,16 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
    {
       struct pipe_constant_buffer cb;
 
-      if (st->constbuf_uploader) {
+      if (!st->has_user_constbuf) {
          cb.buffer = NULL;
          cb.user_buffer = NULL;
-         u_upload_data(st->constbuf_uploader, 0, sizeof(addr->constants),
+         u_upload_data(st->pipe->const_uploader, 0, sizeof(addr->constants),
                        st->ctx->Const.UniformBufferOffsetAlignment,
                        &addr->constants, &cb.buffer_offset, &cb.buffer);
          if (!cb.buffer)
             return false;
 
-         u_upload_unmap(st->constbuf_uploader);
+         u_upload_unmap(st->pipe->const_uploader);
       } else {
          cb.buffer = NULL;
          cb.user_buffer = &addr->constants;