From: Emma Anholt Date: Thu, 18 May 2023 16:32:54 +0000 (-0700) Subject: mesa/ati_fs: Move prog->SamplersUsed/TexturesUsed setup to EndFragmentShader. X-Git-Tag: upstream/23.3.3~7722 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=804647acfc7c17053bb8a4f91c853d6f945bb94c;p=platform%2Fupstream%2Fmesa.git mesa/ati_fs: Move prog->SamplersUsed/TexturesUsed setup to EndFragmentShader. No need to have st_program.c come back into ATI_fs for this when it's a property of program generation. ARB programs set these up in their translation, as well. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c index 6baa6a4..d2c8387 100644 --- a/src/mesa/main/atifragshader.c +++ b/src/mesa/main/atifragshader.c @@ -433,6 +433,29 @@ _mesa_EndFragmentShaderATI(void) /* Don't use _mesa_reference_program(), just take ownership */ ctx->ATIFragmentShader.Current->Program = prog; + prog->SamplersUsed = 0; + prog->Parameters = _mesa_new_parameter_list(); + + /* fill in SamplersUsed, TexturesUsed */ + for (unsigned pass = 0; pass < curProg->NumPasses; pass++) { + for (unsigned r = 0; r < MAX_NUM_FRAGMENT_REGISTERS_ATI; r++) { + struct atifs_setupinst *texinst = &curProg->SetupInst[pass][r]; + + if (texinst->Opcode == ATI_FRAGMENT_SHADER_SAMPLE_OP) { + /* by default there is 1:1 mapping between samplers and textures */ + prog->SamplersUsed |= (1 << r); + /* the target is unknown here, it will be fixed in the draw call */ + prog->TexturesUsed[r] = TEXTURE_2D_BIT; + } + } + } + + /* we always have the ATI_fs constants */ + for (unsigned i = 0; i < MAX_NUM_FRAGMENT_CONSTANTS_ATI; i++) { + _mesa_add_parameter(prog->Parameters, PROGRAM_UNIFORM, + NULL, 4, GL_FLOAT, NULL, NULL, true); + } + if (!st_program_string_notify(ctx, GL_FRAGMENT_SHADER_ATI, curProg->Program)) { ctx->ATIFragmentShader.Current->isValid = GL_FALSE; diff --git a/src/mesa/state_tracker/st_atifs_to_nir.c b/src/mesa/state_tracker/st_atifs_to_nir.c index fefe59d..5c13d07 100644 --- a/src/mesa/state_tracker/st_atifs_to_nir.c +++ b/src/mesa/state_tracker/st_atifs_to_nir.c @@ -528,42 +528,6 @@ st_nir_lower_atifs_samplers_instr(nir_builder *b, nir_instr *instr, void *data) } /** - * Called in ProgramStringNotify, we need to fill the metadata of the - * gl_program attached to the ati_fragment_shader - */ -void -st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog) -{ - /* we know this is st_fragment_program, because of st_new_ati_fs() */ - struct ati_fragment_shader *atifs = prog->ati_fs; - - unsigned pass, i, r; - - prog->SamplersUsed = 0; - prog->Parameters = _mesa_new_parameter_list(); - - /* fill in SamplersUsed, TexturesUsed */ - for (pass = 0; pass < atifs->NumPasses; pass++) { - for (r = 0; r < MAX_NUM_FRAGMENT_REGISTERS_ATI; r++) { - struct atifs_setupinst *texinst = &atifs->SetupInst[pass][r]; - - if (texinst->Opcode == ATI_FRAGMENT_SHADER_SAMPLE_OP) { - /* by default there is 1:1 mapping between samplers and textures */ - prog->SamplersUsed |= (1 << r); - /* the target is unknown here, it will be fixed in the draw call */ - prog->TexturesUsed[r] = TEXTURE_2D_BIT; - } - } - } - - /* we always have the ATI_fs constants */ - for (i = 0; i < MAX_NUM_FRAGMENT_CONSTANTS_ATI; i++) { - _mesa_add_parameter(prog->Parameters, PROGRAM_UNIFORM, - NULL, 4, GL_FLOAT, NULL, NULL, true); - } -} - -/** * Rewrites sampler dimensions and coordinate components for the currently * active texture unit at draw time. */ diff --git a/src/mesa/state_tracker/st_atifs_to_nir.h b/src/mesa/state_tracker/st_atifs_to_nir.h index d393eaf..f13a321 100644 --- a/src/mesa/state_tracker/st_atifs_to_nir.h +++ b/src/mesa/state_tracker/st_atifs_to_nir.h @@ -41,10 +41,6 @@ st_translate_atifs_program(struct ati_fragment_shader *atifs, struct gl_program *program, const nir_shader_compiler_options *options); - -void -st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog); - bool st_nir_lower_atifs_samplers(struct nir_shader *s, const uint8_t *texture_index); #if defined __cplusplus diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 504742c..158c179 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1424,13 +1424,6 @@ st_program_string_notify( struct gl_context *ctx, if (target == GL_FRAGMENT_PROGRAM_ARB || target == GL_FRAGMENT_SHADER_ATI) { - if (target == GL_FRAGMENT_SHADER_ATI) { - assert(prog->ati_fs); - assert(prog->ati_fs->Program == prog); - - st_init_atifs_prog(ctx, prog); - } - if (!st_translate_fragment_program(st, prog)) return false; } else if (target == GL_VERTEX_PROGRAM_ARB) {