i965: Allocate vec4_visitor's uniform_size and uniform_vector_size arrays dynamically.
authorPetri Latvala <petri.latvala@intel.com>
Thu, 27 Feb 2014 14:15:04 +0000 (16:15 +0200)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 28 Feb 2014 23:05:38 +0000 (15:05 -0800)
v2: Don't add function parameters, pass the required size in
prog_data->nr_params.

v3:
- Use the name uniform_array_size instead of uniform_param_count.
- Round up when dividing param_count by 4.
- Use MAX2() instead of taking the maximum by hand.
- Don't crash if prog_data passed to vec4_visitor constructor is NULL

v4: Rebase for current master

v5 (idr): Trivial whitespace change.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71254
Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_gs.c
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c

index fb5c0a6d665fb75114596c2fe1c7be634222d720..d97c1039eb0eeb61b3fd9190fb2fde382fcfdb34 100644 (file)
@@ -387,8 +387,9 @@ public:
     */
    dst_reg output_reg[BRW_VARYING_SLOT_COUNT];
    const char *output_reg_annotation[BRW_VARYING_SLOT_COUNT];
-   int uniform_size[MAX_UNIFORMS];
-   int uniform_vector_size[MAX_UNIFORMS];
+   int *uniform_size;
+   int *uniform_vector_size;
+   int uniform_array_size; /*< Size of uniform_[vector_]size arrays */
    int uniforms;
 
    src_reg shader_start_time;
index 85fb97999c7bdca7d826a1519f9bf7d49ef94a2b..8a9625b52af77db054982f9dc1716948f2c366fd 100644 (file)
@@ -68,6 +68,11 @@ do_gs_prog(struct brw_context *brw,
       rzalloc_array(NULL, const float *, param_count);
    c.prog_data.base.base.pull_param =
       rzalloc_array(NULL, const float *, param_count);
+   /* Setting nr_params here NOT to the size of the param and pull_param
+    * arrays, but to the number of uniform components vec4_visitor
+    * needs. vec4_visitor::setup_uniforms() will set it back to a proper value.
+    */
+   c.prog_data.base.base.nr_params = ALIGN(param_count, 4) / 4 + gs->num_samplers;
 
    if (gp->program.OutputType == GL_POINTS) {
       /* When the output type is points, the geometry shader may output data
index aedab9317019d36678fe3754d33bdb3206411b9c..cc92a8acc8967ad82eac4dd9cb72cceb4fdc6e87 100644 (file)
@@ -3401,6 +3401,17 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
    this->max_grf = brw->gen >= 7 ? GEN7_MRF_HACK_START : BRW_MAX_GRF;
 
    this->uniforms = 0;
+
+   /* Initialize uniform_array_size to at least 1 because pre-gen6 VS requires
+    * at least one. See setup_uniforms() in brw_vec4.cpp.
+    */
+   this->uniform_array_size = 1;
+   if (prog_data) {
+      this->uniform_array_size = MAX2(stage_prog_data->nr_params, 1);
+   }
+
+   this->uniform_size = rzalloc_array(mem_ctx, int, this->uniform_array_size);
+   this->uniform_vector_size = rzalloc_array(mem_ctx, int, this->uniform_array_size);
 }
 
 vec4_visitor::~vec4_visitor()
index d3dbc8eef719879d93a9833dc56fde6e8a628334..d98f1950726d0d97588fca6e72beeb47c5dce1ab 100644 (file)
@@ -236,6 +236,15 @@ do_vs_prog(struct brw_context *brw,
    stage_prog_data->param = rzalloc_array(NULL, const float *, param_count);
    stage_prog_data->pull_param = rzalloc_array(NULL, const float *, param_count);
 
+   /* Setting nr_params here NOT to the size of the param and pull_param
+    * arrays, but to the number of uniform components vec4_visitor
+    * needs. vec4_visitor::setup_uniforms() will set it back to a proper value.
+    */
+   stage_prog_data->nr_params = ALIGN(param_count, 4) / 4;
+   if (vs) {
+      stage_prog_data->nr_params += vs->num_samplers;
+   }
+
    GLbitfield64 outputs_written = vp->program.Base.OutputsWritten;
    prog_data.inputs_read = vp->program.Base.InputsRead;