render: buffer: Orphan before mapping only when used for streaming.
authorDavid Thompson <dthompson2@worcester.edu>
Thu, 6 Sep 2018 13:25:34 +0000 (09:25 -0400)
committerDavid Thompson <dthompson2@worcester.edu>
Thu, 6 Sep 2018 13:25:34 +0000 (09:25 -0400)
* chickdaee/render/buffer.scm (map-buffer!): Orphan buffer data only
  when the buffer usage is 'stream'.

chickadee/render/buffer.scm

index 7f0c168..4363d22 100644 (file)
@@ -196,9 +196,10 @@ vertex buffer data back to the GPU."
         (length (buffer-length buffer))
         (usage (buffer-usage-gl buffer)))
     (gpu-state-set! *buffer-state* buffer)
-    ;; Orphan the buffer to avoid implicit synchronization.
-    ;; See: https://www.opengl.org/wiki/Buffer_Object_Streaming#Buffer_re-specification
-    (gl-buffer-data target length %null-pointer usage)
+    (when (eq? usage 'stream)
+      ;; Orphan the buffer to avoid implicit synchronization.
+      ;; See: https://www.opengl.org/wiki/Buffer_Object_Streaming#Buffer_re-specification
+      (gl-buffer-data target length %null-pointer usage))
     (let ((ptr (gl-map-buffer target (version-1-5 read-write))))
       (set-buffer-data! buffer (pointer->bytevector ptr length)))))