From 746ee0dc5bddeea177aaf609bcc5085b46c4057c Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 11 Jun 2021 12:49:04 -0700 Subject: 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 --- source/slang/slang-ast-builder.cpp | 23 +++++++++++++++++++++++ source/slang/slang-ast-builder.h | 2 ++ source/slang/slang.cpp | 10 +++++++--- 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(DeclRefType::create(this, declRef)); } +DeclRef ASTBuilder::getBuiltinDeclRef(const char* builtinMagicTypeName, ConstArrayView genericArgs) +{ + DeclRef declRef; + declRef.decl = m_sharedASTBuilder->findMagicDecl(builtinMagicTypeName); + if (auto genericDecl = as(declRef.decl)) + { + if (genericArgs.getCount()) + { + auto substitutions = create(); + 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(); 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 getBuiltinDeclRef(const char* builtinMagicTypeName, ConstArrayView 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(); cbType->elementType = type; + cbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "ConstantBuffer", makeConstArrayView(static_cast(type))); containerTypeReflection = cbType; } break; @@ -946,6 +948,8 @@ SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL Linkage::getContainerType( { ParameterBlockType* pbType = getASTBuilder()->create(); pbType->elementType = type; + pbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "ParameterBlock", makeConstArrayView(static_cast(type))); containerTypeReflection = pbType; } break; @@ -954,14 +958,14 @@ SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL Linkage::getContainerType( HLSLStructuredBufferType* sbType = getASTBuilder()->create(); sbType->elementType = type; + sbType->declRef = getASTBuilder()->getBuiltinDeclRef( + "HLSLStructuredBufferType", makeConstArrayView(static_cast(type))); containerTypeReflection = sbType; } break; case slang::ContainerType::UnsizedArray: { - ArrayExpressionType* arrType = getASTBuilder()->create(); - 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 pool = new CPUQueryPool(); + pool->init(desc); returnComPtr(outPool, pool); return SLANG_OK; } -- cgit v1.2.3