From cd7da79f50f2b8fb9bca797131585ff1b85698f6 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:14:05 -0700 Subject: Fix incorrect binding index assignment for StructuredBuffer and ByteAddressBuffer with DescriptorHandle (#8252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [x] Fix segmentation fault in wrapConstantBufferElement for DescriptorHandle types - [x] Split DescriptorKind.Buffer into ConstantBuffer and StorageBuffer - [x] Update binding enums with descriptive names (ConstantBuffer_Read, StorageBuffer_Read, etc.) - [x] Update resource type mappings for correct binding assignments - [x] Update template logic to handle ConstantBuffer and StorageBuffer kinds separately - [x] Update tests to reflect correct binding assignments - [x] Split DescriptorKind.TexelBuffer into UniformTexelBuffer and StorageTexelBuffer - [x] Update TextureBuffer to use UniformTexelBuffer kind - [x] Update _Texture extension to determine texel buffer kind based on access mode - [x] Update test desc-handle-1.slang to handle new DescriptorKind enum cases --- ✨ Let Copilot coding agent [set things up for you](https://github.com/shader-slang/slang/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: Yong He --- source/slang/slang-check-decl.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 77a799f1c..6f2b01aa1 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -8992,6 +8992,7 @@ void SemanticsDeclBodyVisitor::visitEnumDecl(EnumDecl* decl) tryConstantFoldExpr(explicitTagValExpr, ConstantFoldingKind::CompileTime, nullptr); if (explicitTagVal) { + caseDecl->tagVal = explicitTagVal; if (auto constIntVal = as(explicitTagVal)) { defaultTag = constIntVal->getValue(); @@ -9005,8 +9006,10 @@ void SemanticsDeclBodyVisitor::visitEnumDecl(EnumDecl* decl) else { // If this happens, then the explicit tag value expression - // doesn't seem to be a constant after all. In this case - // we expect the checking logic to have applied already. + // doesn't seem to be a constant after all. + getSink()->diagnose( + explicitTagValExpr, + Diagnostics::expectedIntegerConstantNotConstant); } } else @@ -9017,8 +9020,8 @@ void SemanticsDeclBodyVisitor::visitEnumDecl(EnumDecl* decl) tagValExpr->loc = caseDecl->loc; tagValExpr->type = QualType(tagType); tagValExpr->value = defaultTag; - caseDecl->tagExpr = tagValExpr; + caseDecl->tagVal = m_astBuilder->getIntVal(enumType, defaultTag); } // Default tag for the next case will be one more than @@ -9058,15 +9061,9 @@ void SemanticsDeclBodyVisitor::visitEnumCaseDecl(EnumCaseDecl* decl) if (auto initExpr = decl->tagExpr) { initExpr = CheckTerm(initExpr); - initExpr = coerce(CoercionSite::General, tagType, initExpr, getSink()); - // We want to enforce that this is an integer constant - // expression. - decl->tagVal = CheckIntegerConstantExpression( - initExpr, - IntegerConstantExpressionCoercionType::AnyInteger, - nullptr, - ConstantFoldingKind::CompileTime); + if (initExpr->type != decl->type.type) + initExpr = coerce(CoercionSite::General, tagType, initExpr, getSink()); decl->tagExpr = initExpr; } -- cgit v1.2.3