meta: Simplify the blit shader setup steps.
authorEric Anholt <eric@anholt.net>
Wed, 12 Feb 2014 00:08:51 +0000 (16:08 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 12 Feb 2014 23:38:57 +0000 (15:38 -0800)
The only thing that wants to track the glsl_sampler structure is the
shader string generator.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/common/meta.c

index 8569391179b22e7d8dd10e3ebebe45848b592a9a..2b87d3f6ec4fec741bf2afea0885afbc7e7810d9 100644 (file)
@@ -453,12 +453,18 @@ link_program_with_debug(struct gl_context *ctx, GLuint program)
  * \returns a handle to a shader program on success or zero on failure.
  */
 static GLuint
-setup_shader_for_sampler(struct gl_context *ctx, struct glsl_sampler *sampler)
+setup_blit_shader(struct gl_context *ctx,
+                  GLenum target,
+                  struct sampler_table *table)
 {
    const char *vs_source;
    char *fs_source;
    GLuint vs, fs;
    void *const mem_ctx = ralloc_context(NULL);
+   struct glsl_sampler *sampler =
+      setup_texture_sampler(target, table);
+
+   assert(sampler != NULL);
 
    if (sampler->shader_prog != 0)
       return sampler->shader_prog;
@@ -1667,18 +1673,12 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
                             struct blit_state *blit,
                             GLenum target)
 {
-   struct glsl_sampler *sampler;
-
    /* target = GL_TEXTURE_RECTANGLE is not supported in GLES 3.0 */
    assert(_mesa_is_desktop_gl(ctx) || target == GL_TEXTURE_2D);
 
    setup_vertex_objects(&blit->VAO, &blit->VBO, true, 2, 2, 0);
 
-   /* Generate a relevant fragment shader program for the texture target */
-   sampler = setup_texture_sampler(target, &blit->samplers);
-   assert(sampler != NULL);
-
-   setup_shader_for_sampler(ctx, sampler);
+   setup_blit_shader(ctx, target, &blit->samplers);
 }
 
 /**
@@ -3432,15 +3432,10 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
                            struct gen_mipmap_state *mipmap,
                            GLenum target)
 {
-   struct glsl_sampler *sampler;
-
    setup_vertex_objects(&mipmap->VAO, &mipmap->VBO, true, 2, 3, 0);
 
-   /* Generate a fragment shader program appropriate for the texture target */
-   sampler = setup_texture_sampler(target, &mipmap->samplers);
-   assert(sampler != NULL);
-
-   mipmap->ShaderProg = setup_shader_for_sampler(ctx, sampler);
+   mipmap->ShaderProg = setup_blit_shader(ctx, target,
+                                          &mipmap->samplers);
 }
 
 
@@ -3943,16 +3938,10 @@ decompress_texture_image(struct gl_context *ctx,
    }
 
    if (use_glsl_version) {
-      struct glsl_sampler *sampler;
-
       setup_vertex_objects(&decompress->VAO, &decompress->VBO, true,
                            2, 4, 0);
 
-      /* Generate a relevant fragment shader program for the texture target */
-      sampler = setup_texture_sampler(target, &decompress->samplers);
-      assert(sampler != NULL);
-
-      shaderProg = setup_shader_for_sampler(ctx, sampler);
+      shaderProg = setup_blit_shader(ctx, target, &decompress->samplers);
    } else {
       setup_ff_tnl_for_blit(&decompress->VAO, &decompress->VBO, 3);
    }