summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp')
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp304
1 files changed, 175 insertions, 129 deletions
diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
index 3c797f820..d27a8d53a 100755
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
@@ -50,21 +50,25 @@ gl::Error Image11::generateMipmap(Image11 *dest,
ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
D3D11_MAPPED_SUBRESOURCE destMapped;
- ANGLE_TRY(dest->map(D3D11_MAP_WRITE, &destMapped));
+ gl::Error error = dest->map(D3D11_MAP_WRITE, &destMapped);
+ if (error.isError())
+ {
+ return error;
+ }
D3D11_MAPPED_SUBRESOURCE srcMapped;
- gl::Error error = src->map(D3D11_MAP_READ, &srcMapped);
+ error = src->map(D3D11_MAP_READ, &srcMapped);
if (error.isError())
{
dest->unmap();
return error;
}
- const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(srcMapped.pData);
- uint8_t *destData = reinterpret_cast<uint8_t *>(destMapped.pData);
+ const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(srcMapped.pData);
+ uint8_t *destData = reinterpret_cast<uint8_t*>(destMapped.pData);
auto mipGenerationFunction =
- d3d11::Format::Get(src->getInternalFormat(), rendererCaps).format().mipGenerationFunction;
+ d3d11::Format::Get(src->getInternalFormat(), rendererCaps).format.mipGenerationFunction;
mipGenerationFunction(src->getWidth(), src->getHeight(), src->getDepth(), sourceData,
srcMapped.RowPitch, srcMapped.DepthPitch, destData, destMapped.RowPitch,
destMapped.DepthPitch);
@@ -74,14 +78,15 @@ gl::Error Image11::generateMipmap(Image11 *dest,
dest->markDirty();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
bool Image11::isDirty() const
{
- // If mDirty is true AND mStagingTexture doesn't exist AND mStagingTexture doesn't need to be
- // recovered from TextureStorage AND the texture doesn't require init data (i.e. a blank new
- // texture will suffice) then isDirty should still return false.
+ // If mDirty is true
+ // AND mStagingTexture doesn't exist AND mStagingTexture doesn't need to be recovered from TextureStorage
+ // AND the texture doesn't require init data (i.e. a blank new texture will suffice)
+ // then isDirty should still return false.
if (mDirty && !mStagingTexture && !mRecoverFromStorage)
{
const Renderer11DeviceCaps &deviceCaps = mRenderer->getRenderer11DeviceCaps();
@@ -95,45 +100,54 @@ bool Image11::isDirty() const
return mDirty;
}
-gl::Error Image11::copyToStorage(TextureStorage *storage,
- const gl::ImageIndex &index,
- const gl::Box &region)
+gl::Error Image11::copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{
TextureStorage11 *storage11 = GetAs<TextureStorage11>(storage);
- // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage
- // multiple times, then we should just keep the staging texture around to prevent the copying
- // from impacting perf. We allow the Image11 to copy its data to/from TextureStorage once. This
- // accounts for an app making a late call to glGenerateMipmap.
+ // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times,
+ // then we should just keep the staging texture around to prevent the copying from impacting perf.
+ // We allow the Image11 to copy its data to/from TextureStorage once.
+ // This accounts for an app making a late call to glGenerateMipmap.
bool attemptToReleaseStagingTexture = (mRecoveredFromStorageCount < 2);
if (attemptToReleaseStagingTexture)
{
- // If another image is relying on this Storage for its data, then we must let it recover its
- // data before we overwrite it.
- ANGLE_TRY(storage11->releaseAssociatedImage(index, this));
+ // If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it.
+ gl::Error error = storage11->releaseAssociatedImage(index, this);
+ if (error.isError())
+ {
+ return error;
+ }
}
- ID3D11Resource *stagingTexture = NULL;
+ ID3D11Resource *stagingTexture = NULL;
unsigned int stagingSubresourceIndex = 0;
- ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex));
- ANGLE_TRY(
- storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region));
+ gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
+ if (error.isError())
+ {
+ return error;
+ }
+
+ error = storage11->updateSubresourceLevel(stagingTexture, stagingSubresourceIndex, index, region);
+ if (error.isError())
+ {
+ return error;
+ }
// Once the image data has been copied into the Storage, we can release it locally.
if (attemptToReleaseStagingTexture)
{
storage11->associateImage(this, index);
releaseStagingTexture();
- mRecoverFromStorage = true;
- mAssociatedStorage = storage11;
+ mRecoverFromStorage = true;
+ mAssociatedStorage = storage11;
mAssociatedImageIndex = index;
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
-bool Image11::isAssociatedStorageValid(TextureStorage11 *textureStorage) const
+bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const
{
return (mAssociatedStorage == textureStorage);
}
@@ -142,22 +156,28 @@ gl::Error Image11::recoverFromAssociatedStorage()
{
if (mRecoverFromStorage)
{
- ANGLE_TRY(createStagingTexture());
+ gl::Error error = createStagingTexture();
+ if (error.isError())
+ {
+ return error;
+ }
- bool textureStorageCorrect =
- mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this);
+ bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this);
- // This means that the cached TextureStorage has been modified after this Image11 released
- // its copy of its data. This should not have happened. The TextureStorage should have told
- // this Image11 to recover its data before it was overwritten.
+ // This means that the cached TextureStorage has been modified after this Image11 released its copy of its data.
+ // This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten.
ASSERT(textureStorageCorrect);
if (textureStorageCorrect)
{
// CopySubResource from the Storage to the Staging texture
gl::Box region(0, 0, 0, mWidth, mHeight, mDepth);
- ANGLE_TRY(mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource,
- mAssociatedImageIndex, region));
+ error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
+ if (error.isError())
+ {
+ return error;
+ }
+
mRecoveredFromStorageCount += 1;
}
@@ -165,7 +185,7 @@ gl::Error Image11::recoverFromAssociatedStorage()
disassociateStorage();
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
void Image11::disassociateStorage()
@@ -175,18 +195,17 @@ void Image11::disassociateStorage()
// Make the texturestorage release the Image11 too
mAssociatedStorage->disassociateImage(mAssociatedImageIndex, this);
- mRecoverFromStorage = false;
- mAssociatedStorage = NULL;
+ mRecoverFromStorage = false;
+ mAssociatedStorage = NULL;
mAssociatedImageIndex = gl::ImageIndex::MakeInvalid();
}
}
-bool Image11::redefine(GLenum target,
- GLenum internalformat,
- const gl::Extents &size,
- bool forceRelease)
+bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease)
{
- if (mWidth != size.width || mHeight != size.height || mInternalFormat != internalformat ||
+ if (mWidth != size.width ||
+ mHeight != size.height ||
+ mInternalFormat != internalformat ||
forceRelease)
{
// End the association with the TextureStorage, since that data will be out of date.
@@ -194,11 +213,11 @@ bool Image11::redefine(GLenum target,
disassociateStorage();
mRecoveredFromStorageCount = 0;
- mWidth = size.width;
- mHeight = size.height;
- mDepth = size.depth;
+ mWidth = size.width;
+ mHeight = size.height;
+ mDepth = size.depth;
mInternalFormat = internalformat;
- mTarget = target;
+ mTarget = target;
// compute the d3d format that will be used
const d3d11::Format &formatInfo =
@@ -224,87 +243,93 @@ DXGI_FORMAT Image11::getDXGIFormat() const
return mDXGIFormat;
}
-// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as
-// format/type at input
+// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle.
gl::Error Image11::loadData(const gl::Box &area,
const gl::PixelUnpackState &unpack,
- GLenum inputType,
+ GLenum type,
const void *input,
bool applySkipImages)
{
- const auto sizedInputFormat = getSizedInputFormat(inputType);
- const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat);
+ const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLuint inputRowPitch = 0;
ANGLE_TRY_RESULT(
- inputFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
+ formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
inputRowPitch);
GLuint inputDepthPitch = 0;
- ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch),
+ ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment,
+ unpack.rowLength, unpack.imageHeight),
inputDepthPitch);
GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT(
- inputFormat.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages),
+ formatInfo.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack.skipImages,
+ unpack.skipRows, unpack.skipPixels, applySkipImages),
inputSkipBytes);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
- GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
+ GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
const d3d11::Format &d3dFormatInfo =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
- LoadImageFunction loadFunction = d3dFormatInfo.getLoadFunctions()(inputType).loadFunction;
+ LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(type).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
- ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
+ gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
+ if (error.isError())
+ {
+ return error;
+ }
- uint8_t *offsetMappedData = (reinterpret_cast<uint8_t *>(mappedImage.pData) +
- (area.y * mappedImage.RowPitch + area.x * outputPixelSize +
- area.z * mappedImage.DepthPitch));
+ uint8_t *offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (area.y * mappedImage.RowPitch + area.x * outputPixelSize + area.z * mappedImage.DepthPitch));
loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t *>(input) + inputSkipBytes, inputRowPitch,
inputDepthPitch, offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
unmap();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
{
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, 1, 0), inputRowPitch);
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0;
- ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch);
+ ANGLE_TRY_RESULT(
+ formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0),
+ inputDepthPitch);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
- GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
- GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
- GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
+ GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
+ GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
+ GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
ASSERT(area.x % outputBlockWidth == 0);
ASSERT(area.y % outputBlockHeight == 0);
const d3d11::Format &d3dFormatInfo =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
- LoadImageFunction loadFunction =
- d3dFormatInfo.getLoadFunctions()(GL_UNSIGNED_BYTE).loadFunction;
+ LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions(GL_UNSIGNED_BYTE).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
- ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
+ gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
+ if (error.isError())
+ {
+ return error;
+ }
- uint8_t *offsetMappedData =
- reinterpret_cast<uint8_t *>(mappedImage.pData) +
- ((area.y / outputBlockHeight) * mappedImage.RowPitch +
- (area.x / outputBlockWidth) * outputPixelSize + area.z * mappedImage.DepthPitch);
+ uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((area.y / outputBlockHeight) * mappedImage.RowPitch +
+ (area.x / outputBlockWidth) * outputPixelSize +
+ area.z * mappedImage.DepthPitch);
- loadFunction(area.width, area.height, area.depth, reinterpret_cast<const uint8_t *>(input),
- inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch,
- mappedImage.DepthPitch);
+ loadFunction(area.width, area.height, area.depth,
+ reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
+ offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
unmap();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source)
@@ -312,9 +337,13 @@ gl::Error Image11::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureS
TextureStorage11 *storage11 = GetAs<TextureStorage11>(source);
ID3D11Resource *resource = nullptr;
- ANGLE_TRY(storage11->getResource(&resource));
+ gl::Error error = storage11->getResource(&resource);
+ if (error.isError())
+ {
+ return error;
+ }
- UINT subresourceIndex = storage11->getSubresourceIndex(imageIndex);
+ UINT subresourceIndex = storage11->getSubresourceIndex(imageIndex);
TextureHelper11 textureHelper =
TextureHelper11::MakeAndReference(resource, storage11->getFormatSet());
@@ -336,7 +365,11 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
if (d3d11Format.texFormat == mDXGIFormat && sourceInternalFormat == mInternalFormat)
{
RenderTargetD3D *renderTarget = nullptr;
- ANGLE_TRY(srcAttachment->getRenderTarget(&renderTarget));
+ gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
+ if (error.isError())
+ {
+ return error;
+ }
RenderTarget11 *rt11 = GetAs<RenderTarget11>(renderTarget);
ASSERT(rt11->getTexture());
@@ -352,7 +385,11 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
// This format requires conversion, so we must copy the texture to staging and manually convert
// via readPixels
D3D11_MAPPED_SUBRESOURCE mappedImage;
- ANGLE_TRY(map(D3D11_MAP_WRITE, &mappedImage));
+ gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
+ if (error.isError())
+ {
+ return error;
+ }
// determine the offset coordinate into the destination buffer
const auto &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
@@ -366,8 +403,7 @@ gl::Error Image11::copyFromFramebuffer(const gl::Offset &destOffset,
const auto &destD3D11Format =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
- auto loadFunction = destD3D11Format.getLoadFunctions()(destFormatInfo.type);
- gl::Error error = gl::NoError();
+ auto loadFunction = destD3D11Format.loadFunctions(destFormatInfo.type);
if (loadFunction.requiresConversion)
{
size_t bufferSize = destFormatInfo.pixelBytes * sourceArea.width * sourceArea.height;
@@ -404,7 +440,11 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset,
// No conversion needed-- use copyback fastpath
ID3D11Resource *stagingTexture = nullptr;
unsigned int stagingSubresourceIndex = 0;
- ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex));
+ gl::Error error = getStagingTexture(&stagingTexture, &stagingSubresourceIndex);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
@@ -433,7 +473,7 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset,
resolveDesc.MiscFlags = 0;
ID3D11Texture2D *srcTex2D = NULL;
- HRESULT result = device->CreateTexture2D(&resolveDesc, NULL, &srcTex2D);
+ HRESULT result = device->CreateTexture2D(&resolveDesc, NULL, &srcTex2D);
if (FAILED(result))
{
return gl::Error(GL_OUT_OF_MEMORY,
@@ -469,17 +509,20 @@ gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset,
}
mDirty = true;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
-gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture,
- unsigned int *outSubresourceIndex)
+gl::Error Image11::getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex)
{
- ANGLE_TRY(createStagingTexture());
+ gl::Error error = createStagingTexture();
+ if (error.isError())
+ {
+ return error;
+ }
- *outStagingTexture = mStagingTexture;
+ *outStagingTexture = mStagingTexture;
*outSubresourceIndex = mStagingSubresource;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
void Image11::releaseStagingTexture()
@@ -501,8 +544,8 @@ gl::Error Image11::createStagingTexture()
ID3D11Device *device = mRenderer->getDevice();
HRESULT result;
- int lodOffset = 1;
- GLsizei width = mWidth;
+ int lodOffset = 1;
+ GLsizei width = mWidth;
GLsizei height = mHeight;
// adjust size if needed for compressed textures
@@ -513,24 +556,23 @@ gl::Error Image11::createStagingTexture()
ID3D11Texture3D *newTexture = NULL;
D3D11_TEXTURE3D_DESC desc;
- desc.Width = width;
- desc.Height = height;
- desc.Depth = mDepth;
- desc.MipLevels = lodOffset + 1;
- desc.Format = dxgiFormat;
- desc.Usage = D3D11_USAGE_STAGING;
- desc.BindFlags = 0;
+ desc.Width = width;
+ desc.Height = height;
+ desc.Depth = mDepth;
+ desc.MipLevels = lodOffset + 1;
+ desc.Format = dxgiFormat;
+ desc.Usage = D3D11_USAGE_STAGING;
+ desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- desc.MiscFlags = 0;
+ desc.MiscFlags = 0;
if (d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps())
.dataInitializerFunction != NULL)
{
std::vector<D3D11_SUBRESOURCE_DATA> initialData;
std::vector<std::vector<BYTE>> textureData;
- d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(),
- width, height, mDepth, lodOffset + 1, &initialData,
- &textureData);
+ d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), width, height, mDepth,
+ lodOffset + 1, &initialData, &textureData);
result = device->CreateTexture3D(&desc, initialData.data(), &newTexture);
}
@@ -542,39 +584,36 @@ gl::Error Image11::createStagingTexture()
if (FAILED(result))
{
ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.",
- result);
+ return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result);
}
- mStagingTexture = newTexture;
+ mStagingTexture = newTexture;
mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
}
- else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY ||
- mTarget == GL_TEXTURE_CUBE_MAP)
+ else if (mTarget == GL_TEXTURE_2D || mTarget == GL_TEXTURE_2D_ARRAY || mTarget == GL_TEXTURE_CUBE_MAP)
{
ID3D11Texture2D *newTexture = NULL;
D3D11_TEXTURE2D_DESC desc;
- desc.Width = width;
- desc.Height = height;
- desc.MipLevels = lodOffset + 1;
- desc.ArraySize = 1;
- desc.Format = dxgiFormat;
- desc.SampleDesc.Count = 1;
+ desc.Width = width;
+ desc.Height = height;
+ desc.MipLevels = lodOffset + 1;
+ desc.ArraySize = 1;
+ desc.Format = dxgiFormat;
+ desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
- desc.Usage = D3D11_USAGE_STAGING;
- desc.BindFlags = 0;
- desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
- desc.MiscFlags = 0;
+ desc.Usage = D3D11_USAGE_STAGING;
+ desc.BindFlags = 0;
+ desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
+ desc.MiscFlags = 0;
if (d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps())
.dataInitializerFunction != NULL)
{
std::vector<D3D11_SUBRESOURCE_DATA> initialData;
std::vector<std::vector<BYTE>> textureData;
- d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(),
- width, height, 1, lodOffset + 1, &initialData,
- &textureData);
+ d3d11::GenerateInitialTextureData(mInternalFormat, mRenderer->getRenderer11DeviceCaps(), width, height, 1,
+ lodOffset + 1, &initialData, &textureData);
result = device->CreateTexture2D(&desc, initialData.data(), &newTexture);
}
@@ -586,11 +625,10 @@ gl::Error Image11::createStagingTexture()
if (FAILED(result))
{
ASSERT(result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.",
- result);
+ return gl::Error(GL_OUT_OF_MEMORY, "Failed to create staging texture, result: 0x%X.", result);
}
- mStagingTexture = newTexture;
+ mStagingTexture = newTexture;
mStagingSubresource = D3D11CalcSubresource(lodOffset, 0, lodOffset + 1);
}
else
@@ -605,11 +643,19 @@ gl::Error Image11::createStagingTexture()
gl::Error Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{
// We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
- ANGLE_TRY(recoverFromAssociatedStorage());
+ gl::Error error = recoverFromAssociatedStorage();
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *stagingTexture = NULL;
- unsigned int subresourceIndex = 0;
- ANGLE_TRY(getStagingTexture(&stagingTexture, &subresourceIndex));
+ unsigned int subresourceIndex = 0;
+ error = getStagingTexture(&stagingTexture, &subresourceIndex);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();