Safe Haskell | None |
---|---|
Language | Haskell2010 |
Queries.
Queries have some distinct use cases; you can use them to determine if some object is occluded or you can measure how long GPU takes to execute some commands.
- withNumericQuery :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64, a)
- withNumericQuery' :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64)
- withBooleanQuery :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool, a)
- withBooleanQuery' :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool)
- newNumericQuery :: MonadIO m => NumericQueryType -> m (Query Int64)
- newBooleanQuery :: MonadIO m => BooleanQueryType -> m (Query Bool)
- beginQuery :: MonadIO m => Query a -> m ()
- endQuery :: MonadIO m => Query a -> m ()
- getResults :: (MonadIO m, QueryResultType a) => Query a -> m a
- tryGetResults :: (MonadIO m, QueryResultType a) => Query a -> m (Maybe a)
- data NumericQueryType
- data BooleanQueryType = AnySamplesPassed
- data Query a
- class QueryResultType a
Main query operations
withNumericQuery :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64, a) Source
Creates a query, runs some actions in it and then returns an
Query
value.
There can be only one active query for each query type. An user error will be thrown if this is violated.
You can query the returned Query
for results. However, because using the
GPU is typically asynchronous, results may not be (and often are not)
immediately available. Use tryGetResults
to check if results have become
available.
withNumericQuery' :: (MonadIO m, MonadMask m) => NumericQueryType -> m a -> m (Query Int64) Source
Same as withNumericQuery
but throws away the result of the action
itself.
withBooleanQuery :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool, a) Source
Same as withNumericQuery
, but uses boolean queries, whose results is
either True
or False
.
withBooleanQuery' :: (MonadIO m, MonadMask m) => BooleanQueryType -> m a -> m (Query Bool) Source
Same as withBooleanQuery
but throws away the result of the action
itself.
Creating queries manually
newNumericQuery :: MonadIO m => NumericQueryType -> m (Query Int64) Source
Creates a new query object, that returns a numeric type.
Use beginQuery
and endQuery
to decide which part of GPU commands you
want the query to be about.
You may want to use withNumericQuery
instead, which begins and ends
the query for you.
newBooleanQuery :: MonadIO m => BooleanQueryType -> m (Query Bool) Source
Same as newNumericQuery
but for boolean queries.
beginQuery :: MonadIO m => Query a -> m () Source
Begins a query. A query can only be started once.
Retrieving query results
getResults :: (MonadIO m, QueryResultType a) => Query a -> m a Source
Returnts query results, blocks if it has to wait for results.
Note: cannot be interrupted by asynchronous exceptions if it decides to wait.
tryGetResults :: (MonadIO m, QueryResultType a) => Query a -> m (Maybe a) Source
Returns results if they are available or Nothing
.
Query types
data NumericQueryType Source
What kind of query to make? These queries return integer results.
data BooleanQueryType Source
What of query to make? These queries return boolean results.
Types
A query object. The type variable tells the type of the return values from the query.