From dc1e735bbc6a35d4a1d5c1ec720a7a95c0555f49 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 8 Oct 2019 08:37:53 -0400 Subject: Feature/ir entry point profile (#1068) * Split out EntryPointParamDecoration. * Add profile to EntryPointDecoration. * WIP for GS handling for GLSL. * WIP for StreamOut GLSL * Fixed GLSL geometry output. * Clean up - remove unneeded/commented out code from the entry point change. * Use Op nums to identify GeometryTypeDecorations (as opposed to contained enum). --- source/slang/slang-emit-glsl.cpp | 67 ++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 37 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 e43d41d5c..78d34d649 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -654,7 +654,14 @@ void GLSLSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniform void GLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) { - auto profile = entryPointLayout->profile; + SLANG_UNUSED(entryPointLayout); + + IREntryPointDecoration* entryPointDecor = irFunc->findDecoration(); + SLANG_ASSERT(entryPointDecor); + + //auto profile = entryPointLayout->profile; + + auto profile = entryPointDecor->getProfile(); auto stage = profile.GetStage(); switch (stage) @@ -695,50 +702,36 @@ void GLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointL m_writer->emit(") in;\n"); } - for (auto pp : entryPointLayout->getFuncDecl()->GetParameters()) + // These decorations were moved from the parameters to the entry point by ir-glsl-legalize. + // The actual parameters have become potentially multiple global parameters. + if (auto decor = irFunc->findDecoration()) { - if (auto inputPrimitiveTypeModifier = pp->FindModifier()) + switch (decor->op) { - if (as(inputPrimitiveTypeModifier)) - { - m_writer->emit("layout(triangles) in;\n"); - } - else if (as(inputPrimitiveTypeModifier)) - { - m_writer->emit("layout(lines) in;\n"); - } - else if (as(inputPrimitiveTypeModifier)) - { - m_writer->emit("layout(lines_adjacency) in;\n"); - } - else if (as(inputPrimitiveTypeModifier)) + case kIROp_TrianglePrimitiveTypeDecoration: m_writer->emit("layout(triangles) in;\n"); break; + case kIROp_LinePrimitiveTypeDecoration: m_writer->emit("layout(lines) in;\n"); break; + case kIROp_LineAdjPrimitiveTypeDecoration: m_writer->emit("layout(lines_adjacency) in;\n"); break; + case kIROp_PointPrimitiveTypeDecoration: m_writer->emit("layout(points) in;\n"); break; + case kIROp_TriangleAdjPrimitiveTypeDecoration: m_writer->emit("layout(triangles_adjacency) in;\n"); break; + default: { - m_writer->emit("layout(points) in;\n"); - } - else if (as(inputPrimitiveTypeModifier)) - { - m_writer->emit("layout(triangles_adjacency) in;\n"); - } - } - - if (auto outputStreamType = as(pp->type)) - { - if (as(outputStreamType)) - { - m_writer->emit("layout(triangle_strip) out;\n"); - } - else if (as(outputStreamType)) - { - m_writer->emit("layout(line_strip) out;\n"); - } - else if (as(outputStreamType)) - { - m_writer->emit("layout(points) out;\n"); + SLANG_ASSERT(!"Unknown primitive type"); } } } + if (auto decor = irFunc->findDecoration()) + { + IRType* type = decor->getStreamType(); + switch (type->op) + { + case kIROp_HLSLPointStreamType: m_writer->emit("layout(points) out;\n"); break; + case kIROp_HLSLLineStreamType: m_writer->emit("layout(line_strip) out;\n"); break; + case kIROp_HLSLTriangleStreamType: m_writer->emit("layout(triangle_strip) out;\n"); break; + default: SLANG_ASSERT(!"Unknown stream out type"); + } + } } break; case Stage::Pixel: -- cgit v1.2.3