16 mUpdateMapMode(D3D11_MAP_WRITE_DISCARD)
25 LogWarning(
"Buffer usage is not DYNAMIC_UPDATE.");
30 if (numActiveBytes > 0)
34 D3D11_MAPPED_SUBRESOURCE sub;
35 HRESULT hr = context->Map(dxBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub);
43 char*
target = (
char*)sub.pData + offsetInBytes;
44 Memcpy(target, source, numActiveBytes);
50 context->Unmap(dxBuffer, 0);
68 if (numActiveBytes > 0)
71 D3D11_MAPPED_SUBRESOURCE sub;
72 HRESULT hr = context->Map(
mStaging, 0, D3D11_MAP_WRITE, 0, &sub);
80 char*
target = (
char*)sub.pData + offsetInBytes;
81 Memcpy(target, source, numActiveBytes);
86 D3D11_BOX box = { offsetInBytes, 0, 0, offsetInBytes + numActiveBytes, 1, 1 };
87 context->CopySubresourceRegion(
106 if (numActiveBytes > 0)
110 D3D11_BOX box = { offsetInBytes, 0, 0, offsetInBytes + numActiveBytes, 1, 1 };
111 context->CopySubresourceRegion(
115 D3D11_MAPPED_SUBRESOURCE sub;
116 HRESULT hr = context->Map(
mStaging, 0, D3D11_MAP_READ, 0, &sub);
120 char const*
source = (
char*)sub.pData + offsetInBytes;
136 if (numActiveBytes > 0)
140 D3D11_BOX box = { offsetInBytes, 0, 0, offsetInBytes + numActiveBytes, 1, 1 };
141 context->CopySubresourceRegion(
142 target, 0, offsetInBytes, 0, 0,
GetDXBuffer(), 0, &box);
152 LogError(
"This was called polymorphically through DX11Resource.");
158 LogError(
"This was called polymorphically through DX11Resource.");
164 LogError(
"This was called polymorphically through DX11Resource.");
170 LogError(
"This was called polymorphically through DX11Resource.");
174 D3D11_BUFFER_DESC
const& bf)
176 D3D11_BUFFER_DESC desc;
177 desc.ByteWidth = bf.ByteWidth;
178 desc.Usage = D3D11_USAGE_STAGING;
182 desc.StructureByteStride = 0;
184 HRESULT hr = device->CreateBuffer(&desc,
nullptr,
185 reinterpret_cast<ID3D11Buffer**>(&
mStaging));
virtual void CopyGpuToGpu(ID3D11DeviceContext *context, ID3D11Resource *target) override
virtual bool CopyCpuToGpu(ID3D11DeviceContext *context) override
#define D3D11_RESOURCE_MISC_NONE
DX11Buffer(Buffer const *buffer)
#define CHECK_HR_RETURN_NONE(msg)
unsigned int GetOffset() const
#define LogInformation(message)
ID3D11Buffer * GetDXBuffer() const
ID3D11Resource * mStaging
unsigned int GetElementSize() const
GLsizei GLsizei GLchar * source
#define LogError(message)
#define LogWarning(message)
unsigned int GetNumBytes() const
void CreateStaging(ID3D11Device *device, D3D11_BUFFER_DESC const &bf)
Buffer * GetBuffer() const
char const * GetData() const
bool PreparedForCopy(D3D11_CPU_ACCESS_FLAG access) const
static UINT const msStagingAccess[]
virtual bool Update(ID3D11DeviceContext *context) override
void Memcpy(void *target, void const *source, size_t count)
CopyType GetCopyType() const
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
#define CHECK_HR_RETURN(msg, value)
virtual bool CopyGpuToCpu(ID3D11DeviceContext *context) override
unsigned int GetNumActiveBytes() const