floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.63k stars 472 forks source link

sg_make_image crash when Xcode Metal API Validation enabled #905

Closed cai502 closed 10 months ago

cai502 commented 10 months ago

Crash occurs on macbook pro 19 only when Xcode Metal API Validation enabled.

But macbook pro 21(with M1 Chip) is ok.

Pasted image 20230919163456

cai502 commented 10 months ago

info added for macbook pro 19

  1. Xcode Version: 14.3
  2. macOS: Ventura 13.3.1(a)
floooh commented 10 months ago

Hmm, ok. That code is relatively recent, looks like I ignored this little tidbit that StorageModeShared textures are not allowed on Intel GPUs:

https://developer.apple.com/documentation/metal/mtlstoragemode/mtlstoragemodeshared#discussion

Since it looks like that by default Metal does the right thing, I will just remove the explicit storage mode selection again.

Thanks for the bug report!

floooh commented 10 months ago

PS: for a quick workaround you can set the sg_desc.mtl_force_managed_storage_mode option to true in the sg_setup() call, but I'll try to provide a proper fix asap.

floooh commented 10 months ago

PPS: after dusting off my old Intel Mac with Big Sur and Xcode 12 I actually have a couple of more problems (sokol_gfx.h doesn't build because some declarations from more recents SDKs aren't properly conditionally compiled.

I'll see if I can get this stuff to work later today.

floooh commented 10 months ago

Ok, this should be fixed in https://github.com/floooh/sokol/pull/907, basically Intel Macs now use managed storage mode for all resource types (that's the same as it worked before I tried to be clever). On Apple GPUs (and generally on iOS) shared resource storage mode is used.

I'll merge this in a couple of hours.

cai502 commented 10 months ago

Cool, thanks very much!

floooh commented 10 months ago

PS: I tested this on my mid-2014 13" MBP with Big Sur and Xcode 12, my M1 MBP, and the iOS simulator.