Skip to content

Commit b772a95

Browse files
ShabbyXCommit Bot
authored andcommitted
Vulkan: Make texture syncState aware of upcoming generateMipmap
By letting TextureVk::syncState know it's being called for generateMipmap, it can make a better decision to initialize the image: - Staged updates to mips that are going to be overwritten are dropped - The image is created with full mipchain to avoid a redefine in the following generateMipmap() call. Bug: angleproject:4551 Change-Id: Ic70ee6c0a0b29c7bd62beaff612b2f2d5276defb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2249340 Commit-Queue: Shahbaz Youssefi <[email protected]> Reviewed-by: Jamie Madill <[email protected]> Reviewed-by: Tim Van Patten <[email protected]>
1 parent 2919dc6 commit b772a95

File tree

19 files changed

+155
-82
lines changed

19 files changed

+155
-82
lines changed

src/libANGLE/State.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,7 @@ angle::Result State::syncTextures(const Context *context)
31323132
Texture *texture = mActiveTexturesCache[textureIndex];
31333133
if (texture && texture->hasAnyDirtyBit())
31343134
{
3135-
ANGLE_TRY(texture->syncState(context));
3135+
ANGLE_TRY(texture->syncState(context, TextureCommand::Other));
31363136
}
31373137
}
31383138

@@ -3150,7 +3150,7 @@ angle::Result State::syncImages(const Context *context)
31503150
Texture *texture = mImageUnits[imageUnitIndex].texture.get();
31513151
if (texture && texture->hasAnyDirtyBit())
31523152
{
3153-
ANGLE_TRY(texture->syncState(context));
3153+
ANGLE_TRY(texture->syncState(context, TextureCommand::Other));
31543154
}
31553155
}
31563156

