Skip to content

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

Merged
Mailaender merged 6 commits into
OpenRA:bleedfrom
PunkPun:terrain
Sep 23, 2023
Merged

Add IndexBuffer and update SpriteRenderer and TerrainSpriteLayer to use it#21019
Mailaender merged 6 commits into
OpenRA:bleedfrom
PunkPun:terrain

Conversation

@PunkPun

@PunkPun PunkPun commented Aug 24, 2023

Copy link
Copy Markdown
Member

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
Comment thread OpenRA.Game/Map/Map.cs Outdated
Comment thread OpenRA.Game/Graphics/Util.cs
Comment thread OpenRA.Platforms.Default/ThreadedGraphicsContext.cs Outdated
@PunkPun
PunkPun force-pushed the terrain branch 4 times, most recently from 9dfe3b9 to 2e25b8e Compare August 24, 2023 17:34
Comment thread OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated
Comment thread OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated
Comment thread OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated
Comment thread OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated
Comment thread OpenRA.Game/Graphics/TerrainSpriteLayer.cs Outdated
@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

PunkPun commented Aug 28, 2023

Copy link
Copy Markdown
Member Author

Added an IndexBuffer to SpriteRenderer as well

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

Copy link
Copy Markdown
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.

5 participants