summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-glsl.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-08 08:37:53 -0400
committerGitHub <noreply@github.com>2019-10-08 08:37:53 -0400
commitdc1e735bbc6a35d4a1d5c1ec720a7a95c0555f49 (patch)
tree7020737abd74ccfcb6d24e1f294b3193867b3042 /source/slang/slang-emit-glsl.cpp
parent7c8527d20e433c3a10736136d31e4cd882a3baaa (diff)
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).
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
-rw-r--r--source/slang/slang-emit-glsl.cpp67
1 files changed, 30 insertions, 37 deletions
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<IREntryPointDecoration>();
+ 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<IRGeometryPrimitiveTypeDecoration>())
{
- if (auto inputPrimitiveTypeModifier = pp->FindModifier<HLSLGeometryShaderInputPrimitiveTypeModifier>())
+ switch (decor->op)
{
- if (as<HLSLTriangleModifier>(inputPrimitiveTypeModifier))
- {
- m_writer->emit("layout(triangles) in;\n");
- }
- else if (as<HLSLLineModifier>(inputPrimitiveTypeModifier))
- {
- m_writer->emit("layout(lines) in;\n");
- }
- else if (as<HLSLLineAdjModifier>(inputPrimitiveTypeModifier))
- {
- m_writer->emit("layout(lines_adjacency) in;\n");
- }
- else if (as<HLSLPointModifier>(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<HLSLTriangleAdjModifier>(inputPrimitiveTypeModifier))
- {
- m_writer->emit("layout(triangles_adjacency) in;\n");
- }
- }
-
- if (auto outputStreamType = as<HLSLStreamOutputType>(pp->type))
- {
- if (as<HLSLTriangleStreamType>(outputStreamType))
- {
- m_writer->emit("layout(triangle_strip) out;\n");
- }
- else if (as<HLSLLineStreamType>(outputStreamType))
- {
- m_writer->emit("layout(line_strip) out;\n");
- }
- else if (as<HLSLPointStreamType>(outputStreamType))
- {
- m_writer->emit("layout(points) out;\n");
+ SLANG_ASSERT(!"Unknown primitive type");
}
}
}
+ if (auto decor = irFunc->findDecoration<IRStreamOutputTypeDecoration>())
+ {
+ 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: