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

Add IndexBuffer and update SpriteRenderer and TerrainSpriteLayer to use it #21019

Merged
merged 6 commits into from Sep 23, 2023

Conversation

PunkPun
Copy link
Member

@PunkPun PunkPun commented Aug 24, 2023

Its standard practice to use IndexBuffers in all rendering API's, not just in OpenGL. The documentation shows that the new method of rendering glDrawElements exists in OpenGL 1.1. (fyi this is considered the earliest proper OpenGL version)

Why index buffers are important? To draw a rectangle we need 2 triangles, to draw each triangle we need 3 vertices. Meaning we need 6 vertices for a square, but when we think of a square it's really just drawn from 4 points. 2 of the 6 vertices are just holding duplicated data, and do mind that a single vertex holds quite a lot of data

The solution are IndexBuffers, they allow you to reuse vertices or change their order. By using them we reduce the RAM usage on Both the GPU and CPU, as well as data they need to pass around. In TerrainSpriteLayer specific case it also significantly reduces the amount of calculations on the CPU side

I had observed the FPS timer on the RA shellmap, on bleed saw ~202, on this PR ~226 FPS
I also checked out the TS shell map bleed: ~186 PR: ~202

@PunkPun PunkPun force-pushed the terrain branch 2 times, most recently from bccb903 to 3f628ab Compare August 24, 2023 14:05
OpenRA.Game/Map/Map.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the terrain branch 4 times, most recently from 9dfe3b9 to 2e25b8e Compare August 24, 2023 17:34
OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated Show resolved Hide resolved
OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated Show resolved Hide resolved
OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated Show resolved Hide resolved
OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the terrain branch 3 times, most recently from eff48ab to 033b94f Compare August 28, 2023 09:02
@PunkPun PunkPun changed the title Add IndexBuffer and update TerrainSpriteLayer to use it Add IndexBuffer and update SpriteRenderer and TerrainSpriteLayer to use it Aug 28, 2023
@PunkPun
Copy link
Member Author

PunkPun commented Aug 28, 2023

Added an IndexBuffer to SpriteRenderer as well

OpenRA.Platforms.Default/StaticQuadIndexBuffer.cs Outdated Show resolved Hide resolved
OpenRA.Game/Graphics/SpriteRenderer.cs Outdated Show resolved Hide resolved
@PunkPun PunkPun force-pushed the terrain branch 2 times, most recently from dda0a03 to 392a40b Compare September 1, 2023 11:29
OpenRA.Game/Renderer.cs Outdated Show resolved Hide resolved
@Mailaender Mailaender merged commit 3e6123f into OpenRA:bleed Sep 23, 2023
3 checks passed
@Mailaender
Copy link
Member

Changelog

@PunkPun PunkPun deleted the terrain branch September 23, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants