diff options
author | Ian Romanick <[email protected]> | 2012-10-05 15:19:45 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2012-10-07 20:35:50 -0700 |
commit | 86de501f14f11f1e993c8703c0d69bdf1f6c7835 (patch) | |
tree | c2352e7f0fc5769b305f3cb615a980f67aba512d /src/mesa/drivers/common | |
parent | 751737f4975d922d79ae00f3145832043fcc8bab (diff) |
meta: Make shader template literal strings be parameters to asprintf
This enables the C compiler to generate warnings if the formats and the
arguments don't match.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index ba932c78ba6..24d8d485a7e 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3101,8 +3101,6 @@ setup_glsl_generate_mipmap(struct gl_context *ctx, mem_ctx = ralloc_context(NULL); if (ctx->API == API_OPENGLES2 || ctx->Const.GLSLVersion < 130) { - const char *fs_template; - vs_source = "attribute vec2 position;\n" "attribute vec3 textureCoords;\n" @@ -3112,22 +3110,19 @@ setup_glsl_generate_mipmap(struct gl_context *ctx, " texCoords = textureCoords;\n" " gl_Position = vec4(position, 0.0, 1.0);\n" "}\n"; - fs_template = - "#extension GL_EXT_texture_array : enable\n" - "uniform %s texSampler;\n" - "varying vec3 texCoords;\n" - "void main()\n" - "{\n" - " gl_FragColor = %s(texSampler, %s);\n" - "}\n"; - fs_source = ralloc_asprintf(mem_ctx, fs_template, + fs_source = ralloc_asprintf(mem_ctx, + "#extension GL_EXT_texture_array : enable\n" + "uniform %s texSampler;\n" + "varying vec3 texCoords;\n" + "void main()\n" + "{\n" + " gl_FragColor = %s(texSampler, %s);\n" + "}\n", sampler->type, sampler->func, sampler->texcoords); } else { - const char *fs_template; - vs_source = "#version 130\n" "in vec2 position;\n" @@ -3138,18 +3133,16 @@ setup_glsl_generate_mipmap(struct gl_context *ctx, " texCoords = textureCoords;\n" " gl_Position = vec4(position, 0.0, 1.0);\n" "}\n"; - fs_template = - "#version 130\n" - "uniform %s texSampler;\n" - "in vec3 texCoords;\n" - "out vec4 out_color;\n" - "\n" - "void main()\n" - "{\n" - " out_color = texture(texSampler, %s);\n" - "}\n"; - - fs_source = ralloc_asprintf(mem_ctx, fs_template, + fs_source = ralloc_asprintf(mem_ctx, + "#version 130\n" + "uniform %s texSampler;\n" + "in vec3 texCoords;\n" + "out vec4 out_color;\n" + "\n" + "void main()\n" + "{\n" + " out_color = texture(texSampler, %s);\n" + "}\n", sampler->type, sampler->texcoords); } |