1818package com.lambda.graphics.pipeline
1919
2020import com.lambda.graphics.buffer.Buffer.Companion.createPipelineBuffer
21- import com.lambda.graphics.buffer.DynamicByteBuffer
2221import com.lambda.graphics.buffer.DynamicByteBuffer.Companion.dynamicByteBuffer
2322import com.lambda.graphics.gl.kibibyte
24- import org.lwjgl.system.MemoryUtil
2523import org.lwjgl.system.MemoryUtil.memCopy
2624
2725/* *
@@ -64,7 +62,7 @@ class PersistentBuffer(
6462 }
6563
6664 if (snapshotData > 0 && snapshot.capacity >= byteBuffer.bytesPut) {
67- if (memcmp( snapshot, byteBuffer, uploadOffset, dataCount) ) return
65+ if (snapshot.mismatch( byteBuffer) >= 0 ) return
6866 }
6967
7068 glBuffer.update(uploadOffset, dataCount, dataStart)
@@ -90,30 +88,4 @@ class PersistentBuffer(
9088 }
9189
9290 fun use (block : () -> Unit ) = glBuffer.bind { block() }
93-
94- private fun memcmp (a : DynamicByteBuffer , b : DynamicByteBuffer , position : Long , size : Long ): Boolean {
95- if (a.capacity != b.capacity) return false
96-
97- val end = position + size
98- var head = position
99-
100- // Process the aligned bytes in chunks of 8 until we've reached the end
101- while (head + 8 <= end) {
102- val first = MemoryUtil .memGetLong(a.pointer + head)
103- val second = MemoryUtil .memGetLong(b.pointer + head)
104- if (first != second) return false
105-
106- head + = 8
107- }
108-
109- while (head < end) {
110- val first = MemoryUtil .memGetByte(a.pointer + head)
111- val second = MemoryUtil .memGetByte(b.pointer + head)
112- if (first != second) return false
113-
114- head++
115- }
116-
117- return true
118- }
11991}
0 commit comments