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

[SM64/F3D] Use WriteDifferingAndRevert for bleed #461

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Lilaa3
Copy link
Collaborator

@Lilaa3 Lilaa3 commented Sep 15, 2024

Write all logic remains unaffected, obviously.

A new dict was added to map each mode cmd to its default.
For the actual bleed part, we fIrst need to add geo mode reverts of the last material to the geo mode of the current material, since the current material may not set them now. For othermodes we do something different, get all reverts and add any that doesn´t get set again by the current material ignoring bleeding.
For the geo mode revert, we keep track of one geo mode command for set and clear, updating it as we go. For othermodes we keep track of all of the command types and then revert them using the new dict.

Diff example: Lilaa3/HackerSM64@c9d217e

@Lilaa3 Lilaa3 marked this pull request as draft September 15, 2024 15:06
@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Sep 15, 2024

Noticed something othermode is doing sigh back to vs code I go

@Lilaa3 Lilaa3 marked this pull request as ready for review September 15, 2024 16:09
Write all logic remains unaffected, obviously.

A new dict was added to map each mode cmd to its default.
For the actual bleed part, we fIrst need to add geo mode reverts of the last material to the geo mode of the current material, since the current material may not set them now. For othermodes we do something different, get all reverts and add any that doesn´t get set again by the current material ignoring bleeding.
For the geo mode revert, we keep track of one geo mode command for set and clear, updating it as we go. For othermodes we keep track of all of the command types and then revert them using the new dict.
@Lilaa3 Lilaa3 force-pushed the write-differing-in-bleed branch from ba73388 to 8ef2b02 Compare September 15, 2024 18:00
Copy link
Contributor

@Reonu Reonu left a comment

Choose a reason for hiding this comment

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

This fixed my issues with point lights, thank you

@Lilaa3
Copy link
Collaborator Author

Lilaa3 commented Sep 16, 2024

I feel like I could improve this further in terms of how resets are handled, will look into it later today, functionality shouldn't change tho unless I find a bug

@Lilaa3 Lilaa3 marked this pull request as draft September 17, 2024 16:09
We cannot just assume that othermodeh or othermodel are always setting the same bits, so instead we write the diff of the current cmd to the one already in the reset dict, this means that if a materials sets rendermode and another sets alpha compare (for example) it will still revert the rendermode because those bits will be carried over in the reset dict
@Lilaa3 Lilaa3 marked this pull request as ready for review September 18, 2024 11:06
Lilaa3 added a commit to Lilaa3/fast64 that referenced this pull request Oct 1, 2024
Fixes lag at start up from draw layers being set unnecessarily.
Some clean up that I already did in Fast-64#461
Fixes lag at start up from draw layers being set unnecessarily.
Some clean up that I already did in Fast-64#461
Lilaa3 added a commit that referenced this pull request Oct 14, 2024
* [Repo Settings] Only set if different

Fixes lag at start up from draw layers being set unnecessarily.
Some clean up that I already did in #461

* Request Changes

Co-Authored-By: Dragorn421 <[email protected]>

---------

Co-authored-by: Dragorn421 <[email protected]>
@jesusyoshi54 jesusyoshi54 added sm64 Has to do with the Super Mario 64 side f3d Has to do with the "f3d" code common to all games labels Jan 9, 2025
Copy link
Collaborator

@jesusyoshi54 jesusyoshi54 left a comment

Choose a reason for hiding this comment

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

Export using bleed, image differs from expected output.
image
Export without bleed, image matches expectation
image

For reference, I've taken a look at one pair of the offending display lists (the bottom two pictured in the test grid): https://hastebin.com/share/fokuqototo.markdown
You can see that without bleed, I am setting the render mode and othermode settings, and reverting them each time. With bleed, the othermode settings are bled as expected, but so is the render mode

as far as the middle test mats, I am not exactly sure where they went wrong, but they definitely are not right.

# handle write diff, save pre bleed cmds
is_rendermode_cmd = lambda cmd: isinstance(cmd, DPSetRenderMode) or (
isinstance(cmd, SPSetOtherMode) and cmd.sets_rendermode
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't use lambda for a named function, make this a def.

for j, cmd in enumerate(gfx.commands):
if self.bleed_individual_cmd(commands_bled, cmd, bleed_state, last_cmd_list):
commands_bled.commands[j] = None
# remove Nones from list
while None in commands_bled.commands:
commands_bled.commands.remove(None)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not exactly sure what, but something funky is going on here. I inspected some display lists exported using bleed and they were not properly setting the render modes.
the test in question was to have two materials that are the same, but with different geo/render modes. the geo modes were properly set to match the material, but the render modes were not. In fact the render mode setting for the second material was completely missing

@jesusyoshi54
Copy link
Collaborator

jesusyoshi54 commented Jan 19, 2025

actually let me add that something extra extra wrong is going on with the material logic.
this is the test export on main
w/ bleed:
image
without bleed:
image

@jesusyoshi54
Copy link
Collaborator

jesusyoshi54 commented Jan 19, 2025

The exporter is giving the wrong render mode, please compare:
gsDPSetRenderMode(GBL_c1(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1MA) | GBL_c2(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | FORCE_BL),
to settings:
image

cycle 2, A value is being written as fog, when it is not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f3d Has to do with the "f3d" code common to all games sm64 Has to do with the Super Mario 64 side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants