mesa/ati_fs: Move prog->SamplersUsed/TexturesUsed setup to EndFragmentShader.
authorEmma Anholt <emma@anholt.net>
Thu, 18 May 2023 16:32:54 +0000 (09:32 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Jun 2023 23:57:32 +0000 (23:57 +0000)
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>

src/mesa/main/atifragshader.c
src/mesa/state_tracker/st_atifs_to_nir.c
src/mesa/state_tracker/st_atifs_to_nir.h
src/mesa/state_tracker/st_program.c

index 6baa6a4..d2c8387 100644 (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;
index fefe59d..5c13d07 100644 (file)
@@ -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.
  */
index d393eaf..f13a321 100644 (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
index 504742c..158c179 100644 (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) {