Skip to content

Commit

Permalink
Inline more tiny functions on hot path
Browse files Browse the repository at this point in the history
Similar to https://crrev.com/c/6094283, not as hot but broader.

Highlighted by PGO profile of driver_overhead_2 trace combined with size
and offset of the corresponding .so sections to maximize reduction in
TLB misses.
Improves driver_overhead_2 performance by 1~2% on Pixel 8. Almost no
change in .so size as functions are tiny.

Bug: b/383305597
Change-Id: Ib1c021d4635141b879667b59305e4d45de7b8aef
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6088958
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Commit-Queue: Roman Lavrov <romanl@google.com>
  • Loading branch information
romanl-g authored and Angle LUCI CQ committed Dec 17, 2024
1 parent 1c096a8 commit 87d891d
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 102 deletions.
16 changes: 0 additions & 16 deletions src/libANGLE/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10415,22 +10415,6 @@ void StateCache::updateVertexElementLimitsImpl(Context *context)
}
}

void StateCache::updateBasicDrawStatesError()
{
mCachedBasicDrawStatesErrorString = kInvalidPointer;
mCachedBasicDrawStatesErrorCode = GL_NO_ERROR;
}

void StateCache::updateProgramPipelineError()
{
mCachedProgramPipelineError = kInvalidPointer;
}

void StateCache::updateBasicDrawElementsError()
{
mCachedBasicDrawElementsError = kInvalidPointer;
}

intptr_t StateCache::getBasicDrawStatesErrorImpl(const Context *context,
const PrivateStateCache *privateStateCache) const
{
Expand Down
10 changes: 7 additions & 3 deletions src/libANGLE/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,13 @@ class StateCache final : angle::NonCopyable
void updateValidDrawModes(Context *context);
void updateValidBindTextureTypes(Context *context);
void updateValidDrawElementsTypes(Context *context);
void updateBasicDrawStatesError();
void updateProgramPipelineError();
void updateBasicDrawElementsError();
void updateBasicDrawStatesError()
{
mCachedBasicDrawStatesErrorString = kInvalidPointer;
mCachedBasicDrawStatesErrorCode = GL_NO_ERROR;
}
void updateProgramPipelineError() { mCachedProgramPipelineError = kInvalidPointer; }
void updateBasicDrawElementsError() { mCachedBasicDrawElementsError = kInvalidPointer; }
void updateTransformFeedbackActiveUnpaused(Context *context);
void updateVertexAttribTypesValidation(Context *context);
void updateActiveShaderStorageBufferIndices(Context *context);
Expand Down
20 changes: 0 additions & 20 deletions src/libANGLE/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,6 @@ bool HasSupportedStencilBitCount(const Framebuffer *framebuffer)

} // anonymous namespace

bool FramebufferStatus::isComplete() const
{
return status == GL_FRAMEBUFFER_COMPLETE;
}

FramebufferStatus FramebufferStatus::Complete()
{
FramebufferStatus result;
Expand Down Expand Up @@ -804,11 +799,6 @@ Extents FramebufferState::getExtents() const
return Extents(getDefaultWidth(), getDefaultHeight(), 0);
}

bool FramebufferState::isDefault() const
{
return mId == Framebuffer::kDefaultDrawFramebufferHandle;
}

bool FramebufferState::isBoundAsDrawFramebuffer(const Context *context) const
{
return context->getState().getDrawFramebuffer()->id() == mId;
Expand Down Expand Up @@ -1218,11 +1208,6 @@ ComponentTypeMask Framebuffer::getDrawBufferTypeMask() const
return mState.mDrawBufferTypeMask;
}

DrawBufferMask Framebuffer::getDrawBufferMask() const
{
return mState.mEnabledDrawBuffers;
}

bool Framebuffer::hasEnabledDrawBuffer() const
{
for (size_t drawbufferIdx = 0; drawbufferIdx < mState.mDrawBufferStates.size(); ++drawbufferIdx)
Expand Down Expand Up @@ -2697,11 +2682,6 @@ Extents Framebuffer::getExtents() const
return mState.getExtents();
}

bool Framebuffer::isFoveationEnabled() const
{
return (mState.mFoveationState.getFoveatedFeatureBits() & GL_FOVEATION_ENABLE_BIT_QCOM);
}

