OpenGL: allow uploads of buffers to hardware ahead-of-time

This commit is contained in:
sfan5 2024-12-11 14:36:42 +01:00
parent bb550158fc
commit 33b8307119
3 changed files with 34 additions and 0 deletions

@ -310,6 +310,18 @@ public:
0 or another texture first. */
virtual void removeAllTextures() = 0;
//! Eagerly upload buffer to hardware
/** This can be a good idea if you have a newly created or modified buffer,
which you know you will draw in the near future (e.g. end of same frame,
or next frame), because it gives the GPU driver to copy the contents. */
virtual void updateHardwareBuffer(const scene::IVertexBuffer *vb) = 0;
//! Eagerly upload buffer to hardware
/** This can be a good idea if you have a newly created or modified buffer,
which you know you will draw in the near future (e.g. end of same frame,
or next frame), because it gives the GPU driver to copy the contents. */
virtual void updateHardwareBuffer(const scene::IIndexBuffer *ib) = 0;
//! Remove hardware buffer
virtual void removeHardwareBuffer(const scene::IVertexBuffer *vb) = 0;

@ -1167,6 +1167,24 @@ void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer)
delete HWBuffer;
}
void CNullDriver::updateHardwareBuffer(const scene::IVertexBuffer *vb)
{
if (!vb)
return;
auto *link = getBufferLink(vb);
if (link)
updateHardwareBuffer(link);
}
void CNullDriver::updateHardwareBuffer(const scene::IIndexBuffer *ib)
{
if (!ib)
return;
auto *link = getBufferLink(ib);
if (link)
updateHardwareBuffer(link);
}
void CNullDriver::removeHardwareBuffer(const scene::IVertexBuffer *vb)
{
if (!vb)

@ -348,6 +348,10 @@ protected:
virtual SHWBufferLink *createHardwareBuffer(const scene::IIndexBuffer *ib) { return 0; }
public:
virtual void updateHardwareBuffer(const scene::IVertexBuffer *vb) override;
virtual void updateHardwareBuffer(const scene::IIndexBuffer *ib) override;
//! Remove hardware buffer
void removeHardwareBuffer(const scene::IVertexBuffer *vb) override;