diff options
| author | Yong He <yonghe@outlook.com> | 2021-06-11 12:49:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-11 12:49:04 -0700 |
| commit | 746ee0dc5bddeea177aaf609bcc5085b46c4057c (patch) | |
| tree | 699e24ca1c1d6889afed9c6e0b1418d637603df9 | |
| parent | 37e8917d10626b519470f2e34625f0efe741352f (diff) | |
Properly fill `declref` in `Linkage::getContainerType`. (#1882)
* Properly fill `declref` in `Linkage::getContainerType`.
* Fix timestamp query on cpu
* Fix typo.
Co-authored-by: Yong He <yhe@nvidia.com>
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 23 | ||||
| -rw-r--r-- | source/slang/slang-ast-builder.h | 2 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 10 | ||||
| -rw-r--r-- | tools/gfx/cpu/render-cpu.cpp | 2 |
4 files changed, 34 insertions, 3 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 240b39d6c..4948a68a6 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -257,6 +257,29 @@ VectorExpressionType* ASTBuilder::getVectorType( return as<VectorExpressionType>(DeclRefType::create(this, declRef)); } +DeclRef<Decl> ASTBuilder::getBuiltinDeclRef(const char* builtinMagicTypeName, ConstArrayView<Val*> genericArgs) +{ + DeclRef<Decl> declRef; + declRef.decl = m_sharedASTBuilder->findMagicDecl(builtinMagicTypeName); + if (auto genericDecl = as<GenericDecl>(declRef.decl)) + { + if (genericArgs.getCount()) + { + auto substitutions = create<GenericSubstitution>(); + substitutions->genericDecl = genericDecl; + for (auto arg : genericArgs) + substitutions->args.add(arg); + declRef.substitutions = substitutions; + } + declRef.decl = genericDecl->inner; + } + else + { + SLANG_ASSERT(genericArgs.getCount() == 0); + } + return declRef; +} + Type* ASTBuilder::getAndType(Type* left, Type* right) { auto type = create<AndType>(); diff --git a/source/slang/slang-ast-builder.h b/source/slang/slang-ast-builder.h index 702b02e0a..2838230bd 100644 --- a/source/slang/slang-ast-builder.h +++ b/source/slang/slang-ast-builder.h @@ -153,6 +153,8 @@ public: VectorExpressionType* getVectorType(Type* elementType, IntVal* elementCount); + DeclRef<Decl> getBuiltinDeclRef(const char* builtinMagicTypeName, ConstArrayView<Val*> genericArgs); + Type* getAndType(Type* left, Type* right); TypeType* getTypeType(Type* type); diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index f8af39fcb..eed172bbf 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -939,6 +939,8 @@ SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL Linkage::getContainerType( { ConstantBufferType* cbType = getASTBuilder()->create<ConstantBufferType>(); cbType->elementType = type; + cbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "ConstantBuffer", makeConstArrayView<Val*>(static_cast<Val*>(type))); containerTypeReflection = cbType; } break; @@ -946,6 +948,8 @@ SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL Linkage::getContainerType( { ParameterBlockType* pbType = getASTBuilder()->create<ParameterBlockType>(); pbType->elementType = type; + pbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "ParameterBlock", makeConstArrayView<Val*>(static_cast<Val*>(type))); containerTypeReflection = pbType; } break; @@ -954,14 +958,14 @@ SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL Linkage::getContainerType( HLSLStructuredBufferType* sbType = getASTBuilder()->create<HLSLStructuredBufferType>(); sbType->elementType = type; + sbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "HLSLStructuredBufferType", makeConstArrayView<Val*>(static_cast<Val*>(type))); containerTypeReflection = sbType; } break; case slang::ContainerType::UnsizedArray: { - ArrayExpressionType* arrType = getASTBuilder()->create<ArrayExpressionType>(); - arrType->baseType = type; - arrType->arrayLength = nullptr; + ArrayExpressionType* arrType = getASTBuilder()->getArrayType(type, nullptr); containerTypeReflection = arrType; } break; diff --git a/tools/gfx/cpu/render-cpu.cpp b/tools/gfx/cpu/render-cpu.cpp index ac8b612fb..f635cf727 100644 --- a/tools/gfx/cpu/render-cpu.cpp +++ b/tools/gfx/cpu/render-cpu.cpp @@ -1132,6 +1132,7 @@ public: static const float kIdentity[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; ::memcpy(m_info.identityProjectionMatrix, kIdentity, sizeof(kIdentity)); m_info.adapterName = "CPU"; + m_info.timestampFrequency = 1000000000; } return SLANG_OK; @@ -1259,6 +1260,7 @@ public: const IQueryPool::Desc& desc, IQueryPool** outPool) override { RefPtr<CPUQueryPool> pool = new CPUQueryPool(); + pool->init(desc); returnComPtr(outPool, pool); return SLANG_OK; } |
