nir: Store num_direct_uniforms in the nir_shader.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 8 Apr 2015 00:13:45 +0000 (17:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 11 Apr 2015 18:39:48 +0000 (11:39 -0700)
Storing this here is pretty sketchy - I don't know if any driver other
than i965 will want to use it.  But this will make it a lot easier to
generate NIR code at link time.  We'll probably rework it anyway.

(Ian suggested making nir_assign_var_locations_scalar_direct_first
 simply modify the nir_shader's fields, rather than passing pointers
 to them.  If this stays long term, we should do that.  But Jason and
 I suspect we'll be reworking this area again in the near future.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/nir/nir.h
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 653123780ffb841002a2ed4c0837bef61a89d120..2d1d870b1f8f296b736e0de24ad6bd13736dc281 100644 (file)
@@ -1431,6 +1431,9 @@ typedef struct nir_shader {
     * access plus one
     */
    unsigned num_inputs, num_uniforms, num_outputs;
+
+   /** the number of uniforms that are only accessed directly */
+   unsigned num_direct_uniforms;
 } nir_shader;
 
 #define nir_foreach_overload(shader, overload)                        \
index 6bb52ebd8775ee489cae7c021eecb41f760957dd..4ee92a8208cf4a714d5ea12001c365c1cbcffbde 100644 (file)
@@ -120,7 +120,7 @@ fs_visitor::emit_nir_code()
 
    if (shader_prog) {
       nir_assign_var_locations_scalar_direct_first(nir, &nir->uniforms,
-                                                   &num_direct_uniforms,
+                                                   &nir->num_direct_uniforms,
                                                    &nir->num_uniforms);
    } else {
       /* ARB programs generally create a giant array of "uniform" data, and allow
@@ -128,7 +128,7 @@ fs_visitor::emit_nir_code()
        * analysis, it's all or nothing.  num_direct_uniforms is only useful when
        * we have some direct and some indirect access; it doesn't matter here.
        */
-      num_direct_uniforms = 0;
+      nir->num_direct_uniforms = 0;
    }
    nir_assign_var_locations_scalar(&nir->inputs, &nir->num_inputs);
    nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs);
@@ -343,6 +343,7 @@ void
 fs_visitor::nir_setup_uniforms(nir_shader *shader)
 {
    uniforms = shader->num_uniforms;
+   num_direct_uniforms = shader->num_direct_uniforms;
 
    /* We split the uniform register file in half.  The first half is
     * entirely direct uniforms.  The second half is indirect.