diff --git a/irr/include/IVideoDriver.h b/irr/include/IVideoDriver.h index ebb39dfd9..debb2f2ad 100644 --- a/irr/include/IVideoDriver.h +++ b/irr/include/IVideoDriver.h @@ -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; diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp index 80aacb042..033389de1 100644 --- a/irr/src/CNullDriver.cpp +++ b/irr/src/CNullDriver.cpp @@ -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) diff --git a/irr/src/CNullDriver.h b/irr/src/CNullDriver.h index e772dd8e8..8e5638ecf 100644 --- a/irr/src/CNullDriver.h +++ b/irr/src/CNullDriver.h @@ -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;