Closed tycho closed 7 months ago
It looks like MoltenVK is trying to create a linear texture in anticipation of using image atomics with it, even though on macOS 14 that should no longer be necessary. (Are you on macOS 14?)
I should've taken a look at that change...
Yep, currently on 14.2.1.
Also not sure what leads it to think it needs atomics, that seems like an exceptional situation (e.g. image load/store in shaders?)
If you create an image with format R32_UINT
or R32_SINT
, and you set VK_IMAGE_USAGE_STORAGE
, then MoltenVK will create it as a linear texture, because there's no specific usage bit for image atomics. It's part of a hack that Epic Games implemented in SPIRV-Cross, which I then hooked up to MoltenVK, to use atomics on a buffer passed alongside the image. (This was, of course, pre-macOS-14, before Metal finally got support for texture atomics.) But it's only supposed to do this now prior to macOS 14. And regardless, it's only supposed to do this for images with one mip level and one array layer. Your image has six mip levels, so the condition to create a linear Metal texture shouldn't have been met.
@js6i Tag!
I would've directly assigned this issue to you, but I noticed @billhollings's invitation too late, so I no longer have admin privs here.
Another case of mismatched requirements, as I was trying to debug this issue in my game demo build:
-[_MTLDevice minimumLinearTextureAlignmentForPixelFormat:]:4870: failed assertion `Linear textures do not support depth/stencil pixel formats'
This is a VK_FORMAT_D32_SFLOAT
image, but _isLinearForAtomics
is true
for some reason.
I got used to things being initialised by default, and apparently got "lucky" when testing. Sorry!
Thanks @js6i, that change does seem to be sufficient to fix it for my use cases.
@js6i sorry this might be unrelated, but I'm getting this error after #2164:
[MTLTextureDescriptorInternal validateWithDevice:]:1357: failed assertion `Texture Descriptor Validation
MTLPixelFormatR8Unorm is not a valid format to be used with texture atomics.
@js6i sorry this might be unrelated, but I'm getting this error after #2164:
[MTLTextureDescriptorInternal validateWithDevice:]:1357: failed assertion `Texture Descriptor Validation MTLPixelFormatR8Unorm is not a valid format to be used with texture atomics.
2169 doesn't help unfortunately.
I'm aware of that issue (it't the one I mentioned in the PR) and I'm working on a fix.
Ah I see, thanks!
I would've directly assigned this issue to you, but I noticed @billhollings's invitation too late, so I no longer have admin privs here.
@cdavis5e Invite happily resent! I don't know why we lost you in the first place! 😉
PR #2169 fixes the initial issue posted above.
The additional texture format Metal validation issue above has been moved to issue #2172.
This is on an Apple M1 system.
Since yesterday's merge at revision b56c152a1245a95e7d4e8d64baca8ae42e85ae6a (
Merge pull request #2164 from js6i/native-atomics
), texture creation has been crashing in my game. If I build my game with MoltenVK revision 37361ccd5595ff08c050981856903713f96221d2 then the problem goes away.When running the application directly, I get:
When running with Xcode (and Metal API validation enabled), the error message changes a bit:
The callstack of the crash:
The game uses ANGLE's Vulkan backend with MoltenVK for rendering. It's trying to create a swizzled 256x256 GL_RG8 texture with 6 mip levels.
Here's a demo game build with symbols if that helps: https://www.uplinklabs.net/files/Darwinia-macOS-demo-2.3.2-1108-g98f6e5d4a.zip