[Mesa-dev] [PATCH 3/3] i965/fs: Add a MAX_GRF_SIZE define and use it various places

Jason Ekstrand jason at jlekstrand.net
Wed Oct 1 12:18:13 PDT 2014


Previously, we had a MAX_SAMPLER_MESSAGE_SIZE which we used instead.
However, some FB write messages can validly be longer than this so we need
something different.  Since MAX_SAMPLER_MESSAGE_SIZE is validly useful on
its own, we leave it alone and add a new MAX_GRF_SIZE that's big enough for
FB writes.

Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84539
---
 src/mesa/drivers/dri/i965/brw_fs.cpp                   |  2 ++
 src/mesa/drivers/dri/i965/brw_fs.h                     |  1 +
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp      |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp | 10 +++++-----
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 709c5b0..d06810c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1924,6 +1924,7 @@ fs_visitor::split_virtual_grfs()
           * new virtual GRF for the previous offset many registers
           */
          if (split_points[reg]) {
+            assert(offset <= MAX_GRF_SIZE);
             int grf = virtual_grf_alloc(offset);
             for (int k = reg - offset; k < reg; k++)
                new_virtual_grf[k] = grf;
@@ -1935,6 +1936,7 @@ fs_visitor::split_virtual_grfs()
       }
 
       /* The last one gets the original register number */
+      assert(offset <= MAX_GRF_SIZE);
       virtual_grf_sizes[i] = offset;
       for (int k = reg - offset; k < reg; k++)
          new_virtual_grf[k] = i;
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 49024d8..782e96e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -52,6 +52,7 @@ extern "C" {
 #include "glsl/ir.h"
 
 #define MAX_SAMPLER_MESSAGE_SIZE 11
+#define MAX_GRF_SIZE 16
 
 struct bblock_t;
 namespace {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 63d9c05..acb1a9a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -105,7 +105,7 @@ brw_alloc_reg_set(struct intel_screen *screen, int reg_width)
    int class_sizes[BRW_MAX_MRF];
 
    if (devinfo->gen >= 7) {
-      for (class_count = 0; class_count < BRW_MAX_MRF; class_count++)
+      for (class_count = 0; class_count < MAX_GRF_SIZE; class_count++)
          class_sizes[class_count] = class_count + 1;
    } else {
       for (class_count = 0; class_count < 4; class_count++)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
index 69d105a..dbd9935 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
@@ -161,10 +161,10 @@ fs_visitor::register_coalesce()
    int src_size = 0;
    int channels_remaining = 0;
    int reg_from = -1, reg_to = -1;
-   int reg_to_offset[MAX_SAMPLER_MESSAGE_SIZE];
-   fs_inst *mov[MAX_SAMPLER_MESSAGE_SIZE];
-   int var_to[MAX_SAMPLER_MESSAGE_SIZE];
-   int var_from[MAX_SAMPLER_MESSAGE_SIZE];
+   int reg_to_offset[MAX_GRF_SIZE];
+   fs_inst *mov[MAX_GRF_SIZE];
+   int var_to[MAX_GRF_SIZE];
+   int var_from[MAX_GRF_SIZE];
 
    foreach_block_and_inst(block, fs_inst, inst, cfg) {
       if (!is_coalesce_candidate(this, inst))
@@ -180,7 +180,7 @@ fs_visitor::register_coalesce()
          reg_from = inst->src[0].reg;
 
          src_size = virtual_grf_sizes[inst->src[0].reg];
-         assert(src_size <= MAX_SAMPLER_MESSAGE_SIZE);
+         assert(src_size <= MAX_GRF_SIZE);
 
          assert(inst->src[0].width % 8 == 0);
          channels_remaining = src_size;
-- 
2.1.0



More information about the mesa-dev mailing list