From 725735a87b9d223c2afc83bbd049055b1e44a976 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 May 2024 10:43:49 -0700 Subject: RasterizerOrder resource for spirv and metal. (#4175) * RasterizerOrder resource for spirv and metal. Also fixes the byte address buffer logic for metal. * Fix. * Delete commented lines. --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> --- source/slang/slang-emit-metal.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source/slang/slang-emit-metal.cpp') diff --git a/source/slang/slang-emit-metal.cpp b/source/slang/slang-emit-metal.cpp index ff497a20f..c6ffee953 100644 --- a/source/slang/slang-emit-metal.cpp +++ b/source/slang/slang-emit-metal.cpp @@ -349,7 +349,7 @@ bool MetalSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inO emitOperand(buffer, getInfo(EmitOp::General)); m_writer->emit("[("); emitOperand(offset, getInfo(EmitOp::General)); - m_writer->emit(")>>2)]"); + m_writer->emit(")>>2])"); return true; } case kIROp_ByteAddressBufferStore: @@ -361,7 +361,7 @@ bool MetalSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inO emitOperand(buffer, getInfo(EmitOp::General)); m_writer->emit("[("); emitOperand(offset, getInfo(EmitOp::General)); - m_writer->emit(")>>2)] = as_type("); + m_writer->emit(")>>2] = as_type("); emitOperand(inst->getOperand(2), getInfo(EmitOp::General)); m_writer->emit(")"); return true; @@ -433,17 +433,8 @@ void MetalSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerVa void MetalSourceEmitter::emitLoopControlDecorationImpl(IRLoopControlDecoration* decl) { - switch (decl->getMode()) - { - case kIRLoopControl_Unroll: - m_writer->emit("[unroll]\n"); - break; - case kIRLoopControl_Loop: - m_writer->emit("[loop]\n"); - break; - default: - break; - } + // Metal does not support loop control attributes. + SLANG_UNUSED(decl); } static bool _canEmitExport(const Profile& profile) @@ -866,6 +857,23 @@ void MetalSourceEmitter::emitSimpleFuncParamImpl(IRParam* param) emitFuncParamLayoutImpl(param); } +void MetalSourceEmitter::emitPostDeclarationAttributesForType(IRInst* type) +{ + Super::emitPostDeclarationAttributesForType(type); + if (auto textureType = as(type)) + { + if (textureType->getAccess() == SLANG_RESOURCE_ACCESS_RASTER_ORDERED) + { + m_writer->emit(" [[raster_order_group(0)]]"); + } + } + else if (as(type) || + as(type)) + { + m_writer->emit(" [[raster_order_group(0)]]"); + } +} + static UnownedStringSlice _getInterpolationModifierText(IRInterpolationMode mode) { switch (mode) -- cgit v1.2.3