diff --git a/source/Irrlicht/CNullDriver.h b/source/Irrlicht/CNullDriver.h index 0edbee0fa..aefea980a 100644 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@ -82,6 +82,8 @@ namespace video //! Returns amount of textures currently loaded u32 getTextureCount() const override; + virtual size_t getGPUFreeVBOMemory() { return 0; } + ITexture* addTexture(const core::dimension2d& size, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) override; ITexture* addTexture(const io::path& name, IImage* image) override; diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index 5475d6fe8..20517b1e9 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -68,6 +68,8 @@ namespace video GLuint vbo_indicesSize; //tmp }; + virtual size_t getGPUFreeVBOMemory() { return COpenGLExtensionHandler::getGPUFreeVBOMemory(); } + virtual bool convertToOpenGLColors(SHWBufferLink* HWBuffer, c8* vertexBuffer, u32 vertexCount) override; virtual bool subUpdateVertexHardwareBuffer(SHWBufferLink* HWBuffer, c8* vertexBuffer, u32 vertexCount, u32 offset) override; virtual bool subUpdateIndexHardwareBuffer(SHWBufferLink* HWBuffer, c8* indices, u32 indexCount, u32 offset) override; diff --git a/source/Irrlicht/COpenGLExtensionHandler.cpp b/source/Irrlicht/COpenGLExtensionHandler.cpp index 44cd489a0..93751241a 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.cpp +++ b/source/Irrlicht/COpenGLExtensionHandler.cpp @@ -648,6 +648,28 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const } +size_t COpenGLExtensionHandler::getGPUFreeVBOMemory() { + + if (FeatureAvailable[IRR_NVX_gpu_memory_info]) + { + // undocumented flags, so use the RAW values + GLint val; + glGetIntegerv(0x9049, &val); + return val; + } + + #ifdef GL_ATI_meminfo + if (FeatureAvailable[IRR_ATI_meminfo]) + { + GLint val[4]; + glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, val); + return val[0]; + } + #endif + + return 0; +} + } } diff --git a/source/Irrlicht/COpenGLExtensionHandler.h b/source/Irrlicht/COpenGLExtensionHandler.h index e3b4bb58d..0eaa836d6 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.h +++ b/source/Irrlicht/COpenGLExtensionHandler.h @@ -1009,6 +1009,8 @@ class COpenGLExtensionHandler return FeatureAvailable[feature]; } + size_t getGPUFreeVBOMemory(); + //! show all features with availability void dump(ELOG_LEVEL logLevel) const;