Skip to content

Conversation

@mariovisic
Copy link
Contributor

To improve rendering performance of textures we now store the texture vertices
in the same VBO buffer that we use for regular shape drawing.

We do have an added loop through all of the verticesTextureIds, values,
though the benchmark for pixel rendering is still showing the same 52fps as
before. So it seems like there's not a big impact there.

One thing to note is that we're now duplicating our vertices for textures as
we're not defining our own indices (textured objects have 6 vertices now,
rather than 4), rather using the default for GL_TRIANGLES. This is convenient
as we can use the same GLDrawArrays call for both triangles and textures.

I did experiement with using glDrawElementsInstancedBaseVertex for rendering
our textured objects to see if it would increase performance, but I couldn't
get it to render properly and performance seemed unchanged, so there doesn't
seem to big a big performance penalty of allocating the extra vertices.

I've added a benchmark for rendering tilesets, on the main branch I'm getting
16fps, with this patch the performance is now at 28fps, so 75% more frames per
second compared to before.

Lastly fix a bug where tilesets would throw an exception when rendering due to
a missing z value.

mariovisic and others added 2 commits August 16, 2021 20:27
To improve rendering performance of textures we now store the texture vertices
in the same VBO buffer that we use for regular shape drawing.

We do have an added loop through all of the `verticesTextureIds`, values,
though the benchmark for pixel rendering is still showing the same 52fps as
before. So it seems like there's not a big impact there.

One thing to note is that we're now duplicating our vertices for textures as
we're not defining our own indices (textured objects have 6 vertices now,
rather than 4), rather using the default for GL_TRIANGLES. This is convenient
as we can use the same `GLDrawArrays` call for both triangles and textures.

I did experiement with using `glDrawElementsInstancedBaseVertex` for rendering
our textured objects to see if it would increase performance, but I couldn't
get it to render properly and performance seemed unchanged, so there doesn't
seem to big a big performance penalty of allocating the extra vertices.

I've added a benchmark for rendering tilesets, on the main branch I'm getting
16fps, with this patch the performance is now at 28fps, so 75% more frames per
second compared to before.

Lastly fix a bug where tilesets would throw an exception when rendering due to
a missing z value.
@mariovisic
Copy link
Contributor Author

Thanks for the warning fix @blacktm 🥳

@mariovisic mariovisic merged commit e0e1c73 into ruby2d:main Aug 16, 2021
@mariovisic mariovisic deleted the texture_render_perf branch August 16, 2021 22:54
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.

2 participants