[Mesa-dev] [PATCH 15/20] i965: Replace initialization loops with memset().

Matt Turner mattst88 at gmail.com
Tue Sep 2 21:34:26 PDT 2014


---
 src/mesa/drivers/dri/i965/brw_fs.cpp           | 10 +++-------
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 10 ++--------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5277420..39603cd 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1498,9 +1498,8 @@ fs_visitor::assign_curb_setup()
 void
 fs_visitor::calculate_urb_setup()
 {
-   for (unsigned int i = 0; i < VARYING_SLOT_MAX; i++) {
-      prog_data->urb_setup[i] = -1;
-   }
+   memset(prog_data->urb_setup, -1,
+          sizeof(prog_data->urb_setup[0]) * VARYING_SLOT_MAX);
 
    int urb_next = 0;
    /* Figure out where each of the incoming setup attributes lands. */
@@ -1792,10 +1791,7 @@ fs_visitor::move_uniform_array_access_to_pull_constants()
       return;
 
    pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
-
-   for (unsigned int i = 0; i < uniforms; i++) {
-      pull_constant_loc[i] = -1;
-   }
+   memset(pull_constant_loc, -1, sizeof(pull_constant_loc[0]) * uniforms);
 
    /* Walk through and find array access of uniforms.  Put a copy of that
     * uniform in the pull constant buffer.
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 411f67a..592fa1c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3272,10 +3272,7 @@ void
 vec4_visitor::move_grf_array_access_to_scratch()
 {
    int scratch_loc[this->virtual_grf_count];
-
-   for (int i = 0; i < this->virtual_grf_count; i++) {
-      scratch_loc[i] = -1;
-   }
+   memset(scratch_loc, -1, sizeof(scratch_loc));
 
    /* First, calculate the set of virtual GRFs that need to be punted
     * to scratch due to having any array access on them, and where in
@@ -3378,10 +3375,7 @@ void
 vec4_visitor::move_uniform_array_access_to_pull_constants()
 {
    int pull_constant_loc[this->uniforms];
-
-   for (int i = 0; i < this->uniforms; i++) {
-      pull_constant_loc[i] = -1;
-   }
+   memset(pull_constant_loc, -1, sizeof(pull_constant_loc));
 
    /* Walk through and find array access of uniforms.  Put a copy of that
     * uniform in the pull constant buffer.
-- 
1.8.5.5



More information about the mesa-dev mailing list