| Summary: | Metal renderer produces black screen when calling SDL_RenderPresent after changing render target | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Pennie Quinn <pennie.ada.quinn> |
| Component: | render | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | pennie.ada.quinn, ssrobins |
| Version: | 2.0.10 | Keywords: | target-2.0.14 |
| Hardware: | x86_64 | ||
| OS: | macOS 10.15 | ||
|
Description
Pennie Quinn
2020-03-02 02:59:55 UTC
Ryan, this sounds like a regression, can you look at this for 2.0.12 release? Sounds similar to what I hit on Android: https://bugzilla.libsdl.org/show_bug.cgi?id=5077
METAL_SetRenderTarget commits data.mtlcmdbuffer to the GPU and then sets it to nil.
METAL_RenderPresent tries to add a presentDrawable command to the now-nil command buffer, and commit it, which are safe no-ops in Objective-C, so the framebuffer never gets presented in this scenario.
This code is probably also wrong if you try to present without setting the render target back to NULL first, but I'm not sure what SDL is meant to do in that case.
I _think_ if you just stick this line:
METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil);
Before this in METAL_RenderPresent:
if (data.mtlcmdencoder != nil) {
It'll fix the first issue (but not the second I mentioned).
I'll try this on a mac later, but if you get there before me, let me know if it works, please!
--ryan.
I tried this, it definitely fixes the issue, so this fix is now https://hg.libsdl.org/SDL/rev/f3aaa73bf221 ! |