Add IndexBuffer and update SpriteRenderer and TerrainSpriteLayer to use it - #21019
Merged
Conversation
PunkPun
force-pushed
the
terrain
branch
2 times, most recently
from
August 24, 2023 14:05
bccb903 to
3f628ab
Compare
pchote
reviewed
Aug 24, 2023
PunkPun
force-pushed
the
terrain
branch
4 times, most recently
from
August 24, 2023 17:34
9dfe3b9 to
2e25b8e
Compare
RoosterDragon
suggested changes
Aug 24, 2023
PunkPun
force-pushed
the
terrain
branch
3 times, most recently
from
August 28, 2023 09:02
eff48ab to
033b94f
Compare
Member
Author
|
Added an |
anvilvapre
reviewed
Aug 28, 2023
RoosterDragon
suggested changes
Aug 29, 2023
PunkPun
force-pushed
the
terrain
branch
2 times, most recently
from
September 1, 2023 11:29
dda0a03 to
392a40b
Compare
RoosterDragon
suggested changes
Sep 1, 2023
RoosterDragon
approved these changes
Sep 1, 2023
pchote
reviewed
Sep 1, 2023
Mailaender
approved these changes
Sep 23, 2023
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Its standard practice to use IndexBuffers in all rendering API's, not just in OpenGL. The documentation shows that the new method of rendering
glDrawElementsexists 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
TerrainSpriteLayerspecific case it also significantly reduces the amount of calculations on the CPU sideI had observed the FPS timer on the RA shellmap, on bleed saw
~202, on this PR~226FPSI also checked out the TS shell map bleed:
~186PR:~202