From 4d286aab2ec23c081f23846f5dfdb30b1c05728b Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:59:49 -0600 Subject: Metal fix (#6413) Partially fix #6378 * Fix invalid access mode for texture_buffer * Fix texture view create issue in metal In newTextureView, levelRange should represent the mipmap level range, while sliceRange should represent the texture layer range for texture array. But the implement inverse those two wrongly. --- source/slang/slang-emit-metal.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/slang/slang-emit-metal.cpp b/source/slang/slang-emit-metal.cpp index 166f02535..0a7db8b28 100644 --- a/source/slang/slang-emit-metal.cpp +++ b/source/slang/slang-emit-metal.cpp @@ -136,8 +136,15 @@ void MetalSourceEmitter::_emitHLSLTextureType(IRTextureTypeBase* texType) switch (texType->getAccess()) { case SLANG_RESOURCE_ACCESS_READ: - m_writer->emit("access::sample"); - break; + { + // Metal does not support access::sample for texture buffers, so we need to emit + // access::read instead. + if (texType->GetBaseShape() == SLANG_TEXTURE_BUFFER) + m_writer->emit("access::read"); + else + m_writer->emit("access::sample"); + break; + } case SLANG_RESOURCE_ACCESS_WRITE: m_writer->emit("access::write"); -- cgit v1.2.3