shader: drop needless snprintf calls

[airlied: found a couple of others]

Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Erik Faye-Lund 6 years ago committed by Dave Airlie
parent d10d000029
commit ea97380ec8
  1. 51
      src/vrend_shader.c

@ -4522,8 +4522,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->early_depth_stencil) { if (ctx->early_depth_stencil) {
snprintf(buf, 255, "layout(early_fragment_tests) in;\n"); STRCAT_WITH_RET(glsl_hdr, "layout(early_fragment_tests) in;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
} }
@ -4609,9 +4608,8 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && ctx->cfg->use_gles && if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && ctx->cfg->use_gles &&
!ctx->key->winsys_adjust_y_emitted && !ctx->key->winsys_adjust_y_emitted &&
(ctx->key->coord_replace & (1 << ctx->inputs[i].sid))) { (ctx->key->coord_replace & (1 << ctx->inputs[i].sid))) {
snprintf(buf, 255, "uniform float winsys_adjust_y;\n");
ctx->key->winsys_adjust_y_emitted = true; ctx->key->winsys_adjust_y_emitted = true;
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, "uniform float winsys_adjust_y;\n");
} }
} }
if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) { if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) {
@ -4719,8 +4717,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX || if (ctx->prog_type == TGSI_PROCESSOR_VERTEX ||
ctx->prog_type == TGSI_PROCESSOR_GEOMETRY || ctx->prog_type == TGSI_PROCESSOR_GEOMETRY ||
ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) { ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) {
snprintf(buf, 255, "uniform float winsys_adjust_y;\n"); STRCAT_WITH_RET(glsl_hdr, "uniform float winsys_adjust_y;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX) { if (ctx->prog_type == TGSI_PROCESSOR_VERTEX) {
@ -4744,8 +4741,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} else } else
snprintf(clip_buf, 64, "out float gl_ClipDistance[%d];\n", num_clip_dists); snprintf(clip_buf, 64, "out float gl_ClipDistance[%d];\n", num_clip_dists);
if (ctx->key->clip_plane_enable) { if (ctx->key->clip_plane_enable) {
snprintf(buf, 255, "uniform vec4 clipp[8];\n"); STRCAT_WITH_RET(glsl_hdr, "uniform vec4 clipp[8];\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->key->gs_present || ctx->key->tes_present) { if (ctx->key->gs_present || ctx->key->tes_present) {
ctx->vs_has_pervertex = true; ctx->vs_has_pervertex = true;
@ -4755,8 +4751,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
snprintf(buf, 255, "%s%s", clip_buf, cull_buf); snprintf(buf, 255, "%s%s", clip_buf, cull_buf);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
snprintf(buf, 255, "vec4 clip_dist_temp[2];\n"); STRCAT_WITH_RET(glsl_hdr, "vec4 clip_dist_temp[2];\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
} }
@ -4857,29 +4852,22 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} }
if (ctx->write_mul_utemp) { if (ctx->write_mul_utemp) {
snprintf(buf, 255, "uvec4 mul_utemp;\n"); STRCAT_WITH_RET(glsl_hdr, "uvec4 mul_utemp;\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, "uvec4 umul_temp;\n");
snprintf(buf, 255, "uvec4 umul_temp;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->write_mul_itemp) { if (ctx->write_mul_itemp) {
snprintf(buf, 255, "ivec4 mul_itemp;\n"); STRCAT_WITH_RET(glsl_hdr, "ivec4 mul_itemp;\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, "ivec4 imul_temp;\n");
snprintf(buf, 255, "ivec4 imul_temp;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->ssbo_used_mask || ctx->has_file_memory) { if (ctx->ssbo_used_mask || ctx->has_file_memory) {
snprintf(buf, 255, "uint ssbo_addr_temp;\n"); STRCAT_WITH_RET(glsl_hdr, "uint ssbo_addr_temp;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->shader_req_bits & SHADER_REQ_FP64) { if (ctx->shader_req_bits & SHADER_REQ_FP64) {
snprintf(buf, 255, "dvec2 fp64_dst[3];\n"); STRCAT_WITH_RET(glsl_hdr, "dvec2 fp64_dst[3];\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, "dvec2 fp64_src[4];\n");
snprintf(buf, 255, "dvec2 fp64_src[4];\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
for (i = 0; i < ctx->num_address; i++) { for (i = 0; i < ctx->num_address; i++) {
@ -4893,14 +4881,10 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} }
if (ctx->key->color_two_side) { if (ctx->key->color_two_side) {
if (ctx->color_in_mask & 1) { if (ctx->color_in_mask & 1)
snprintf(buf, 255, "vec4 realcolor0;\n"); STRCAT_WITH_RET(glsl_hdr, "vec4 realcolor0;\n");
STRCAT_WITH_RET(glsl_hdr, buf); if (ctx->color_in_mask & 2)
} STRCAT_WITH_RET(glsl_hdr, "vec4 realcolor1;\n");
if (ctx->color_in_mask & 2) {
snprintf(buf, 255, "vec4 realcolor1;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
}
} }
if (ctx->num_ubo) { if (ctx->num_ubo) {
const char *cname = tgsi_proc_to_prefix(ctx->prog_type); const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
@ -4987,8 +4971,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT &&
ctx->key->pstipple_tex == true) { ctx->key->pstipple_tex == true) {
snprintf(buf, 255, "uniform sampler2D pstipple_sampler;\nfloat stip_temp;\n"); STRCAT_WITH_RET(glsl_hdr, "uniform sampler2D pstipple_sampler;\nfloat stip_temp;\n");
STRCAT_WITH_RET(glsl_hdr, buf);
} }
return glsl_hdr; return glsl_hdr;
} }

Loading…
Cancel
Save