Skip to content

Conversation

@mardy
Copy link
Collaborator

@mardy mardy commented Dec 10, 2024

crack-attack performance went down a lot when we introduced support for clipping, since that's an extra TEV stage and it involves some matrix multiplications. On the other hand, we don't have to setup the TEV stages if no parameters affecting it have been changed.

This MR fixes a couple of regressions, cleans up the fogging setup and adds a "dirty bit" to decide when the TEV stages must be rebuilt.

To be merged after #88

mardy added 8 commits December 8, 2024 21:05
GX matrices are 3x4, and the old code was overflowing: wee need to skip
the fourth row of the matrix.

Fixes one issue from devkitPro#87
It was using the Mtx44 matrix, which is row-major, whereas glMultMatrix
expects a column-major matrix.
This causes FIFO errors, since we told GX that we are sending two
coordinates, but effectively send three. So we need to ensure that we
never send more than two texture coordinates.
Add an "as_int" member that allows comparing the structure as a whole.
Move the setup_fog() sunction out of the _ogx_setup_render_stages()
function and into _ogx_apply_state(), since by render stages we mean all
waht is related with the TEV stages.

Add a dirty bit to signal when the fogging configuration has changed and
needs to be setup again.
Add a dirty flag to track whether the TEV stages must be rebuilt. The
replaces the dirty_lighting, dirty_clip_planes, dirty_stencil and the
(de facto unused) dirty_material flags, because all these factors
ultimately require the TEV to be rebuilt.

This is not super-precide, and we err on the side of rendering safety,
but it still brings a huge speed up in the crack-attack game, which uses
call lists with several draw commands in each (so the state is
guaranteed to be clean between one command and the next).
This is not a terribly heavy operation, but since it's not hard to
optimize it out, let's do it.
@WinterMute WinterMute merged commit 2e11efd into devkitPro:master Dec 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants