summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-02-10 13:58:45 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2016-02-10 14:00:38 +0100
commit1346744e6cd28e62e346f118fde8898d8e6fdf7d (patch)
tree37a8961392f0a51a77b2854b6010d467bc131ee4
parent47bcfe1c19da12b4c0a5b2f4f031e6a016ea3e46 (diff)
Fix -Wformat-nonliteral warningsHEADmaster
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--src/vrend_blitter.c8
-rw-r--r--src/vrend_blitter.h60
-rw-r--r--src/vrend_shader.c40
3 files changed, 60 insertions, 48 deletions
diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c
index 7ecd8c1..8783a4f 100644
--- a/src/vrend_blitter.c
+++ b/src/vrend_blitter.c
@@ -93,7 +93,7 @@ static bool blit_build_vs_passthrough(struct vrend_blitter_ctx *blit_ctx)
{
blit_ctx->vs = glCreateShader(GL_VERTEX_SHADER);
- if (!build_and_check(blit_ctx->vs, vs_passthrough)) {
+ if (!build_and_check(blit_ctx->vs, VS_PASSTHROUGH)) {
glDeleteShader(blit_ctx->vs);
blit_ctx->vs = 0;
return false;
@@ -142,7 +142,7 @@ static GLuint blit_build_frag_tex_col(struct vrend_blitter_ctx *blit_ctx, int tg
tgsi_tex_target == TGSI_TEXTURE_SHADOWCUBE_ARRAY)
ext_str = "#extension GL_ARB_texture_cube_map_array : require\n";
- snprintf(shader_buf, 4096, fs_texfetch_col, ext_str, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm, "");
+ snprintf(shader_buf, 4096, FS_TEXFETCH_COL, ext_str, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm, "");
fs_id = glCreateShader(GL_FRAGMENT_SHADER);
@@ -191,7 +191,7 @@ static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx,
break;
}
- snprintf(shader_buf, 4096, fs_texfetch_ds, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm);
+ snprintf(shader_buf, 4096, FS_TEXFETCH_DS, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER);
@@ -224,7 +224,7 @@ static GLuint blit_build_frag_blit_msaa_depth(struct vrend_blitter_ctx *blit_ctx
return 0;
}
- snprintf(shader_buf, 4096, fs_texfetch_ds_msaa, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), ivec, twm);
+ snprintf(shader_buf, 4096, FS_TEXFETCH_DS_MSAA, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), ivec, twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER);
diff --git a/src/vrend_blitter.h b/src/vrend_blitter.h
index 46f62b2..a6612f8 100644
--- a/src/vrend_blitter.h
+++ b/src/vrend_blitter.h
@@ -26,44 +26,40 @@
/* shaders for blitting */
-static const char *vs_passthrough = {
- "#version 130\n"
- "in vec4 arg0;\n"
- "in vec4 arg1;\n"
- "out vec4 tc;\n"
- "void main() {\n"
- " gl_Position = arg0;\n"
- " tc = arg1;\n"
+#define VS_PASSTHROUGH \
+ "#version 130\n" \
+ "in vec4 arg0;\n" \
+ "in vec4 arg1;\n" \
+ "out vec4 tc;\n" \
+ "void main() {\n" \
+ " gl_Position = arg0;\n" \
+ " tc = arg1;\n" \
"}\n"
-};
-static const char *fs_texfetch_col = {
- "#version 130\n"
- "%s"
- "uniform sampler%s samp;\n"
- "in vec4 tc;\n"
- "void main() {\n"
- " gl_FragColor = texture(samp, tc%s)%s;\n"
+#define FS_TEXFETCH_COL \
+ "#version 130\n" \
+ "%s" \
+ "uniform sampler%s samp;\n" \
+ "in vec4 tc;\n" \
+ "void main() {\n" \
+ " gl_FragColor = texture(samp, tc%s)%s;\n" \
"}\n"
-};
-static const char *fs_texfetch_ds = {
- "#version 130\n"
- "uniform sampler%s samp;\n"
- "in vec4 tc;\n"
- "void main() {\n"
- " gl_FragDepth = float(texture(samp, tc%s).x);\n"
+#define FS_TEXFETCH_DS \
+ "#version 130\n" \
+ "uniform sampler%s samp;\n" \
+ "in vec4 tc;\n" \
+ "void main() {\n" \
+ " gl_FragDepth = float(texture(samp, tc%s).x);\n" \
"}\n"
-};
-static const char *fs_texfetch_ds_msaa = {
- "#version 130\n"
- "#extension GL_ARB_texture_multisample : enable\n"
- "uniform sampler%s samp;\n"
- "in vec4 tc;\n"
- "void main() {\n"
- " gl_FragDepth = float(texelFetch(samp, %s(tc%s), int(tc.z)).x);\n"
+#define FS_TEXFETCH_DS_MSAA \
+ "#version 130\n" \
+ "#extension GL_ARB_texture_multisample : enable\n" \
+ "uniform sampler%s samp;\n" \
+ "in vec4 tc;\n" \
+ "void main() {\n" \
+ " gl_FragDepth = float(texelFetch(samp, %s(tc%s), int(tc.z)).x);\n" \
"}\n"
-};
#endif
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 9ee4612..a588a29 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -705,17 +705,6 @@ static int emit_cbuf_writes(struct dump_ctx *ctx)
return 0;
}
-static const char *atests[PIPE_FUNC_ALWAYS + 1] = {
- "false",
- "%s < %f",
- "%s == %f",
- "%s <= %f",
- "%s > %f",
- "%s != %f",
- "%s >= %f",
- "true",
-};
-
static int emit_a8_swizzle(struct dump_ctx *ctx)
{
char buf[255];
@@ -727,12 +716,39 @@ static int emit_a8_swizzle(struct dump_ctx *ctx)
return 0;
}
+static const char *atests[PIPE_FUNC_ALWAYS + 1] = {
+ "false",
+ "<",
+ "==",
+ "<=",
+ ">",
+ "!=",
+ ">=",
+ "true"
+};
+
static int emit_alpha_test(struct dump_ctx *ctx)
{
char buf[255];
char comp_buf[128];
char *sret;
- snprintf(comp_buf, 128, atests[ctx->key->alpha_test], "fsout_c0.w", ctx->key->alpha_ref_val);
+
+ switch (ctx->key->alpha_test) {
+ case PIPE_FUNC_NEVER:
+ case PIPE_FUNC_ALWAYS:
+ snprintf(comp_buf, 128, "%s", atests[ctx->key->alpha_test]);
+ break;
+ case PIPE_FUNC_LESS:
+ case PIPE_FUNC_EQUAL:
+ case PIPE_FUNC_LEQUAL:
+ case PIPE_FUNC_GREATER:
+ case PIPE_FUNC_NOTEQUAL:
+ case PIPE_FUNC_GEQUAL:
+ snprintf(comp_buf, 128, "%s %s %f", "fsout_c0.w", atests[ctx->key->alpha_test], ctx->key->alpha_ref_val);
+ default:
+ fprintf(stderr, "invalid alpha-test: %x\n", ctx->key->alpha_test);
+ return EINVAL;
+ }
snprintf(buf, 255, "if (!(%s)) {\n\tdiscard;\n}\n", comp_buf);
sret = add_str_to_glsl_main(ctx, buf);