From 341e34652e088f78b0eaa09965fbdf3393265c1f Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 15 Feb 2022 08:26:37 +0100 Subject: [PATCH] shader: Handle TGSI_SEMANTIC_TEXCOORD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With that we can enable PIPE_CAP_TGSI_TEXCOORD in the guest Signed-off-by: Gert Wollny Reviewed-by: Corentin Noël --- .../host/piglit-virgl-gl-fails.txt | 2 -- .../host/piglit-virgl-gles-fails.txt | 2 -- src/vrend_renderer.c | 2 +- src/vrend_shader.c | 24 ++++++++++++++++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt b/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt index e7d4eae..4ca1b1a 100644 --- a/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt +++ b/.gitlab-ci/expectations/host/piglit-virgl-gl-fails.txt @@ -739,8 +739,6 @@ spec@!opengl 2.0@vertex-program-two-side enabled back front2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front2 back2@vs and fs,Fail -spec@!opengl 2.0@vertex-program-two-side enabled front2,Fail -spec@!opengl 2.0@vertex-program-two-side enabled front2@vs- gs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back back2,Fail diff --git a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt index 7028b2e..40195e6 100644 --- a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt +++ b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt @@ -3423,8 +3423,6 @@ spec@!opengl 2.0@vertex-program-two-side enabled back front2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled back@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front2 back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front2 back2@vs and fs,Fail -spec@!opengl 2.0@vertex-program-two-side enabled front2,Fail -spec@!opengl 2.0@vertex-program-two-side enabled front2@vs- gs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back2,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back2@vs and fs,Fail spec@!opengl 2.0@vertex-program-two-side enabled front back back2,Fail diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 461dbdc..c4ed454 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -10654,7 +10654,7 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c * this value to avoid regressions when a guest with a new mesa version is * run on an old virgl host. Use it also to indicate non-cap fixes on the * host that help enable features in the guest. */ - caps->v2.host_feature_check_version = 7; + caps->v2.host_feature_check_version = 8; /* Forward host GL_RENDERER to the guest. */ strncpy(caps->v2.renderer, renderer, sizeof(caps->v2.renderer) - 1); diff --git a/src/vrend_shader.c b/src/vrend_shader.c index fb95bf0..d6ee1ae 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -1240,6 +1240,7 @@ iter_declaration(struct tgsi_iterate_context *iter, /* fallthrough */ case TGSI_SEMANTIC_PATCH: case TGSI_SEMANTIC_GENERIC: + case TGSI_SEMANTIC_TEXCOORD: if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) { if (ctx->key->fs.coord_replace & (1 << ctx->inputs[i].sid)) { if (ctx->cfg->use_gles) @@ -1254,7 +1255,8 @@ iter_declaration(struct tgsi_iterate_context *iter, break; } } - + /* fallthrough */ + case TGSI_SEMANTIC_TESSCOORD: if (ctx->inputs[i].first != ctx->inputs[i].last || ctx->inputs[i].array_id > 0) { ctx->guest_sent_io_arrays = true; @@ -1287,6 +1289,8 @@ iter_declaration(struct tgsi_iterate_context *iter, snprintf(ctx->inputs[i].glsl_name, 128, "%s_g%dA%d", name_prefix, ctx->inputs[i].sid, ctx->inputs[i].array_id); else if (ctx->inputs[i].name == TGSI_SEMANTIC_PATCH) snprintf(ctx->inputs[i].glsl_name, 128, "%s_p%dA%d", name_prefix, ctx->inputs[i].sid, ctx->inputs[i].array_id); + else if (ctx->inputs[i].name == TGSI_SEMANTIC_TEXCOORD) + snprintf(ctx->inputs[i].glsl_name, 64, "%s_t%d", name_prefix, ctx->inputs[i].sid); else snprintf(ctx->inputs[i].glsl_name, 128, "%s_%d", name_prefix, ctx->inputs[i].first); } @@ -1504,6 +1508,9 @@ iter_declaration(struct tgsi_iterate_context *iter, /* fallthrough */ case TGSI_SEMANTIC_PATCH: case TGSI_SEMANTIC_GENERIC: + case TGSI_SEMANTIC_TEXCOORD: + case TGSI_SEMANTIC_TESSCOORD: + if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC) color_offset = -1; @@ -1542,6 +1549,8 @@ iter_declaration(struct tgsi_iterate_context *iter, snprintf(ctx->outputs[i].glsl_name, 64, "%s_p%dA%d", name_prefix, ctx->outputs[i].sid, ctx->outputs[i].array_id); else if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC) snprintf(ctx->outputs[i].glsl_name, 64, "%s_g%dA%d", name_prefix, ctx->outputs[i].sid, ctx->outputs[i].array_id); + else if (ctx->outputs[i].name == TGSI_SEMANTIC_TEXCOORD) + snprintf(ctx->outputs[i].glsl_name, 64, "%s_t%d", name_prefix, ctx->outputs[i].sid); else snprintf(ctx->outputs[i].glsl_name, 64, "%s_%d", name_prefix, ctx->outputs[i].first + color_offset); @@ -1940,7 +1949,9 @@ get_blockvarname(char outvar[64], const char *stage_prefix, const struct vrend_s static void get_so_name(const struct dump_ctx *ctx, bool from_block, const struct vrend_shader_io *output, int index, char out_var[255], char *wm) { - if (output->first == output->last || output->name != TGSI_SEMANTIC_GENERIC) + if (output->first == output->last || + (output->name != TGSI_SEMANTIC_GENERIC && + output->name != TGSI_SEMANTIC_TEXCOORD)) snprintf(out_var, 255, "%s%s", output->glsl_name, wm); else { if ((output->name == TGSI_SEMANTIC_GENERIC) && prefer_generic_io_block(ctx, io_out)) { @@ -3855,6 +3866,9 @@ get_destination_info(struct dump_ctx *ctx, struct vrend_shader_io *io = ctx->generic_ios.output_range.used ? &ctx->generic_ios.output_range.io : &ctx->outputs[j]; get_destination_info_generic(ctx, dst_reg, io, writemask, dsts[i]); dinfo->dst_override_no_wm[i] = ctx->outputs[j].override_no_wm; + } else if (ctx->outputs[j].name == TGSI_SEMANTIC_TEXCOORD) { + get_destination_info_generic(ctx, dst_reg, &ctx->outputs[j], writemask, dsts[i]); + dinfo->dst_override_no_wm[i] = ctx->outputs[j].override_no_wm; } else if (ctx->outputs[j].name == TGSI_SEMANTIC_PATCH) { struct vrend_shader_io *io = ctx->patch_ios.output_range.used ? &ctx->patch_ios.output_range.io : &ctx->outputs[j]; char reswizzled[6] = ""; @@ -4180,7 +4194,8 @@ get_source_info(struct dump_ctx *ctx, if (ctx->inputs[j].first <= src->Register.Index && ctx->inputs[j].last >= src->Register.Index && (ctx->inputs[j].usage_mask & usage_mask)) { - if (ctx->key->color_two_side && ctx->inputs[j].name == TGSI_SEMANTIC_COLOR) + if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && + ctx->key->color_two_side && ctx->inputs[j].name == TGSI_SEMANTIC_COLOR) strbuf_fmt(src_buf, "%s(%s%s%d%s%s)", get_string(stypeprefix), prefix, "realcolor", ctx->inputs[j].sid, arrayname, swizzle); else if (ctx->inputs[j].glsl_gl_block) { /* GS input clipdist requires a conversion */ @@ -4220,6 +4235,8 @@ get_source_info(struct dump_ctx *ctx, } else if (ctx->inputs[j].name == TGSI_SEMANTIC_GENERIC) { struct vrend_shader_io *io = ctx->generic_ios.input_range.used ? &ctx->generic_ios.input_range.io : &ctx->inputs[j]; get_source_info_generic(ctx, io_in, srcstypeprefix, prefix, src, io, arrayname, swizzle, src_buf); + } else if (ctx->inputs[j].name == TGSI_SEMANTIC_TEXCOORD) { + get_source_info_generic(ctx, io_in, srcstypeprefix, prefix, src, &ctx->inputs[j], arrayname, swizzle, src_buf); } else if (ctx->inputs[j].name == TGSI_SEMANTIC_PATCH) { struct vrend_shader_io *io = ctx->patch_ios.input_range.used ? &ctx->patch_ios.input_range.io : &ctx->inputs[j]; get_source_info_patch(srcstypeprefix, prefix, src, io, arrayname, swizzle, src_buf); @@ -7580,6 +7597,7 @@ iter_vs_declaration(struct tgsi_iterate_context *iter, case TGSI_SEMANTIC_PATCH: case TGSI_SEMANTIC_GENERIC: + case TGSI_SEMANTIC_TESSCOORD: if (ctx->inputs[i].first != ctx->inputs[i].last || ctx->inputs[i].array_id > 0) { ctx->guest_sent_io_arrays = true;