This will be important when we start adding a uniform for the CS thread local invocation index.
Signed-off-by: Jordan Justen <[email protected]> --- src/intel/vulkan/anv_pipeline.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index d63e50e..8021348 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -78,6 +78,31 @@ void anv_DestroyShaderModule( anv_free2(&device->alloc, pAllocator, module); } +static void +anv_nir_lower_uniforms(nir_shader *nir, bool is_scalar) +{ + if (is_scalar) { + nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms, + type_size_scalar_bytes); + nir_lower_io(nir, nir_var_uniform, type_size_scalar_bytes); + } else { + nir_assign_var_locations(&nir->uniforms, &nir->num_uniforms, + type_size_vec4_bytes); + nir_lower_io(nir, nir_var_uniform, type_size_vec4_bytes); + } +} + +static void +add_nir_push_constant_uniforms(nir_shader *shader) +{ + for (unsigned i = 0; i < MAX_PUSH_CONSTANTS_SIZE / sizeof(float); i++) { + char *name = ralloc_asprintf(shader, "push%02d", i); + nir_variable *var = + nir_variable_create(shader, nir_var_uniform, glsl_uint_type(), name); + var->data.location = i; + } +} + #define SPIR_V_MAGIC_NUMBER 0x07230203 /* Eventually, this will become part of anv_CreateShader. Unfortunately, @@ -168,7 +193,8 @@ anv_shader_compile_to_nir(struct anv_device *device, nir_lower_io_to_temporaries(entry_point->shader, entry_point, true, false); - nir_lower_system_values(nir); + add_nir_push_constant_uniforms(nir); + nir_validate_shader(nir); } @@ -177,6 +203,10 @@ anv_shader_compile_to_nir(struct anv_device *device, nir = brw_preprocess_nir(compiler, nir); + nir_lower_system_values(nir); + const bool is_scalar = compiler->scalar_stage[nir->stage]; + anv_nir_lower_uniforms(nir, is_scalar); + nir_shader_gather_info(nir, entry_point->impl); nir_variable_mode indirect_mask = 0; -- 2.8.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
