[Bf-blender-cvs] [e4e1b0c] blender2.8: OpenGL: invalidate buffers the modern way

Mike Erwin noreply at git.blender.org
Tue Aug 9 23:19:01 CEST 2016


Commit: e4e1b0c7d353d1c37ef88cd1670001974e717841
Author: Mike Erwin
Date:   Tue Aug 9 17:17:34 2016 -0400
Branches: blender2.8
https://developer.blender.org/rBe4e1b0c7d353d1c37ef88cd1670001974e717841

OpenGL: invalidate buffers the modern way

There are older ways to give OpenGL hints about buffer invalidation, but
glInvalidateBufferData does exactly what we want. Use this function when
OpenGL 4.3 is available (Windows and proprietary Linux drivers).

Part of Gawain immediate mode.

===================================================================

M	source/blender/gpu/intern/gpu_immediate.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 5e85c9a..b08484e 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -318,8 +318,10 @@ void immBegin(GLenum primitive, unsigned vertex_ct)
 #if APPLE_LEGACY
 		glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
 #else
-		glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
-		// glInvalidateBufferData(imm.vbo_id); // VERSION >= 4.3 || ARB_invalidate_subdata
+		if (GLEW_VERSION_4_3 || GLEW_ARB_invalidate_subdata)
+			glInvalidateBufferData(imm.vbo_id);
+		else
+			glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
 #endif
 
 		imm.buffer_offset = 0;




More information about the Bf-blender-cvs mailing list