KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.76k stars 419 forks source link

Issues with native atomics #2172

Closed js6i closed 7 months ago

js6i commented 7 months ago

The only Metal pixel formats that support MTLTextureUsageShaderAtomic are R32Int, R32UInt and RG32UInt. Currently other textures can be assigned that usage, causing an assertion. That's fallout from #2164.

First case is buffer views. We should only add atomic usage to the supported formats. VK_EXT_shader_atomic_float needs to be handled in some other way - maybe we could just use the old emulated path. However, we don't know the format when setting up the layout, which maybe is a problem in some cases..

Second is images which support integer views, but the base pixel format does not support atomics. My initial idea was to make the base Metal texture be integer instead, and return views on that, which seems to work, but I'm a bit worried about it breaking something, and we could instead try just not setting MTLTextureUsageShaderAtomic - that's wrong by the docs, but in my testing, Metal does not seem to sound any alarms.

This issue was initially reported here.

@billhollings @cdavis5e