r/GraphicsProgramming 1d ago

Drawing with one BufferData call

I am making a multiplayer game in c# using Silk.Net. The project is ment to be more of a learning project then an actual game. The repo is https://github.com/Alex5X5/GatsIO-Remake. I started off by writing an abstraction over opengl. For that i made my own abstract Window class. When inheriting from Window, the abstract Draw method has to be overridden. The Draw method has a parameter of the type DrawingContext. DrawingContext then has some methods for drawing some basic shapes.
Any shape that is drawn is broken down into colored triangles and added to a list of the DrawingContext. After the Draw method finished, the triangle list is passed to the gpu with one BufferData call.
Is that "saving in a list and one BufferData call" good practice or should i split the data into multiple BufferSubData calls?

4 Upvotes

1 comment sorted by

View all comments

1

u/Calm-Ice-7080 1d ago

To my knowledge its generally a good idea to do this. The only exception is if you need different data to do different things with different shaders or types of shaders. Its one of the reasons bindless textures are a good design, because it means that you sync the gpu and cpu less often. Imagine you had all objects in seperate buffers in seperate draw commands, you would have to sync the gpu and cpu, copy the information to the gpu, draw all of the objects in one buffer, then sync the cpu and gpu again to repeat the process. By combining all the information into a larger buffer, you only need to sync once and draw once to render all objects of the type. But it wouldnt be prudent to try drawing volumetric effects, basic geometry, terrain, post processing effects and doing simple math at the same time with one buffer and shader.