12#if defined(_XBOX_ONE) && defined(_TITLE)
19#if !defined(NO_D3D11_DEBUG_NAME) && (defined(_DEBUG) || defined(PROFILE))
20#if !defined(_XBOX_ONE) || !defined(_TITLE)
21#pragma comment(lib, "dxguid.lib")
26#ifndef IID_GRAPHICS_PPV_ARGS
27#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x)
36#ifndef DIRECTX_TOOLKIT_API
37#ifdef DIRECTX_TOOLKIT_EXPORT
39#define DIRECTX_TOOLKIT_API __attribute__((dllexport))
41#define DIRECTX_TOOLKIT_API __declspec(dllexport)
43#elif defined(DIRECTX_TOOLKIT_IMPORT)
45#define DIRECTX_TOOLKIT_API __attribute__((dllimport))
47#define DIRECTX_TOOLKIT_API __declspec(dllimport)
50#define DIRECTX_TOOLKIT_API
87 _In_ ID3D11Resource* resource,
88 _In_
unsigned int subresource,
89 _In_ D3D11_MAP mapType,
90 _In_
unsigned int mapFlags)
noexcept(
false)
95 HRESULT hr =
mContext->Map(resource, subresource, mapType, mapFlags,
this);
98 throw std::exception();
111#pragma clang diagnostic push
112#pragma clang diagnostic ignored "-Wunknown-warning-option"
113#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
116 uint8_t*
get() const noexcept {
return static_cast<uint8_t*
>(pData); }
117 uint8_t*
get(
size_t slice)
const noexcept {
return static_cast<uint8_t*
>(pData) + (slice * DepthPitch); }
119 uint8_t*
scanline(
size_t row)
const noexcept {
return static_cast<uint8_t*
>(pData) + (row * RowPitch); }
120 uint8_t*
scanline(
size_t slice,
size_t row)
const noexcept
122 return static_cast<uint8_t*
>(pData) + (slice * DepthPitch) + (row * RowPitch);
126#pragma clang diagnostic pop
130 void copy(_In_reads_(count) T
const* data,
size_t count)
noexcept
132 memcpy(pData, data, count *
sizeof(T));
136 void copy(T
const& data)
noexcept
138 memcpy(pData, data.data(), data.size() *
sizeof(
typename T::value_type));
148#if !defined(NO_D3D11_DEBUG_NAME) && (defined(_DEBUG) || defined(PROFILE))
149 template<UINT TNameLength>
150 inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_
const char (&name)[TNameLength])
noexcept
152#if defined(_XBOX_ONE) && defined(_TITLE)
153 wchar_t wname[MAX_PATH];
154 int result = MultiByteToWideChar(CP_UTF8, 0, name, TNameLength, wname, MAX_PATH);
157 resource->SetName(wname);
160 resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
164 template<UINT TNameLength>
169#if !defined(NO_D3D11_DEBUG_NAME) && (defined(_DEBUG) || defined(PROFILE))
170 template<UINT TNameLength>
171 inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_z_
const wchar_t (&name)[TNameLength])
173#if defined(_XBOX_ONE) && defined(_TITLE)
174 resource->SetName(name);
176 char aname[MAX_PATH];
177 int result = WideCharToMultiByte(CP_UTF8, 0, name, TNameLength, aname, MAX_PATH,
nullptr,
nullptr);
180 resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, aname);
185 template<UINT TNameLength>
186 inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_z_
const wchar_t (&)[TNameLength])
190 inline namespace DX11
196 return ((x != 0) && !(x & (x - 1)));
205 assert(((alignment - 1) & alignment) == 0);
206 auto mask =
static_cast<T
>(alignment - 1);
213 inline T
AlignUp(T size,
size_t alignment)
noexcept
217 assert(((alignment - 1) & alignment) == 0);
218 auto mask =
static_cast<T
>(alignment - 1);
219 return (size + mask) & ~mask;
228 _In_ IEffect* effect,
229 _In_reads_(count)
const D3D11_INPUT_ELEMENT_DESC* desc,
231 _COM_Outptr_ ID3D11InputLayout** pInputLayout)
noexcept;
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
#define DIRECTX_TOOLKIT_API
void copy(T const &data) noexcept
unsigned int mSubresource
ID3D11Resource * mResource
uint8_t * scanline(size_t slice, size_t row) const noexcept
uint8_t * get() const noexcept
uint8_t * get(size_t slice) const noexcept
MapGuard & operator=(MapGuard &&)=delete
MapGuard(MapGuard const &)=delete
MapGuard & operator=(MapGuard const &)=delete
void copy(_In_reads_(count) T const *data, size_t count) noexcept
MapGuard(MapGuard &&)=delete
uint8_t * scanline(size_t row) const noexcept
MapGuard(_In_ ID3D11DeviceContext *context, _In_ ID3D11Resource *resource, _In_ unsigned int subresource, _In_ D3D11_MAP mapType, _In_ unsigned int mapFlags) noexcept(false)
ID3D11DeviceContext * mContext
T AlignUp(T size, size_t alignment) noexcept
T AlignDown(T size, size_t alignment) noexcept
constexpr bool IsPowerOf2(T x) noexcept
DIRECTX_TOOLKIT_API HRESULT __cdecl CreateInputLayoutFromEffect(_In_ ID3D11Device *device, _In_ IEffect *effect, _In_reads_(count) const D3D11_INPUT_ELEMENT_DESC *desc, size_t count, _COM_Outptr_ ID3D11InputLayout **pInputLayout) noexcept
void SetDebugObjectName(_In_ ID3D11DeviceChild *, _In_z_ const char(&)[TNameLength]) noexcept