[Mesa-dev] [PATCH 8/9] nir/glsl_to_nir: Initialize num_shared

Jordan Justen jordan.l.justen at intel.com
Tue Mar 15 06:57:04 UTC 2016


If the glsl compiler option LowerShaderSharedVariables is set, then
this will be a non-zero value, and nir should not need to lower shared
variables. If LowerShaderSharedVariables is not set, then nir will
need to lower the shared variables.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/compiler/nir/glsl_to_nir.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp
index 613b138..dffa6b6 100644
--- a/src/compiler/nir/glsl_to_nir.cpp
+++ b/src/compiler/nir/glsl_to_nir.cpp
@@ -46,7 +46,7 @@ namespace {
 class nir_visitor : public ir_visitor
 {
 public:
-   nir_visitor(nir_shader *shader);
+   nir_visitor(nir_shader *shader, unsigned initial_shared_size);
    ~nir_visitor();
 
    virtual void visit(ir_variable *);
@@ -135,10 +135,11 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
             const nir_shader_compiler_options *options)
 {
    struct gl_shader *sh = shader_prog->_LinkedShaders[stage];
+   const unsigned initial_shared_size = shader_prog->Comp.SharedSize;
 
    nir_shader *shader = nir_shader_create(NULL, stage, options);
 
-   nir_visitor v1(shader);
+   nir_visitor v1(shader, initial_shared_size);
    nir_function_visitor v2(&v1);
    v2.run(sh->ir);
    visit_exec_list(sh->ir, &v1);
@@ -204,7 +205,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    return shader;
 }
 
-nir_visitor::nir_visitor(nir_shader *shader)
+nir_visitor::nir_visitor(nir_shader *shader, unsigned initial_shared_size)
 {
    this->supports_ints = shader->options->native_integers;
    this->shader = shader;
@@ -213,6 +214,7 @@ nir_visitor::nir_visitor(nir_shader *shader)
                                              _mesa_key_pointer_equal);
    this->overload_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
                                                   _mesa_key_pointer_equal);
+   shader->num_shared = initial_shared_size;
 }
 
 nir_visitor::~nir_visitor()
-- 
2.7.0



More information about the mesa-dev mailing list