Skip to content

igl | metal | MTLRenderCommandEncoder::draw() fix the missed instanceCount on versions below iOS 16.#252

Closed
vinsentli wants to merge 11 commits into
facebook:mainfrom
vinsentli:patch-4
Closed

igl | metal | MTLRenderCommandEncoder::draw() fix the missed instanceCount on versions below iOS 16.#252
vinsentli wants to merge 11 commits into
facebook:mainfrom
vinsentli:patch-4

Conversation

@vinsentli

@vinsentli vinsentli commented Mar 18, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@EricGriffith

Copy link
Copy Markdown
Contributor

I'm a little worried about this one. I think we chose iOS 16 because it's a guarantee that all devices on that iOS version would actually support it. The proper fix for detecting whether it is actually supported or not is to handle this via DeviceFeatures.

@vinsentli vinsentli changed the title igl | metal | MTLRenderCommandEncoder::drawInstance() is available from iOS 9.0. Mar 25, 2025
@vinsentli

Copy link
Copy Markdown
Contributor Author

Strictly speaking, there are also some issues with the else branch. The instanceCount parameter is lost, although Metal actually supports it.

@corporateshark corporateshark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new changes do no address what @EricGriffith mentioned about the version 9 and igl::DeviceFeatures.

@vinsentli

Copy link
Copy Markdown
Contributor Author

@corporateshark
From Apple's documentation and SDK, the information I obtained is:

MTLRenderCommandEncoder::draw:instancecount: is available from iOS 8.0.
MTLRenderCommandEncoder::draw:instancecount:baseInstance: is available from iOS 9.0.

@EricGriffith Have you encountered any devices running between iOS 9 and iOS 16 (exclusive) that don't support baseInstance?

https://developer.apple.com/documentation/metal/mtlrendercommandencoder/drawindexedprimitives(type:indexcount:indextype:indexbuffer:indexbufferoffset:instancecount:basevertex:baseinstance:)?language=objc

Clipboard_Screenshot_1742882788 Clipboard_Screenshot_1742882890
@EricGriffith

Copy link
Copy Markdown
Contributor

@vinsentli I don't recall the specifics of why we set it up this way. It's been over a year. However, the consequences for us getting this wrong are pretty severe. We need to make sure we're properly checking MTLDevice features.

@vinsentli

Copy link
Copy Markdown
Contributor Author

@vinsentli I don't recall the specifics of why we set it up this way. It's been over a year. However, the consequences for us getting this wrong are pretty severe. We need to make sure we're properly checking MTLDevice features.

@EricGriffith

Clipboard_Screenshot_1743996357

We tested on iOS 12.5 devices and found that this API is not supported, which causes crashes. Are you encountering the same issue? As a result, I've reverted the changes related to the @available version and only kept the fix for the missing instanceCount issue on versions below iOS 16.

@vinsentli vinsentli changed the title igl | metal | MTLRenderCommandEncoder::draw:baseInstance: is available from iOS 9.0. Apr 7, 2025
@vinsentli vinsentli requested a review from corporateshark April 7, 2025 03:30
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread src/igl/metal/RenderCommandEncoder.mm Outdated
Comment thread src/igl/metal/RenderCommandEncoder.mm Outdated
Comment thread src/igl/metal/RenderCommandEncoder.mm Outdated
@vinsentli vinsentli requested a review from corporateshark April 7, 2025 07:42
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment thread src/igl/metal/RenderCommandEncoder.mm
@vinsentli vinsentli requested a review from corporateshark April 8, 2025 07:46
Comment thread src/igl/metal/RenderCommandEncoder.mm
@vinsentli vinsentli requested a review from corporateshark April 8, 2025 08:58
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@corporateshark merged this pull request in dded52c.

@vinsentli vinsentli deleted the patch-4 branch April 18, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants