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

VideoCommon: Account for pixel quads in bounding box calculation #9736

Merged
merged 2 commits into from May 22, 2021

Conversation

Techjar
Copy link
Contributor

@Techjar Techjar commented May 22, 2021

The GC/Wii GPU rasterizes in 2x2 pixel groups, so bounding box values will be rounded to the extents of these groups, rather than the exact pixel. To account for this, we'll round the top/left down to even and the bottom/right up to odd. I have verified that the values resulting from this change exactly match a real Wii.

I would have implemented this in the pixel shaders, but the NVIDIA driver seems to be outsmarting me and optimizes out all my attempts to perform these operations in there, as it works on Vulkan but not OpenGL.

I used this modified homebrew to perform the hardware test: https://qimg.techjargaming.com/f/vRk5NA28/triangle.elf
Source code (ignore the mess, I've used it for a number of tests): https://gist.github.com/Techjar/4f38aa7807d0f5334011ef14ec721219
The values it outputs are as follows:

@Techjar Techjar changed the title Account for pixel quads in bbox calculations VideoBackends: Account for pixel quads in bounding box calculation May 22, 2021
@Techjar Techjar marked this pull request as ready for review May 22, 2021 02:40
…tion variants

This will allow for some aspects of bounding box to be handled in
VideoCommon instead of individual backends.
@Techjar Techjar changed the title VideoBackends: Account for pixel quads in bounding box calculation VideoCommon: Account for pixel quads in bounding box calculation May 22, 2021
@BhaaLseN
Copy link
Member

I would have implemented this in the pixel shaders, but the NVIDIA driver seems to be outsmarting me and optimizes out all my attempts to perform these operations in there, as it works on Vulkan but not OpenGL.

I wonder if this is something that should be left as comment next to the implementation of BBoxRead (just to make it more visible)

The GC/Wii GPU rasterizes in 2x2 pixel groups, so bounding box values
will be rounded to the extents of these groups, rather than the exact
pixel. To account for this, we'll round the top/left down to even and
the bottom/right up to odd. I have verified that the values resulting
from this change exactly match a real Wii.
@JMC47
Copy link
Contributor

JMC47 commented May 22, 2021

This fixes a crash in Ultimate Spider-Man during missions with lots of smoke, notably the Rhino mission in https://bugs.dolphin-emu.org/issues/12516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants