Go to the documentation of this file.
33 #include "../../../Platforms/Basic/interface/DebugUtilities.hpp"
34 #include "../../../Common/interface/RefCntAutoPtr.hpp"
35 #include "../../GraphicsEngine/interface/DeviceContext.h"
36 #include "../../GraphicsEngine/interface/Buffer.h"
53 template <
typename DataType,
bool KeepStrongReferences = false>
62 m_pMappedData {
nullptr},
63 m_MapType {
static_cast<MAP_TYPE>(-1)},
64 m_MapFlags {
static_cast<Uint32>(-1) }
74 Map(pContext, pBuffer, MapType, MapFlags);
80 m_pBuffer {std::move(Helper.m_pBuffer) },
81 m_pMappedData {std::move(Helper.m_pMappedData)},
82 m_pContext {std::move(Helper.m_pContext) },
83 m_MapType {std::move(Helper.m_MapType) },
84 m_MapFlags {std::move(Helper.m_MapFlags) }
87 Helper.m_pBuffer =
nullptr;
88 Helper.m_pContext =
nullptr;
89 Helper.m_pMappedData =
nullptr;
90 Helper.m_MapType =
static_cast<MAP_TYPE>(-1);
91 Helper.m_MapFlags =
static_cast<Uint32>(-1);
97 m_pBuffer = std::move(Helper.m_pBuffer);
98 m_pMappedData = std::move(Helper.m_pMappedData);
99 m_pContext = std::move(Helper.m_pContext);
100 m_MapType = std::move(Helper.m_MapType);
101 m_MapFlags = std::move(Helper.m_MapFlags);
103 Helper.m_pBuffer =
nullptr;
104 Helper.m_pContext =
nullptr;
105 Helper.m_pMappedData =
nullptr;
106 Helper.m_MapType =
static_cast<MAP_TYPE>(-1);
107 Helper.m_MapFlags =
static_cast<Uint32>(-1);
120 VERIFY(!m_pBuffer && !m_pMappedData && !m_pContext,
"Object already mapped");
122 #ifdef DILIGENT_DEBUG
124 auto& BuffDesc = pBuffer->
GetDesc();
125 VERIFY(
sizeof(DataType) <= BuffDesc.uiSizeInBytes,
"Data type size exceeds buffer size");
128 pContext->
MapBuffer(pBuffer, MapType, MapFlags, (
PVoid&)m_pMappedData);
129 if (m_pMappedData !=
nullptr)
131 m_pContext = pContext;
134 m_MapFlags = MapFlags;
143 m_pContext->UnmapBuffer(m_pBuffer, m_MapType);
145 m_MapType =
static_cast<MAP_TYPE>(-1);
146 m_MapFlags =
static_cast<Uint32>(-1);
148 m_pContext =
nullptr;
149 m_pMappedData =
nullptr;
153 operator DataType*() {
return m_pMappedData; }
156 operator const DataType*()
const {
return m_pMappedData; }
174 template <
typename PtrType,
bool UseStrongReference>
175 struct PtrTypeSelector
178 template <
typename PtrType>
179 struct PtrTypeSelector<PtrType, true>
181 typedef RefCntAutoPtr<PtrType>
Type;
184 template <
typename PtrType>
185 struct PtrTypeSelector<PtrType, false>
187 typedef PtrType*
Type;
197 DataType* m_pMappedData;
MAP_FLAGS
Special map flags.
Definition: GraphicsTypes.h:227
void * PVoid
Definition: BasicTypes.h:56
Buffer interface.
Definition: Buffer.h:187
MapHelper & operator=(MapHelper &&Helper)
Move-assignement operator: takes over resource ownership from Helper.
Definition: MapHelper.hpp:95
void Map(IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags)
Maps the provided resource.
Definition: MapHelper.hpp:118
MapHelper()
Initializes the class member with null values.
Definition: MapHelper.hpp:59
virtual void METHOD() MapBuffer(IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid &pMappedData)
Maps the buffer.
MapHelper(MapHelper &&Helper)
Move constructor: takes over resource ownership from Helper.
Definition: MapHelper.hpp:79
MapHelper(IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags)
Initializes the object and maps the provided resource. See Map() for details.
Definition: MapHelper.hpp:71
const DataType * operator->() const
Operator const ->
Definition: MapHelper.hpp:162
const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type
Definition: PipelineStateD3D12Impl.cpp:69
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DataType * operator->()
Operator ->
Definition: MapHelper.hpp:159
Device context interface.
Definition: DeviceContext.h:1460
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
~MapHelper()
Unamps the resource.
Definition: MapHelper.hpp:165
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:206
Facilitates resource mapping.
Definition: MapHelper.hpp:54
void Unmap()
Unamps the resource and resets the object state to default.
Definition: MapHelper.hpp:139
virtual const BufferDesc &METHOD() GetDesc() const override=0
Returns the buffer description used to create the object.
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37