From b2563956dd76875b8a29ddc363b8b0826443a8b7 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 15 Feb 2022 15:23:27 +0900 Subject: [PATCH] shader: Do not fall through in iter_declaration Signed-off-by: Akihiko Odaki Reviewed-by: Gert Wollny --- .../host/piglit-virgl-gl-fails.txt | 16 ----- .../host/piglit-virgl-gles-fails.txt | 16 ----- .../virt/piglit-virgl-gl-fails.txt | 10 --- .../virt/piglit-virgl-gles-fails.txt | 10 --- src/vrend_shader.c | 66 ++++++------------- 5 files changed, 20 insertions(+), 98 deletions(-) diff --git a/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt b/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt index 4ca1b1a..2444c3b 100644 --- a/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt +++ b/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt @@ -723,10 +723,6 @@ spec@!opengl 1.5@depth-tex-compare,Fail spec@!opengl 1.5@draw-elements-user,Fail spec@!opengl 2.0@gl-2.0-edgeflag,Fail spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side back front2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back back2,Fail @@ -753,18 +749,6 @@ spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2@vs- gs and fs,Fail spec@!opengl 2.0@vertex-program-two-side front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front front2 back2@gs-out and fs,Fail spec@!opengl 3.2@gl-3.2-adj-prims cull-back pv-first,Fail spec@!opengl 3.2@gl-3.2-adj-prims cull-front pv-first,Fail spec@!opengl 3.2@gl-3.2-adj-prims line cull-back pv-first,Fail diff --git a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt index 1b83905..33c3d59 100644 --- a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt +++ b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt @@ -3407,10 +3407,6 @@ spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail spec@!opengl 2.0@gl-2.0-large-point-fs,Fail spec@!opengl 2.0@gl-2.0-vertexattribpointer,Fail spec@!opengl 2.0@occlusion-query-discard,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side back front2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back back2,Fail @@ -3437,18 +3433,6 @@ spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2@vs- gs and fs,Fail spec@!opengl 2.0@vertex-program-two-side front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front front2 back2@gs-out and fs,Fail spec@!opengl 3.0@required-texture-attachment-formats,Fail spec@!opengl 3.0@sampler-cube-shadow,Fail spec@!opengl 3.2@gl-3.2-adj-prims cull-back pv-first,ExpectedFail diff --git a/.gitlab-ci/expectations/virt/piglit-virgl-gl-fails.txt b/.gitlab-ci/expectations/virt/piglit-virgl-gl-fails.txt index d48cdf4..9c5afd8 100644 --- a/.gitlab-ci/expectations/virt/piglit-virgl-gl-fails.txt +++ b/.gitlab-ci/expectations/virt/piglit-virgl-gl-fails.txt @@ -744,10 +744,6 @@ spec@!opengl 1.5@depth-tex-compare,Fail spec@!opengl 1.5@draw-elements-user,Fail spec@!opengl 2.0@gl-2.0-edgeflag,Fail spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side back front2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back back2,Fail @@ -772,13 +768,7 @@ spec@!opengl 2.0@vertex-program-two-side enabled front back front2@vs and fs,Fai spec@!opengl 2.0@vertex-program-two-side enabled front back@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2@vs and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front front2 back2@gs-out and fs,Fail diff --git a/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt b/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt index 3c4cf4f..126ed2a 100644 --- a/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt +++ b/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt @@ -3434,10 +3434,6 @@ spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail spec@!opengl 2.0@gl-2.0-large-point-fs,Fail spec@!opengl 2.0@gl-2.0-vertexattribpointer,Fail spec@!opengl 2.0@occlusion-query-discard,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side back front2,Fail -spec@!opengl 2.0@vertex-program-two-side back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back back2,Fail @@ -3462,13 +3458,7 @@ spec@!opengl 2.0@vertex-program-two-side enabled front back front2@vs and fs,Fai spec@!opengl 2.0@vertex-program-two-side enabled front back@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front front2 back2@vs and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front2 back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back back2@gs-out and fs,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2,Fail -spec@!opengl 2.0@vertex-program-two-side front back front2 back2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back front2@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front back@gs-out and fs,Fail spec@!opengl 2.0@vertex-program-two-side front front2 back2@gs-out and fs,Fail diff --git a/src/vrend_shader.c b/src/vrend_shader.c index dc102e0..8b9215f 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -1003,7 +1003,7 @@ iter_declaration(struct tgsi_iterate_context *iter, struct dump_ctx *ctx = (struct dump_ctx *)iter; int i; int color_offset = 0; - const char *name_prefix = ""; + const char *name_prefix; bool add_two_side = false; unsigned mask_temp; @@ -1054,6 +1054,8 @@ iter_declaration(struct tgsi_iterate_context *iter, if (ctx->inputs[i].first != ctx->inputs[i].last) ctx->glsl_ver_required = require_glsl_ver(ctx, 150); + name_prefix = get_stage_input_name_prefix(ctx, iter->processor.Processor); + switch (ctx->inputs[i].name) { case TGSI_SEMANTIC_COLOR: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { @@ -1105,11 +1107,8 @@ iter_declaration(struct tgsi_iterate_context *iter, } name_prefix = "ex"; } - } else { - name_prefix = get_stage_input_name_prefix(ctx, iter->processor.Processor); } break; - /* fallthrough */ case TGSI_SEMANTIC_PRIMID: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { name_prefix = "gl_PrimitiveIDIn"; @@ -1117,16 +1116,14 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].glsl_no_index = true; ctx->inputs[i].override_no_wm = true; ctx->shader_req_bits |= SHADER_REQ_INTS; - break; } else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { name_prefix = "gl_PrimitiveID"; ctx->inputs[i].glsl_predefined_no_emit = true; ctx->inputs[i].glsl_no_index = true; ctx->glsl_ver_required = require_glsl_ver(ctx, 150); ctx->shader_req_bits |= SHADER_REQ_GEOMETRY_SHADER; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_VIEWPORT_INDEX: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { ctx->inputs[i].glsl_predefined_no_emit = true; @@ -1139,9 +1136,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->shader_req_bits |= SHADER_REQ_LAYER; if (ctx->cfg->use_gles) ctx->shader_req_bits |= SHADER_REQ_VIEWPORT_IDX; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_LAYER: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { name_prefix = "gl_Layer"; @@ -1151,9 +1147,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].type = VEC_INT; ctx->inputs[i].override_no_wm = true; ctx->shader_req_bits |= SHADER_REQ_LAYER; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PSIZE: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL || @@ -1165,9 +1160,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].glsl_gl_block = true; ctx->shader_req_bits |= SHADER_REQ_PSIZE; ctx->has_pointsize_input = true; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_CLIPDIST: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL || @@ -1180,7 +1174,6 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; if (ctx->inputs[i].last != ctx->inputs[i].first) ctx->guest_sent_io_arrays = true; - break; } else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { name_prefix = "gl_ClipDistance"; ctx->inputs[i].glsl_predefined_no_emit = true; @@ -1189,9 +1182,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->shader_req_bits |= SHADER_REQ_CLIP_DISTANCE; if (ctx->inputs[i].last != ctx->inputs[i].first) ctx->guest_sent_io_arrays = true; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_POSITION: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL || @@ -1200,7 +1192,6 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].glsl_predefined_no_emit = true; ctx->inputs[i].glsl_no_index = true; ctx->inputs[i].glsl_gl_block = true; - break; } else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { if (ctx->cfg->use_gles && ctx->fs_pixel_center) { name_prefix = "(gl_FragCoord - vec4(0.5, 0.5, 0.0, 0.0))"; @@ -1208,9 +1199,8 @@ iter_declaration(struct tgsi_iterate_context *iter, name_prefix = "gl_FragCoord"; ctx->inputs[i].glsl_predefined_no_emit = true; ctx->inputs[i].glsl_no_index = true; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_FACE: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { if (ctx->front_face_emitted) { @@ -1221,9 +1211,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].glsl_predefined_no_emit = true; ctx->inputs[i].glsl_no_index = true; ctx->front_face_emitted = true; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PCOORD: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { if (ctx->cfg->use_gles) @@ -1235,9 +1224,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->inputs[i].num_components = 4; ctx->inputs[i].swizzle_offset = 0; ctx->inputs[i].usage_mask = 0xf; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PATCH: case TGSI_SEMANTIC_GENERIC: case TGSI_SEMANTIC_TEXCOORD: @@ -1267,10 +1255,6 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->shader_req_bits |= SHADER_REQ_ARRAYS_OF_ARRAYS; } } - - /* fallthrough */ - default: - name_prefix = get_stage_input_name_prefix(ctx, iter->processor.Processor); break; } @@ -1337,6 +1321,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->outputs[i].is_int = false; ctx->outputs[i].fbfetch_used = false; + name_prefix = get_stage_output_name_prefix(iter->processor.Processor); + switch (ctx->outputs[i].name) { case TGSI_SEMANTIC_POSITION: if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX || @@ -1425,7 +1411,6 @@ iter_declaration(struct tgsi_iterate_context *iter, } ctx->outputs[i].override_no_wm = false; break; - /* fallthrough */ case TGSI_SEMANTIC_BCOLOR: if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) { if (ctx->glsl_ver_required < 140) { @@ -1434,14 +1419,12 @@ iter_declaration(struct tgsi_iterate_context *iter, name_prefix = "gl_BackColor"; else if (ctx->outputs[i].sid == 1) name_prefix = "gl_BackSecondaryColor"; - break; } else { ctx->outputs[i].override_no_wm = false; ctx->color_out_mask |= (1 << decl->Semantic.Index) << 2; } - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PSIZE: if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX || iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY || @@ -1455,9 +1438,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->has_pointsize_output = true; if (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) ctx->outputs[i].glsl_gl_block = true; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_LAYER: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { ctx->outputs[i].glsl_predefined_no_emit = true; @@ -1465,9 +1447,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->outputs[i].override_no_wm = true; ctx->outputs[i].is_int = true; name_prefix = "gl_Layer"; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PRIMID: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { ctx->outputs[i].glsl_predefined_no_emit = true; @@ -1475,9 +1456,8 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->outputs[i].override_no_wm = true; ctx->outputs[i].is_int = true; name_prefix = "gl_PrimitiveID"; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_VIEWPORT_INDEX: if (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { ctx->outputs[i].glsl_predefined_no_emit = true; @@ -1487,27 +1467,24 @@ iter_declaration(struct tgsi_iterate_context *iter, name_prefix = "gl_ViewportIndex"; if (ctx->glsl_ver_required >= 140 || ctx->cfg->use_gles) ctx->shader_req_bits |= SHADER_REQ_VIEWPORT_IDX; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_TESSOUTER: if (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) { ctx->outputs[i].glsl_predefined_no_emit = true; ctx->outputs[i].glsl_no_index = true; ctx->outputs[i].override_no_wm = true; name_prefix = "gl_TessLevelOuter"; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_TESSINNER: if (iter->processor.Processor == TGSI_PROCESSOR_TESS_CTRL) { ctx->outputs[i].glsl_predefined_no_emit = true; ctx->outputs[i].glsl_no_index = true; ctx->outputs[i].override_no_wm = true; name_prefix = "gl_TessLevelInner"; - break; } - /* fallthrough */ + break; case TGSI_SEMANTIC_PATCH: case TGSI_SEMANTIC_GENERIC: case TGSI_SEMANTIC_TEXCOORD: @@ -1528,9 +1505,6 @@ iter_declaration(struct tgsi_iterate_context *iter, ctx->shader_req_bits |= SHADER_REQ_ARRAYS_OF_ARRAYS; } } - /* fallthrough */ - default: - name_prefix = get_stage_output_name_prefix(iter->processor.Processor); break; }