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 <alyssa@rosenzweig.io>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23111>
This commit is contained in:
Emma Anholt 2023-05-18 09:32:54 -07:00 committed by Marge Bot
parent 6fde02816d
commit 804647acfc
4 changed files with 23 additions and 47 deletions

View file

@ -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;

View file

@ -527,42 +527,6 @@ st_nir_lower_atifs_samplers_instr(nir_builder *b, nir_instr *instr, void *data)
return true;
}
/**
* 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.

View file

@ -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

View file

@ -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) {