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

Some material system fixes and cleanup #1416

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

VReaperV
Copy link
Contributor

@VReaperV VReaperV commented Nov 4, 2024

Fixes a material system crash where the first dynamic surface shader has a non-0 padding.
Fixes incorrect drawSurf index being returned by R_AddDrawSurf().

Made u_DepthMap and u_PortalMap into global uniforms, and cleaned up some of the material system code.


// Make sure padding is taken into account for dynamicDrawSurfsOffset
if ( !dynamicDrawSurfOffsetSet ) {
dynamicDrawSurfsOffset = offset;
Copy link
Member

Choose a reason for hiding this comment

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

So this variable needs to point to the end of the first material? That seems weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To the start of the first dynamic material, rather. Since the buffer is structured like this:

staticMaterial_0
...
staticMaterial_last
padding
dynamicMaterial_0
...

Padding after material n depends on the material n + 1, and is added at the offset += padding; line (last dynamic material never has any padding after it). dynamicDrawSurfsOffset is then used as the start of the range when mapping the buffer to update it, so it has to point to the index directly after the last static material padding.

@slipher
Copy link
Member

slipher commented Nov 7, 2024

LGTM

@VReaperV VReaperV merged commit e8c4c1a into DaemonEngine:master Nov 7, 2024
9 checks passed
@VReaperV VReaperV deleted the material-misc branch November 7, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants