From 43c146794aab638924d2ab838d10f8af2ebf02a7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 5 Jun 2020 18:20:09 -0400 Subject: ASTNodes use MemoryArena (#1376) * Add a ASTBuilder to a Module Only construct on valid ASTBuilder (was being called on nullptr on occassion) * Add nodes to ASTBuilder. * Compiles with RefPtr removed from AST node types. * Initialize all AST node pointer variables in headers to nullptr; * Initialize AST node variables as nullptr. Make ASTBuilder keep a ref on node types. Make SyntaxParseCallback returns a NodeBase * Don't release canonicalType on dtor (managed by ASTBuilder). * Give ASTBuilders a name and id, to help in debugging. For now destroy the session TypeCache, to stop it holding things released when the compile request destroys ASTBuilders. * Moved the TypeCheckingCache over to Linkage from Session. * NodeBase no longer derived from RefObject. * Only add/dtor nodes that need destruction. First pass compile on linux. --- source/slang/slang-parameter-binding.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/slang/slang-parameter-binding.cpp') diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 58ce76c45..ea45612ec 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -584,7 +584,7 @@ LayoutSemanticInfo ExtractLayoutSemanticInfo( // a particular sub-argument and extract its value if present. template static bool findLayoutArg( - RefPtr syntax, + ModifiableSyntaxNode* syntax, UInt* outVal) { for( auto modifier : syntax->getModifiersOfType() ) @@ -674,7 +674,7 @@ struct EntryPointParameterState static RefPtr processEntryPointVaryingParameter( ParameterBindingContext* context, - RefPtr type, + Type* type, EntryPointParameterState const& state, RefPtr varLayout); @@ -707,7 +707,7 @@ static void collectGlobalScopeParameter( auto varDeclRef = shaderParamInfo.paramDeclRef; // We apply any substitutions for global generic parameters here. - auto type = getType(astBuilder, varDeclRef)->substitute(astBuilder, globalGenericSubst).as(); + auto type = as(getType(astBuilder, varDeclRef)->substitute(astBuilder, globalGenericSubst)); // We use a single operation to both check whether the // variable represents a shader parameter, and to compute @@ -1014,8 +1014,10 @@ static void addExplicitParameterBindings_GLSL( } else if( (resInfo = typeLayout->FindResourceInfo(LayoutResourceKind::SpecializationConstant)) != nullptr ) { + DeclRef varDecl2(varDecl); + // Try to find `constant_id` binding - if(!findLayoutArg(varDecl, &semanticInfo.index)) + if(!findLayoutArg(varDecl2, &semanticInfo.index)) return; } @@ -1382,7 +1384,7 @@ SimpleSemanticInfo decomposeSimpleSemantic( static RefPtr processSimpleEntryPointParameter( ParameterBindingContext* context, - RefPtr type, + Type* type, EntryPointParameterState const& inState, RefPtr varLayout, int semanticSlotCount = 1) @@ -1546,7 +1548,7 @@ static RefPtr processSimpleEntryPointParameter( static RefPtr processEntryPointVaryingParameterDecl( ParameterBindingContext* context, Decl* decl, - RefPtr type, + Type* type, EntryPointParameterState const& inState, RefPtr varLayout) { @@ -1703,7 +1705,7 @@ static RefPtr processEntryPointVaryingParameterDecl( static RefPtr processEntryPointVaryingParameter( ParameterBindingContext* context, - RefPtr type, + Type* type, EntryPointParameterState const& state, RefPtr varLayout) { @@ -2712,7 +2714,7 @@ static void collectSpecializationParams( case SpecializationParam::Flavor::GenericValue: { RefPtr paramLayout = new GenericSpecializationParamLayout(); - paramLayout->decl = specializationParam.object.as(); + paramLayout->decl = as(specializationParam.object); context->shared->programLayout->specializationParams.add(paramLayout); } break; @@ -2721,7 +2723,7 @@ static void collectSpecializationParams( case SpecializationParam::Flavor::ExistentialValue: { RefPtr paramLayout = new ExistentialSpecializationParamLayout(); - paramLayout->type = specializationParam.object.as(); + paramLayout->type = as(specializationParam.object); context->shared->programLayout->specializationParams.add(paramLayout); } break; -- cgit v1.2.3