diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-10-08 11:50:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-08 11:50:43 -0400 |
| commit | c61d529d9aec30dd80e0e915cfad01d42be7e153 (patch) | |
| tree | 6b7d8ac25df9469fa9a2816f8756b10a66019891 /source | |
| parent | cae56127251b4766f686c2ec6d4672da3ded160f (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')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 9 | ||||
| -rw-r--r-- | source/slang/slang-emit-c-like.h | 5 | ||||
| -rw-r--r-- | source/slang/slang-emit-cpp.cpp | 14 | ||||
| -rw-r--r-- | source/slang/slang-emit-cpp.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 7 | ||||
| -rw-r--r-- | source/slang/slang-emit-glsl.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-emit-hlsl.cpp | 143 | ||||
| -rw-r--r-- | source/slang/slang-emit-hlsl.h | 4 |
8 files changed, 85 insertions, 101 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 101987387..63e80615e 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -2476,9 +2476,9 @@ String CLikeSourceEmitter::getFuncName(IRFunc* func) } -void CLikeSourceEmitter::emitEntryPointAttributes(IRFunc* irFunc, EntryPointLayout* entryPointLayout) +void CLikeSourceEmitter::emitEntryPointAttributes(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) { - emitEntryPointAttributesImpl(irFunc, entryPointLayout); + emitEntryPointAttributesImpl(irFunc, entryPointDecor); } void CLikeSourceEmitter::emitPhiVarDecls(IRFunc* func) @@ -2544,10 +2544,9 @@ void CLikeSourceEmitter::emitSimpleFuncImpl(IRFunc* func) // Deal with decorations that need // to be emitted as attributes - auto entryPointLayout = asEntryPoint(func); - if (entryPointLayout) + if ( IREntryPointDecoration* entryPointDecor = func->findDecoration<IREntryPointDecoration>()) { - emitEntryPointAttributes(func, entryPointLayout); + emitEntryPointAttributes(func, entryPointDecor); } auto name = getFuncName(func); diff --git a/source/slang/slang-emit-c-like.h b/source/slang/slang-emit-c-like.h index c55335de7..1460135a5 100644 --- a/source/slang/slang-emit-c-like.h +++ b/source/slang/slang-emit-c-like.h @@ -241,7 +241,7 @@ public: String getFuncName(IRFunc* func); - void emitEntryPointAttributes(IRFunc* irFunc, EntryPointLayout* entryPointLayout); + void emitEntryPointAttributes(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor); void emitPhiVarDecls(IRFunc* func); @@ -326,7 +326,8 @@ public: virtual void emitLayoutSemanticsImpl(IRInst* inst, char const* uniformSemanticSpelling = "register") { SLANG_UNUSED(inst); SLANG_UNUSED(uniformSemanticSpelling); } virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) = 0; - virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) = 0; + virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) = 0; + virtual void emitImageFormatModifierImpl(IRInst* varDecl, IRType* varType) { SLANG_UNUSED(varDecl); SLANG_UNUSED(varType); } virtual void emitLayoutQualifiersImpl(VarLayout* layout) { SLANG_UNUSED(layout); } virtual void emitPreprocessorDirectivesImpl() {} diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 3727bf45e..916444d3e 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -1905,12 +1905,12 @@ void CPPSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformP } } -void CPPSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) +void CPPSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) { - SLANG_UNUSED(irFunc); + SLANG_UNUSED(entryPointDecor); - auto profile = m_effectiveProfile; - auto stage = entryPointLayout->profile.GetStage(); + auto profile = m_effectiveProfile; + auto stage = profile.GetStage(); switch (stage) { @@ -2450,10 +2450,12 @@ struct GlobalParamInfo void CPPSourceEmitter::_emitEntryPointDefinitionStart(IRFunc* func, IRGlobalParam* entryPointGlobalParams, const String& funcName, const UnownedStringSlice& varyingTypeName) { auto resultType = func->getResultType(); - auto entryPointLayout = asEntryPoint(func); + + auto entryPointDecl = func->findDecoration<IREntryPointDecoration>(); + SLANG_ASSERT(entryPointDecl); // Emit the actual function - emitEntryPointAttributes(func, entryPointLayout); + emitEntryPointAttributes(func, entryPointDecl); emitType(resultType, funcName); m_writer->emit("("); diff --git a/source/slang/slang-emit-cpp.h b/source/slang/slang-emit-cpp.h index af7aef271..0af2d4555 100644 --- a/source/slang/slang-emit-cpp.h +++ b/source/slang/slang-emit-cpp.h @@ -212,7 +212,7 @@ protected: // Implement CLikeSourceEmitter interface virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) SLANG_OVERRIDE; - virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) SLANG_OVERRIDE; + virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) SLANG_OVERRIDE; virtual void emitSimpleTypeImpl(IRType* type) SLANG_OVERRIDE; virtual void emitTypeImpl(IRType* type, const StringSliceLoc* nameLoc) SLANG_OVERRIDE; virtual void emitVectorTypeNameImpl(IRType* elementType, IRIntegerValue elementCount) SLANG_OVERRIDE; diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 78d34d649..280eafd70 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -652,15 +652,10 @@ void GLSLSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniform _emitGLSLParameterGroup(varDecl, type); } -void GLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) +void GLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) { - SLANG_UNUSED(entryPointLayout); - - IREntryPointDecoration* entryPointDecor = irFunc->findDecoration<IREntryPointDecoration>(); SLANG_ASSERT(entryPointDecor); - //auto profile = entryPointLayout->profile; - auto profile = entryPointDecor->getProfile(); auto stage = profile.GetStage(); diff --git a/source/slang/slang-emit-glsl.h b/source/slang/slang-emit-glsl.h index 0451ec0b9..e3517d5be 100644 --- a/source/slang/slang-emit-glsl.h +++ b/source/slang/slang-emit-glsl.h @@ -20,7 +20,7 @@ public: protected: virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) SLANG_OVERRIDE; - virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) SLANG_OVERRIDE; + virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) SLANG_OVERRIDE; virtual void emitImageFormatModifierImpl(IRInst* varDecl, IRType* varType) SLANG_OVERRIDE; virtual void emitLayoutQualifiersImpl(VarLayout* layout) SLANG_OVERRIDE; 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) diff --git a/source/slang/slang-emit-hlsl.h b/source/slang/slang-emit-hlsl.h index b6b5fa740..b06a24583 100644 --- a/source/slang/slang-emit-hlsl.h +++ b/source/slang/slang-emit-hlsl.h @@ -20,7 +20,7 @@ protected: virtual void emitLayoutSemanticsImpl(IRInst* inst, char const* uniformSemanticSpelling) SLANG_OVERRIDE; virtual void emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniformParameterGroupType* type) SLANG_OVERRIDE; - virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, EntryPointLayout* entryPointLayout) SLANG_OVERRIDE; + virtual void emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) SLANG_OVERRIDE; virtual void emitLayoutDirectivesImpl(TargetRequest* targetReq) SLANG_OVERRIDE; virtual void emitRateQualifiersImpl(IRRate* rate) SLANG_OVERRIDE; virtual void emitSemanticsImpl(IRInst* inst) SLANG_OVERRIDE; @@ -46,8 +46,6 @@ protected: void _emitHLSLParameterGroup(IRGlobalParam* varDecl, IRUniformParameterGroupType* type); - void _emitHLSLEntryPointAttributes(IRFunc* irFunc, EntryPointLayout* entryPointLayout); - void _emitHLSLTextureType(IRTextureTypeBase* texType); void _emitHLSLDecorationSingleString(const char* name, IRFunc* entryPoint, IRStringLit* val); |
