diff options
| author | Yong He <yonghe@outlook.com> | 2024-05-16 10:43:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-16 10:43:49 -0700 |
| commit | 725735a87b9d223c2afc83bbd049055b1e44a976 (patch) | |
| tree | 225f381774fb9b5209007ae7fc455a14f57a6fe6 /source/slang/slang-emit-metal.cpp | |
| parent | 0a6180299352d7a2ec850004564c7a95b37a41c4 (diff) | |
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>
Diffstat (limited to 'source/slang/slang-emit-metal.cpp')
| -rw-r--r-- | source/slang/slang-emit-metal.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
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<uint32_t>("); + m_writer->emit(")>>2] = as_type<uint32_t>("); 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<IRTextureTypeBase>(type)) + { + if (textureType->getAccess() == SLANG_RESOURCE_ACCESS_RASTER_ORDERED) + { + m_writer->emit(" [[raster_order_group(0)]]"); + } + } + else if (as<IRHLSLRasterizerOrderedByteAddressBufferType>(type) || + as<IRHLSLRasterizerOrderedStructuredBufferType>(type)) + { + m_writer->emit(" [[raster_order_group(0)]]"); + } +} + static UnownedStringSlice _getInterpolationModifierText(IRInterpolationMode mode) { switch (mode) |
