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: Fix scissorOffset, handle negative value correctly #9660

Merged
merged 1 commit into from Apr 24, 2021

Conversation

ezio1900
Copy link
Contributor

@ezio1900 ezio1900 commented Apr 21, 2021

VideoCommon: Fix scissorOffset, handle negative value correctly
VideoBackends: Fix Software Clipper.PerspectiveDivide function, use bpmem.scissorOffset instead of hard code 342

Origin pull request: #9656
Can some one help me to reopen #9656, I found a way to reset the commits.

@ezio1900
Copy link
Contributor Author

This PR fix a bug about BPMemory.scissorOffset.
The scissor offset register should be 10bit signed [-512, 511].
(e.g. In Super Mario Galaxy 1 and 2, during the Boss roar effect, the scissor offset register will be set to -61, so the scissor offset is -464).
Also fix Clipper.PerspectiveDivide function in Software renderer, using bpmem.scissorOffset instead of hard code 342.

This RP fix the bug: Super Mario Galaxy 1/2 - Roar shockwave does not display, reported here: Issues #8327. And should fix any other similar bug.

Before fix:
broken1

broken2

RMGE01_2021-04-19_17-19-37_1

After fix:
fixed1

fixed2

RMGE01_2021-04-19_17-16-55

Reference:
NS Super Mario 3D All Stars: Video

Copy link
Contributor

@Pokechu22 Pokechu22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, git rebase origin/master and git push --force-with-lease are an easier way to handle updating your changes. But these changes (as a copy of #9656 without the broken merge) are fine.

@ezio1900
Copy link
Contributor Author

I'm not familiar with git, I try to Squash Commits, but just broke the PR.

@Pokechu22
Copy link
Contributor

Can some one help me to reopen #9656, I found a way to reset the commits.

You should be able to just click the reopen button at the bottom (in the same place as the close button was).

@ezio1900
Copy link
Contributor Author

The reopen button is dimmed, I guess I don't have permission to reopen it.
Buy the way, any suggestion about the comments in the commits is welcome.

Comment on lines 42 to 62
/* NOTE: the minimum value here for the scissor rect and offset is -342.
* GX internally adds on an offset of 342 to both the offset and scissor
* coords to ensure that the register was always unsigned.
/* NOTE: the minimum value here for the scissor rect is -342.
* GX internally adds on an offset of 342 to scissor coords to
* ensure that the register was always unsigned.
*
* The code that was here before tried to "undo" this offset, but
* since we always take the difference, the +342 added to both
* sides cancels out. */

/* The scissor offset is always even, so to save space, the scissor offset
/* NOTE: With positive scissor offset the scissor rectangle is shifted left and/or up;
* and with negative scissor offset, the scissor rectangle is shifted right and/or down.
*
* GX internally also adds on an offset of 342 to scissor offset.
* The scissor offset is always even, so to save space, the scissor offset
* register is scaled down by 2. So, if somebody calls
* GX_SetScissorBoxOffset(20, 20); the registers will be set to 10, 10. */
const int xoff = bpmem.scissorOffset.x * 2;
const int yoff = bpmem.scissorOffset.y * 2;
* GX_SetScissorBoxOffset(20, 20); the registers will be set to (10 + 171, 10 + 171).
*
* The scissor offset register is 10bit signed [-512, 511].
* (e.g. In Super Mario Galaxy 1 and 2, during the Boss roar effect,
* the scissor offset register will be set to -61, so the scissor offset is -464)
*/
Copy link
Contributor Author

@ezio1900 ezio1900 Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion about this comments is welcome, so we can make it more clear.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"With positive scissor offset" should be "With a positive scissor offset" (and there should be a comma after offset on both lines).

It might be worth clarifying that "GX internally also adds on an offset of 342 to scissor offset." means "The GX SDK functions internally add an offset of 342".

It would also be useful to elaborate on the math, e.g. "the scissor offset register will be set to -61, so the scissor offset is (-61)*2 - 342 = -122 - 342 = -464", or maybe it makes more sense in the opposite direction: "for a scissor offset of -464, the scissor offset register will be set to (-464 + 342)/2 = -122/2 = -61".

@PatrickFerry
Copy link
Contributor

There's no need to reopen the last one since this one is opened now.

Just as a FYI for the future it is better to make a new branch based on master and make commits there rather than making them directly on master in your fork.

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. Please squash your commits.

VideoCommon: Change the type of BPMemory.scissorOffset to 10bit signed: S32X10Y10
VideoBackends: Fix Software Clipper.PerspectiveDivide function, use BPMemory.scissorOffset instead of hard code 342
@Pokechu22
Copy link
Contributor

Pokechu22 commented Apr 24, 2021

Can you also rebase off of origin/master? #9321 has been merged, so updating would allow fifoci to compare for Rogue Squadron 2 as well. (We've decided to merge it anyways; fifo.ci will run on the merged version afterwards)

@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • luigi-shadows on sw-lin-mesa: diff
  • mmx-light on sw-lin-mesa: diff
  • monkeyball-fuse on sw-lin-mesa: diff
  • smb-mirror on sw-lin-mesa: diff
  • thps3-earlyz on sw-lin-mesa: diff

automated-fifoci-reporter

Copy link
Contributor

@JMC47 JMC47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash and it is good to go.

@JMC47
Copy link
Contributor

JMC47 commented Apr 24, 2021

Just noticed it was squashed.

@JMC47 JMC47 merged commit 18e8436 into dolphin-emu:master Apr 24, 2021
@Pokechu22
Copy link
Contributor

Final FifoCI results: https://fifo.ci/version/18e84361d925af09586b940b265f10e501e889d6/

There were 9 changes on sw-lin-mesa (those listed above, and also 4 of them for RS2): luigi-shadows mmx-light monkeyball-fuse rs2-bumpmapping rs2-glass rs2-skybox rs2-zfreeze smb-mirror thps3-earlyz.

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