lid6j86's picture

deleting shaders, programs, etc...

How expensive are the calls to delete shaders, programs, etc...?

is it better to keep the program around if it's going to be used a lot, or to just create it every time I'm about to use it, then delete it immediately afterward? Does creating and destroying them every frame cost that much? (this question also applies to VBO's, etc...)


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mOfl's picture

It is of course more performant to keep the resources and reuse them. The pipeline of shader program creation involves compiling, linking and uploading the program to the video card, which is a very large overhead. This is even more significant for buffers such as VBOs, because they store potentially much more data than just a few bytes of shader instructions. The transfer between CPU and GPU is usually the main bottleneck of an application, so you should aim for a minimum GL calls and data uploads and downloads (i.e. GL.Get* commands, for example). You should even try to use the same shader for different objects, if possible, to minimize program switching at runtime.

lid6j86's picture

question in regards to VBOs then, I've had no problem attaching multidimensional arrays to VBOs, but I'm getting an error putting a jagged array in there, with it saying "The type 'OpenTK.Vector3[]' must be a non-nullable value type".

is there something special I need to do with jagged arrays?

by the way, I think I owe an apology to most of the regulars on here, I've posted a lot of stupid questions... half of which i was able to answer on my own, half of which were sort of dumb. anyways, thank you for the help!

mOfl's picture
lid6j86 wrote:

question in regards to VBOs then, I've had no problem attaching multidimensional arrays to VBOs, but I'm getting an error putting a jagged array in there, with it saying "The type 'OpenTK.Vector3[]' must be a non-nullable value type".

Does this help you?

lid6j86's picture

I just ended up changing it into a multidimensional array instead of a jagged, got the end result i was looking for anyway