u_upload_mgr: remove the return value from u_upload_alloc
authorMarek Olšák <marek.olsak@amd.com>
Wed, 2 Sep 2015 13:08:23 +0000 (15:08 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 3 Sep 2015 16:14:09 +0000 (18:14 +0200)
The return buffer or the returned pointer can be used instead.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_upload_mgr.c
src/gallium/auxiliary/util/u_upload_mgr.h
src/gallium/auxiliary/util/u_vbuf.c
src/mesa/state_tracker/st_cb_bitmap.c
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_drawtex.c

index 4c560848e87bedf651a6ab5c0d56b48d9de065a5..7826b61bf871bf47ad89d74677605dd0c3b36b06 100644 (file)
@@ -179,12 +179,13 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
    return PIPE_OK;
 }
 
-enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
-                                unsigned min_out_offset,
-                                unsigned size,
-                                unsigned *out_offset,
-                                struct pipe_resource **outbuf,
-                                void **ptr )
+void
+u_upload_alloc(struct u_upload_mgr *upload,
+               unsigned min_out_offset,
+               unsigned size,
+               unsigned *out_offset,
+               struct pipe_resource **outbuf,
+               void **ptr)
 {
    unsigned alloc_size = align(size, upload->alignment);
    unsigned alloc_offset = align(min_out_offset, upload->alignment);
@@ -200,7 +201,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
          *out_offset = ~0;
          pipe_resource_reference(outbuf, NULL);
          *ptr = NULL;
-         return ret;
+         return;
       }
 
       buffer_size = upload->buffer->width0;
@@ -219,7 +220,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
          *out_offset = ~0;
          pipe_resource_reference(outbuf, NULL);
          *ptr = NULL;
-         return PIPE_ERROR_OUT_OF_MEMORY;
+         return;
       }
 
       upload->map -= offset;
@@ -235,7 +236,6 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
    *out_offset = offset;
 
    upload->offset = offset + alloc_size;
-   return PIPE_OK;
 }
 
 enum pipe_error u_upload_data( struct u_upload_mgr *upload,
@@ -246,11 +246,12 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
                                struct pipe_resource **outbuf)
 {
    uint8_t *ptr;
-   enum pipe_error ret = u_upload_alloc(upload, min_out_offset, size,
-                                        out_offset, outbuf,
-                                        (void**)&ptr);
-   if (ret != PIPE_OK)
-      return ret;
+
+   u_upload_alloc(upload, min_out_offset, size,
+                  out_offset, outbuf,
+                  (void**)&ptr);
+   if (!outbuf)
+      return PIPE_ERROR_OUT_OF_MEMORY;
 
    memcpy(ptr, data, size);
    return PIPE_OK;
index 63bf30e38ebe1ee2b646c5f89aad6a9f052830e7..2c319779eca375ec5fdd17140e70e9cbc1060c0d 100644 (file)
@@ -78,12 +78,12 @@ void u_upload_unmap( struct u_upload_mgr *upload );
  * \param outbuf           Pointer to where the upload buffer will be returned.
  * \param ptr              Pointer to the allocated memory that is returned.
  */
-enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
-                                unsigned min_out_offset,
-                                unsigned size,
-                                unsigned *out_offset,
-                                struct pipe_resource **outbuf,
-                                void **ptr );
+void u_upload_alloc(struct u_upload_mgr *upload,
+                    unsigned min_out_offset,
+                    unsigned size,
+                    unsigned *out_offset,
+                    struct pipe_resource **outbuf,
+                    void **ptr);
 
 
 /**
index 02ae0b840f028ede57b2f2f2ced2fbd856bc4d68..791d82bb65f7a54079a69a83cb3fe75a9e6d9f05 100644 (file)
@@ -406,7 +406,6 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
    struct pipe_resource *out_buffer = NULL;
    uint8_t *out_map;
    unsigned out_offset, mask;
-   enum pipe_error err;
 
    /* Get a translate object. */
    tr = translate_cache_find(mgr->translate_cache, key);
