shader: Sort FS color outputs

NIR-to-TGSI doesn't necessarily sort the outputs, and that breaks some
CTS tests.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
macos/master
Gert Wollny 3 years ago
parent d1c6cd20dd
commit 01e050b701
  1. 14
      src/vrend_shader.c

@ -7138,6 +7138,17 @@ static bool vrend_patch_vertex_shader_interpolants(const struct vrend_shader_cfg
const char *oprefix, const char *oprefix,
bool flatshade); bool flatshade);
static int compare_sid(const void *lhs, const void *rhs)
{
const struct vrend_shader_io *l = (struct vrend_shader_io *)lhs;
const struct vrend_shader_io *r = (struct vrend_shader_io *)rhs;
if (l->name != r->name)
return l->name - r->name;
return l->sid - r->sid;
}
bool vrend_convert_shader(const struct vrend_context *rctx, bool vrend_convert_shader(const struct vrend_context *rctx,
const struct vrend_shader_cfg *cfg, const struct vrend_shader_cfg *cfg,
const struct tgsi_token *tokens, const struct tgsi_token *tokens,
@ -7217,6 +7228,9 @@ bool vrend_convert_shader(const struct vrend_context *rctx,
for (size_t i = 0; i < ARRAY_SIZE(ctx.src_bufs); ++i) for (size_t i = 0; i < ARRAY_SIZE(ctx.src_bufs); ++i)
strbuf_free(ctx.src_bufs + i); strbuf_free(ctx.src_bufs + i);
if (ctx.prog_type == TGSI_PROCESSOR_FRAGMENT)
qsort(ctx.outputs, ctx.num_outputs, sizeof(struct vrend_shader_io), compare_sid);
emit_header(&ctx, &ctx.glsl_strbufs); emit_header(&ctx, &ctx.glsl_strbufs);
ctx.glsl_ver_required = emit_ios(&ctx, &ctx.glsl_strbufs, &ctx.generic_ios, ctx.glsl_ver_required = emit_ios(&ctx, &ctx.glsl_strbufs, &ctx.generic_ios,
ctx.front_back_color_emitted_flags, ctx.front_back_color_emitted_flags,

Loading…
Cancel
Save