[Mesa-dev] [PATCH 14/21] intel/vs: Grow the param array for clip planes

Jason Ekstrand jason at jlekstrand.net
Fri Sep 29 21:25:14 UTC 2017


Instead of requiring the caller of brw_compile_vs to figure it out, just
grow the param array on-demand.
---
 src/intel/compiler/brw_fs_visitor.cpp      | 7 +++++++
 src/intel/compiler/brw_vec4_vs_visitor.cpp | 7 +++++++
 src/mesa/drivers/dri/i965/brw_vs.c         | 5 -----
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/intel/compiler/brw_fs_visitor.cpp b/src/intel/compiler/brw_fs_visitor.cpp
index 4ee1d4e..32fe0fc 100644
--- a/src/intel/compiler/brw_fs_visitor.cpp
+++ b/src/intel/compiler/brw_fs_visitor.cpp
@@ -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) {
diff --git a/src/intel/compiler/brw_vec4_vs_visitor.cpp b/src/intel/compiler/brw_vec4_vs_visitor.cpp
index 86f365e..aca40ae 100644
--- a/src/intel/compiler/brw_vec4_vs_visitor.cpp
+++ b/src/intel/compiler/brw_vec4_vs_visitor.cpp
@@ -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 == 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;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 8672d1e..c3440fd 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -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;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list