aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-30 03:40:19 -0300
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:34 -0400
commit916ca7432474e891864524dcbc6c879d5cdbfb72 (patch)
tree07ff6cc3f9737b20b4e65786f94cabe1dd3b254f /src/shader_recompiler/backend
parenta7e9756671be5bb99566277709e5becdea774f34 (diff)
opengl: Declare fragment outputs even if they are not used
Fixes Ori and the Blind Forest's menu on GLASM. For some reason (probably high level optimizations) it is not sanitized on SPIR-V for OpenGL. Vulkan is unaffected by this change.
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.cpp10
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp3
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp2
3 files changed, 5 insertions, 10 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp
index e18526816b..08918a5c2e 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_context.cpp
@@ -117,13 +117,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
index, index);
}
}
- for (size_t index = 0; index < info.stores_frag_color.size(); ++index) {
- if (!info.stores_frag_color[index]) {
- continue;
- }
- if (index == 0) {
- Add("OUTPUT frag_color0=result.color;");
- } else {
+ if (stage == Stage::Fragment) {
+ Add("OUTPUT frag_color0=result.color;");
+ for (size_t index = 1; index < info.stores_frag_color.size(); ++index) {
Add("OUTPUT frag_color{}=result.color[{}];", index, index);
}
}
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index e23208d2c4..70ca6f621f 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -298,8 +298,7 @@ void SetupOptions(const IR::Program& program, const Profile& profile,
if (stage == Stage::Fragment && runtime_info.force_early_z != 0) {
header += "OPTION NV_early_fragment_tests;";
}
- const auto non_zero_frag_colors{info.stores_frag_color | std::views::drop(1)};
- if (std::ranges::find(non_zero_frag_colors, true) != non_zero_frag_colors.end()) {
+ if (stage == Stage::Fragment) {
header += "OPTION ARB_draw_buffers;";
}
}
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index 3e8899f534..7c618125e0 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -1320,7 +1320,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
break;
case Stage::Fragment:
for (u32 index = 0; index < 8; ++index) {
- if (!info.stores_frag_color[index]) {
+ if (!info.stores_frag_color[index] && !profile.need_declared_frag_colors) {
continue;
}
frag_color[index] = DefineOutput(*this, F32[4], std::nullopt);