From 5290c580632cfb56847b863a32dc020a21d1c93e Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 10 Jan 2025 10:57:04 -0800 Subject: Initial implementation of SP#015 `DescriptorHandle`. (#6028) * Initial implementation of `ResourcePtr`. * 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> --- source/slang/slang-emit-c-like.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-emit-c-like.cpp') 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(type); + if (isResourceTypeBindless(resPtrType->getResourceType())) + _emitType(resPtrType->getResourceType(), declarator); + else + { + // Otherwise, emit the DescriptorHandle 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: -- cgit v1.2.3