GLuint Framebuffer::getFoveatedFeatureBits() const
{
return mState.mFoveationState.getFoveatedFeatureBits();
Expand Down
14 changes: 11 additions & 3 deletions src/libANGLE/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TextureCapsMap;

struct FramebufferStatus
{
bool isComplete() const;
bool isComplete() const { return status == GL_FRAMEBUFFER_COMPLETE; }

static FramebufferStatus Complete();
static FramebufferStatus Incomplete(GLenum status, const char *reason);
Expand Down Expand Up @@ -280,7 +280,7 @@ class Framebuffer final : public angle::ObserverInterface,
const FramebufferAttachment *getDrawBuffer(size_t drawBuffer) const;
ComponentType getDrawbufferWriteType(size_t drawBuffer) const;
ComponentTypeMask getDrawBufferTypeMask() const;
DrawBufferMask getDrawBufferMask() const;
DrawBufferMask getDrawBufferMask() const { return mState.mEnabledDrawBuffers; }
bool hasEnabledDrawBuffer() const;

GLenum getReadBufferState() const;
Expand Down Expand Up @@ -313,7 +313,10 @@ class Framebuffer final : public angle::ObserverInterface,
void setDefaultLayers(GLint defaultLayers);
void setFlipY(bool flipY);

bool isFoveationEnabled() const;
bool isFoveationEnabled() const
{
return (mState.mFoveationState.getFoveatedFeatureBits() & GL_FOVEATION_ENABLE_BIT_QCOM);
}
void setFoveatedFeatureBits(const GLuint features);
GLuint getFoveatedFeatureBits() const;
bool isFoveationConfigured() const;
Expand Down Expand Up @@ -568,6 +571,11 @@ class Framebuffer final : public angle::ObserverInterface,
bool mAttachmentChangedAfterEnablingFoveation;
};

inline bool FramebufferState::isDefault() const
{
return mId == Framebuffer::kDefaultDrawFramebufferHandle;
}

using UniqueFramebufferPointer = angle::UniqueObjectPointer<Framebuffer, Context>;

} // namespace gl
Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/Sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ const ColorGeneric &Sampler::getBorderColor() const
return mState.getBorderColor();
}

const SamplerState &Sampler::getSamplerState() const
{
return mState;
}

