fix infinite loop when expanding buffers

This commit is contained in:
nek0 2020-12-23 07:20:23 +01:00
parent 5c90eee84a
commit a859814fda
2 changed files with 52 additions and 46 deletions

View File

@ -59,11 +59,14 @@ instance Buffer IndexBuffer where
unbind buf
write buf offset dat = do
currentBufSize <- readTVarIO (iBufSize buf)
whileM_
(pure $ (fromIntegral offset + VS.length dat) *
(do
currentSize <- readTVarIO (iBufSize buf)
pure $ (fromIntegral offset + VS.length dat) *
sizeOf (undefined :: StoreType IndexBuffer)
> fromIntegral currentBufSize) $ do
> fromIntegral currentSize)
$ do
currentBufSize <- readTVarIO (iBufSize buf)
allocaArray
(fromIntegral currentBufSize `div`
sizeOf (undefined :: StoreType IndexBuffer))

View File

@ -89,11 +89,14 @@ instance Buffer VertexBuffer where
unbind buf
write buf offset dat = do
currentBufSize <- readTVarIO (vBufSize buf)
whileM_
(pure $ (fromIntegral offset + VS.length dat) *
(do
currentSize <- readTVarIO (vBufSize buf)
pure $ (fromIntegral offset + VS.length dat) *
sizeOf (undefined :: StoreType VertexBuffer)
> fromIntegral currentBufSize) $ do
> fromIntegral currentSize)
$ do
currentBufSize <- readTVarIO (vBufSize buf)
allocaArray
(fromIntegral currentBufSize `div`
sizeOf (undefined :: StoreType VertexBuffer))