[Mesa-dev] [PATCH 02/23] i965/fs: Allocate the param_size array dynamically.

Francisco Jerez currojerez at riseup.net
Mon Dec 2 11:31:07 PST 2013


Useful because the total number of uniform components might exceed
MAX_UNIFORMS * 4 in some cases because of the image metadata we'll be
passing as push constants.
---
 src/mesa/drivers/dri/i965/brw_fs.h           | 2 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_wm.c           | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 9f4a1be..ad165f0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -432,7 +432,7 @@ public:
    struct brw_wm_compile *c;
    unsigned int sanity_param_count;
 
-   int param_size[MAX_UNIFORMS * 4];
+   int *param_size;
 
    int *virtual_grf_sizes;
    int virtual_grf_count;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index a045100..a66fe38 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2925,7 +2925,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
 
    this->spilled_any_registers = false;
 
-   memset(&this->param_size, 0, sizeof(this->param_size));
+   this->param_size = rzalloc_array(mem_ctx, int, c->prog_data.nr_params);
 }
 
 fs_visitor::~fs_visitor()
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index bc1480c..b745d8f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -165,6 +165,7 @@ bool do_wm_prog(struct brw_context *brw,
    param_count += 2 * BRW_MAX_TEX_UNIT;
    c->prog_data.param = rzalloc_array(NULL, const float *, param_count);
    c->prog_data.pull_param = rzalloc_array(NULL, const float *, param_count);
+   c->prog_data.nr_params = param_count;
 
    memcpy(&c->key, key, sizeof(*key));
 
-- 
1.8.3.4



More information about the mesa-dev mailing list