<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 27, 2016 at 11:24 AM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This will be important when we start adding a uniform for the CS<br>
thread local invocation index.<br>
<br>
Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
---<br>
src/intel/vulkan/anv_pipeline.c | 32 +++++++++++++++++++++++++++++++-<br>
1 file changed, 31 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c<br>
index d63e50e..8021348 100644<br>
--- a/src/intel/vulkan/anv_pipeline.c<br>
+++ b/src/intel/vulkan/anv_pipeline.c<br>
@@ -78,6 +78,31 @@ void anv_DestroyShaderModule(<br>
anv_free2(&device->alloc, pAllocator, module);<br>
}<br>
<br>
+static void<br>
+anv_nir_lower_uniforms(nir_shader *nir, bool is_scalar)<br>
+{<br>
+ if (is_scalar) {<br>
+ nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms,<br>
+ type_size_scalar_bytes);<br>
+ nir_lower_io(nir, nir_var_uniform, type_size_scalar_bytes);<br>
+ } else {<br>
+ nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms,<br>
+ type_size_vec4_bytes);<br>
+ nir_lower_io(nir, nir_var_uniform, type_size_vec4_bytes);<br>
+ }<br>
+}<br>
+<br>
+static void<br>
+add_nir_push_constant_uniforms(nir_shader *shader)<br>
+{<br>
+ for (unsigned i = 0; i < MAX_PUSH_CONSTANTS_SIZE / sizeof(float); i++) {<br>
+ char *name = ralloc_asprintf(shader, "push%02d", i);<br>
+ nir_variable *var =<br>
+ nir_variable_create(shader, nir_var_uniform, glsl_uint_type(), name);<br>
+ var->data.location = i;'<br></blockquote><div><br></div><div>This, combined with the code above isn't going to be correct for vec4. The vec4 backend will make each float take a whole vec4. It doesn't actually matter though since it's going to be ignored. :-/<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+}<br>
+<br>
#define SPIR_V_MAGIC_NUMBER 0x07230203<br>
<br>
/* Eventually, this will become part of anv_CreateShader. Unfortunately,<br>
@@ -168,7 +193,8 @@ anv_shader_compile_to_nir(struct anv_device *device,<br>
<br>
nir_lower_io_to_temporaries(entry_point->shader, entry_point, true, false);<br>
<br>
- nir_lower_system_values(nir);<br>
+ add_nir_push_constant_uniforms(nir);<br>
+<br>
nir_validate_shader(nir);<br>
}<br>
<br>
@@ -177,6 +203,10 @@ anv_shader_compile_to_nir(struct anv_device *device,<br>
<br>
nir = brw_preprocess_nir(compiler, nir);<br>
<br>
+ nir_lower_system_values(nir);<br>
+ const bool is_scalar = compiler->scalar_stage[nir->stage];<br>
+ anv_nir_lower_uniforms(nir, is_scalar);<br>
+<br>
nir_shader_gather_info(nir, entry_point->impl);<br>
<br>
nir_variable_mode indirect_mask = 0;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.8.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>