st/mesa: deduplicate st_common_program code in st_program_string_notify
authorMarek Olšák <marek.olsak@amd.com>
Mon, 30 Sep 2019 21:37:42 +0000 (17:37 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 17 Oct 2019 00:10:47 +0000 (20:10 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_cb_program.c

index c59da29a2b8035b16be9f1466b8551fcb061db17..7e23c0875f6eb218d381c4fbf3a920e942eb66ea 100644 (file)
@@ -165,18 +165,7 @@ st_program_string_notify( struct gl_context *ctx,
 
       if (st->fp == stfp)
         st->dirty |= stfp->affected_states;
-   }
-   else if (target == GL_GEOMETRY_PROGRAM_NV) {
-      struct st_common_program *stgp = st_common_program(prog);
-
-      st_release_basic_variants(st, stgp);
-      if (!st_translate_common_program(st, stgp))
-         return false;
-
-      if (st->gp == stgp)
-        st->dirty |= stgp->affected_states;
-   }
-   else if (target == GL_VERTEX_PROGRAM_ARB) {
+   } else if (target == GL_VERTEX_PROGRAM_ARB) {
       struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
 
       st_release_vp_variants(st, stvp);
@@ -185,39 +174,18 @@ st_program_string_notify( struct gl_context *ctx,
 
       if (st->vp == stvp)
         st->dirty |= ST_NEW_VERTEX_PROGRAM(st, stvp);
-   }
-   else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
-      struct st_common_program *sttcp =
-         st_common_program(prog);
-
-      st_release_basic_variants(st, sttcp);
-      if (!st_translate_common_program(st, sttcp))
-         return false;
-
-      if (st->tcp == sttcp)
-         st->dirty |= sttcp->affected_states;
-   }
-   else if (target == GL_TESS_EVALUATION_PROGRAM_NV) {
-      struct st_common_program *sttep =
-         st_common_program(prog);
-
-      st_release_basic_variants(st, sttep);
-      if (!st_translate_common_program(st, sttep))
-         return false;
-
-      if (st->tep == sttep)
-         st->dirty |= sttep->affected_states;
-   }
-   else if (target == GL_COMPUTE_PROGRAM_NV) {
-      struct st_common_program *stcp =
-         (struct st_common_program *) prog;
+   } else {
+      struct st_common_program *stcp = st_common_program(prog);
 
       st_release_basic_variants(st, stcp);
       if (!st_translate_common_program(st, stcp))
          return false;
 
-      if (st->cp == stcp)
-         st->dirty |= stcp->affected_states;
+      if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) ||
+          (prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) ||
+          (prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) ||
+          (prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp))
+        st->dirty |= stcp->affected_states;
    }
 
    if (ST_DEBUG & DEBUG_PRECOMPILE ||