-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable unsupported Metal Pixel formats for iOS/tvOS Simulator #2361
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A version check is only necessary for when earlier versions don't have the pixel format enumerator in the SDK but later versions do. That doesn't apply here, since all of those pixel formats have been supported since iOS 8. AFAIK, those formats have never been supported under the simulator, even on Apple Silicon for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this! And thanks everyone for all the discussion on #2353!
First of all, I'm sorry that my 5afeaa4 triggered the need for this!
Based upon the "I recall reading somewhere" comment by @cdavis5e in #2353, I went hunting, and sure enough, hidden away in the Apple docs, is the explanation.
Unfortunately, that doc also make this somewhat more complicated.
These 5 formats you identified MTLPixelFormats
, plus all of the XR10 and YUV formats, are not supported on the simulator platforms.
So, @SRSaunders, can you add the following to this PR, please and thanks?
- Add all the XR10 and YUV formats to your conditional format remapping.
- Add
&& !MVK_OS_SIMULATOR
to the#if MVK_APPLE_SILICON
for the XR10 formats inMVKPhysicalDevice::getSurfaceFormats()
. - According to the same doc, the format
MTLPixelFormatRGB9E5Float
cannot be used as a render target on the simulator. I think the best way to deal with this is inMVKPixelFormats::modifyMTLFormatCapabilities()
. Perhaps add the following, right below the other two mods there forRGB9E5Float
:
disableMTLPixFmtCapsIf( MVK_OS_SIMULATOR, RGB9E5Float, ColorAtt );
- And finally, none of the
_sRGB
formats can be written to in the simulator. I think the best way to handle this might be in#define addMTLPixelFormatDescSRGB()
, by adding something like:
if(MVK_APPLE_SILICON) { mvkDisableFlags(appleGPUCaps, kMVKMTLFmtCapsWrite); }
Uggh! Needless to say, I'm not a fan of the simulator! 😉
Looking at the Apple docs, they do not mention These changes run correctly for my limited test cases (Vulkan-Samples project running on iOS Simulator on x86_64 host, macOS Ventura, Xcode 15.2). However, I cannot test all of the new changes here. This PR could benefit from additional code review at a minimum. Question: Given release timing, does this mean the Simulator will be broken for MVK 1.2.11, Vulkan SDK 1.3.296? If so that's an unfortunate regression, and at minimum should be highlighted in the release notes. Lastly, I have another Simulator issue outstanding - see #2285. When running the Vulkan-Samples on the Simulator, starting with MoltenVK 1.2.11, certain samples do not render (black screen) unless I disable Metal Argument Buffers. What is the status of Argument Buffers on the Simulator? Should they be disabled by default on the Simulator, or is there another defect lingering somewhere else that causes this behaviour? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM now.
Bummer about all the changes required to the define macros, but that's the nature of macros.
I'll just wait for @cdavis5e to have a look before pulling this in.
Now that the SDK release is done, I'll have another closer look at #2285. I really, REALLY don't want to have to disable arg buffers for any platform, so that will be an absolute last resort. Moving forward, arg buffers are important for a lot of Vulkan functionality, starting with the availability of larger numbers of bindless descriptors. |
Agreed the macro changes are kind of ugly. If you see a better solution please feel free to modify.
That's fine. The issue identified some Vulkan-Samples problems and a potential solution in the form of Arg Buffer disabling on the Simulator. But first I wanted to determine your overall intentions re Arg Buffers and the Simulator. I have my answer now, and will look at #2285 as a possible defect. Thanks. |
A small change to move unsupported pixel formats to top level to ensure visionOS Simulator is covered too, not just iOS and tvOS Simulators. Docs indicate these pixel format restrictions apply to all Simulators. |
Not sure if you care, but looking around in the code where In MVKDevice.mm:
and
|
Yes. Makes sense to deal with them here. Thanks for taking a wider inventory. I assume you're thinking of setting the non-simulator value (eg. |
Yes, exactly. In fact there is already a However, I do notice two things: a) |
Good catch on visionOS is only partially supported on MoltenVK. It really requires someone with an Apple Vision device to overhaul it. For now, you can leave it until that gets done in a separate PR in the future. |
Are you able to make this change on this PR, or should we leave it for another PR? I'm just waiting on this before pulling this PR in. |
Sorry for the delay, but I have been trying to test Vulkan-Samples on tvOS Simulator to see if we have things right. I have now pushed this change, and also added one more difference that I see for AppleGPUFamily cases that are <= Apple3: The Vulkan-Samples tests run mostly ok on tvOS Simulator, with the exception of samples hpp_oit_linked_lists and oit_linked_lists. On those I get the following:
This happens in:
Unfortunately I don't have time to research now as I will be away for a bit. Otherwise I would try to track this down. I think this is the relevant SPIRV and MSL: [mvk-info] Compiling Metal shader with FastMath enabled. End SPIR-V Converted MSL: #include <metal_stdlib> using namespace metal; struct FragmentCounter struct SceneConstants struct FragmentBuffer struct main0_in fragment void main0(main0_in in [[stage_in]], constant SceneConstants& sceneConstants [[buffer(8)]], device FragmentBuffer& fragmentBuffer [[buffer(10)]], device FragmentCounter& fragmentCounter [[buffer(11)]], texture2d<uint, access::read_write> linkedListHeadTex [[texture(0)]], float4 gl_FragCoord [[position]]) End MSL |
Okay. Thanks. I'm going to pull this in now to get the basics working, and we can explore the the simulator issues you mentioned separately. |
Defines certain unsupported Metal Pixel formats as invalid for the iOS/tvOS Simulator. Fixes #2353 for MoltenVK 1.2.11.
I have tested this on an x86_64 host using Xcode 15.2 with the iOS Simulator (running iOS 17.2). I can't test on tvOS so I would appreciate others (@warmenhoven) checking out this scenario.
Also, I am not sure whether the
#ifdef
condition should also contain an Xcode version test. Perhaps @cdavis5e could weigh in on that aspect. Thanks.