On Fri, May 27, 2016 at 1:31 PM, Jason Ekstrand <[email protected]> wrote:
> > > On Fri, May 27, 2016 at 11:24 AM, Jordan Justen <[email protected] > > wrote: > >> 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;' >> > > 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. :-/ > I think this patch can actually be avoided all together as follows: 1) Make brw_nir_lower_intrinsics take a thread_id_location parameter and use the load_uniform intrinsic directly instead of a variable. 2) In the GL driver, run brw_nir_lower_intrinsics after lower_uniforms and pass nir->num_uniforms in as the thread_id_location. 3) Pass in the right location from the Vulkan driver. 4) Profit? I'm not sure if that's cleaner, but it seems better than magic variables. It may also let us run brw_nir_lower_intrinsics in brw_prepare_nir rather than making each driver call it separately. > + } >> +} >> + >> #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 >> > >
_______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
