38 LogWarning(
"Texture usage is not DYNAMIC_UPDATE.");
44 D3D11_MAPPED_SUBRESOURCE sub;
45 HRESULT hr = context->Map(dxTexture, sri, D3D11_MAP_WRITE_DISCARD, 0, &sub);
51 if (numDimensions == 1)
55 else if (numDimensions == 2)
58 sr.data, sub.RowPitch, sub.pData);
64 sr.data, sub.RowPitch, sub.DepthPitch, sub.pData);
66 context->Unmap(dxTexture, sri);
100 D3D11_MAPPED_SUBRESOURCE sub;
101 HRESULT hr = context->Map(
mStaging, sri, D3D11_MAP_WRITE, 0, &sub);
107 if (numDimensions == 1)
111 else if (numDimensions == 2)
114 sr.data, sub.RowPitch, sub.pData);
120 sr.slicePitch, sr.data, sub.RowPitch, sub.DepthPitch,
127 context->CopySubresourceRegion(dxTexture, sri, 0, 0, 0,
mStaging, sri,
nullptr);
146 context->GenerateMips(
mSRView);
156 LogWarning(
"Subresource index out of range.");
167 context->CopySubresourceRegion(
mStaging, sri, 0, 0, 0, dxTexture, sri,
nullptr);
170 D3D11_MAPPED_SUBRESOURCE sub;
171 HRESULT hr = context->Map(
mStaging, sri, D3D11_MAP_READ, 0, &sub);
177 if (numDimensions == 1)
181 else if (numDimensions == 2)
184 sub.pData, sr.rowPitch, sr.data);
190 sub.DepthPitch, sub.pData, sr.rowPitch, sr.slicePitch, sr.data);
211 ID3D11Resource*
target,
unsigned int sri)
216 LogWarning(
"Subresource index out of range.");
222 context->CopySubresourceRegion(target, sri, 0, 0, 0, dxTexture, sri,
nullptr);
245 unsigned int srcRowPitch,
void const* srcData,
unsigned int trgRowPitch,
248 if (srcRowPitch == trgRowPitch)
251 Memcpy(trgData, srcData, trgRowPitch*numRows);
257 unsigned int numRowBytes = std::min(srcRowPitch, trgRowPitch);
258 char const* srcRow =
static_cast<char const*
>(srcData);
259 char* trgRow =
static_cast<char*
>(trgData);
260 for (
unsigned int row = 0;
row < numRows; ++
row)
262 Memcpy(trgRow, srcRow, numRowBytes);
263 srcRow += srcRowPitch;
264 trgRow += trgRowPitch;
270 unsigned int numSlices,
unsigned int srcRowPitch,
271 unsigned int srcSlicePitch,
void const* srcData,
unsigned int trgRowPitch,
272 unsigned int trgSlicePitch,
void* trgData)
274 if (srcRowPitch == trgRowPitch && srcSlicePitch == trgSlicePitch)
277 Memcpy(trgData, srcData, trgSlicePitch*numSlices);
283 unsigned int numRowBytes = std::min(srcRowPitch, trgRowPitch);
284 char const* srcSlice =
static_cast<char const*
>(srcData);
285 char* trgSlice =
static_cast<char*
>(trgData);
286 for (
unsigned int slice = 0; slice < numSlices; ++slice)
288 char const* srcRow = srcSlice;
289 char* trgRow = trgSlice;
290 for (
unsigned int row = 0;
row < numRows; ++
row)
292 Memcpy(trgRow, srcRow, numRowBytes);
293 srcRow += srcRowPitch;
294 trgRow += trgRowPitch;
296 srcSlice += srcSlicePitch;
297 trgSlice += trgSlicePitch;
virtual void SetName(std::string const &name) override
DX11Texture(Texture const *gtTexture)
#define CHECK_HR_RETURN_NONE(msg)
virtual bool CopyGpuToCpu(ID3D11DeviceContext *context, unsigned int sri) override
static void CopyPitched3(unsigned int numRows, unsigned int numSlices, unsigned int srcRowPitch, unsigned int srcSlicePitch, void const *srcData, unsigned int trgRowPitch, unsigned int trgSlicePitch, void *trgData)
HRESULT SetPrivateName(ID3D11DeviceChild *object, std::string const &name)
GLuint const GLchar * name
ID3D11UnorderedAccessView * mUAView
ULONG FinalRelease(T *&object)
unsigned int GetNumDimensions() const
ID3D11Resource * mStaging
virtual bool CopyCpuToGpu(ID3D11DeviceContext *context, unsigned int sri) override
GLenum GLenum GLsizei void * row
GLsizei const GLchar *const * string
virtual void CopyGpuToGpu(ID3D11DeviceContext *context, ID3D11Resource *target, unsigned int sri) override
static void CopyPitched2(unsigned int numRows, unsigned int srcRowPitch, void const *srcData, unsigned int trgRowPitch, void *trgData)
virtual bool Update(ID3D11DeviceContext *context, unsigned int sri) override
#define LogWarning(message)
unsigned int GetNumBytesFor(unsigned int level) const
unsigned int GetDimensionFor(unsigned int level, int i) const
bool PreparedForCopy(D3D11_CPU_ACCESS_FLAG access) const
Subresource GetSubresource(unsigned int index) const
ID3D11Resource * GetDXResource() const
void Memcpy(void *target, void const *source, size_t count)
#define CHECK_HR_RETURN(msg, value)
Texture * GetTexture() const
bool WantAutogenerateMipmaps() const
ID3D11ShaderResourceView * mSRView
unsigned int GetNumSubresources() const
virtual void SetName(std::string const &name) override