Commit eb335950 by Jamie Madill Committed by Commit Bot

D3D11: Only update swizzles after a state change.

Triggers the swizzle update whenever a new texture is bound, or when a subImage call triggers a swizzle cache update. BUG=angleproject:1387 Change-Id: Ia2a82126a621d8a643f715ea7e4a9c35b97e0a18 Reviewed-on: https://chromium-review.googlesource.com/648729 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent af4ffe0a
......@@ -338,6 +338,7 @@ StateManager11::StateManager11(Renderer11 *renderer)
mInputLayoutIsDirty(false),
mDirtyVertexBufferRange(gl::MAX_VERTEX_ATTRIBS, 0),
mCurrentPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_UNDEFINED),
mDirtySwizzles(false),
mAppliedIB(nullptr),
mAppliedIBFormat(DXGI_FORMAT_UNKNOWN),
mAppliedIBOffset(0),
......@@ -1195,6 +1196,12 @@ void StateManager11::invalidateViewport(const gl::Context *context)
void StateManager11::invalidateTexturesAndSamplers()
{
mInternalDirtyBits.set(DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE);
mDirtySwizzles = true;
}
void StateManager11::invalidateSwizzles()
{
mDirtySwizzles = true;
}
void StateManager11::setOneTimeRenderTarget(const gl::Context *context,
......@@ -1600,8 +1607,12 @@ gl::Error StateManager11::updateState(const gl::Context *context, GLenum drawMod
invalidateTexturesAndSamplers();
}
// TODO(jmadill): Use dirty bits.
ANGLE_TRY(generateSwizzles(context));
// Swizzling can cause internal state changes with blit shaders.
if (mDirtySwizzles)
{
ANGLE_TRY(generateSwizzles(context));
mDirtySwizzles = false;
}
// TODO(jmadill): Use dirty bits.
ANGLE_TRY(syncProgram(context, drawMode));
......@@ -1658,6 +1669,7 @@ gl::Error StateManager11::updateState(const gl::Context *context, GLenum drawMod
ANGLE_TRY(syncDepthStencilState(glState));
break;
case DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE:
// TODO(jmadill): More fine-grained update.
ANGLE_TRY(syncTextures(context));
break;
default:
......
......@@ -151,6 +151,7 @@ class StateManager11 final : angle::NonCopyable
void invalidateEverything(const gl::Context *context);
void invalidateViewport(const gl::Context *context);
void invalidateTexturesAndSamplers();
void invalidateSwizzles();
// Called from VertexArray11::updateVertexAttribStorage.
void invalidateCurrentValueAttrib(size_t attribIndex);
......@@ -409,6 +410,9 @@ class StateManager11 final : angle::NonCopyable
SamplerMetadata11 mSamplerMetadataPS;
SamplerMetadata11 mSamplerMetadataCS;
// Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass.
bool mDirtySwizzles;
// Currently applied index buffer
ID3D11Buffer *mAppliedIB;
DXGI_FORMAT mAppliedIBFormat;
......
......@@ -378,7 +378,12 @@ void TextureStorage11::markLevelDirty(int mipLevel)
{
// The default constructor of SwizzleState has GL_INVALID_INDEX for all channels which is
// not a valid swizzle combination
mSwizzleCache[mipLevel] = gl::SwizzleState();
if (mSwizzleCache[mipLevel] != gl::SwizzleState())
{
// TODO(jmadill): Invalidate specific swizzle.
mRenderer->getStateManager()->invalidateSwizzles();
mSwizzleCache[mipLevel] = gl::SwizzleState();
}
}
if (mDropStencilTexture.valid())
......
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