Commit a59fc19f by Jamie Madill Committed by Commit Bot

Use active textures mask with robust init.

This should speed up clearUnclearedActiveTextures considerably. It was showing up as a hotspot when running the aquarium demo with the passthrough command decoder. Also rename the complete textures mask in gl::State to an active textures mask, since it includes incomplete textures. BUG=angleproject:2188 Change-Id: Idf020fc49c1e74f17a8005c3b88516829767b84c Reviewed-on: https://chromium-review.googlesource.com/722421Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6a89d227
...@@ -2838,8 +2838,13 @@ void Context::initWorkarounds() ...@@ -2838,8 +2838,13 @@ void Context::initWorkarounds()
Error Context::prepareForDraw() Error Context::prepareForDraw()
{ {
syncRendererState(); syncRendererState();
ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this));
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureDrawAttachmentsInitialized(this)); if (isRobustResourceInitEnabled())
{
ANGLE_TRY(mGLState.clearUnclearedActiveTextures(this));
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureDrawAttachmentsInitialized(this));
}
return NoError(); return NoError();
} }
...@@ -4283,7 +4288,10 @@ void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGr ...@@ -4283,7 +4288,10 @@ void Context::dispatchCompute(GLuint numGroupsX, GLuint numGroupsY, GLuint numGr
} }
// TODO(jmadill): Dirty bits for compute. // TODO(jmadill): Dirty bits for compute.
ANGLE_CONTEXT_TRY(mGLState.clearUnclearedActiveTextures(this)); if (isRobustResourceInitEnabled())
{
ANGLE_CONTEXT_TRY(mGLState.clearUnclearedActiveTextures(this));
}
handleError(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ)); handleError(mImplementation->dispatchCompute(this, numGroupsX, numGroupsY, numGroupsZ));
} }
......
...@@ -2299,8 +2299,8 @@ void State::syncProgramTextures(const Context *context) ...@@ -2299,8 +2299,8 @@ void State::syncProgramTextures(const Context *context)
// Bind the texture unconditionally, to recieve completeness change notifications. // Bind the texture unconditionally, to recieve completeness change notifications.
mCompleteTextureBindings[textureUnitIndex].bind(texture->getDirtyChannel()); mCompleteTextureBindings[textureUnitIndex].bind(texture->getDirtyChannel());
mActiveTexturesMask.set(textureUnitIndex);
newActiveTextures.set(textureUnitIndex); newActiveTextures.set(textureUnitIndex);
mCompleteTexturesMask.set(textureUnitIndex);
if (sampler != nullptr) if (sampler != nullptr)
{ {
...@@ -2310,14 +2310,14 @@ void State::syncProgramTextures(const Context *context) ...@@ -2310,14 +2310,14 @@ void State::syncProgramTextures(const Context *context)
} }
// Unset now missing textures. // Unset now missing textures.
ActiveTextureMask negativeMask = mCompleteTexturesMask & ~newActiveTextures; ActiveTextureMask negativeMask = mActiveTexturesMask & ~newActiveTextures;
if (negativeMask.any()) if (negativeMask.any())
{ {
for (auto textureIndex : negativeMask) for (auto textureIndex : negativeMask)
{ {
mCompleteTextureBindings[textureIndex].reset(); mCompleteTextureBindings[textureIndex].reset();
mCompleteTextureCache[textureIndex] = nullptr; mCompleteTextureCache[textureIndex] = nullptr;
mCompleteTexturesMask.reset(textureIndex); mActiveTexturesMask.reset(textureIndex);
} }
} }
} }
...@@ -2422,19 +2422,17 @@ void State::signal(size_t textureIndex, InitState initState) ...@@ -2422,19 +2422,17 @@ void State::signal(size_t textureIndex, InitState initState)
Error State::clearUnclearedActiveTextures(const Context *context) Error State::clearUnclearedActiveTextures(const Context *context)
{ {
if (!mRobustResourceInit) ASSERT(mRobustResourceInit);
{
return NoError();
}
// TODO(jmadill): Investigate improving the speed here. for (auto textureIndex : mActiveTexturesMask)
for (Texture *texture : mCompleteTextureCache)
{ {
Texture *texture = mCompleteTextureCache[textureIndex];
if (texture) if (texture)
{ {
ANGLE_TRY(texture->ensureInitialized(context)); ANGLE_TRY(texture->ensureInitialized(context));
} }
} }
return NoError(); return NoError();
} }
......
...@@ -573,7 +573,7 @@ class State : public OnAttachmentDirtyReceiver, angle::NonCopyable ...@@ -573,7 +573,7 @@ class State : public OnAttachmentDirtyReceiver, angle::NonCopyable
std::vector<Texture *> mCompleteTextureCache; std::vector<Texture *> mCompleteTextureCache;
std::vector<OnAttachmentDirtyBinding> mCompleteTextureBindings; std::vector<OnAttachmentDirtyBinding> mCompleteTextureBindings;
using ActiveTextureMask = angle::BitSet<IMPLEMENTATION_MAX_ACTIVE_TEXTURES>; using ActiveTextureMask = angle::BitSet<IMPLEMENTATION_MAX_ACTIVE_TEXTURES>;
ActiveTextureMask mCompleteTexturesMask; ActiveTextureMask mActiveTexturesMask;
typedef std::vector<BindingPointer<Sampler>> SamplerBindingVector; typedef std::vector<BindingPointer<Sampler>> SamplerBindingVector;
SamplerBindingVector mSamplers; SamplerBindingVector mSamplers;
......
...@@ -103,14 +103,14 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D) ...@@ -103,14 +103,14 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D)
// Should be complete - expect red. // Should be complete - expect red.
drawQuad(mProgram, "position", 0.5f); drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red) << "complete texture should be red";
// Make texture incomplete. // Make texture incomplete.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
// Should be incomplete - expect black. // Should be incomplete - expect black.
drawQuad(mProgram, "position", 0.5f); drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black) << "incomplete texture should be black";
// Make texture complete by defining the second mip. // Make texture complete by defining the second mip.
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, kTextureSize >> 1, kTextureSize >> 1, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, kTextureSize >> 1, kTextureSize >> 1, 0, GL_RGBA,
...@@ -118,7 +118,7 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D) ...@@ -118,7 +118,7 @@ TEST_P(IncompleteTextureTest, IncompleteTexture2D)
// Should be complete - expect red. // Should be complete - expect red.
drawQuad(mProgram, "position", 0.5f); drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red) << "mip-complete texture should be red";
} }
// Tests redefining a texture with half the size works as expected. // Tests redefining a texture with half the size works as expected.
......
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