[Mesa-dev] [PATCH 2/2] st/glsl_to_nir: use nir_shader_gather_info()
Nicolai Hähnle
nhaehnle at gmail.com
Thu Nov 2 16:29:06 UTC 2017
Both patches:
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
On 01.11.2017 12:01, Timothy Arceri wrote:
> Use the NIR helper rather than the GLSL IR helper to get in/out
> masks. This allows us to ignore varyings removed by NIR
> optimisations.
> ---
> src/mesa/state_tracker/st_glsl_to_nir.cpp | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index d59e472584..7f4651a3cc 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -266,30 +266,26 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
> * This should be enough for Bitmap and DrawPixels constants.
> */
> _mesa_reserve_parameter_storage(prog->Parameters, 8);
>
> /* This has to be done last. Any operation the can cause
> * prog->ParameterValues to get reallocated (e.g., anything that adds a
> * program constant) has to happen before creating this linkage.
> */
> _mesa_associate_uniform_storage(st->ctx, shader_program, prog, true);
>
> - st_set_prog_affected_state_flags(prog);
> -
> NIR_PASS_V(nir, nir_lower_io_to_temporaries,
> nir_shader_get_entrypoint(nir),
> true, true);
> NIR_PASS_V(nir, nir_lower_global_vars_to_local);
> NIR_PASS_V(nir, nir_split_var_copies);
> NIR_PASS_V(nir, nir_lower_var_copies);
> - NIR_PASS_V(nir, st_nir_lower_builtin);
> - NIR_PASS_V(nir, nir_lower_atomics, shader_program);
>
> /* fragment shaders may need : */
> if (stage == MESA_SHADER_FRAGMENT) {
> static const gl_state_index wposTransformState[STATE_LENGTH] = {
> STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
> };
> nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
> struct pipe_screen *pscreen = st->pipe->screen;
>
> memcpy(wpos_options.state_tokens, wposTransformState,
> @@ -302,20 +298,30 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
> pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
> wpos_options.fs_coord_pixel_center_half_integer =
> pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER);
>
> if (nir_lower_wpos_ytransform(nir, &wpos_options)) {
> nir_validate_shader(nir);
> _mesa_add_state_reference(prog->Parameters, wposTransformState);
> }
> }
>
> + NIR_PASS_V(nir, nir_lower_system_values);
> +
> + nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
> + prog->info = nir->info;
> +
> + st_set_prog_affected_state_flags(prog);
> +
> + NIR_PASS_V(nir, st_nir_lower_builtin);
> + NIR_PASS_V(nir, nir_lower_atomics, shader_program);
> +
> if (st->ctx->_Shader->Flags & GLSL_DUMP) {
> _mesa_log("\n");
> _mesa_log("NIR IR for linked %s program %d:\n",
> _mesa_shader_stage_to_string(stage),
> shader_program->Name);
> nir_print_shader(nir, _mesa_get_log_file());
> _mesa_log("\n\n");
> }
>
> prog->nir = nir;
> @@ -387,44 +393,40 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
> } else {
> unreachable("invalid shader type for tgsi bypass\n");
> }
>
> 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,
> &nir->uniforms, &nir->num_uniforms);
>
> - NIR_PASS_V(nir, nir_lower_system_values);
> -
> if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
> NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
> else
> NIR_PASS_V(nir, nir_lower_samplers, shader_program);
> }
>
> struct gl_program *
> st_nir_get_mesa_program(struct gl_context *ctx,
> struct gl_shader_program *shader_program,
> struct gl_linked_shader *shader)
> {
> struct st_context *st = st_context(ctx);
> struct gl_program *prog;
>
> validate_ir_tree(shader->ir);
>
> prog = shader->Program;
>
> prog->Parameters = _mesa_new_parameter_list();
>
> - do_set_program_inouts(shader->ir, prog, shader->Stage);
> -
> _mesa_copy_linked_program_data(shader_program, shader);
> _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
> prog->Parameters);
>
> if (ctx->_Shader->Flags & GLSL_DUMP) {
> _mesa_log("\n");
> _mesa_log("GLSL IR for linked %s program %d:\n",
> _mesa_shader_stage_to_string(shader->Stage),
> shader_program->Name);
> _mesa_print_ir(_mesa_get_log_file(), shader->ir, NULL);
>
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
More information about the mesa-dev
mailing list