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

Improve glsl shader performance #211

Merged
merged 9 commits into from
Nov 8, 2024
Merged

Improve glsl shader performance #211

merged 9 commits into from
Nov 8, 2024

Conversation

uis246
Copy link
Collaborator

@uis246 uis246 commented Oct 11, 2024

Most optimizations are done by abusing mathematical properties and replacing slow on some hardware(e.g. Inetl) min and max with saturation.
For example dot product is in range [-1, 1], so max(0, dot(...)) = sat(dot(...)).
In places where this potentially can mess with HDR comments were added.

@uis246
Copy link
Collaborator Author

uis246 commented Oct 11, 2024

Riiight, forgot to rebase.

@uis246
Copy link
Collaborator Author

uis246 commented Oct 11, 2024

There is room for improvement, for example texture matrix, but it will require changing rendering code, so it will not be here for sake of simplicity.

Copy link
Contributor

@divVerent divVerent left a comment

Choose a reason for hiding this comment

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

Seems good; someone else please test run this before merging though.

@hemebond
Copy link
Contributor

Seems good; someone else please test run this before merging though.

I've tested it with Quake. I didn't notice any problems. @uis246 if there's any in particular that might be affected please let me know.

@uis246
Copy link
Collaborator Author

uis246 commented Oct 29, 2024

I've used only properties of linear algebra(like elements of normalized vector are always in range of [-1, 1]), basic arithmetics, shuffling between registers, using proper built-ins instead of hacks and assumption of samples being in range of [0, 1]. Seems to be it.

@uis246
Copy link
Collaborator Author

uis246 commented Nov 3, 2024

So there should be no existing game being affected

Copy link
Contributor

@divVerent divVerent left a comment

Choose a reason for hiding this comment

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

Looked through it once more - if it's not horribly breaking as is, it's good to merge.

@divVerent divVerent merged commit 6803afa into master Nov 8, 2024
1 of 2 checks passed
@uis246 uis246 deleted the uis/shader branch November 13, 2024 01:23
@uis246 uis246 restored the uis/shader branch November 13, 2024 01:31
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.

3 participants