-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix(metal): clear only bound textures #3310
base: master
Are you sure you want to change the base?
fix(metal): clear only bound textures #3310
Conversation
Yes, it should be valid to pass
It would be actually great if you could create small repro (for example by modifying 13-stencil). |
Thx, I currently don't have enough time but I'll try to do it in a week or two. |
`clearQuad()` can be operating on framebuffers that don't have all the color/depth/stencil buffers attached. For example, if there is no stencil buffer in the framebuffer, the Metal driver asserts with: ``` validateDepthStencilState: failed assertion `MTLDepthStencilDescriptor uses frontFaceStencil but MTLRenderPassDescriptor has a nil stencilAttachment texture' ``` Copy the logic from `setFrameBuffer()` to check which buffers we can clear. Using this info set the pipeline state that is valid for currently bound buffers.
f4018da
to
628d98c
Compare
I updated the code with a force push because it didn't compile. The original code was copied from some older commit, I guess I didn't try it on the branch I was making a PR for :( I managed to reproduce the issue on example
To force the example into calling into The example produces:
The depth texture is not bound/attached. The PR fixes the issue for each attachment separately (color, depth and stencil). Removing the |
clearQuad()
can be operating on framebuffers that don't have all the color/depth/stencil buffers attached.For example, if there is no stencil buffer in the framebuffer, the Metal driver asserts with:
Copy the logic from
setFrameBuffer()
to check which buffers we can clear. Using this info set the pipeline state that is valid for currently bound buffers.The issue appeared when we created a render texture with no stencil. When trying to clear the render texture it crashed with the above message (the clear flags included
BGFX_CLEAR_STENCIL
).The crash does not happen when the code path inside
RendererContextMtl::submit()
sets theclearWithRenderPass
variable and the clearing happens elsewhere.Is it invalid to set
BGFX_CLEAR_STENCIL
clear flag when there is no stencil bound? On other platforms it seems to work. In our engine we normally always set both depth and stencil clear since we don't always have the info what is bound. If it is invalid to sendBGFX_CLEAR_STENCIL
if there is no stencil, please ignore this PR.I don't have a simple repro example but if needed I can try creating one.