[Bf-blender-cvs] [75fac519c05] blender2.8: Gawain: safely orphan immediate mode's VBO
Mike Erwin
noreply at git.blender.org
Thu Apr 27 17:46:41 CEST 2017
Commit: 75fac519c0535df6c13c3d534796e8b263af895f
Author: Mike Erwin
Date: Thu Apr 27 10:16:20 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB75fac519c0535df6c13c3d534796e8b263af895f
Gawain: safely orphan immediate mode's VBO
There are multiple ways to orphan a buffer resource, and this code picks the oldest/safest way no matter which OpenGL version we're running.
TODO: use other (more recent) methods after thorough testing
Follow up to 8e0c57a812e8
===================================================================
M intern/gawain/src/immediate.c
===================================================================
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index 0cf24668b10..f7c2a172c9b 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -208,12 +208,26 @@ void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
else
{
// orphan this buffer & start with a fresh one
+#if 1 || APPLE_LEGACY
+ // this method works on all platforms, old & new
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
-#if !APPLE_LEGACY
+#else
+ // TODO: use other (more recent) methods after thorough testing
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);
+ {
+ // glitches!
+// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE, GL_MAP_INVALIDATE_BUFFER_BIT);
+
+ // works
+// glMapBufferRange(GL_ARRAY_BUFFER, 0, IMM_BUFFER_SIZE,
+// GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
+// glUnmapBuffer(GL_ARRAY_BUFFER);
+
+ // also works
+ glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
+ }
#endif
imm.buffer_offset = 0;
More information about the Bf-blender-cvs
mailing list