diff options
-rw-r--r-- | chickadee/graphics/buffer.scm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm index f2fbfe0..625a9e0 100644 --- a/chickadee/graphics/buffer.scm +++ b/chickadee/graphics/buffer.scm @@ -237,9 +237,11 @@ never sent to the GPU." ;; those memory regions we avoid bytevector allocation after a frame ;; or two of warmup. (define (pointer->bytevector/cached buffer pointer length) - (let ((cache (buffer-stream-cache buffer)) - (address (pointer-address pointer))) - (or (hashv-ref cache address) + (let* ((cache (buffer-stream-cache buffer)) + (address (pointer-address pointer)) + (cached (hashv-ref cache address))) + (if (and cached (= (bytevector-length cached) length)) + cached (let ((bv (pointer->bytevector pointer length))) (hashv-set! cache address bv) bv)))) |