diff options
| author | Yong He <yonghe@outlook.com> | 2025-01-10 10:57:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 10:57:04 -0800 |
| commit | 5290c580632cfb56847b863a32dc020a21d1c93e (patch) | |
| tree | 4c543f28d13f62a1dc3293b76151dda7585743ab /source/slang/slang-emit-c-like.cpp | |
| parent | 4cfae806a6f9c0203ce44c4ce04df5ad66cdc8a2 (diff) | |
Initial implementation of SP#015 `DescriptorHandle<T>`. (#6028)
* Initial implementation of `ResourcePtr<T>`.
* Update docs
* Fix build error.
* Add more discussion.
* Update documentation.
* Update TOC.
* Fix.
* Fix.
* Add test case for custom `getResourceFromBindlessHandle`.
* Add namehint to generated descriptor heap param.
* Fix.
* Fix.
* format code
* Rename to `DescriptorHandle`, and add `T.Handle` alias.
* Fix compiler error.
* Fix.
* Fix build.
* Renames.
* Fix documentation.
* Documentation fix.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index b63b9118e..7b51495e2 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -391,6 +391,23 @@ void CLikeSourceEmitter::_emitType(IRType* type, DeclaratorInfo* declarator) _emitType(rateQualifiedType->getValueType(), declarator); } break; + case kIROp_DescriptorHandleType: + { + // If the T is already bindless for target, emit it directly. + auto resPtrType = cast<IRDescriptorHandleType>(type); + if (isResourceTypeBindless(resPtrType->getResourceType())) + _emitType(resPtrType->getResourceType(), declarator); + else + { + // Otherwise, emit the DescriptorHandle<T> as uint2. + IRBuilder builder(resPtrType); + builder.setInsertBefore(resPtrType); + emitSimpleTypeAndDeclarator( + builder.getVectorType(builder.getUIntType(), 2), + declarator); + } + } + break; case kIROp_ArrayType: { @@ -2568,7 +2585,11 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO emitOperand(inst->getOperand(1), rightSide(outerPrec, prec)); break; } - + case kIROp_CastDescriptorHandleToUInt2: + case kIROp_CastUInt2ToDescriptorHandle: + case kIROp_CastDescriptorHandleToResource: + emitOperand(inst->getOperand(0), outerPrec); + break; // Binary ops case kIROp_Add: case kIROp_Sub: |
