From 395302d2404e3429f3cdfa406e89fa76bc0d444b Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Thu, 13 Mar 2025 06:28:03 -0400 Subject: Add mesh shader output topology checks (#6592) * initial wip * more wip * add test * add unexpected for invalid target * fixups and improve error message * fixups and improve error message * remove incorrect comment --------- Co-authored-by: Ellie Hermaszewska --- source/slang/slang-emit-glsl.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 86699df48..ac98a0a3c 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -4,6 +4,7 @@ #include "../core/slang-writer.h" #include "slang-emit-source-writer.h" #include "slang-ir-call-graph.h" +#include "slang-ir-entry-point-decorations.h" #include "slang-ir-layout.h" #include "slang-ir-util.h" #include "slang-legalize-types.h" @@ -1415,6 +1416,23 @@ void GLSLSourceEmitter::emitParameterGroupImpl( _emitGLSLParameterGroup(varDecl, type); } +static String getOutputTopologyString(OutputTopologyType topology) +{ + SLANG_ASSERT(topology != OutputTopologyType::Unknown); + + switch (topology) + { + case OutputTopologyType::Point: + return "points"; + case OutputTopologyType::Line: + return "lines"; + case OutputTopologyType::Triangle: + return "triangles"; + default: + return ""; + } +} + void GLSLSourceEmitter::emitEntryPointAttributesImpl( IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) @@ -1617,12 +1635,10 @@ void GLSLSourceEmitter::emitEntryPointAttributesImpl( } if (auto decor = as(decoration)) { - // TODO: Ellie validate here/elsewhere, what's allowed here is - // different from the tesselator - // The naming here is plural, so add an 's' m_writer->emit("layout("); - m_writer->emit(decor->getTopology()->getStringSlice()); - m_writer->emit("s) out;\n"); + m_writer->emit( + getOutputTopologyString(OutputTopologyType(decor->getTopologyType()))); + m_writer->emit(") out;\n"); } break; default: -- cgit v1.2.3