@@ -454,12 +453,12 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
       assert((ib->buffer || ib->user_buffer) && ib->index_size);
 
       /* Create and map the output buffer. */
-      err = u_upload_alloc(mgr->uploader, 0,
-                           key->output_stride * num_indices,
-                           &out_offset, &out_buffer,
-                           (void**)&out_map);
-      if (err != PIPE_OK)
-         return err;
+      u_upload_alloc(mgr->uploader, 0,
+                     key->output_stride * num_indices,
+                     &out_offset, &out_buffer,
+                     (void**)&out_map);
+      if (!out_buffer)
+         return PIPE_ERROR_OUT_OF_MEMORY;
 
       if (ib->user_buffer) {
          map = (uint8_t*)ib->user_buffer + offset;
@@ -486,13 +485,13 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
       }
    } else {
       /* Create and map the output buffer. */
-      err = u_upload_alloc(mgr->uploader,
-                           key->output_stride * start_vertex,
-                           key->output_stride * num_vertices,
-                           &out_offset, &out_buffer,
-                           (void**)&out_map);
-      if (err != PIPE_OK)
-         return err;
+      u_upload_alloc(mgr->uploader,
+                     key->output_stride * start_vertex,
+                     key->output_stride * num_vertices,
+                     &out_offset, &out_buffer,
+                     (void**)&out_map);
+      if (!out_buffer)
+         return PIPE_ERROR_OUT_OF_MEMORY;
 
       out_offset -= key->output_stride * start_vertex;
 
index 01a96c18264899d892a6c2e89508b5ce6c51d744..ce593a94593d7b2eac7895f52c1d2812cf48b6b3 100644 (file)
@@ -349,8 +349,9 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
       tBot = (GLfloat) height;
    }
 
-   if (u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
-                      vbuf_offset, vbuf, (void **) &vertices) != PIPE_OK) {
+   u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
+                  vbuf_offset, vbuf, (void **) &vertices);
+   if (!vbuf) {
       return;
    }
 
index 137fac8a9a90c9b38c095572739007e77ae2059a..18efd14a57cdb70c8711e746c1e036c2842ab550 100644 (file)
@@ -184,9 +184,10 @@ draw_quad(struct st_context *st,
 
    vb.stride = 8 * sizeof(float);
 
-   if (u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
-                      &vb.buffer_offset, &vb.buffer,
-                      (void **) &vertices) != PIPE_OK) {
+   u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
+                  &vb.buffer_offset, &vb.buffer,
+                  (void **) &vertices);
+   if (!vb.buffer) {
       return;
    }
 
index b372697026b59bec365be38784799d6b0fae4ae8..152160e1dd27088c547b6a86a82d87df71030609 100644 (file)
@@ -580,8 +580,9 @@ draw_quad(struct gl_context *ctx, GLfloat x0, GLfloat y0, GLfloat z,
    struct pipe_resource *buf = NULL;
    unsigned offset;
 
-   if (u_upload_alloc(st->uploader, 0, 4 * sizeof(verts[0]), &offset,
-                      &buf, (void **) &verts) != PIPE_OK) {
+   u_upload_alloc(st->uploader, 0, 4 * sizeof(verts[0]), &offset,
+                  &buf, (void **) &verts);
+   if (!buf) {
       return;
    }
 
index 2af4f6d4cf63e44c60fb6ff3e483be09a70dbfab..2634b09d777971e815007256d9f10f1f0b85e38d 100644 (file)
@@ -149,9 +149,10 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
       GLfloat *vbuf = NULL;
       GLuint attr;
 
-      if (u_upload_alloc(st->uploader, 0,
-                         numAttribs * 4 * 4 * sizeof(GLfloat),
-                         &offset, &vbuffer, (void **) &vbuf) != PIPE_OK) {
+      u_upload_alloc(st->uploader, 0,
+                     numAttribs * 4 * 4 * sizeof(GLfloat),
+                     &offset, &vbuffer, (void **) &vbuf);
+      if (!vbuffer) {
          return;
       }