[Mesa-dev] [PATCH 09/14] st/glsl_to_nir: add support for packed builtin uniforms
Marek Olšák
maraeo at gmail.com
Mon Mar 19 23:25:22 UTC 2018
For patches 8, 9:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Wed, Mar 14, 2018 at 2:01 AM, Timothy Arceri <tarceri at itsqueeze.com>
wrote:
> ---
> src/mesa/state_tracker/st_glsl_to_nir.cpp | 42
> +++++++++++++++++++++++++++----
> 1 file changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 0bd9c4e4e3..1fd553fdf8 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -218,7 +218,8 @@ st_nir_lookup_parameter_index(const struct
> gl_program_parameter_list *params,
> }
>
> static void
> -st_nir_assign_uniform_locations(struct gl_program *prog,
> +st_nir_assign_uniform_locations(struct gl_context *ctx,
> + struct gl_program *prog,
> struct gl_shader_program *shader_program,
> struct exec_list *uniform_list, unsigned
> *size)
> {
> @@ -247,7 +248,21 @@ st_nir_assign_uniform_locations(struct gl_program
> *prog,
> /* This state reference has already been setup by ir_to_mesa,
> but we'll
> * get the same index back here.
> */
> - loc = _mesa_add_state_reference(prog->Parameters, stateTokens);
> +
> + unsigned comps;
> + const struct glsl_type *type = glsl_without_array(uniform->
> type);
> + if (glsl_type_is_struct(type)) {
> + comps = 4;
> + } else {
> + comps = glsl_get_vector_elements(type);
> + }
> +
> + if (ctx->Const.PackedDriverUniformStorage) {
> + loc = _mesa_add_sized_state_reference(prog->Parameters,
> + stateTokens, comps,
> false);
> + } else {
> + loc = _mesa_add_state_reference(prog->Parameters,
> stateTokens);
> + }
> } else {
> loc = st_nir_lookup_parameter_index(prog->Parameters,
> uniform->name);
> }
> @@ -359,9 +374,26 @@ st_glsl_to_nir_post_opts(struct st_context *st,
> struct gl_program *prog,
> const nir_state_slot *const slots = var->state_slots;
> assert(var->state_slots != NULL);
>
> + const struct glsl_type *type = glsl_without_array(var->type);
> for (unsigned int i = 0; i < var->num_state_slots; i++) {
> - _mesa_add_state_reference(prog->Parameters,
> - slots[i].tokens);
> + unsigned comps;
> + if (glsl_type_is_struct(type)) {
> + /* Builtin struct require specical handling for now we just
> + * make all members vec4. See st_nir_lower_builtin.
> + */
> + comps = 4;
> + } else {
> + comps = glsl_get_vector_elements(type);
> + }
> +
> + if (st->ctx->Const.PackedDriverUniformStorage) {
> + _mesa_add_sized_state_reference(prog->Parameters,
> + slots[i].tokens,
> + comps, false);
> + } else {
> + _mesa_add_state_reference(prog->Parameters,
> + slots[i].tokens);
> + }
> }
> }
> }
> @@ -717,7 +749,7 @@ st_finalize_nir(struct st_context *st, struct
> gl_program *prog,
> NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
> st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
>
> - st_nir_assign_uniform_locations(prog, shader_program,
> + st_nir_assign_uniform_locations(st->ctx, prog, shader_program,
> &nir->uniforms, &nir->num_uniforms);
>
> if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180319/af6faf2f/attachment-0001.html>
More information about the mesa-dev
mailing list