From 3638e7735be67c8f4dae3f4544134441aa1e029d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 21 Apr 2022 13:47:18 -0400 Subject: `export` support in HLSL (#2188) * #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments. * Fix multiple adding of PublicDecoration. Make public output export for DXIL/lib. Add checking for simpleDecorations such that only added once. * Use 'whole program' to identify library build. * Add -target dxil so test infrastructure knows it needs DXC. --- source/slang/slang-ir.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 09a28e394..b53c247c3 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -23,8 +23,36 @@ namespace Slang sb << nameHint->getName(); } - // !!!!!!!!!!!!!!!!!!!!!!!!!!!! DiagnosticSink Impls !!!!!!!!!!!!!!!!!!!!! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + + bool isSimpleDecoration(IROp op) + { + switch (op) + { + case kIROp_EarlyDepthStencilDecoration: return true; + case kIROp_GloballyCoherentDecoration: return true; + case kIROp_KeepAliveDecoration: return true; + case kIROp_LineAdjInputPrimitiveTypeDecoration: return true; + case kIROp_LineInputPrimitiveTypeDecoration: return true; + case kIROp_NoInlineDecoration: return true; + case kIROp_PointInputPrimitiveTypeDecoration: return true; + case kIROp_PreciseDecoration: return true; + case kIROp_PublicDecoration: return true; + case kIROp_ReadNoneDecoration: return true; + case kIROp_RequiresNVAPIDecoration: return true; + case kIROp_TriangleAdjInputPrimitiveTypeDecoration: return true; + case kIROp_TriangleInputPrimitiveTypeDecoration: return true; + case kIROp_UnsafeForceInlineEarlyDecoration: return true; + case kIROp_VulkanCallablePayloadDecoration: return true; + case kIROp_VulkanHitAttributesDecoration: return true; + case kIROp_VulkanRayPayloadDecoration: return true; + default: break; + } + return false; + } + IRInst* cloneGlobalValueWithLinkage( IRSpecContext* context, IRInst* originalVal, @@ -4172,6 +4200,16 @@ namespace Slang IRDecoration* IRBuilder::addDecoration(IRInst* value, IROp op, IRInst* const* operands, Int operandCount) { + // If it's a simple (ie stateless) decoration, don't add it again. + if (operandCount == 0 && isSimpleDecoration(op)) + { + auto decoration = value->findDecorationImpl(op); + if (decoration) + { + return decoration; + } + } + auto decoration = createInstWithTrailingArgs( this, op, -- cgit v1.2.3