@@ -348,6 +348,13 @@ void WGSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
348
348
}
349
349
break ;
350
350
351
+ case kIROp_HLSLByteAddressBufferType :
352
+ case kIROp_HLSLRWByteAddressBufferType :
353
+ {
354
+ m_writer->emit (" array<u32>" );
355
+ }
356
+ break ;
357
+
351
358
case kIROp_VoidType :
352
359
{
353
360
// There is no void type in WGSL.
@@ -590,13 +597,15 @@ void WGSLSourceEmitter::emitVarKeywordImpl(IRType * type, IRInst* varDecl)
590
597
m_writer->emit (" <workgroup>" );
591
598
}
592
599
else if (type->getOp () == kIROp_HLSLRWStructuredBufferType ||
593
- type->getOp () == kIROp_HLSLRasterizerOrderedStructuredBufferType )
600
+ type->getOp () == kIROp_HLSLRasterizerOrderedStructuredBufferType ||
601
+ type->getOp () == kIROp_HLSLRWByteAddressBufferType )
594
602
{
595
603
m_writer->emit (" <" );
596
604
m_writer->emit (" storage, read_write" );
597
605
m_writer->emit (" >" );
598
606
}
599
- else if (type->getOp () == kIROp_HLSLStructuredBufferType )
607
+ else if (type->getOp () == kIROp_HLSLStructuredBufferType ||
608
+ type->getOp () == kIROp_HLSLByteAddressBufferType )
600
609
{
601
610
m_writer->emit (" <" );
602
611
m_writer->emit (" storage, read" );
@@ -1178,6 +1187,33 @@ bool WGSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
1178
1187
}
1179
1188
}
1180
1189
break ;
1190
+
1191
+ case kIROp_ByteAddressBufferLoad :
1192
+ {
1193
+ // Indices in Slang code count bytes, but in WASM they count u32's since
1194
+ // byte address buffers translate to array<u32> in WASM, so divide by 4.
1195
+ emitOperand (inst->getOperand (0 ), getInfo (EmitOp::General));
1196
+ m_writer->emit (" [(" );
1197
+ emitOperand (inst->getOperand (1 ), getInfo (EmitOp::General));
1198
+ m_writer->emit (" )/4]" );
1199
+ return true ;
1200
+ }
1201
+ break ;
1202
+
1203
+ case kIROp_ByteAddressBufferStore :
1204
+ {
1205
+ // Indices in Slang code count bytes, but in WASM they count u32's since
1206
+ // byte address buffers translate to array<u32> in WASM, so divide by 4.
1207
+ auto base = inst->getOperand (0 );
1208
+ emitOperand (base, EmitOpInfo ());
1209
+ m_writer->emit (" [(" );
1210
+ emitOperand (inst->getOperand (1 ), getInfo (EmitOp::General));
1211
+ m_writer->emit (" )/4] = " );
1212
+ emitOperand (inst->getOperand (inst->getOperandCount () - 1 ), getInfo (EmitOp::General));
1213
+ return true ;
1214
+ }
1215
+ break ;
1216
+
1181
1217
}
1182
1218
1183
1219
return false ;
0 commit comments