Skip to content

Commit

Permalink
fix not loading frames bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-sts committed Mar 1, 2024
1 parent 53abd97 commit 722a17d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import solve.rendering.engine.utils.toIntVector
import solve.scene.controller.SceneController
import solve.scene.model.VisualizationFrame
import solve.utils.ceilToInt
import java.util.Collections.synchronizedList
import java.util.Date
import kotlin.math.abs
import kotlin.math.min
Expand Down Expand Up @@ -59,7 +60,7 @@ class FramesRenderer(

private var cameraLastGridCellPosition = getScreenCenterGridCellPosition()

private val bufferFramesToUpload = mutableListOf<LoadedBufferFrameData>()
private val bufferFramesToUpload = synchronizedList<LoadedBufferFrameData>(mutableListOf())
private val framesLoadingCoroutineScope = CoroutineScope(Dispatchers.Default)

private var needToReinitializeBuffers = false
Expand Down Expand Up @@ -136,8 +137,8 @@ class FramesRenderer(
}

if (haveNewFramesSelection) {
uploadAllFramesToBuffer()
bufferFramesToUpload.clear()
uploadAllFramesToBuffer()
haveNewFramesSelection = false
enableVirtualization()
}
Expand Down Expand Up @@ -167,7 +168,9 @@ class FramesRenderer(

private fun uploadLoadedFramesToBuffers() {
bufferFramesToUpload.toList().forEach { frame ->
bufferFramesToUpload.remove(frame)
synchronized(bufferFramesToUpload) {
bufferFramesToUpload.remove(frame)
}
bufferFramesArrayTexture?.uploadTexture(frame.textureData, frame.bufferIndex)
Texture2D.freeData(frame.textureData)
}
Expand Down Expand Up @@ -293,7 +296,9 @@ class FramesRenderer(
return@launch
}

bufferFramesToUpload.add(LoadedBufferFrameData(textureData, index, loadTime))
synchronized(bufferFramesToUpload) {
bufferFramesToUpload.add(LoadedBufferFrameData(textureData, index, loadTime))
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/engine/shaders/frame/frame.geom
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ void main() {

if (isColored) {
int frameID = gs_in[0].frameID;
int frameX = int(mod(frameID, uGridWidth));
int frameX = frameID % uGridWidth;
int frameY = frameID / uGridWidth;

int bufferX = int(mod(frameX, uBuffersSize.x));
int bufferY = int(mod(frameY, uBuffersSize.y));
int bufferX = frameX % uBuffersSize.x;
int bufferY = frameY % uBuffersSize.y;
float texID = float(bufferY * uBuffersSize.x + bufferX);

vec4 initialPosition = vec4(
Expand Down

0 comments on commit 722a17d

Please sign in to comment.