summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp')
-rwxr-xr-xgfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp733
1 files changed, 399 insertions, 334 deletions
diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
index 36c888dd3..738dae13f 100755
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
@@ -31,15 +31,15 @@
namespace rx
{
-TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle, bool dropStencil)
- : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle), dropStencil(dropStencil)
+TextureStorage11::SRVKey::SRVKey(int baseLevel, int mipLevels, bool swizzle)
+ : baseLevel(baseLevel), mipLevels(mipLevels), swizzle(swizzle)
{
}
bool TextureStorage11::SRVKey::operator<(const SRVKey &rhs) const
{
- return std::tie(baseLevel, mipLevels, swizzle, dropStencil) <
- std::tie(rhs.baseLevel, rhs.mipLevels, rhs.swizzle, rhs.dropStencil);
+ return std::tie(baseLevel, mipLevels, swizzle) <
+ std::tie(rhs.baseLevel, rhs.mipLevels, rhs.swizzle);
}
TextureStorage11::TextureStorage11(Renderer11 *renderer,
@@ -53,7 +53,6 @@ TextureStorage11::TextureStorage11(Renderer11 *renderer,
mTextureWidth(0),
mTextureHeight(0),
mTextureDepth(0),
- mDropStencilTexture(nullptr),
mBindFlags(bindFlags),
mMiscFlags(miscFlags)
{
@@ -74,7 +73,6 @@ TextureStorage11::~TextureStorage11()
SafeRelease(i->second);
}
mSrvCache.clear();
- SafeRelease(mDropStencilTexture);
}
DWORD TextureStorage11::GetTextureBindFlags(GLenum internalFormat,
@@ -110,7 +108,9 @@ DWORD TextureStorage11::GetTextureMiscFlags(GLenum internalFormat,
const d3d11::Format &formatInfo = d3d11::Format::Get(internalFormat, renderer11DeviceCaps);
if (renderTarget && levels > 1)
{
- if (d3d11::SupportsMipGen(formatInfo.texFormat, renderer11DeviceCaps.featureLevel))
+ const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(formatInfo.texFormat);
+
+ if (dxgiFormatInfo.nativeMipmapSupport(renderer11DeviceCaps.featureLevel))
{
miscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
}
@@ -185,8 +185,8 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
{
// Make sure to add the level offset for our tiny compressed texture workaround
const GLuint effectiveBaseLevel = textureState.getEffectiveBaseLevel();
- bool swizzleRequired = textureState.swizzleRequired();
- bool mipmapping = gl::IsMipmapFiltered(textureState.getSamplerState());
+ bool swizzleRequired = textureState.swizzleRequired();
+ bool mipmapping = gl::IsMipmapFiltered(textureState.getSamplerState());
unsigned int mipLevels =
mipmapping ? (textureState.getEffectiveMaxLevel() - effectiveBaseLevel + 1) : 1;
@@ -203,7 +203,11 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
// We must ensure that the level zero texture is in sync with mipped texture.
- ANGLE_TRY(useLevelZeroWorkaroundTexture(mipLevels == 1));
+ gl::Error error = useLevelZeroWorkaroundTexture(mipLevels == 1);
+ if (error.isError())
+ {
+ return error;
+ }
}
if (swizzleRequired)
@@ -211,22 +215,7 @@ gl::Error TextureStorage11::getSRV(const gl::TextureState &textureState,
verifySwizzleExists(textureState.getSwizzleState());
}
- // We drop the stencil when sampling from the SRV if three conditions hold:
- // 1. the drop stencil workaround is enabled.
- bool workaround = mRenderer->getWorkarounds().emulateTinyStencilTextures;
- // 2. this is a stencil texture.
- bool hasStencil = (mFormatInfo.format().stencilBits > 0);
- // 3. the texture has a 1x1 or 2x2 mip.
- bool hasSmallMips = (getLevelWidth(mMipLevels - 1) <= 2 || getLevelHeight(mMipLevels - 1) <= 2);
-
- bool useDropStencil = (workaround && hasStencil && hasSmallMips);
- if (useDropStencil)
- {
- // Ensure drop texture gets re-created, if SRV is cached.
- ANGLE_TRY(createDropStencilTexture());
- }
-
- SRVKey key(effectiveBaseLevel, mipLevels, swizzleRequired, useDropStencil);
+ SRVKey key(effectiveBaseLevel, mipLevels, swizzleRequired);
ANGLE_TRY(getCachedOrCreateSRV(key, outSRV));
return gl::NoError();
@@ -243,30 +232,17 @@ gl::Error TextureStorage11::getCachedOrCreateSRV(const SRVKey &key,
}
ID3D11Resource *texture = nullptr;
- DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN;
-
if (key.swizzle)
{
- const auto &swizzleFormat =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps());
- ASSERT(!key.dropStencil || swizzleFormat.format().stencilBits == 0);
ANGLE_TRY(getSwizzleTexture(&texture));
- format = swizzleFormat.srvFormat;
- }
- else if (key.dropStencil)
- {
- ASSERT(mDropStencilTexture);
- texture = mDropStencilTexture;
- format = DXGI_FORMAT_R32_FLOAT;
}
else
{
ANGLE_TRY(getResource(&texture));
- format = mFormatInfo.srvFormat;
}
ID3D11ShaderResourceView *srv = nullptr;
-
+ DXGI_FORMAT format = (key.swizzle ? mFormatInfo.swizzle.srvFormat : mFormatInfo.srvFormat);
ANGLE_TRY(createSRV(key.baseLevel, key.mipLevels, format, texture, &srv));
mSrvCache.insert(std::make_pair(key, srv));
@@ -295,17 +271,25 @@ gl::Error TextureStorage11::getSRVLevel(int mipLevel,
else
{
ID3D11Resource *resource = nullptr;
- ANGLE_TRY(getResource(&resource));
+ gl::Error error = getResource(&resource);
+ if (error.isError())
+ {
+ return error;
+ }
DXGI_FORMAT resourceFormat =
blitSRV ? mFormatInfo.blitSRVFormat : mFormatInfo.srvFormat;
- ANGLE_TRY(createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]));
+ error = createSRV(mipLevel, 1, resourceFormat, resource, &levelSRVs[mipLevel]);
+ if (error.isError())
+ {
+ return error;
+ }
}
}
*outSRV = levelSRVs[mipLevel];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11::getSRVLevels(GLint baseLevel,
@@ -326,12 +310,14 @@ gl::Error TextureStorage11::getSRVLevels(GLint baseLevel,
if (mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
// We must ensure that the level zero texture is in sync with mipped texture.
- ANGLE_TRY(useLevelZeroWorkaroundTexture(mipLevels == 1));
+ gl::Error error = useLevelZeroWorkaroundTexture(mipLevels == 1);
+ if (error.isError())
+ {
+ return error;
+ }
}
- // TODO(jmadill): Assert we don't need to drop stencil.
-
- SRVKey key(baseLevel, mipLevels, false, false);
+ SRVKey key(baseLevel, mipLevels, false);
ANGLE_TRY(getCachedOrCreateSRV(key, outSRV));
return gl::NoError();
@@ -351,25 +337,38 @@ gl::Error TextureStorage11::generateSwizzles(const gl::SwizzleState &swizzleTarg
{
// Need to re-render the swizzle for this level
ID3D11ShaderResourceView *sourceSRV = nullptr;
- ANGLE_TRY(getSRVLevel(level, true, &sourceSRV));
+ gl::Error error = getSRVLevel(level, true, &sourceSRV);
+
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11RenderTargetView *destRTV = nullptr;
- ANGLE_TRY(getSwizzleRenderTarget(level, &destRTV));
+ error = getSwizzleRenderTarget(level, &destRTV);
+ if (error.isError())
+ {
+ return error;
+ }
gl::Extents size(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
Blit11 *blitter = mRenderer->getBlitter();
- ANGLE_TRY(blitter->swizzleTexture(sourceSRV, destRTV, size, swizzleTarget));
+ error = blitter->swizzleTexture(sourceSRV, destRTV, size, swizzleTarget);
+ if (error.isError())
+ {
+ return error;
+ }
mSwizzleCache[level] = swizzleTarget;
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
-void TextureStorage11::markLevelDirty(int mipLevel)
+void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel)
{
if (mipLevel >= 0 && static_cast<unsigned int>(mipLevel) < ArraySize(mSwizzleCache))
{
@@ -377,15 +376,13 @@ void TextureStorage11::markLevelDirty(int mipLevel)
// not a valid swizzle combination
mSwizzleCache[mipLevel] = gl::SwizzleState();
}
-
- SafeRelease(mDropStencilTexture);
}
-void TextureStorage11::markDirty()
+void TextureStorage11::invalidateSwizzleCache()
{
for (unsigned int mipLevel = 0; mipLevel < ArraySize(mSwizzleCache); mipLevel++)
{
- markLevelDirty(mipLevel);
+ invalidateSwizzleCacheLevel(mipLevel);
}
}
@@ -398,7 +395,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture,
const GLint level = index.mipIndex;
- markLevelDirty(level);
+ invalidateSwizzleCacheLevel(level);
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
@@ -428,7 +425,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture,
if (!fullCopy && mFormatInfo.dsvFormat != DXGI_FORMAT_UNKNOWN)
{
// CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
- Blit11 *blitter = mRenderer->getBlitter();
+ Blit11 *blitter = mRenderer->getBlitter();
TextureHelper11 source = TextureHelper11::MakeAndReference(srcTexture, getFormatSet());
TextureHelper11 dest = TextureHelper11::MakeAndReference(dstTexture, getFormatSet());
return blitter->copyDepthStencil(source, sourceSubresource, copyArea, texSize, dest,
@@ -460,16 +457,22 @@ gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource *dstTexture,
ASSERT(dstTexture);
ID3D11Resource *srcTexture = nullptr;
+ gl::Error error(GL_NO_ERROR);
// If the zero-LOD workaround is active and we want to update a level greater than zero, then we
// should update the mipmapped texture, even if mapmaps are currently disabled.
if (index.mipIndex > 0 && mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{
- ANGLE_TRY(getMippedResource(&srcTexture));
+ error = getMippedResource(&srcTexture);
}
else
{
- ANGLE_TRY(getResource(&srcTexture));
+ error = getResource(&srcTexture);
+ }
+
+ if (error.isError())
+ {
+ return error;
}
ASSERT(srcTexture);
@@ -508,17 +511,25 @@ gl::Error TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex,
{
ASSERT(sourceIndex.layerIndex == destIndex.layerIndex);
- markLevelDirty(destIndex.mipIndex);
+ invalidateSwizzleCacheLevel(destIndex.mipIndex);
RenderTargetD3D *source = nullptr;
- ANGLE_TRY(getRenderTarget(sourceIndex, &source));
+ gl::Error error = getRenderTarget(sourceIndex, &source);
+ if (error.isError())
+ {
+ return error;
+ }
RenderTargetD3D *dest = nullptr;
- ANGLE_TRY(getRenderTarget(destIndex, &dest));
+ error = getRenderTarget(destIndex, &dest);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *sourceSRV =
GetAs<RenderTarget11>(source)->getBlitShaderResourceView();
- ID3D11RenderTargetView *destRTV = GetAs<RenderTarget11>(dest)->getRenderTargetView();
+ ID3D11RenderTargetView *destRTV = GetAs<RenderTarget11>(dest)->getRenderTargetView();
gl::Box sourceArea(0, 0, 0, source->getWidth(), source->getHeight(), source->getDepth());
gl::Extents sourceSize(source->getWidth(), source->getHeight(), source->getDepth());
@@ -543,7 +554,7 @@ void TextureStorage11::verifySwizzleExists(const gl::SwizzleState &swizzleState)
void TextureStorage11::clearSRVCache()
{
- markDirty();
+ invalidateSwizzleCache();
auto iter = mSrvCache.begin();
while (iter != mSrvCache.end())
@@ -571,64 +582,72 @@ gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage)
ASSERT(destStorage);
ID3D11Resource *sourceResouce = nullptr;
- ANGLE_TRY(getResource(&sourceResouce));
+ gl::Error error = getResource(&sourceResouce);
+ if (error.isError())
+ {
+ return error;
+ }
TextureStorage11 *dest11 = GetAs<TextureStorage11>(destStorage);
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
immediateContext->CopyResource(destResource, sourceResouce);
- dest11->markDirty();
+ dest11->invalidateSwizzleCache();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
ImageD3D *image,
const gl::Box *destBox,
- GLenum inputType,
+ GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixelData)
{
ASSERT(!image->isDirty());
- markLevelDirty(index.mipIndex);
-
ID3D11Resource *resource = nullptr;
ANGLE_TRY(getResource(&resource));
ASSERT(resource);
UINT destSubresource = getSubresourceIndex(index);
- const auto sizedInputFormat = image->getSizedInputFormat(inputType);
- const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat);
+ const gl::InternalFormat &internalFormatInfo =
+ gl::GetInternalFormatInfo(image->getInternalFormat());
gl::Box levelBox(0, 0, 0, getLevelWidth(index.mipIndex), getLevelHeight(index.mipIndex),
getLevelDepth(index.mipIndex));
bool fullUpdate = (destBox == nullptr || *destBox == levelBox);
- ASSERT(inputFormat.depthBits == 0 || fullUpdate);
+ ASSERT(internalFormatInfo.depthBits == 0 || fullUpdate);
// TODO(jmadill): Handle compressed formats
// Compressed formats have different load syntax, so we'll have to handle them with slightly
// different logic. Will implemnent this in a follow-up patch, and ensure we do not use SetData
// with compressed formats in the calling logic.
- ASSERT(!inputFormat.compressed);
+ ASSERT(!internalFormatInfo.compressed);
- const int width = destBox ? destBox->width : static_cast<int>(image->getWidth());
- const int height = destBox ? destBox->height : static_cast<int>(image->getHeight());
- const int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth());
+ const int width = destBox ? destBox->width : static_cast<int>(image->getWidth());
+ const int height = destBox ? destBox->height : static_cast<int>(image->getHeight());
+ const int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth());
GLuint srcRowPitch = 0;
ANGLE_TRY_RESULT(
- inputFormat.computeRowPitch(width, unpack.alignment, unpack.rowLength),
+ internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength),
srcRowPitch);
GLuint srcDepthPitch = 0;
- ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
+ ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(type, width, height, unpack.alignment,
+ unpack.rowLength, unpack.imageHeight),
srcDepthPitch);
GLuint srcSkipBytes = 0;
ANGLE_TRY_RESULT(
- inputFormat.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack, index.is3D()),
+ internalFormatInfo.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack.skipImages,
+ unpack.skipRows, unpack.skipPixels, index.is3D()),
srcSkipBytes);
const d3d11::Format &d3d11Format =
@@ -645,7 +664,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
MemoryBuffer *conversionBuffer = nullptr;
const uint8_t *data = nullptr;
- LoadImageFunctionInfo loadFunctionInfo = d3d11Format.getLoadFunctions()(inputType);
+ LoadImageFunctionInfo loadFunctionInfo = d3d11Format.loadFunctions(type);
if (loadFunctionInfo.requiresConversion)
{
ANGLE_TRY(mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer));
@@ -687,12 +706,6 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
return gl::NoError();
}
-gl::Error TextureStorage11::createDropStencilTexture()
-{
- UNIMPLEMENTED();
- return gl::Error(GL_INVALID_OPERATION, "Drop stencil texture not implemented.");
-}
-
TextureStorage11_2D::TextureStorage11_2D(Renderer11 *renderer, SwapChain11 *swapchain)
: TextureStorage11(renderer,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE,
@@ -778,7 +791,6 @@ TextureStorage11_2D::~TextureStorage11_2D()
if (error.isError())
{
// TODO: Find a way to report this back to the context
- ERR("Error initialization texture storage: %x", error.getCode());
}
}
}
@@ -817,37 +829,63 @@ gl::Error TextureStorage11_2D::copyToStorage(TextureStorage *destStorage)
// corresponding textures in destStorage.
if (mTexture)
{
- ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(false));
+ gl::Error error = dest11->useLevelZeroWorkaroundTexture(false);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
immediateContext->CopyResource(destResource, mTexture);
}
if (mLevelZeroTexture)
{
- ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(true));
+ gl::Error error = dest11->useLevelZeroWorkaroundTexture(true);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
immediateContext->CopyResource(destResource, mLevelZeroTexture);
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
+ else
+ {
+ ID3D11Resource *sourceResouce = nullptr;
+ gl::Error error = getResource(&sourceResouce);
+ if (error.isError())
+ {
+ return error;
+ }
- ID3D11Resource *sourceResouce = nullptr;
- ANGLE_TRY(getResource(&sourceResouce));
-
- ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ ID3D11Resource *destResource = nullptr;
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
- immediateContext->CopyResource(destResource, sourceResouce);
- dest11->markDirty();
+ immediateContext->CopyResource(destResource, sourceResouce);
+ dest11->invalidateSwizzleCache();
+ }
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTexture)
@@ -858,7 +896,11 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe
{
if (!mUseLevelZeroTexture && mTexture)
{
- ANGLE_TRY(ensureTextureExists(1));
+ gl::Error error = ensureTextureExists(1);
+ if (error.isError())
+ {
+ return error;
+ }
// Pull data back from the mipped texture if necessary.
ASSERT(mLevelZeroTexture);
@@ -872,7 +914,11 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe
{
if (mUseLevelZeroTexture && mLevelZeroTexture)
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
// Pull data back from the level zero texture if necessary.
ASSERT(mTexture);
@@ -899,7 +945,7 @@ gl::Error TextureStorage11_2D::useLevelZeroWorkaroundTexture(bool useLevelZeroTe
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
void TextureStorage11_2D::associateImage(Image11 *image, const gl::ImageIndex &index)
@@ -972,28 +1018,42 @@ gl::Error TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &inde
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to nullptr too.
- ANGLE_TRY(mAssociatedImages[level]->recoverFromAssociatedStorage());
+ gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
+ if (error.isError())
+ {
+ return error;
+ }
}
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2D::getResource(ID3D11Resource **outResource)
{
if (mUseLevelZeroTexture && mMipLevels > 1)
{
- ANGLE_TRY(ensureTextureExists(1));
+ gl::Error error = ensureTextureExists(1);
+ if (error.isError())
+ {
+ return error;
+ }
*outResource = mLevelZeroTexture;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
+ else
+ {
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
- ANGLE_TRY(ensureTextureExists(mMipLevels));
-
- *outResource = mTexture;
- return gl::NoError();
+ *outResource = mTexture;
+ return gl::Error(GL_NO_ERROR);
+ }
}
gl::Error TextureStorage11_2D::getMippedResource(ID3D11Resource **outResource)
@@ -1001,10 +1061,14 @@ gl::Error TextureStorage11_2D::getMippedResource(ID3D11Resource **outResource)
// This shouldn't be called unless the zero max LOD workaround is active.
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
*outResource = mTexture;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels)
@@ -1078,17 +1142,29 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
if (mRenderTarget[level])
{
*outRT = mRenderTarget[level];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
ID3D11Resource *texture = nullptr;
- ANGLE_TRY(getResource(&texture));
+ gl::Error error = getResource(&texture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *srv = nullptr;
- ANGLE_TRY(getSRVLevel(level, false, &srv));
+ error = getSRVLevel(level, false, &srv);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *blitSRV = nullptr;
- ANGLE_TRY(getSRVLevel(level, true, &blitSRV));
+ error = getSRVLevel(level, true, &blitSRV);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
@@ -1122,7 +1198,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
}
*outRT = mLevelZeroRenderTarget;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
if (mFormatInfo.rtvFormat != DXGI_FORMAT_UNKNOWN)
@@ -1183,7 +1259,7 @@ gl::Error TextureStorage11_2D::getRenderTarget(const gl::ImageIndex &index, Rend
SafeRelease(dsv);
*outRT = mRenderTarget[level];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2D::createSRV(int baseLevel,
@@ -1251,7 +1327,7 @@ gl::Error TextureStorage11_2D::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels;
desc.ArraySize = 1;
- desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat;
+ desc.Format = mFormatInfo.swizzle.texFormat;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
@@ -1283,13 +1359,16 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render
if (!mSwizzleRenderTargets[mipLevel])
{
ID3D11Resource *swizzleTexture = nullptr;
- ANGLE_TRY(getSwizzleTexture(&swizzleTexture));
+ gl::Error error = getSwizzleTexture(&swizzleTexture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat;
+ rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
@@ -1306,41 +1385,7 @@ gl::Error TextureStorage11_2D::getSwizzleRenderTarget(int mipLevel, ID3D11Render
}
*outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::NoError();
-}
-
-gl::Error TextureStorage11_2D::createDropStencilTexture()
-{
- if (mDropStencilTexture)
- {
- return gl::NoError();
- }
-
- D3D11_TEXTURE2D_DESC dropDesc = {};
- dropDesc.ArraySize = 1;
- dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL;
- dropDesc.CPUAccessFlags = 0;
- dropDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- dropDesc.Height = mTextureHeight;
- dropDesc.MipLevels = mMipLevels;
- dropDesc.MiscFlags = 0;
- dropDesc.SampleDesc.Count = 1;
- dropDesc.SampleDesc.Quality = 0;
- dropDesc.Usage = D3D11_USAGE_DEFAULT;
- dropDesc.Width = mTextureWidth;
-
- ID3D11Device *device = mRenderer->getDevice();
-
- HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture);
- if (FAILED(hr))
- {
- return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture.");
- }
- d3d11::SetDebugName(mDropStencilTexture, "TexStorage2D.DropStencil");
-
- ANGLE_TRY(initDropStencilTexture(gl::ImageIndexIterator::Make2D(0, mMipLevels)));
-
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
TextureStorage11_External::TextureStorage11_External(
@@ -1352,15 +1397,15 @@ TextureStorage11_External::TextureStorage11_External(
ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11TextureNV12);
StreamProducerNV12 *producer = static_cast<StreamProducerNV12 *>(stream->getImplementation());
mTexture = producer->getD3DTexture();
- mSubresourceIndex = producer->getArraySlice();
+ mSubresourceIndex = producer->getArraySlice();
mTexture->AddRef();
mMipLevels = 1;
D3D11_TEXTURE2D_DESC desc;
mTexture->GetDesc(&desc);
- mTextureWidth = desc.Width;
- mTextureHeight = desc.Height;
- mTextureDepth = 1;
+ mTextureWidth = desc.Width;
+ mTextureHeight = desc.Height;
+ mTextureDepth = 1;
mHasKeyedMutex = (desc.MiscFlags & D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX) != 0;
}
@@ -1504,10 +1549,10 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer,
{
mCurrentRenderTarget = reinterpret_cast<uintptr_t>(renderTarget11);
- mMipLevels = 1;
- mTextureWidth = renderTarget11->getWidth();
- mTextureHeight = renderTarget11->getHeight();
- mTextureDepth = 1;
+ mMipLevels = 1;
+ mTextureWidth = renderTarget11->getWidth();
+ mTextureHeight = renderTarget11->getHeight();
+ mTextureDepth = 1;
}
TextureStorage11_EGLImage::~TextureStorage11_EGLImage()
@@ -1549,8 +1594,13 @@ gl::Error TextureStorage11_EGLImage::getRenderTarget(const gl::ImageIndex &index
{
ASSERT(!index.hasLayer());
ASSERT(index.mipIndex == 0);
+ UNUSED_ASSERTION_VARIABLE(index);
- ANGLE_TRY(checkForUpdatedRenderTarget());
+ gl::Error error = checkForUpdatedRenderTarget();
+ if (error.isError())
+ {
+ return error;
+ }
return mImage->getRenderTarget(outRT);
}
@@ -1558,19 +1608,27 @@ gl::Error TextureStorage11_EGLImage::getRenderTarget(const gl::ImageIndex &index
gl::Error TextureStorage11_EGLImage::copyToStorage(TextureStorage *destStorage)
{
ID3D11Resource *sourceResouce = nullptr;
- ANGLE_TRY(getResource(&sourceResouce));
+ gl::Error error = getResource(&sourceResouce);
+ if (error.isError())
+ {
+ return error;
+ }
ASSERT(destStorage);
TextureStorage11_2D *dest11 = GetAs<TextureStorage11_2D>(destStorage);
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
immediateContext->CopyResource(destResource, sourceResouce);
- dest11->markDirty();
+ dest11->invalidateSwizzleCache();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
void TextureStorage11_EGLImage::associateImage(Image11 *, const gl::ImageIndex &)
@@ -1610,7 +1668,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleTexture(ID3D11Resource **outTextu
desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels;
desc.ArraySize = 1;
- desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat;
+ desc.Format = mFormatInfo.swizzle.texFormat;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
@@ -1643,13 +1701,16 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel,
if (!mSwizzleRenderTargets[mipLevel])
{
ID3D11Resource *swizzleTexture = nullptr;
- ANGLE_TRY(getSwizzleTexture(&swizzleTexture));
+ gl::Error error = getSwizzleTexture(&swizzleTexture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat;
+ rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
rtvDesc.Texture2D.MipSlice = mTopLevel + mipLevel;
@@ -1666,7 +1727,7 @@ gl::Error TextureStorage11_EGLImage::getSwizzleRenderTarget(int mipLevel,
}
*outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_EGLImage::checkForUpdatedRenderTarget()
@@ -1719,7 +1780,11 @@ gl::Error TextureStorage11_EGLImage::createSRV(int baseLevel,
else
{
RenderTarget11 *renderTarget = nullptr;
- ANGLE_TRY(getImageRenderTarget(&renderTarget));
+ gl::Error error = getImageRenderTarget(&renderTarget);
+ if (error.isError())
+ {
+ return error;
+ }
ASSERT(texture == renderTarget->getTexture());
@@ -1860,20 +1925,36 @@ gl::Error TextureStorage11_Cube::copyToStorage(TextureStorage *destStorage)
// corresponding textures in destStorage.
if (mTexture)
{
- ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(false));
+ gl::Error error = dest11->useLevelZeroWorkaroundTexture(false);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
immediateContext->CopyResource(destResource, mTexture);
}
if (mLevelZeroTexture)
{
- ANGLE_TRY(dest11->useLevelZeroWorkaroundTexture(true));
+ gl::Error error = dest11->useLevelZeroWorkaroundTexture(true);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
immediateContext->CopyResource(destResource, mLevelZeroTexture);
}
@@ -1881,18 +1962,26 @@ gl::Error TextureStorage11_Cube::copyToStorage(TextureStorage *destStorage)
else
{
ID3D11Resource *sourceResouce = nullptr;
- ANGLE_TRY(getResource(&sourceResouce));
+ gl::Error error = getResource(&sourceResouce);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Resource *destResource = nullptr;
- ANGLE_TRY(dest11->getResource(&destResource));
+ error = dest11->getResource(&destResource);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
immediateContext->CopyResource(destResource, sourceResouce);
}
- dest11->markDirty();
+ dest11->invalidateSwizzleCache();
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZeroTexture)
@@ -1901,7 +1990,11 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero
{
if (!mUseLevelZeroTexture && mTexture)
{
- ANGLE_TRY(ensureTextureExists(1));
+ gl::Error error = ensureTextureExists(1);
+ if (error.isError())
+ {
+ return error;
+ }
// Pull data back from the mipped texture if necessary.
ASSERT(mLevelZeroTexture);
@@ -1920,7 +2013,11 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero
{
if (mUseLevelZeroTexture && mLevelZeroTexture)
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
// Pull data back from the level zero texture if necessary.
ASSERT(mTexture);
@@ -1936,7 +2033,7 @@ gl::Error TextureStorage11_Cube::useLevelZeroWorkaroundTexture(bool useLevelZero
mUseLevelZeroTexture = false;
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
void TextureStorage11_Cube::associateImage(Image11 *image, const gl::ImageIndex &index)
@@ -2029,29 +2126,43 @@ gl::Error TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &in
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to nullptr too.
- ANGLE_TRY(
- mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage());
+ gl::Error error =
+ mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage();
+ if (error.isError())
+ {
+ return error;
+ }
}
}
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::getResource(ID3D11Resource **outResource)
{
if (mUseLevelZeroTexture && mMipLevels > 1)
{
- ANGLE_TRY(ensureTextureExists(1));
+ gl::Error error = ensureTextureExists(1);
+ if (error.isError())
+ {
+ return error;
+ }
+
*outResource = mLevelZeroTexture;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
else
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
+
*outResource = mTexture;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
}
@@ -2060,9 +2171,14 @@ gl::Error TextureStorage11_Cube::getMippedResource(ID3D11Resource **outResource)
// This shouldn't be called unless the zero max LOD workaround is active.
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ gl::Error error = ensureTextureExists(mMipLevels);
+ if (error.isError())
+ {
+ return error;
+ }
+
*outResource = mTexture;
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels)
@@ -2113,7 +2229,7 @@ gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels)
d3d11::SetDebugName(*outputTexture, "TexStorageCube.Texture");
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_Cube::createRenderTargetSRV(ID3D11Resource *texture,
@@ -2167,7 +2283,11 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
HRESULT result;
ID3D11Resource *texture = nullptr;
- ANGLE_TRY(getResource(&texture));
+ gl::Error error = getResource(&texture);
+ if (error.isError())
+ {
+ return error;
+ }
if (mUseLevelZeroTexture)
{
@@ -2206,12 +2326,15 @@ gl::Error TextureStorage11_Cube::getRenderTarget(const gl::ImageIndex &index,
}
ID3D11ShaderResourceView *srv = nullptr;
- ANGLE_TRY(createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv));
+ error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *blitSRV = nullptr;
if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{
- gl::Error error =
- createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
+ error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
if (error.isError())
{
SafeRelease(srv);
@@ -2319,8 +2442,8 @@ gl::Error TextureStorage11_Cube::createSRV(int baseLevel,
// Unnormalized integer cube maps are not supported by DX11; we emulate them as an array of six
// 2D textures
- const GLenum componentType = d3d11::GetComponentType(format);
- if (componentType == GL_INT || componentType == GL_UNSIGNED_INT)
+ const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(format);
+ if (dxgiFormatInfo.componentType == GL_INT || dxgiFormatInfo.componentType == GL_UNSIGNED_INT)
{
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
srvDesc.Texture2DArray.MostDetailedMip = mTopLevel + baseLevel;
@@ -2386,7 +2509,7 @@ gl::Error TextureStorage11_Cube::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels;
desc.ArraySize = CUBE_FACE_COUNT;
- desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat;
+ desc.Format = mFormatInfo.swizzle.texFormat;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
@@ -2419,13 +2542,16 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel,
if (!mSwizzleRenderTargets[mipLevel])
{
ID3D11Resource *swizzleTexture = nullptr;
- ANGLE_TRY(getSwizzleTexture(&swizzleTexture));
+ gl::Error error = getSwizzleTexture(&swizzleTexture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat;
+ rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = 0;
@@ -2444,67 +2570,7 @@ gl::Error TextureStorage11_Cube::getSwizzleRenderTarget(int mipLevel,
}
*outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::NoError();
-}
-
-gl::Error TextureStorage11::initDropStencilTexture(const gl::ImageIndexIterator &it)
-{
- ID3D11Resource *resource = nullptr;
- ANGLE_TRY(getResource(&resource));
- TextureHelper11 sourceTexture = TextureHelper11::MakeAndReference(resource, mFormatInfo);
- TextureHelper11 destTexture = TextureHelper11::MakeAndReference(
- mDropStencilTexture,
- d3d11::Format::Get(GL_DEPTH_COMPONENT32F, mRenderer->getRenderer11DeviceCaps()));
-
- gl::ImageIndexIterator itCopy = it;
-
- while (itCopy.hasNext())
- {
- gl::ImageIndex index = itCopy.next();
- gl::Box wholeArea(0, 0, 0, getLevelWidth(index.mipIndex), getLevelHeight(index.mipIndex),
- 1);
- gl::Extents wholeSize(wholeArea.width, wholeArea.height, 1);
- UINT subresource = getSubresourceIndex(index);
- ANGLE_TRY(mRenderer->getBlitter()->copyDepthStencil(sourceTexture, subresource, wholeArea,
- wholeSize, destTexture, subresource,
- wholeArea, wholeSize, nullptr));
- }
-
- return gl::NoError();
-}
-
-gl::Error TextureStorage11_Cube::createDropStencilTexture()
-{
- if (mDropStencilTexture)
- {
- return gl::NoError();
- }
-
- D3D11_TEXTURE2D_DESC dropDesc = {};
- dropDesc.ArraySize = 6;
- dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL;
- dropDesc.CPUAccessFlags = 0;
- dropDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- dropDesc.Height = mTextureHeight;
- dropDesc.MipLevels = mMipLevels;
- dropDesc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
- dropDesc.SampleDesc.Count = 1;
- dropDesc.SampleDesc.Quality = 0;
- dropDesc.Usage = D3D11_USAGE_DEFAULT;
- dropDesc.Width = mTextureWidth;
-
- ID3D11Device *device = mRenderer->getDevice();
-
- HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture);
- if (FAILED(hr))
- {
- return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture.");
- }
- d3d11::SetDebugName(mDropStencilTexture, "TexStorageCube.DropStencil");
-
- ANGLE_TRY(initDropStencilTexture(gl::ImageIndexIterator::MakeCube(0, mMipLevels)));
-
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
TextureStorage11_3D::TextureStorage11_3D(Renderer11 *renderer,
@@ -2647,12 +2713,16 @@ gl::Error TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &inde
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to nullptr too.
- ANGLE_TRY(mAssociatedImages[level]->recoverFromAssociatedStorage());
+ gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
+ if (error.isError())
+ {
+ return error;
+ }
}
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_3D::getResource(ID3D11Resource **outResource)
@@ -2740,13 +2810,25 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
if (!mLevelRenderTargets[mipLevel])
{
ID3D11Resource *texture = nullptr;
- ANGLE_TRY(getResource(&texture));
+ gl::Error error = getResource(&texture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *srv = nullptr;
- ANGLE_TRY(getSRVLevel(mipLevel, false, &srv));
+ error = getSRVLevel(mipLevel, false, &srv);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *blitSRV = nullptr;
- ANGLE_TRY(getSRVLevel(mipLevel, true, &blitSRV));
+ error = getSRVLevel(mipLevel, true, &blitSRV);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
@@ -2796,10 +2878,14 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
HRESULT result;
ID3D11Resource *texture = nullptr;
- ANGLE_TRY(getResource(&texture));
+ gl::Error error = getResource(&texture);
+ if (error.isError())
+ {
+ return error;
+ }
// TODO, what kind of SRV is expected here?
- ID3D11ShaderResourceView *srv = nullptr;
+ ID3D11ShaderResourceView *srv = nullptr;
ID3D11ShaderResourceView *blitSRV = nullptr;
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
@@ -2836,7 +2922,7 @@ gl::Error TextureStorage11_3D::getRenderTarget(const gl::ImageIndex &index, Rend
ASSERT(outRT);
*outRT = mLevelLayerRenderTargets[key];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
}
@@ -2853,7 +2939,7 @@ gl::Error TextureStorage11_3D::getSwizzleTexture(ID3D11Resource **outTexture)
desc.Height = mTextureHeight;
desc.Depth = mTextureDepth;
desc.MipLevels = mMipLevels;
- desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat;
+ desc.Format = mFormatInfo.swizzle.texFormat;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0;
@@ -2883,13 +2969,16 @@ gl::Error TextureStorage11_3D::getSwizzleRenderTarget(int mipLevel, ID3D11Render
if (!mSwizzleRenderTargets[mipLevel])
{
ID3D11Resource *swizzleTexture = nullptr;
- ANGLE_TRY(getSwizzleTexture(&swizzleTexture));
+ gl::Error error = getSwizzleTexture(&swizzleTexture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat;
+ rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
rtvDesc.Texture3D.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture3D.FirstWSlice = 0;
@@ -3052,12 +3141,16 @@ gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to nullptr too.
- ANGLE_TRY(mAssociatedImages[key]->recoverFromAssociatedStorage());
+ gl::Error error = mAssociatedImages[key]->recoverFromAssociatedStorage();
+ if (error.isError())
+ {
+ return error;
+ }
}
}
}
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2DArray::getResource(ID3D11Resource **outResource)
@@ -3180,14 +3273,21 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
HRESULT result;
ID3D11Resource *texture = nullptr;
- ANGLE_TRY(getResource(&texture));
+ gl::Error error = getResource(&texture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *srv;
- ANGLE_TRY(createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv));
+ error = createRenderTargetSRV(texture, index, mFormatInfo.srvFormat, &srv);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11ShaderResourceView *blitSRV;
if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{
- gl::Error error =
- createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
+ error = createRenderTargetSRV(texture, index, mFormatInfo.blitSRVFormat, &blitSRV);
if (error.isError())
{
SafeRelease(srv);
@@ -3275,7 +3375,7 @@ gl::Error TextureStorage11_2DArray::getRenderTarget(const gl::ImageIndex &index,
ASSERT(outRT);
*outRT = mRenderTargets[key];
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTexture)
@@ -3289,7 +3389,7 @@ gl::Error TextureStorage11_2DArray::getSwizzleTexture(ID3D11Resource **outTextur
desc.Height = mTextureHeight;
desc.MipLevels = mMipLevels;
desc.ArraySize = mTextureDepth;
- desc.Format = mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).texFormat;
+ desc.Format = mFormatInfo.swizzle.texFormat;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
@@ -3322,13 +3422,16 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel,
if (!mSwizzleRenderTargets[mipLevel])
{
ID3D11Resource *swizzleTexture = nullptr;
- ANGLE_TRY(getSwizzleTexture(&swizzleTexture));
+ gl::Error error = getSwizzleTexture(&swizzleTexture);
+ if (error.isError())
+ {
+ return error;
+ }
ID3D11Device *device = mRenderer->getDevice();
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
- rtvDesc.Format =
- mFormatInfo.getSwizzleFormat(mRenderer->getRenderer11DeviceCaps()).rtvFormat;
+ rtvDesc.Format = mFormatInfo.swizzle.rtvFormat;
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvDesc.Texture2DArray.MipSlice = mTopLevel + mipLevel;
rtvDesc.Texture2DArray.FirstArraySlice = 0;
@@ -3347,44 +3450,6 @@ gl::Error TextureStorage11_2DArray::getSwizzleRenderTarget(int mipLevel,
}
*outRTV = mSwizzleRenderTargets[mipLevel];
- return gl::NoError();
-}
-
-gl::Error TextureStorage11_2DArray::createDropStencilTexture()
-{
- if (mDropStencilTexture)
- {
- return gl::NoError();
- }
-
- D3D11_TEXTURE2D_DESC dropDesc = {};
- dropDesc.ArraySize = mTextureDepth;
- dropDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL;
- dropDesc.CPUAccessFlags = 0;
- dropDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- dropDesc.Height = mTextureHeight;
- dropDesc.MipLevels = mMipLevels;
- dropDesc.MiscFlags = 0;
- dropDesc.SampleDesc.Count = 1;
- dropDesc.SampleDesc.Quality = 0;
- dropDesc.Usage = D3D11_USAGE_DEFAULT;
- dropDesc.Width = mTextureWidth;
-
- ID3D11Device *device = mRenderer->getDevice();
-
- HRESULT hr = device->CreateTexture2D(&dropDesc, nullptr, &mDropStencilTexture);
- if (FAILED(hr))
- {
- return gl::Error(GL_INVALID_OPERATION, "Error creating drop stencil texture.");
- }
- d3d11::SetDebugName(mDropStencilTexture, "TexStorage2DArray.DropStencil");
-
- std::vector<GLsizei> layerCounts(mMipLevels, mTextureDepth);
-
- ANGLE_TRY(initDropStencilTexture(
- gl::ImageIndexIterator::Make2DArray(0, mMipLevels, layerCounts.data())));
-
- return gl::NoError();
+ return gl::Error(GL_NO_ERROR);
}
-
} // namespace rx