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

Render to tex improvements #70

Merged
merged 6 commits into from
Apr 22, 2024

Commits on Apr 19, 2024

  1. ogc: reduces number of copies from EFB to texture

    Instead of copying at the end of every command queue flush, copy the EFB
    to the texture only when the texture stops being a render target.
    
    Unfortunately SDL invokes the SetRenderTarget() method after having
    updated the render target pointer, forcing us to keep our own copy of
    it.
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    5d6a35c View commit details
    Browse the repository at this point in the history
  2. ogc: avoid copying to XFB when clearing with a render target

    If we are rendering to a texture, we must avoid writing to the XFB,
    because the image we are rendering might not be intended to be shown
    as-is on the XFB.
    So, when clearing the display, pay attention to whether we are rendering
    to a texture and, in that case, do not copy the EFB to the XFB. Instead,
    copy it to the texture itself (not that we care a lot about this copy,
    since the texture will anyway be overwitten once it stops being a render
    target; but we do care about this operation causing a full clearing of
    the EFB).
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    a21ac5b View commit details
    Browse the repository at this point in the history
  3. ogc: flush the FIFO after executing the command queue

    It can happens that the client program immediately calls
    SDL_DestroyTexture() after draawing it. Luckily for us, SDL is smart
    enough to realize that the texture has been used in a draw operation and
    issues a SDL_RenderFlush() so that all the operations get executed. But
    this means that on our side, we must also make sure that when we return
    from OGC_RunCommandQueue() the texture data is no longer needed. The
    call to GX_DrawDone() does exactly this.
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    5b08f93 View commit details
    Browse the repository at this point in the history
  4. ogc: save and restore EFB when rendering to a texture starts and stops

    Indeed, the situation where a rendering to texture operation begins
    after the EFB has already been painted can happen. In order not to lose
    the existing EFB contents, make a copy of them into a texture (using the
    same size of the render-to-texture target) and then restore them by
    redrawing the saved texture over the EFB, once the render-to-texture
    operation has completed.
    
    Note that it's important that any calls to GX_SetPixelFmt() happen in
    the appropriate order:
    
    1. Save the current EFB contents
    2. Change the EFB format (by calling GX_SetPixelFmt())
    3. Perform all the render-to-texture drawing operations
    4. Save the EFB into the target texture
    5. Restore the EFB format
    6. Restore the EFB contents by drawing the texture saved in step 1
    
    Swapping the 5th and 6th steps does not cause any visible issues in
    Dolphin, but causes the EFB to be painted back with wrong colors on a
    real Wii.
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    c1115ad View commit details
    Browse the repository at this point in the history
  5. ogc: invalidate current texture contents before copying the EFB onto it

    This is needed to avoid visual artifacts on the saved texture.
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    63cb49e View commit details
    Browse the repository at this point in the history
  6. ogc: call GX_PixModeSync() after copying the EFB to a texture

    The documentation says that this is needed, though in practice I haven't
    yet seen any issue with not using it.
    mardy committed Apr 19, 2024
    Configuration menu
    Copy the full SHA
    47e30ca View commit details
    Browse the repository at this point in the history