[Mesa-dev] [PATCH 8/8] i965/upload: Rename "buffer" to "staging_buffer".

Kenneth Graunke kenneth at whitecape.org
Thu Mar 13 01:57:16 PDT 2014


This clarifies the purpose of the buffer, and also avoids some confusion
between the two data stores---buffer and bo both are generic names.

To match this, also rename "buffer_len" to "staging_buffer_len."
Don't rename buffer_offset, as it's actually a bo offset.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_context.h  |  4 +--
 src/mesa/drivers/dri/i965/intel_upload.c | 50 ++++++++++++++++----------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 659af92..659f64f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1065,7 +1065,7 @@ struct brw_context
       /**
        * The amount of staged data needing to be copied to the BO.
        */
-      uint32_t buffer_len;
+      uint32_t staging_buffer_len;
 
       /**
        * Offset into "bo" representing the starting destination address for
@@ -1076,7 +1076,7 @@ struct brw_context
       /**
        * The CPU-side staging buffer containing data yet to be uploaded.
        */
-      char buffer[4096];
+      char staging_buffer[4096];
    } upload;
 
    /**
diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c
index 3abc314..cb488b0 100644
--- a/src/mesa/drivers/dri/i965/intel_upload.c
+++ b/src/mesa/drivers/dri/i965/intel_upload.c
@@ -76,12 +76,12 @@ intel_upload_finish(struct brw_context *brw)
    if (!brw->upload.bo)
       return;
 
-   if (brw->upload.buffer_len) {
+   if (brw->upload.staging_buffer_len) {
       drm_intel_bo_subdata(brw->upload.bo,
                            brw->upload.buffer_offset,
-                           brw->upload.buffer_len,
-                           brw->upload.buffer);
-      brw->upload.buffer_len = 0;
+                           brw->upload.staging_buffer_len,
+                           brw->upload.staging_buffer);
+      brw->upload.staging_buffer_len = 0;
    }
 
    drm_intel_bo_unreference(brw->upload.bo);
@@ -150,26 +150,26 @@ intel_upload_data(struct brw_context *brw,
    /* If there isn't enough space in the staging buffer, go upload the
     * staged data to free up space.
     */
-   if (brw->upload.buffer_len &&
-       brw->upload.buffer_len + delta + size > sizeof(brw->upload.buffer)) {
+   if (brw->upload.staging_buffer_len &&
+       brw->upload.staging_buffer_len + delta + size > sizeof(brw->upload.staging_buffer)) {
       drm_intel_bo_subdata(brw->upload.bo,
                            brw->upload.buffer_offset,
-                           brw->upload.buffer_len,
-                           brw->upload.buffer);
-      brw->upload.buffer_len = 0;
+                           brw->upload.staging_buffer_len,
+                           brw->upload.staging_buffer);
+      brw->upload.staging_buffer_len = 0;
    }
 
-   if (size <= sizeof(brw->upload.buffer)) {
+   if (size <= sizeof(brw->upload.staging_buffer)) {
       /* The new data is small enough to fit in the staging buffer, so
        * stage it to be copied to the BO later.
        */
-      if (brw->upload.buffer_len == 0)
+      if (brw->upload.staging_buffer_len == 0)
          brw->upload.buffer_offset = base;
       else
-         brw->upload.buffer_len += delta;
+         brw->upload.staging_buffer_len += delta;
 
-      memcpy(brw->upload.buffer + brw->upload.buffer_len, ptr, size);
-      brw->upload.buffer_len += size;
+      memcpy(brw->upload.staging_buffer + brw->upload.staging_buffer_len, ptr, size);
+      brw->upload.staging_buffer_len += size;
    } else {
       /* The new data is too large to fit in the (empty) staging buffer,
        * which means it wouldn't benefit from batched uploading anyway.
@@ -218,26 +218,26 @@ intel_upload_map(struct brw_context *brw, unsigned size, unsigned align)
    /* If there isn't enough space in the staging buffer, go upload the
     * staged data to free up space.
     */
-   if (brw->upload.buffer_len &&
-       brw->upload.buffer_len + delta + size > sizeof(brw->upload.buffer)) {
+   if (brw->upload.staging_buffer_len &&
+       brw->upload.staging_buffer_len + delta + size > sizeof(brw->upload.staging_buffer)) {
       drm_intel_bo_subdata(brw->upload.bo,
                            brw->upload.buffer_offset,
-                           brw->upload.buffer_len,
-                           brw->upload.buffer);
-      brw->upload.buffer_len = 0;
+                           brw->upload.staging_buffer_len,
+                           brw->upload.staging_buffer);
+      brw->upload.staging_buffer_len = 0;
    }
 
-   if (size <= sizeof(brw->upload.buffer)) {
+   if (size <= sizeof(brw->upload.staging_buffer)) {
       /* The new data is small enough to fit in the staging buffer, so
        * stage it to be copied to the BO later.
        */
-      if (brw->upload.buffer_len == 0)
+      if (brw->upload.staging_buffer_len == 0)
          brw->upload.buffer_offset = base;
       else
-         brw->upload.buffer_len += delta;
+         brw->upload.staging_buffer_len += delta;
 
-      ptr = brw->upload.buffer + brw->upload.buffer_len;
-      brw->upload.buffer_len += size;
+      ptr = brw->upload.staging_buffer + brw->upload.staging_buffer_len;
+      brw->upload.staging_buffer_len += size;
    } else {
       /* The new data is too large to fit into the default staging buffer,
        * even when empty.  Allocate a larger, one-shot staging buffer.
@@ -269,7 +269,7 @@ intel_upload_unmap(struct brw_context *brw,
    unsigned base;
 
    base = ALIGN_NPOT(brw->upload.offset, align);
-   if (size > sizeof(brw->upload.buffer)) {
+   if (size > sizeof(brw->upload.staging_buffer)) {
       /* The data was too large to fit in the default staging buffer, so we
        * allocated a one-shot temporary staging buffer in intel_upload_map().
        *
-- 
1.9.0



More information about the mesa-dev mailing list