Commit dea2777c by Jamie Madill Committed by Commit Bot

D3D11: Rename TextureStorage swizzle invalidation.

Since we'll also be storing a cache of depth textures as well as swizzle info, generalize the invalidation methods. BUG=angleproject:1493 BUG=chromium:638323 Change-Id: I8fef049b01c81483fcf28196866a22d5cfed32a1 Reviewed-on: https://chromium-review.googlesource.com/380036Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 96f4f45e
......@@ -29,7 +29,7 @@ namespace rx
namespace
{
gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *attachment)
gl::Error MarkAttachmentsDirty(const gl::FramebufferAttachment *attachment)
{
if (attachment && attachment->type() == GL_TEXTURE)
{
......@@ -45,7 +45,7 @@ gl::Error InvalidateAttachmentSwizzles(const gl::FramebufferAttachment *attachme
TextureStorage11 *texStorage11 = GetAs<TextureStorage11>(texStorage);
ASSERT(texStorage11);
texStorage11->invalidateSwizzleCacheLevel(attachment->mipLevel());
texStorage11->markLevelDirty(attachment->mipLevel());
}
}
......@@ -89,18 +89,18 @@ Framebuffer11::~Framebuffer11()
{
}
gl::Error Framebuffer11::invalidateSwizzles() const
gl::Error Framebuffer11::markAttachmentsDirty() const
{
for (const auto &colorAttachment : mState.getColorAttachments())
{
if (colorAttachment.isAttached())
{
ANGLE_TRY(InvalidateAttachmentSwizzles(&colorAttachment));
ANGLE_TRY(MarkAttachmentsDirty(&colorAttachment));
}
}
ANGLE_TRY(InvalidateAttachmentSwizzles(mState.getDepthAttachment()));
ANGLE_TRY(InvalidateAttachmentSwizzles(mState.getStencilAttachment()));
ANGLE_TRY(MarkAttachmentsDirty(mState.getDepthAttachment()));
ANGLE_TRY(MarkAttachmentsDirty(mState.getStencilAttachment()));
return gl::NoError();
}
......@@ -128,7 +128,7 @@ gl::Error Framebuffer11::clearImpl(ContextImpl *context, const ClearParameters &
ANGLE_TRY(clearer->clearFramebuffer(clearParams, mState));
}
ANGLE_TRY(invalidateSwizzles());
ANGLE_TRY(markAttachmentsDirty());
return gl::NoError();
}
......@@ -351,7 +351,7 @@ gl::Error Framebuffer11::blitImpl(const gl::Rectangle &sourceArea,
blitDepth, blitStencil));
}
ANGLE_TRY(invalidateSwizzles());
ANGLE_TRY(markAttachmentsDirty());
return gl::NoError();
}
......
......@@ -28,7 +28,7 @@ class Framebuffer11 : public FramebufferD3D, public angle::SignalReceiver
gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override;
// Invalidate the cached swizzles of all bound texture attachments.
gl::Error invalidateSwizzles() const;
gl::Error markAttachmentsDirty() const;
void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override;
......
......@@ -2934,7 +2934,7 @@ gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer,
ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget));
storage11->invalidateSwizzleCacheLevel(level);
storage11->markLevelDirty(level);
return gl::NoError();
}
......@@ -2952,7 +2952,7 @@ gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl
ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget));
storage11->invalidateSwizzleCacheLevel(level);
storage11->markLevelDirty(level);
return gl::NoError();
}
......@@ -2970,7 +2970,7 @@ gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::
ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget));
storage11->invalidateSwizzleCacheLevel(level);
storage11->markLevelDirty(level);
return gl::NoError();
}
......@@ -2987,7 +2987,7 @@ gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const
ASSERT(destRenderTarget);
ANGLE_TRY(copyImageInternal(framebuffer, sourceRect, destFormat, destOffset, destRenderTarget));
storage11->invalidateSwizzleCacheLevel(level);
storage11->markLevelDirty(level);
return gl::NoError();
}
......@@ -3077,7 +3077,7 @@ gl::Error Renderer11::copyTexture(const gl::Texture *source,
unpackUnmultiplyAlpha));
}
destStorage11->invalidateSwizzleCacheLevel(destLevel);
destStorage11->markLevelDirty(destLevel);
return gl::Error(GL_NO_ERROR);
}
......
......@@ -492,16 +492,11 @@ gl::Error StateManager11::setBlendState(const gl::Framebuffer *framebuffer,
{
if (!mBlendStateIsDirty && sampleMask == mCurSampleMask)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
ID3D11BlendState *dxBlendState = nullptr;
gl::Error error =
mRenderer->getStateCache().getBlendState(framebuffer, blendState, &dxBlendState);
if (error.isError())
{
return error;
}
ANGLE_TRY(mRenderer->getStateCache().getBlendState(framebuffer, blendState, &dxBlendState));
ASSERT(dxBlendState != nullptr);
......@@ -532,7 +527,7 @@ gl::Error StateManager11::setBlendState(const gl::Framebuffer *framebuffer,
mBlendStateIsDirty = false;
return error;
return gl::NoError();
}
gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
......@@ -552,7 +547,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
disableDepth == mCurDisableDepth.value() && mCurDisableStencil.valid() &&
disableStencil == mCurDisableStencil.value())
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
const auto &depthStencilState = glState.getDepthStencilState();
......@@ -572,12 +567,8 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
(depthStencilState.stencilBackMask & maxStencil));
ID3D11DepthStencilState *dxDepthStencilState = NULL;
gl::Error error = mRenderer->getStateCache().getDepthStencilState(
depthStencilState, disableDepth, disableStencil, &dxDepthStencilState);
if (error.isError())
{
return error;
}
ANGLE_TRY(mRenderer->getStateCache().getDepthStencilState(
depthStencilState, disableDepth, disableStencil, &dxDepthStencilState));
ASSERT(dxDepthStencilState);
......@@ -601,7 +592,7 @@ gl::Error StateManager11::setDepthStencilState(const gl::State &glState)
mDepthStencilStateIsDirty = false;
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterState)
......@@ -610,11 +601,10 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt
if (!mRasterizerStateIsDirty && rasterState.pointDrawMode == mCurRasterState.pointDrawMode &&
rasterState.multiSample == mCurRasterState.multiSample)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
ID3D11RasterizerState *dxRasterState = nullptr;
gl::Error error(GL_NO_ERROR);
if (mCurPresentPathFastEnabled)
{
......@@ -633,18 +623,13 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt
modifiedRasterState.frontFace = GL_CCW;
}
error = mRenderer->getStateCache().getRasterizerState(modifiedRasterState,
mCurScissorEnabled, &dxRasterState);
ANGLE_TRY(mRenderer->getStateCache().getRasterizerState(
modifiedRasterState, mCurScissorEnabled, &dxRasterState));
}
else
{
error = mRenderer->getStateCache().getRasterizerState(rasterState, mCurScissorEnabled,
&dxRasterState);
}
if (error.isError())
{
return error;
ANGLE_TRY(mRenderer->getStateCache().getRasterizerState(rasterState, mCurScissorEnabled,
&dxRasterState));
}
mRenderer->getDeviceContext()->RSSetState(dxRasterState);
......@@ -652,7 +637,7 @@ gl::Error StateManager11::setRasterizerState(const gl::RasterizerState &rasterSt
mCurRasterState = rasterState;
mRasterizerStateIsDirty = false;
return error;
return gl::NoError();
}
void StateManager11::setScissorRectangle(const gl::Rectangle &scissor, bool enabled)
......@@ -867,7 +852,7 @@ gl::Error StateManager11::onMakeCurrent(const gl::ContextState &data)
}
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void StateManager11::setShaderResource(gl::SamplerType shaderType,
......@@ -901,7 +886,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
{
if (rangeStart == rangeEnd)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
auto &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
......@@ -911,7 +896,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
if (clearRange.empty())
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
auto deviceContext = mRenderer->getDeviceContext();
......@@ -933,7 +918,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
currentSRVs.update(samplerIndex, nullptr);
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
void StateManager11::unsetConflictingSRVs(gl::SamplerType samplerType,
......@@ -989,11 +974,7 @@ void StateManager11::deinitialize()
gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer)
{
Framebuffer11 *framebuffer11 = GetImplAs<Framebuffer11>(framebuffer);
gl::Error error = framebuffer11->invalidateSwizzles();
if (error.isError())
{
return error;
}
ANGLE_TRY(framebuffer11->markAttachmentsDirty());
if (framebuffer11->hasAnyInternalDirtyBit())
{
......@@ -1003,7 +984,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer)
if (!mRenderTargetIsDirty)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
mRenderTargetIsDirty = false;
......@@ -1017,7 +998,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer)
const gl::Extents &size = framebuffer->getFirstColorbuffer()->getSize();
if (size.width == 0 || size.height == 0)
{
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
}
......@@ -1101,7 +1082,7 @@ gl::Error StateManager11::syncFramebuffer(gl::Framebuffer *framebuffer)
setViewportBounds(renderTargetWidth, renderTargetHeight);
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state,
......@@ -1124,15 +1105,11 @@ gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state,
currentValueAttrib->currentValueType = currentValue.Type;
currentValueAttrib->attribute = &vertexAttributes[attribIndex];
gl::Error error = vertexDataManager->storeCurrentValue(currentValue, currentValueAttrib,
static_cast<size_t>(attribIndex));
if (error.isError())
{
return error;
}
ANGLE_TRY(vertexDataManager->storeCurrentValue(currentValue, currentValueAttrib,
static_cast<size_t>(attribIndex)));
}
return gl::Error(GL_NO_ERROR);
return gl::NoError();
}
const std::vector<TranslatedAttribute> &StateManager11::getCurrentValueAttribs() const
......
......@@ -368,7 +368,7 @@ gl::Error TextureStorage11::generateSwizzles(const gl::SwizzleState &swizzleTarg
return gl::Error(GL_NO_ERROR);
}
void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel)
void TextureStorage11::markLevelDirty(int mipLevel)
{
if (mipLevel >= 0 && static_cast<unsigned int>(mipLevel) < ArraySize(mSwizzleCache))
{
......@@ -378,11 +378,11 @@ void TextureStorage11::invalidateSwizzleCacheLevel(int mipLevel)
}
}
void TextureStorage11::invalidateSwizzleCache()
void TextureStorage11::markDirty()
{
for (unsigned int mipLevel = 0; mipLevel < ArraySize(mSwizzleCache); mipLevel++)
{
invalidateSwizzleCacheLevel(mipLevel);
markLevelDirty(mipLevel);
}
}
......@@ -395,7 +395,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture,
const GLint level = index.mipIndex;
invalidateSwizzleCacheLevel(level);
markLevelDirty(level);
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
......@@ -511,7 +511,7 @@ gl::Error TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex,
{
ASSERT(sourceIndex.layerIndex == destIndex.layerIndex);
invalidateSwizzleCacheLevel(destIndex.mipIndex);
markLevelDirty(destIndex.mipIndex);
RenderTargetD3D *source = nullptr;
gl::Error error = getRenderTarget(sourceIndex, &source);
......@@ -554,7 +554,7 @@ void TextureStorage11::verifySwizzleExists(const gl::SwizzleState &swizzleState)
void TextureStorage11::clearSRVCache()
{
invalidateSwizzleCache();
markDirty();
auto iter = mSrvCache.begin();
while (iter != mSrvCache.end())
......@@ -599,7 +599,7 @@ gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage)
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
immediateContext->CopyResource(destResource, sourceResouce);
dest11->invalidateSwizzleCache();
dest11->markDirty();
return gl::Error(GL_NO_ERROR);
}
......@@ -613,7 +613,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
{
ASSERT(!image->isDirty());
invalidateSwizzleCacheLevel(index.mipIndex);
markLevelDirty(index.mipIndex);
ID3D11Resource *resource = nullptr;
ANGLE_TRY(getResource(&resource));
......@@ -884,7 +884,7 @@ gl::Error TextureStorage11_2D::copyToStorage(TextureStorage *destStorage)
}
immediateContext->CopyResource(destResource, sourceResouce);
dest11->invalidateSwizzleCache();
dest11->markDirty();
}
return gl::Error(GL_NO_ERROR);
......@@ -1628,7 +1628,7 @@ gl::Error TextureStorage11_EGLImage::copyToStorage(TextureStorage *destStorage)
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
immediateContext->CopyResource(destResource, sourceResouce);
dest11->invalidateSwizzleCache();
dest11->markDirty();
return gl::Error(GL_NO_ERROR);
}
......@@ -1981,7 +1981,7 @@ gl::Error TextureStorage11_Cube::copyToStorage(TextureStorage *destStorage)
immediateContext->CopyResource(destResource, sourceResouce);
}
dest11->invalidateSwizzleCache();
dest11->markDirty();
return gl::Error(GL_NO_ERROR);
}
......
......@@ -59,8 +59,8 @@ class TextureStorage11 : public TextureStorage
virtual UINT getSubresourceIndex(const gl::ImageIndex &index) const;
gl::Error generateSwizzles(const gl::SwizzleState &swizzleTarget);
void invalidateSwizzleCacheLevel(int mipLevel);
void invalidateSwizzleCache();
void markLevelDirty(int mipLevel);
void markDirty();
gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource,
const gl::ImageIndex &index, const gl::Box &copyArea);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment