template<typename DataType, bool KeepStrongReferences = false>
MapHelper class
Facilitates resource mapping.
| Template parameters | |
|---|---|
| DataType | - type of the mapped data. |
| KeepStrongReferences | |
Contents
This class is designed to automate resource mapping/unmapping process. The class automatically unmaps the resource when the class instance gets out of scope.
Usage example:
{
MapHelper<float> UniformData( pDeviceContext, pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD );
UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1;
}
Constructors, destructors, conversion operators
- MapHelper()
- Initializes the class member with null values.
-
MapHelper(IDeviceContext* pContext,
IBuffer* pBuffer,
MAP_
TYPE MapType, MAP_ FLAGS MapFlags) - Initializes the object and maps the provided resource. See Map() for details.
- MapHelper(MapHelper&& Helper)
- Move constructor: takes over resource ownership from Helper.
- operator DataType*()
- Converts mapped data pointer to DataType*.
- operator const DataType*() const
- Converts mapped data pointer to const DataType*.
- ~MapHelper()
- Unamps the resource.
Public functions
- auto operator=(MapHelper&& Helper) -> MapHelper&
- Move-assignement operator: takes over resource ownership from Helper.
-
void Map(IDeviceContext* pContext,
IBuffer* pBuffer,
MAP_
TYPE MapType, MAP_ FLAGS MapFlags) - Maps the provided resource.
- void Unmap()
- Unamps the resource and resets the object state to default.
- auto operator->() -> DataType*
- Operator ->
- auto operator->() const -> const DataType*
- Operator const ->
Function documentation
template<typename DataType, bool KeepStrongReferences>
void Diligent:: MapHelper<DataType, KeepStrongReferences>:: Map(IDeviceContext* pContext,
IBuffer* pBuffer,
MAP_ TYPE MapType,
MAP_ FLAGS MapFlags)
Maps the provided resource.
| Parameters | |
|---|---|
| pContext | - Pointer to the device context to perform mapping with. |
| pBuffer | - Pointer to the buffer interface to map. |
| MapType | - Type of the map operation, see Diligent:: |
| MapFlags | - Additional map flags, see Diligent:: |