@@ -3306,7 +3306,7 @@ angle::Result State::onProgramExecutableChange(const Context *context, Program *
33063306

33073307
if (image->hasAnyDirtyBit())
33083308
{
3309-
ANGLE_TRY(image->syncState(context));
3309+
ANGLE_TRY(image->syncState(context, TextureCommand::Other));
33103310
}
33113311

33123312
if (mRobustResourceInit && image->initState() == InitState::MayNeedInit)
@@ -3351,7 +3351,7 @@ angle::Result State::onProgramPipelineExecutableChange(const Context *context,
33513351

33523352
if (image->hasAnyDirtyBit())
33533353
{
3354-
ANGLE_TRY(image->syncState(context));
3354+
ANGLE_TRY(image->syncState(context, TextureCommand::Other));
33553355
}
33563356

33573357
if (mRobustResourceInit && image->initState() == InitState::MayNeedInit)

src/libANGLE/Texture.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,10 +1501,7 @@ angle::Result Texture::generateMipmap(Context *context)
15011501
return angle::Result::Continue;
15021502
}
15031503

1504-
if (hasAnyDirtyBit())
1505-
{
1506-
ANGLE_TRY(syncState(context));
1507-
}
1504+
ANGLE_TRY(syncState(context, TextureCommand::GenerateMipmap));
15081505

15091506
// Clear the base image(s) immediately if needed
15101507
if (context->isRobustResourceInitEnabled())
@@ -1526,7 +1523,7 @@ angle::Result Texture::generateMipmap(Context *context)
15261523

15271524
ANGLE_TRY(mTexture->generateMipmap(context));
15281525

1529-
// Propagate the format and size of the bsae mip to the smaller ones. Cube maps are guaranteed
1526+
// Propagate the format and size of the base mip to the smaller ones. Cube maps are guaranteed
15301527
// to have faces of the same size and format so any faces can be picked.
15311528
const ImageDesc &baseImageInfo = mState.getImageDesc(mState.getBaseImageTarget(), baseLevel);
15321529
mState.setImageDescChain(baseLevel, maxLevel, baseImageInfo.size, baseImageInfo.format,
@@ -1787,10 +1784,10 @@ GLuint Texture::getNativeID() const
17871784
return mTexture->getNativeID();
17881785
}
17891786

1790-
angle::Result Texture::syncState(const Context *context)
1787+
angle::Result Texture::syncState(const Context *context, TextureCommand source)
17911788
{
1792-
ASSERT(hasAnyDirtyBit());
1793-
ANGLE_TRY(mTexture->syncState(context, mDirtyBits));
1789+
ASSERT(hasAnyDirtyBit() || source == TextureCommand::GenerateMipmap);
1790+
ANGLE_TRY(mTexture->syncState(context, mDirtyBits, source));
17941791
mDirtyBits.reset();
17951792
return angle::Result::Continue;
17961793
}
@@ -2006,7 +2003,7 @@ angle::Result Texture::getTexImage(const Context *context,
20062003
{
20072004
if (hasAnyDirtyBit())
20082005
{
2009-
ANGLE_TRY(syncState(context));
2006+
ANGLE_TRY(syncState(context, TextureCommand::Other));
20102007
}
20112008

20122009
return mTexture->getTexImage(context, packState, packBuffer, target, level, format, type,

src/libANGLE/Texture.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ struct ContextBindingCount
9999
uint32_t imageBindingCount;
100100
};
101101

102+
// The source of the syncState call. Knowing why syncState is being called can help the back-end
103+
// make more-informed decisions.
104+
enum class TextureCommand
105+
{
106+
GenerateMipmap,
107+
Other,
108+
};
109+
102110
// State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec.
103111
class TextureState final : private angle::NonCopyable
104112
{
@@ -580,7 +588,7 @@ class Texture final : public RefCountObject<TextureID>,
580588
};
581589
using DirtyBits = angle::BitSet<DIRTY_BIT_COUNT>;
582590

583-
angle::Result syncState(const Context *context);
591+
angle::Result syncState(const Context *context, TextureCommand source);
584592
bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
585593

586594
// ObserverInterface implementation.

src/libANGLE/renderer/TextureImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
187187
virtual GLint getNativeID() const;
188188

189189
virtual angle::Result syncState(const gl::Context *context,
190-
const gl::Texture::DirtyBits &dirtyBits) = 0;
190+
const gl::Texture::DirtyBits &dirtyBits,
191+
gl::TextureCommand source) = 0;
191192

192193
virtual GLenum getColorReadFormat(const gl::Context *context);
193194
virtual GLenum getColorReadType(const gl::Context *context);

src/libANGLE/renderer/TextureImpl_mock.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class MockTextureImpl : public TextureImpl
129129

130130
MOCK_METHOD2(setBaseLevel, angle::Result(const gl::Context *, GLuint));
131131

132-
MOCK_METHOD2(syncState, angle::Result(const gl::Context *, const gl::Texture::DirtyBits &));
132+
MOCK_METHOD3(syncState,
133+
angle::Result(const gl::Context *,
134+
const gl::Texture::DirtyBits &,
135+
gl::TextureCommand source));
133136

134137
MOCK_METHOD0(destructor, void());
135138

src/libANGLE/renderer/d3d/TextureD3D.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,8 @@ angle::Result TextureD3D::setBaseLevel(const gl::Context *context, GLuint baseLe
681681
}
682682

683683
angle::Result TextureD3D::syncState(const gl::Context *context,
684-
const gl::Texture::DirtyBits &dirtyBits)
684+
const gl::Texture::DirtyBits &dirtyBits,
685+
gl::TextureCommand source)
685686
{
686687
// This could be improved using dirty bits.
687688
return angle::Result::Continue;

src/libANGLE/renderer/d3d/TextureD3D.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class TextureD3D : public TextureImpl, public angle::ObserverInterface
107107
angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) override;
108108

109109
angle::Result syncState(const gl::Context *context,
110-
const gl::Texture::DirtyBits &dirtyBits) override;
110+
const gl::Texture::DirtyBits &dirtyBits,
111+
gl::TextureCommand source) override;
111112

112113
angle::Result initializeContents(const gl::Context *context,
113114
const gl::ImageIndex &imageIndex) override;

src/libANGLE/renderer/gl/TextureGL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,8 @@ GLint TextureGL::getNativeID() const
13821382
}
13831383

13841384
angle::Result TextureGL::syncState(const gl::Context *context,
1385-
const gl::Texture::DirtyBits &dirtyBits)
1385+
const gl::Texture::DirtyBits &dirtyBits,
1386+
gl::TextureCommand source)
13861387
{
13871388
if (dirtyBits.none() && mLocalDirtyBits.none())
13881389
{

src/libANGLE/renderer/gl/TextureGL.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class TextureGL : public TextureImpl
190190
gl::TextureType getType() const;
191191

192192
angle::Result syncState(const gl::Context *context,
193-
const gl::Texture::DirtyBits &dirtyBits) override;
193+
const gl::Texture::DirtyBits &dirtyBits,
194+
gl::TextureCommand source) override;
194195
bool hasAnyDirtyBit() const;
195196

196197
angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) override;

src/libANGLE/renderer/metal/TextureMtl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ class TextureMtl : public TextureImpl
131131
FramebufferAttachmentRenderTarget **rtOut) override;
132132

133133
angle::Result syncState(const gl::Context *context,
134-
const gl::Texture::DirtyBits &dirtyBits) override;
134+
const gl::Texture::DirtyBits &dirtyBits,
135+
gl::TextureCommand source) override;
135136

136137
angle::Result setStorageMultisample(const gl::Context *context,
137138
gl::TextureType type,

0 commit comments

Comments
 (0)