Skip to content

Commit d7a0760

Browse files
alsepkowCopilot
andcommitted
Fix min precision store widening: scope to ByteAddressBuffer only
The store widening for min precision types was applying to both RawBufferStore (scalar) and RawBufferVectorStore (vector). This broke StructuredBuffer stores (struct_buf3.hlsl) because it replaced the correct sext/zext from TranslateMinPrecisionRawBuffer with a blanket sext, losing signedness info for min16uint. Scope the RawBufferStore widening to RawBuffer (ByteAddressBuffer) only. StructuredBuffer scalar stores are correctly handled by the later TranslateMinPrecisionRawBuffer pass in DxilGenerationPass, which has signedness info from struct type annotations. ByteAddressBuffer scalar stores still need widening here because the later pass crashes on non-struct resource types (cast<StructType> on ByteAddressBuffer's i32 inner element). Co-authored-by: Copilot <[email protected]>
1 parent 81a1f81 commit d7a0760

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/HLSL/HLOperationLower.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,8 +4603,14 @@ void TranslateStore(DxilResource::Kind RK, Value *handle, Value *val,
46034603
}
46044604

46054605
// Min precision alloc size is 32-bit; widen to match store intrinsic.
4606-
if (opcode == OP::OpCode::RawBufferStore ||
4607-
opcode == OP::OpCode::RawBufferVectorStore) {
4606+
// StructuredBuffer scalar stores are handled by
4607+
// TranslateMinPrecisionRawBuffer in DxilGenerationPass, which has signedness
4608+
// info from struct annotations. ByteAddressBuffer (RawBuffer) scalar stores
4609+
// must be widened here because that later pass crashes on non-struct resource
4610+
// types (cast<StructType> fail).
4611+
if (opcode == OP::OpCode::RawBufferVectorStore ||
4612+
(opcode == OP::OpCode::RawBufferStore &&
4613+
RK == DxilResource::Kind::RawBuffer)) {
46084614
const DataLayout &DL =
46094615
OP->GetModule()->GetHLModule().GetModule()->getDataLayout();
46104616
Type *WideTy = widenMinPrecisionType(Ty, Builder.getContext(), DL);

0 commit comments

Comments
 (0)