From: Mike Blumenkrantz Date: Mon, 6 Jul 2020 12:58:28 +0000 (-0400) Subject: zink: translate gl_FragColor to gl_FragData before ntv to fix multi-rt output X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ca7bd73c6f1f59dcb41ead7a3923c55040377d9;p=mesa.git zink: translate gl_FragColor to gl_FragData before ntv to fix multi-rt output according to EXT_multiview_draw_buffers, gl_FragColor outputs to all available render targets when used, so we need to translate this to gl_FragData[PIPE_MAX_COLOR_BUFS] in order to correctly handle more than one color buffer attachment this fixes the rest of spec@arb_framebuffer_object tests in piglit Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 76fd90ed24b..095b8e08fcf 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -394,15 +394,14 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var) ctx->so_output_gl_types[var->data.location] = var->type; ctx->so_output_types[var->data.location] = var_type; } else if (ctx->stage == MESA_SHADER_FRAGMENT) { - if (var->data.location >= FRAG_RESULT_DATA0) + if (var->data.location >= FRAG_RESULT_DATA0) { spirv_builder_emit_location(&ctx->builder, var_id, var->data.location - FRAG_RESULT_DATA0); - else { + spirv_builder_emit_index(&ctx->builder, var_id, var->data.index); + } else { switch (var->data.location) { case FRAG_RESULT_COLOR: - spirv_builder_emit_location(&ctx->builder, var_id, 0); - spirv_builder_emit_index(&ctx->builder, var_id, var->data.index); - break; + unreachable("gl_FragColor should be lowered by now"); case FRAG_RESULT_DEPTH: spirv_builder_emit_builtin(&ctx->builder, var_id, SpvBuiltInFragDepth); @@ -411,6 +410,7 @@ emit_output(struct ntv_context *ctx, struct nir_variable *var) default: spirv_builder_emit_location(&ctx->builder, var_id, var->data.driver_location); + spirv_builder_emit_index(&ctx->builder, var_id, var->data.index); } } } diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 9761b8e1805..65d4a2e3390 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -191,6 +191,7 @@ zink_compile_nir(struct zink_screen *screen, struct nir_shader *nir, optimize_nir(nir); NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); NIR_PASS_V(nir, lower_discard_if); + NIR_PASS_V(nir, nir_lower_fragcolor); NIR_PASS_V(nir, nir_convert_from_ssa, true); if (zink_debug & ZINK_DEBUG_NIR) {