[Mesa-dev] [PATCH 04/23] i965: Drop the degenerate brw_sampler_default_color structure.

Kenneth Graunke kenneth at whitecape.org
Tue Jul 29 16:29:09 PDT 2014


It's just an array of four floats, and we have an array of four floats,
so this is literally just a memcpy...but with custom structs and strange
macros to give the appearance of doing something more.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_sampler_state.c |  9 +++------
 src/mesa/drivers/dri/i965/brw_state_dump.c    | 11 +++++------
 src/mesa/drivers/dri/i965/brw_structs.h       |  4 ----
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 12aea39..6343ceb 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -197,12 +197,9 @@ upload_default_color(struct brw_context *brw,
       sdc->f[2] = color[2];
       sdc->f[3] = color[3];
    } else {
-      struct brw_sampler_default_color *sdc;
-
-      sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
-			    sizeof(*sdc), 32, sdc_offset);
-
-      COPY_4V(sdc->color, color);
+      float *sdc = brw_state_batch(brw, AUB_TRACE_SAMPLER_DEFAULT_COLOR,
+			           4 * 4, 32, sdc_offset);
+      memcpy(sdc, color, 4 * 4);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
index f0f185b..9d83859 100644
--- a/src/mesa/drivers/dri/i965/brw_state_dump.c
+++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
@@ -243,12 +243,11 @@ dump_sdc(struct brw_context *brw, uint32_t offset)
       batch_out(brw, name, offset, 10, "s16 ba\n");
       batch_out(brw, name, offset, 11, "s8 rgba\n");
    } else {
-      struct brw_sampler_default_color *sdc = (brw->batch.bo->virtual +
-					       offset);
-      batch_out(brw, name, offset, 0, "r %f\n", sdc->color[0]);
-      batch_out(brw, name, offset, 1, "g %f\n", sdc->color[1]);
-      batch_out(brw, name, offset, 2, "b %f\n", sdc->color[2]);
-      batch_out(brw, name, offset, 3, "a %f\n", sdc->color[3]);
+      float *sdc = brw->batch.bo->virtual + offset;
+      batch_out(brw, name, offset, 0, "r %f\n", sdc[0]);
+      batch_out(brw, name, offset, 1, "g %f\n", sdc[1]);
+      batch_out(brw, name, offset, 2, "b %f\n", sdc[2]);
+      batch_out(brw, name, offset, 3, "a %f\n", sdc[3]);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h b/src/mesa/drivers/dri/i965/brw_structs.h
index 620962e..9408ba2 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -589,10 +589,6 @@ struct brw_wm_unit_state
    } wm10;
 };
 
-struct brw_sampler_default_color {
-   float color[4];
-};
-
 struct gen5_sampler_default_color {
    uint8_t ub[4];
    float f[4];
-- 
2.0.2



More information about the mesa-dev mailing list