intel/vs: Grow the param array for clip planes
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 29 Sep 2017 17:50:07 +0000 (10:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 13 Oct 2017 05:39:30 +0000 (22:39 -0700)
Instead of requiring the caller of brw_compile_vs to figure it out, just
grow the param array on-demand.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_fs_visitor.cpp
src/intel/compiler/brw_vec4_vs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c

index 4ee1d4e002282c2f9234066db64fe57b03226280..32fe0fc054b97233498fea2e52908254ac08b801 100644 (file)
@@ -470,6 +470,13 @@ fs_visitor::setup_uniform_clipplane_values()
    const struct brw_vs_prog_key *key =
       (const struct brw_vs_prog_key *) this->key;
 
+   if (key->nr_userclip_plane_consts == 0)
+      return;
+
+   assert(stage_prog_data->nr_params == uniforms);
+   brw_stage_prog_data_add_params(stage_prog_data,
+                                  key->nr_userclip_plane_consts * 4);
+
    for (int i = 0; i < key->nr_userclip_plane_consts; i++) {
       this->userplane[i] = fs_reg(UNIFORM, uniforms);
       for (int j = 0; j < 4; ++j) {
index 86f365e2f0f6cf93639d77287124bf6d7afcd718..4d8ae23b0c73d25e9fdd76a3bb636dc0afaeba71 100644 (file)
@@ -119,6 +119,13 @@ vec4_vs_visitor::emit_clip_distances(dst_reg reg, int offset)
 void
 vec4_vs_visitor::setup_uniform_clipplane_values()
 {
+   if (key->nr_userclip_plane_consts == 0)
+      return;
+
+   assert(stage_prog_data->nr_params == (unsigned)this->uniforms * 4);
+   brw_stage_prog_data_add_params(stage_prog_data,
+                                  key->nr_userclip_plane_consts * 4);
+
    for (int i = 0; i < key->nr_userclip_plane_consts; ++i) {
       this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
       this->userplane[i].type = BRW_REGISTER_TYPE_F;
index 8672d1ec1806223c306aa2e8e63c2439ed5817d4..c3440fde58dd7b958df6031afc75631b38174224 100644 (file)
@@ -184,11 +184,6 @@ brw_codegen_vs_prog(struct brw_context *brw,
     */
    int param_count = vp->program.nir->num_uniforms / 4;
 
-   /* vec4_visitor::setup_uniform_clipplane_values() also uploads user clip
-    * planes as uniforms.
-    */
-   param_count += key->nr_userclip_plane_consts * 4;
-
    stage_prog_data->param = rzalloc_array(NULL, uint32_t, param_count);
    stage_prog_data->pull_param = rzalloc_array(NULL, uint32_t, param_count);
    stage_prog_data->nr_params = param_count;