Skip to content
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

_sg_mtl_begin_pass: explicit store action for depth and stencil attachments (MTLStoreActionStore) #815

Closed

Conversation

allcreater
Copy link
Contributor

Sometimes two passes with different color attachments must share a depth or/and stencil buffers.

The default Metal action is "don't care" so that the buffers could be invalidated (and it happens on some iOS versions)

I suggest setting the default action to "store" to provide support of such passes.

@floooh
Copy link
Owner

floooh commented Apr 3, 2023

This topic is coming up from time to time, and I think a better solution is to change the public API to better align with Metal and WebGPU, e.g. have separate load and store actions, e.g. see #563

@floooh floooh closed this Apr 3, 2023
@allcreater
Copy link
Contributor Author

allcreater commented Apr 3, 2023

I completely agree that it's much better to set pass store actions directly (and will be glad to implement it for #563 a bit later, if you don't mind :) ) but right now the behavior is different for OpenGL and Metal, it seems like a bug, is the behavior of such passes undefined in the current API version?

@floooh
Copy link
Owner

floooh commented Apr 3, 2023

Yeah, you're right, change of plans :)

I would prefer however, if only offscreen render passes would need to store the depth/stencil buffer result. (e.g. only the first half of your PR, would this work for your case)?

(PS: argh hit 'Send' too early)

PPS: I wrote another ticket for how to revamp this whole area: #816

@floooh floooh reopened this Apr 3, 2023
@allcreater allcreater force-pushed the mtl_depth_stencil_storeaction branch from 33886ea to 66cac7b Compare April 3, 2023 14:19
…hments (MTLStoreActionStore) (non-default pass only)
@allcreater allcreater force-pushed the mtl_depth_stencil_storeaction branch from 66cac7b to 7a07260 Compare April 3, 2023 14:20
@allcreater
Copy link
Contributor Author

@floooh I guess the first half is perfectly fine, especially if two calls of default pass is undefined behavior :)

Thank you for your attention :)

floooh added a commit that referenced this pull request Apr 3, 2023
Excplicitly sets MTLStoreActionStore on offscreen depth/stencil
surfaces, not great from perspective point of view, but addresses
#815.

Also see #816 for a proper
cleanup proposal.
@floooh
Copy link
Owner

floooh commented Apr 3, 2023

I have committed your fix for offscreen render targets only here: e56c596

...oops, I messed up the commit message, should be "performance point of view" :D

As for the 'proper cleanup', I'll try to tackle this before coming back to finish the WebGPU backend (that's the next big thing on my list because it looks like WebGPu is now actually close to release).

@floooh floooh closed this Apr 3, 2023
@floooh
Copy link
Owner

floooh commented Apr 3, 2023

(ah sorry, I wasn't aware that you also fixed the PR)

@allcreater
Copy link
Contributor Author

@floooh It's OK, you already mentioned me a couple of times, and also I'll be glad to do anything else later :)

@allcreater allcreater deleted the mtl_depth_stencil_storeaction branch April 3, 2023 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants