glsl: Only declare fragment outputs on fragment shaders

merge-requests/60/head
ReinUsesLisp 2021-06-16 04:48:05 +07:00 committed by ameerj
parent 0ffea97e2e
commit 892b8aa2ad
1 changed files with 6 additions and 4 deletions

@ -340,12 +340,14 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
const auto qualifier{stage == Stage::TessellationControl ? "out" : "in"}; const auto qualifier{stage == Stage::TessellationControl ? "out" : "in"};
header += fmt::format("layout(location={})patch {} vec4 patch{};", index, qualifier, index); header += fmt::format("layout(location={})patch {} vec4 patch{};", index, qualifier, index);
} }
if (stage == Stage::Fragment) {
for (size_t index = 0; index < info.stores_frag_color.size(); ++index) { for (size_t index = 0; index < info.stores_frag_color.size(); ++index) {
if (!info.stores_frag_color[index] && !profile.need_declared_frag_colors) { if (!info.stores_frag_color[index] && !profile.need_declared_frag_colors) {
continue; continue;
} }
header += fmt::format("layout(location={})out vec4 frag_color{};", index, index); header += fmt::format("layout(location={})out vec4 frag_color{};", index, index);
} }
}
for (size_t index = 0; index < info.stores_generics.size(); ++index) { for (size_t index = 0; index < info.stores_generics.size(); ++index) {
// TODO: Properly resolve attribute issues // TODO: Properly resolve attribute issues
if (info.stores_generics[index] || StageInitializesVaryings()) { if (info.stores_generics[index] || StageInitializesVaryings()) {