summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-hlsl.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-08 11:50:43 -0400
committerGitHub <noreply@github.com>2019-10-08 11:50:43 -0400
commitc61d529d9aec30dd80e0e915cfad01d42be7e153 (patch)
tree6b7d8ac25df9469fa9a2816f8756b10a66019891 /source/slang/slang-emit-hlsl.cpp
parentcae56127251b4766f686c2ec6d4672da3ded160f (diff)
Remove EntryPointLayout* use in emit logic. (#1071)
* 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). * Remove setSampleRateFlag & doSampleRateInputCheck * Remove EntryPointLayout from emit. * Change to force CI.
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
-rw-r--r--source/slang/slang-emit-hlsl.cpp143
1 files changed, 66 insertions, 77 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 0ce3a682d..64dfb385a 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -220,13 +220,75 @@ void HLSLSourceEmitter::_emitHLSLParameterGroup(IRGlobalParam* varDecl, IRUnifor
m_writer->emit("}\n");
}
-void HLSLSourceEmitter::_emitHLSLEntryPointAttributes(IRFunc* irFunc, EntryPointLayout* entryPointLayout)
+void HLSLSourceEmitter::_emitHLSLTextureType(IRTextureTypeBase* texType)
{
- SLANG_UNUSED(entryPointLayout);
+ switch (texType->getAccess())
+ {
+ case SLANG_RESOURCE_ACCESS_READ:
+ break;
+
+ case SLANG_RESOURCE_ACCESS_READ_WRITE:
+ m_writer->emit("RW");
+ break;
+
+ case SLANG_RESOURCE_ACCESS_RASTER_ORDERED:
+ m_writer->emit("RasterizerOrdered");
+ break;
+
+ case SLANG_RESOURCE_ACCESS_APPEND:
+ m_writer->emit("Append");
+ break;
- IREntryPointDecoration* entryPointDecor = irFunc->findDecoration<IREntryPointDecoration>();
- SLANG_ASSERT(entryPointDecor);
+ case SLANG_RESOURCE_ACCESS_CONSUME:
+ m_writer->emit("Consume");
+ break;
+ default:
+ SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled resource access mode");
+ break;
+ }
+
+ switch (texType->GetBaseShape())
+ {
+ case TextureFlavor::Shape::Shape1D: m_writer->emit("Texture1D"); break;
+ case TextureFlavor::Shape::Shape2D: m_writer->emit("Texture2D"); break;
+ case TextureFlavor::Shape::Shape3D: m_writer->emit("Texture3D"); break;
+ case TextureFlavor::Shape::ShapeCube: m_writer->emit("TextureCube"); break;
+ case TextureFlavor::Shape::ShapeBuffer: m_writer->emit("Buffer"); break;
+ default:
+ SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled resource shape");
+ break;
+ }
+
+ if (texType->isMultisample())
+ {
+ m_writer->emit("MS");
+ }
+ if (texType->isArray())
+ {
+ m_writer->emit("Array");
+ }
+ m_writer->emit("<");
+ emitType(texType->getElementType());
+ m_writer->emit(" >");
+}
+
+void HLSLSourceEmitter::emitLayoutSemanticsImpl(IRInst* inst, char const* uniformSemanticSpelling)
+{
+ auto layout = getVarLayout(inst);
+ if (layout)
+ {
+ _emitHLSLRegisterSemantics(layout, uniformSemanticSpelling);
+ }
+}
+
+void HLSLSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type)
+{
+ _emitHLSLParameterGroup(varDecl, type);
+}
+
+void HLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor)
+{
auto profile = m_effectiveProfile;
auto stage = entryPointDecor->getProfile().GetStage();
@@ -343,79 +405,6 @@ void HLSLSourceEmitter::_emitHLSLEntryPointAttributes(IRFunc* irFunc, EntryPoint
}
}
-
-void HLSLSourceEmitter::_emitHLSLTextureType(IRTextureTypeBase* texType)
-{
- switch (texType->getAccess())
- {
- case SLANG_RESOURCE_ACCESS_READ:
- break;
-
- case SLANG_RESOURCE_ACCESS_READ_WRITE:
- m_writer->emit("RW");
- break;
-
- case SLANG_RESOURCE_ACCESS_RASTER_ORDERED:
- m_writer->emit("RasterizerOrdered");
- break;
-
- case SLANG_RESOURCE_ACCESS_APPEND:
- m_writer->emit("Append");
- break;
-
- case SLANG_RESOURCE_ACCESS_CONSUME:
- m_writer->emit("Consume");
- break;
-
- default:
- SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled resource access mode");
- break;
- }
-
- switch (texType->GetBaseShape())
- {
- case TextureFlavor::Shape::Shape1D: m_writer->emit("Texture1D"); break;
- case TextureFlavor::Shape::Shape2D: m_writer->emit("Texture2D"); break;
- case TextureFlavor::Shape::Shape3D: m_writer->emit("Texture3D"); break;
- case TextureFlavor::Shape::ShapeCube: m_writer->emit("TextureCube"); break;
- case TextureFlavor::Shape::ShapeBuffer: m_writer->emit("Buffer"); break;
- default:
- SLANG_DIAGNOSE_UNEXPECTED(getSink(), SourceLoc(), "unhandled resource shape");
- break;
- }
-
- if (texType->isMultisample())
- {
- m_writer->emit("MS");
- }
- if (texType->isArray())
- {
- m_writer->emit("Array");
- }
- m_writer->emit("<");
- emitType(texType->getElementType());
- m_writer->emit(" >");
-}
-
-void HLSLSourceEmitter::emitLayoutSemanticsImpl(IRInst* inst, char const* uniformSemanticSpelling)
-{
- auto layout = getVarLayout(inst);
- if (layout)
- {
- _emitHLSLRegisterSemantics(layout, uniformSemanticSpelling);
- }
-}
-
-void HLSLSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type)
-{
- _emitHLSLParameterGroup(varDecl, type);
-}
-
-void HLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout)
-{
- _emitHLSLEntryPointAttributes(irFunc, entryPointLayout);
-}
-
bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOuterPrec)
{
switch (inst->op)