Skip to content

Introduce integer vertex attributes#21146

Merged
PunkPun merged 5 commits intoOpenRA:bleedfrom
pchote:vertex-attributes
Oct 23, 2023
Merged

Introduce integer vertex attributes#21146
PunkPun merged 5 commits intoOpenRA:bleedfrom
pchote:vertex-attributes

Conversation

@pchote
Copy link
Copy Markdown
Member

@pchote pchote commented Oct 22, 2023

With GL 2.1 out of the picture, we are finally able to use integers and bitwise operations in shaders. This PR replaces the legacy workaround simulating a bitfield with a float to a real bitfield. This allows us to use the full 32 bits of storage, which I use to pack the palette row (as a 16 bit int) to shave 4 bytes off the vertex size.

I expect this should give a minor performance boost, but the focus is on shader readability and maintability.

@pchote
Copy link
Copy Markdown
Member Author

pchote commented Oct 22, 2023

A future PR could make additional, more invasive, optimisations to reduce the vertex size further: Replace the two (float x, float y) texture coordinates with a single (uint xy) coordinate (saves 8 bytes). The color renderer could then use the first integer to encode the colour (it currently needs all 4 floats), which would allow mods that don't need the second sprite channel to save an additional 4 bytes.

@pchote pchote force-pushed the vertex-attributes branch from 1dc4b42 to fd728c0 Compare October 23, 2023 07:56
@pchote
Copy link
Copy Markdown
Member Author

pchote commented Oct 23, 2023

Added some additional improvements.

Copy link
Copy Markdown
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

this PR is running ra shellmap at 3FPS, where as on bleed I'm getting 200+

Comment thread glsl/postprocess_flash.frag Outdated
@pchote
Copy link
Copy Markdown
Member Author

pchote commented Oct 23, 2023

RA shellmap is ~340 FPS for me, compared to ~340 FPS on bleed. Can you have a poke around and try to identify what is causing your perf regression?

@pchote pchote force-pushed the vertex-attributes branch from c210b88 to a1fbd7e Compare October 23, 2023 13:36
@PunkPun
Copy link
Copy Markdown
Member

PunkPun commented Oct 23, 2023

It seems to be caused by the first commit

within the render loop
Screenshot 2023-10-23 at 16 40 30

@dnqbob
Copy link
Copy Markdown
Contributor

dnqbob commented Oct 23, 2023

@PunkPun

Windowed or full screen?

@pchote pchote force-pushed the vertex-attributes branch from a1fbd7e to 9cf8fd7 Compare October 23, 2023 16:40
@pchote
Copy link
Copy Markdown
Member Author

pchote commented Oct 23, 2023

@PunkPun can you please try again on the updated version?

Comment thread OpenRA.Platforms.Default/Shader.cs Outdated
@pchote pchote force-pushed the vertex-attributes branch from 9cf8fd7 to ae7e6bc Compare October 23, 2023 17:58
@pchote pchote force-pushed the vertex-attributes branch from ae7e6bc to 19f625d Compare October 23, 2023 18:08
Copy link
Copy Markdown
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM, this is a massive performance and shader readability improvement

@PunkPun PunkPun merged commit 3bb4252 into OpenRA:bleed Oct 23, 2023
@PunkPun
Copy link
Copy Markdown
Member

PunkPun commented Oct 23, 2023

Changelog

@pchote pchote deleted the vertex-attributes branch October 29, 2023 10:36
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