@@ -361,7 +361,7 @@ mapBufferRange ::
361
361
mapBufferRange t o l b =
362
362
fmap (maybeNullPtr Nothing Just ) $ mapBufferRange_ t o l b
363
363
364
- flushMappedBufferRange :: BufferTarget -> Offset -> Length -> IO ()
364
+ flushMappedBufferRange :: BufferTarget -> Offset -> Length -> IO ()
365
365
flushMappedBufferRange t = glFlushMappedBufferRange (marshalBufferTarget t)
366
366
367
367
--------------------------------------------------------------------------------
@@ -373,62 +373,71 @@ type RangeSize = GLsizeiptr
373
373
type BufferRange = (BufferObject , RangeStartIndex , RangeSize )
374
374
375
375
data IndexedBufferTarget =
376
- IndexedTransformFeedbackBuffer
377
- -- marshaling
376
+ IndexedAtomicCounterBuffer
377
+ | IndexedShaderStorageBuffer
378
+ | IndexedTransformFeedbackBuffer
379
+ | IndexedUniformBuffer
380
+ deriving ( Eq , Ord , Show )
381
+
378
382
marshalIndexedBufferTarget :: IndexedBufferTarget -> IPName1I
379
383
marshalIndexedBufferTarget x = case x of
384
+ IndexedAtomicCounterBuffer -> GetAtomicCounterBuffer
385
+ IndexedShaderStorageBuffer -> GetShaderStorageBuffer
380
386
IndexedTransformFeedbackBuffer -> GetTransformFeedbackBuffer
387
+ IndexedUniformBuffer -> GetUniformBuffer
381
388
382
- marshalIndexedBufferStart :: IndexedBufferTarget -> IPName1I
383
- marshalIndexedBufferStart x = case x of
384
- IndexedTransformFeedbackBuffer -> GetTransformFeedbackBufferStart
385
-
386
- marshalIndexedBufferSize :: IndexedBufferTarget -> IPName1I
387
- marshalIndexedBufferSize x = case x of
388
- IndexedTransformFeedbackBuffer -> GetTransformFeedbackBufferSize
389
-
390
- getIndexed :: Num a => IPName1I -> BufferIndex -> GettableStateVar a
391
- getIndexed e i = makeGettableStateVar $ getInteger1i fromIntegral e i
392
-
393
- -- buffer
394
389
bindBufferBase :: IndexedBufferTarget -> BufferIndex -> StateVar (Maybe BufferObject )
395
390
bindBufferBase t i = makeStateVar (getIndexedBufferBinding t i) (setIndexedBufferBase t i)
396
391
397
- setIndexedBufferBase :: IndexedBufferTarget -> BufferIndex -> Maybe BufferObject -> IO ()
398
- setIndexedBufferBase t i buf=
399
- case marshalGetPName . marshalIndexedBufferTarget $ t of
400
- Nothing -> recordInvalidEnum
401
- Just t' ->
402
- glBindBufferBase t' i . bufferID . fromMaybe noBufferObject $ buf
403
-
404
392
getIndexedBufferBinding :: IndexedBufferTarget -> BufferIndex -> IO (Maybe BufferObject )
405
393
getIndexedBufferBinding t i = do
406
394
buf <- getInteger1i (BufferObject . fromIntegral ) (marshalIndexedBufferTarget t) i
407
395
return $ if buf == noBufferObject then Nothing else Just buf
408
396
397
+ setIndexedBufferBase :: IndexedBufferTarget -> BufferIndex -> Maybe BufferObject -> IO ()
398
+ setIndexedBufferBase t i buf =
399
+ case marshalGetPName . marshalIndexedBufferTarget $ t of
400
+ Nothing -> recordInvalidEnum
401
+ Just t' -> glBindBufferBase t' i . bufferID . fromMaybe noBufferObject $ buf
402
+
409
403
bindBufferRange :: IndexedBufferTarget -> BufferIndex -> StateVar (Maybe BufferRange )
410
404
bindBufferRange t i = makeStateVar (getIndexedBufferRange t i) (setIndexedBufferRange t i)
411
405
406
+ getIndexedBufferRange :: IndexedBufferTarget -> BufferIndex -> IO (Maybe BufferRange )
407
+ getIndexedBufferRange t i = do
408
+ buf <- getInteger1i (BufferObject . fromIntegral ) (marshalIndexedBufferTarget t) i
409
+ if buf == noBufferObject
410
+ then return Nothing
411
+ else do start <- get $ indexedBufferStart t i
412
+ size <- get $ indexedBufferSize t i
413
+ return $ Just (buf, start, size)
414
+
412
415
setIndexedBufferRange :: IndexedBufferTarget -> BufferIndex -> Maybe BufferRange -> IO ()
413
- setIndexedBufferRange t i ( Just (buf, start, range)) =
416
+ setIndexedBufferRange t i br =
414
417
case marshalGetPName . marshalIndexedBufferTarget $ t of
415
418
Nothing -> recordInvalidEnum
416
419
Just t' -> glBindBufferRange t' i (bufferID buf) start range
417
- setIndexedBufferRange t i Nothing = setIndexedBufferBase t i Nothing
420
+ where (buf, start, range) = fromMaybe (noBufferObject, 0 , 0 ) br
418
421
419
- getIndexedBufferRange :: IndexedBufferTarget -> BufferIndex -> IO (Maybe BufferRange )
420
- getIndexedBufferRange t i = do
421
- buf <- getInteger1i (BufferObject . fromIntegral ) (marshalIndexedBufferTarget t) i
422
- if buf == noBufferObject
423
- then return Nothing
424
- else do
425
- start <- get $ indexedBufferStart t i
426
- size <- get $ indexedBufferSize t i
427
- return $ Just (buf, start, size)
422
+ getIndexed :: Num a => IPName1I -> BufferIndex -> GettableStateVar a
423
+ getIndexed e i = makeGettableStateVar $ getInteger641i fromIntegral e i
428
424
425
+ marshalIndexedBufferStart :: IndexedBufferTarget -> IPName1I
426
+ marshalIndexedBufferStart x = case x of
427
+ IndexedAtomicCounterBuffer -> GetAtomicCounterBufferStart
428
+ IndexedShaderStorageBuffer -> GetShaderStorageBufferStart
429
+ IndexedTransformFeedbackBuffer -> GetTransformFeedbackBufferStart
430
+ IndexedUniformBuffer -> GetUniformBufferStart
429
431
430
432
indexedBufferStart :: IndexedBufferTarget -> BufferIndex -> GettableStateVar RangeStartIndex
431
433
indexedBufferStart = getIndexed . marshalIndexedBufferStart
432
434
435
+ marshalIndexedBufferSize :: IndexedBufferTarget -> IPName1I
436
+ marshalIndexedBufferSize x = case x of
437
+ IndexedAtomicCounterBuffer -> GetAtomicCounterBufferSize
438
+ IndexedShaderStorageBuffer -> GetShaderStorageBufferSize
439
+ IndexedTransformFeedbackBuffer -> GetTransformFeedbackBufferSize
440
+ IndexedUniformBuffer -> GetUniformBufferSize
441
+
433
442
indexedBufferSize :: IndexedBufferTarget -> BufferIndex -> GettableStateVar RangeSize
434
443
indexedBufferSize = getIndexed . marshalIndexedBufferSize
0 commit comments