[Mesa-dev] [PATCH v3 1/9] mesa: move use_program() inside _mesa_use_program()

Timothy Arceri tarceri at itsqueeze.com
Thu May 11 12:29:50 UTC 2017


---
 src/mesa/main/shaderapi.c | 50 ++++++++++++++++++++---------------------------
 1 file changed, 21 insertions(+), 29 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 7430cfe..f63215a 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1235,59 +1235,32 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
 		  "%s(program %u not linked)", caller, shProg->Name);
       return;
    }
 
    if (ctx->Shader.ActiveProgram != shProg) {
       _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg);
    }
 }
 
 
-static void
-use_program(struct gl_context *ctx, gl_shader_stage stage,
-            struct gl_shader_program *shProg, struct gl_program *new_prog,
-            struct gl_pipeline_object *shTarget)
-{
-   struct gl_program **target;
-
-   target = &shTarget->CurrentProgram[stage];
-   if (new_prog) {
-      _mesa_program_init_subroutine_defaults(ctx, new_prog);
-   }
-
-   if (*target != new_prog) {
-      /* Program is current, flush it */
-      if (shTarget == ctx->_Shader) {
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
-      }
-
-      _mesa_reference_shader_program(ctx,
-                                     &shTarget->ReferencedPrograms[stage],
-                                     shProg);
-      _mesa_reference_program(ctx, target, new_prog);
-      return;
-   }
-}
-
-
 /**
  * Use the named shader program for subsequent rendering.
  */
 void
 _mesa_use_shader_program(struct gl_context *ctx,
                          struct gl_shader_program *shProg)
 {
    for (int i = 0; i < MESA_SHADER_STAGES; i++) {
       struct gl_program *new_prog = NULL;
       if (shProg && shProg->_LinkedShaders[i])
          new_prog = shProg->_LinkedShaders[i]->Program;
-      use_program(ctx, i, shProg, new_prog, &ctx->Shader);
+      _mesa_use_program(ctx, i, shProg, new_prog, &ctx->Shader);
    }
    _mesa_active_program(ctx, shProg, "glUseProgram");
 }
 
 
 /**
  * Do validation of the given shader program.
  * \param errMsg  returns error message if validation fails.
  * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg)
  */
@@ -2157,21 +2130,40 @@ invalid_value:
                _mesa_enum_to_string(pname),
                value);
 }
 
 
 void
 _mesa_use_program(struct gl_context *ctx, gl_shader_stage stage,
                   struct gl_shader_program *shProg, struct gl_program *prog,
                   struct gl_pipeline_object *shTarget)
 {
-   use_program(ctx, stage, shProg, prog, shTarget);
+   struct gl_program **target;
+
+   target = &shTarget->CurrentProgram[stage];
+   if (prog) {
+      _mesa_program_init_subroutine_defaults(ctx, prog);
+   }
+
+   if (*target != prog) {
+      /* Program is current, flush it */
+      if (shTarget == ctx->_Shader) {
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+      }
+
+      _mesa_reference_shader_program(ctx,
+                                     &shTarget->ReferencedPrograms[stage],
+                                     shProg);
+      _mesa_reference_program(ctx, target, prog);
+      return;
+   }
+
 }
 
 
 /**
  * Copy program-specific data generated by linking from the gl_shader_program
  * object to the gl_program object referred to by the gl_linked_shader.
  *
  * This function expects _mesa_reference_program() to have been previously
  * called setting the gl_linked_shaders program reference.
  */
-- 
2.9.3



More information about the mesa-dev mailing list