From 12ef06ba8bca5b20069e24b36f9216d01d4fe904 Mon Sep 17 00:00:00 2001
From: ameerj <52414509+ameerj@users.noreply.github.com>
Date: Tue, 15 Jun 2021 21:01:44 -0400
Subject: glsl: Obey need_declared_frag_colors to declare and initialize all
 frag_color

Fixes Ori and the blind forest title screen
---
 src/shader_recompiler/backend/glsl/emit_glsl_special.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'src/shader_recompiler/backend/glsl/emit_glsl_special.cpp')

diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
index 59ca52f07f..f8e8aaa67b 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
@@ -8,6 +8,7 @@
 #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h"
 #include "shader_recompiler/frontend/ir/program.h"
 #include "shader_recompiler/frontend/ir/value.h"
+#include "shader_recompiler/profile.h"
 
 namespace Shader::Backend::GLSL {
 namespace {
@@ -58,6 +59,14 @@ void EmitPrologue(EmitContext& ctx) {
     if (ctx.StageInitializesVaryings()) {
         InitializeVaryings(ctx);
     }
+    if (ctx.stage == Stage::Fragment && ctx.profile.need_declared_frag_colors) {
+        for (size_t index = 0; index < ctx.info.stores_frag_color.size(); ++index) {
+            if (ctx.info.stores_frag_color[index]) {
+                continue;
+            }
+            ctx.Add("frag_color{}=vec4(0,0,0,1);", index);
+        }
+    }
 }
 
 void EmitEpilogue(EmitContext&) {}
-- 
cgit v1.2.3-70-g09d2