rx::SamplerImpl *Sampler::getImplementation() const
{
return mSampler;
Expand Down
2 changes: 1 addition & 1 deletion src/libANGLE/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Sampler final : public RefCountObject<SamplerID>, public LabeledObject, pu
void setBorderColor(const Context *context, const ColorGeneric &color);
const ColorGeneric &getBorderColor() const;

const SamplerState &getSamplerState() const;
const SamplerState &getSamplerState() const { return mState; }

rx::SamplerImpl *getImplementation() const;

Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2575,11 +2575,6 @@ void State::setSamplerTexture(const Context *context, TextureType type, Texture
mDirtyBits.set(state::DIRTY_BIT_TEXTURE_BINDINGS);
}

Texture *State::getTargetTexture(TextureType type) const
{
return getSamplerTexture(getActiveSampler(), type);
}

TextureID State::getSamplerTextureId(unsigned int sampler, TextureType type) const
{
ASSERT(sampler < mSamplerTextures[type].size());
Expand Down
5 changes: 4 additions & 1 deletion src/libANGLE/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,10 @@ class State : angle::NonCopyable

// Texture binding & active texture unit manipulation
void setSamplerTexture(const Context *context, TextureType type, Texture *texture);
Texture *getTargetTexture(TextureType type) const;
Texture *getTargetTexture(TextureType type) const
{
return getSamplerTexture(getActiveSampler(), type);
}

Texture *getSamplerTexture(unsigned int sampler, TextureType type) const
{
Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/TransformFeedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ bool TransformFeedback::buffersBoundForOtherUseInWebGL() const
return false;
}

rx::TransformFeedbackImpl *TransformFeedback::getImplementation() const
{
return mImplementation;
}

void TransformFeedback::onBindingChanged(const Context *context, bool bound)
{
for (auto &buffer : mState.mIndexedBuffers)
Expand Down
2 changes: 1 addition & 1 deletion src/libANGLE/TransformFeedback.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TransformFeedback final : public RefCountObject<TransformFeedbackID>, publ

angle::Result detachBuffer(const Context *context, BufferID bufferID);

rx::TransformFeedbackImpl *getImplementation() const;
rx::TransformFeedbackImpl *getImplementation() const { return mImplementation; }

void onBindingChanged(const Context *context, bool bound);

Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/formatutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,10 @@ GLuint InternalFormat::getEGLConfigBufferSize() const

Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}

Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}

Format::Format(GLenum internalFormat, GLenum type)
: info(&GetInternalFormatInfo(internalFormat, type))
{}

Format::Format(const Format &other) = default;
Format &Format::operator=(const Format &other) = default;

bool Format::valid() const
{
return info->internalFormat != GL_NONE;
Expand Down
7 changes: 4 additions & 3 deletions src/libANGLE/formatutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ struct Format
explicit Format(GLenum internalFormat);

// Sized or unsized types.
explicit Format(const InternalFormat &internalFormat);
explicit Format(const InternalFormat &internalFormat) : info(&internalFormat) {}

Format(GLenum internalFormat, GLenum type);

Format(const Format &other);
Format &operator=(const Format &other);
Format(const Format &other) = default;
Format &operator=(const Format &other) = default;

bool valid() const;

Expand Down
13 changes: 0 additions & 13 deletions src/libANGLE/renderer/vulkan/FramebufferVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,6 @@ angle::Result FramebufferVk::readPixels(const gl::Context *context,
return angle::Result::Continue;
}

RenderTargetVk *FramebufferVk::getDepthStencilRenderTarget() const
{
return mRenderTargetCache.getDepthStencil();
}

RenderTargetVk *FramebufferVk::getColorDrawRenderTarget(size_t colorIndexGL) const
{
RenderTargetVk *renderTarget = mRenderTargetCache.getColorDraw(mState, colorIndexGL);
Expand Down Expand Up @@ -3734,14 +3729,6 @@ gl::Extents FramebufferVk::getReadImageExtents() const
return readRenderTarget->getExtents();
}

// Return the framebuffer's non-rotated render area. This is a gl::Rectangle that is based on the
// dimensions of the framebuffer, IS NOT rotated, and IS NOT y-flipped
gl::Rectangle FramebufferVk::getNonRotatedCompleteRenderArea() const
{
const gl::Box &dimensions = mState.getDimensions();
return gl::Rectangle(0, 0, dimensions.width, dimensions.height);
}

// Return the framebuffer's rotated render area. This is a gl::Rectangle that is based on the
// dimensions of the framebuffer, IS ROTATED for the draw FBO, and IS NOT y-flipped
//
Expand Down
13 changes: 11 additions & 2 deletions src/libANGLE/renderer/vulkan/FramebufferVk.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ class FramebufferVk : public FramebufferImpl
angle::Result getSamplePosition(const gl::Context *context,
size_t index,
GLfloat *xy) const override;
RenderTargetVk *getDepthStencilRenderTarget() const;
RenderTargetVk *getDepthStencilRenderTarget() const
{
return mRenderTargetCache.getDepthStencil();
}

// Internal helper function for readPixels operations.
angle::Result readPixelsImpl(ContextVk *contextVk,
Expand All @@ -99,7 +102,13 @@ class FramebufferVk : public FramebufferImpl
void *pixels);

gl::Extents getReadImageExtents() const;
gl::Rectangle getNonRotatedCompleteRenderArea() const;
// Return the framebuffer's non-rotated render area. This is a gl::Rectangle that is based on
// the dimensions of the framebuffer, IS NOT rotated, and IS NOT y-flipped
gl::Rectangle getNonRotatedCompleteRenderArea() const
{
const gl::Box &dimensions = mState.getDimensions();
return gl::Rectangle(0, 0, dimensions.width, dimensions.height);
}
gl::Rectangle getRotatedCompleteRenderArea(ContextVk *contextVk) const;
gl::Rectangle getRotatedScissoredRenderArea(ContextVk *contextVk) const;
// Returns render area with deferred clears in consideration. When deferred clear is used
Expand Down
10 changes: 0 additions & 10 deletions src/libANGLE/renderer/vulkan/vk_cache_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4827,16 +4827,6 @@ AttachmentOpsArray &AttachmentOpsArray::operator=(const AttachmentOpsArray &othe
return *this;
}

const PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](PackedAttachmentIndex index) const
{
return mOps[index.get()];
}

PackedAttachmentOpsDesc &AttachmentOpsArray::operator[](PackedAttachmentIndex index)
{
return mOps[index.get()];
}

void AttachmentOpsArray::initWithLoadStore(PackedAttachmentIndex index,
ImageLayout initialLayout,
ImageLayout finalLayout)
Expand Down
7 changes: 5 additions & 2 deletions src/libANGLE/renderer/vulkan/vk_cache_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,11 @@ class AttachmentOpsArray final
AttachmentOpsArray(const AttachmentOpsArray &other);
AttachmentOpsArray &operator=(const AttachmentOpsArray &other);

const PackedAttachmentOpsDesc &operator[](PackedAttachmentIndex index) const;
PackedAttachmentOpsDesc &operator[](PackedAttachmentIndex index);
const PackedAttachmentOpsDesc &operator[](PackedAttachmentIndex index) const
{
return mOps[index.get()];
}
PackedAttachmentOpsDesc &operator[](PackedAttachmentIndex index) { return mOps[index.get()]; }

// Initialize an attachment op with all load and store operations.
void initWithLoadStore(PackedAttachmentIndex index,
Expand Down
6 changes: 0 additions & 6 deletions src/libANGLE/renderer/vulkan/vk_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,12 +1306,6 @@ VkSamplerAddressMode GetSamplerAddressMode(const GLenum wrap)
}
}

VkRect2D GetRect(const gl::Rectangle &source)
{
return {{source.x, source.y},
{static_cast<uint32_t>(source.width), static_cast<uint32_t>(source.height)}};
}

VkPrimitiveTopology GetPrimitiveTopology(gl::PrimitiveMode mode)
{
switch (mode)
Expand Down
6 changes: 5 additions & 1 deletion src/libANGLE/renderer/vulkan/vk_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,11 @@ GLenum CalculateGenerateMipmapFilter(ContextVk *contextVk, angle::FormatID forma

namespace gl_vk
{
VkRect2D GetRect(const gl::Rectangle &source);
inline VkRect2D GetRect(const gl::Rectangle &source)
{
return {{source.x, source.y},
{static_cast<uint32_t>(source.width), static_cast<uint32_t>(source.height)}};
}
VkFilter GetFilter(const GLenum filter);
VkSamplerMipmapMode GetSamplerMipmapMode(const GLenum filter);
VkSamplerAddressMode GetSamplerAddressMode(const GLenum wrap);
Expand Down

0 comments on commit 87d891d

Please sign in to comment.