[Mesa-dev] [PATCH] mesa: pass ctx to add_uniform_to_shader constructor
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Aug 22 10:35:57 UTC 2017
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
On 08/22/2017 12:33 PM, Timothy Arceri wrote:
> Fixes: 4c2422067b5c ("glsl: pass UseSTD430AsDefaultPacking to where it will be used")
> ---
> src/mesa/program/ir_to_mesa.cpp | 10 ++++++----
> src/mesa/program/ir_to_mesa.h | 3 ++-
> src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 +-
> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
> 4 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index c168162b57..78f2449878 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -2409,21 +2409,22 @@ print_program(struct prog_instruction *mesa_instructions,
>
> indent = _mesa_fprint_instruction_opt(stdout, mesa_inst, indent,
> PROG_PRINT_DEBUG, NULL);
> }
> }
>
> namespace {
>
> class add_uniform_to_shader : public program_resource_visitor {
> public:
> - add_uniform_to_shader(struct gl_shader_program *shader_program,
> + add_uniform_to_shader(struct gl_context *ctx,
> + struct gl_shader_program *shader_program,
> struct gl_program_parameter_list *params)
> : ctx(ctx), params(params), idx(-1)
> {
> /* empty */
> }
>
> void process(ir_variable *var)
> {
> this->idx = -1;
> this->var = var;
> @@ -2475,27 +2476,28 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
>
> /**
> * Generate the program parameters list for the user uniforms in a shader
> *
> * \param shader_program Linked shader program. This is only used to
> * emit possible link errors to the info log.
> * \param sh Shader whose uniforms are to be processed.
> * \param params Parameter list to be filled in.
> */
> void
> -_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
> +_mesa_generate_parameters_list_for_uniforms(struct gl_context *ctx,
> + struct gl_shader_program
> *shader_program,
> struct gl_linked_shader *sh,
> struct gl_program_parameter_list
> *params)
> {
> - add_uniform_to_shader add(shader_program, params);
> + add_uniform_to_shader add(ctx, shader_program, params);
>
> foreach_in_list(ir_instruction, node, sh->ir) {
> ir_variable *var = node->as_variable();
>
> if ((var == NULL) || (var->data.mode != ir_var_uniform)
> || var->is_in_buffer_block() || (strncmp(var->name, "gl_", 3) == 0))
> continue;
>
> add.process(var);
> }
> @@ -2843,21 +2845,21 @@ get_mesa_program(struct gl_context *ctx,
>
> validate_ir_tree(shader->ir);
>
> prog = shader->Program;
> prog->Parameters = _mesa_new_parameter_list();
> v.ctx = ctx;
> v.prog = prog;
> v.shader_program = shader_program;
> v.options = options;
>
> - _mesa_generate_parameters_list_for_uniforms(shader_program, shader,
> + _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
> prog->Parameters);
>
> /* Emit Mesa IR for main(). */
> visit_exec_list(shader->ir, &v);
> v.emit(NULL, OPCODE_END);
>
> prog->arb.NumTemporaries = v.next_temp;
>
> unsigned num_instructions = v.instructions.length();
>
> diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
> index e3d364455c..9714f50443 100644
> --- a/src/mesa/program/ir_to_mesa.h
> +++ b/src/mesa/program/ir_to_mesa.h
> @@ -31,21 +31,22 @@ extern "C" {
> #endif
>
> struct gl_context;
> struct gl_shader;
> struct gl_shader_program;
>
> void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
> GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
>
> void
> -_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
> +_mesa_generate_parameters_list_for_uniforms(struct gl_context *ctx,
> + struct gl_shader_program
> *shader_program,
> struct gl_linked_shader *sh,
> struct gl_program_parameter_list
> *params);
> void
> _mesa_associate_uniform_storage(struct gl_context *ctx,
> struct gl_shader_program *shader_program,
> struct gl_program *prog,
> bool propagate_to_storage);
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index a2522070b1..38d6c7068c 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -393,21 +393,21 @@ st_nir_get_mesa_program(struct gl_context *ctx,
>
> 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(shader_program, shader,
> + _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
> prog->Parameters);
>
> /* Make a pass over the IR to add state references for any built-in
> * uniforms that are used. This has to be done now (during linking).
> * Code generation doesn't happen until the first time this shader is
> * used for rendering. Waiting until then to generate the parameters is
> * too late. At that point, the values for the built-in uniforms won't
> * get sent to the shader.
> */
> foreach_in_list(ir_instruction, node, shader->ir) {
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 9264d18a3f..45064c5aff 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -6884,21 +6884,21 @@ get_mesa_program_tgsi(struct gl_context *ctx,
> PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED);
> v->has_tex_txf_lz = pscreen->get_param(pscreen,
> PIPE_CAP_TGSI_TEX_TXF_LZ);
>
> v->variables = _mesa_hash_table_create(v->mem_ctx, _mesa_hash_pointer,
> _mesa_key_pointer_equal);
> skip_merge_registers =
> pscreen->get_shader_param(pscreen, ptarget,
> PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS);
>
> - _mesa_generate_parameters_list_for_uniforms(shader_program, shader,
> + _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
> prog->Parameters);
>
> /* Remove reads from output registers. */
> if (!pscreen->get_param(pscreen, PIPE_CAP_TGSI_CAN_READ_OUTPUTS))
> lower_output_reads(shader->Stage, shader->ir);
>
> /* Emit intermediate IR for main(). */
> visit_exec_list(shader->ir, v);
>
> #if 0
>
More information about the mesa-dev
mailing list