Commit 53286c6f authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Dave Airlie

Fix -Wformat-nonliteral warnings

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent aa48af98
......@@ -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);
......
......@@ -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
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment