Commit 7b2f0274 by Jamie Madill Committed by Commit Bot

Inline more buffer binding calls.

This splits checkObjectAllocation into the inline part and the slow part. It uses ANGLE_INLINE to force the former to be inlined. Also inlines and optimizes a few other buffer binding related checks. Improves performance in a bindings performance test by about 20%. Includes contributions from matavenrath@nvidia.com. Test: Bindings_gl_100_objects_allocated_at_initialization Bug: angleproject:2777 Change-Id: I71b07d72a8e81db7a90140ef84eca599a29239ed Reviewed-on: https://chromium-review.googlesource.com/1190442Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 22f7aafb
......@@ -7593,11 +7593,6 @@ bool Context::isTextureGenerated(GLuint texture) const
return mState.mTextures->isHandleGenerated(texture);
}
bool Context::isBufferGenerated(GLuint buffer) const
{
return mState.mBuffers->isHandleGenerated(buffer);
}
bool Context::isRenderbufferGenerated(GLuint renderbuffer) const
{
return mState.mRenderbuffers->isHandleGenerated(renderbuffer);
......
......@@ -25,6 +25,7 @@
#include "libANGLE/HandleAllocator.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/ResourceMap.h"
#include "libANGLE/ResourceManager.h"
#include "libANGLE/VertexAttribute.h"
#include "libANGLE/Workarounds.h"
#include "libANGLE/angletypes.h"
......@@ -1526,7 +1527,11 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
Shader *getShader(GLuint handle) const;
bool isTextureGenerated(GLuint texture) const;
bool isBufferGenerated(GLuint buffer) const;
bool isBufferGenerated(GLuint buffer) const
{
return mState.mBuffers->isHandleGenerated(buffer);
}
bool isRenderbufferGenerated(GLuint renderbuffer) const;
bool isFramebufferGenerated(GLuint framebuffer) const;
bool isProgramPipelineGenerated(GLuint pipeline) const;
......
......@@ -75,7 +75,9 @@ class TypedResourceManager : public ResourceManagerBase<HandleAllocatorType>
// Inlined in the header for performance.
template <typename... ArgTypes>
ResourceType *checkObjectAllocation(rx::GLImplFactory *factory, GLuint handle, ArgTypes... args)
ANGLE_INLINE ResourceType *checkObjectAllocation(rx::GLImplFactory *factory,
GLuint handle,
ArgTypes... args)
{
ResourceType *value = mObjectMap.query(handle);
if (value)
......@@ -88,6 +90,19 @@ class TypedResourceManager : public ResourceManagerBase<HandleAllocatorType>
return nullptr;
}
return checkObjectAllocationImpl(factory, handle, args...);
}
void reset(const Context *context) override;
ResourceMap<ResourceType> mObjectMap;
private:
template <typename... ArgTypes>
ResourceType *checkObjectAllocationImpl(rx::GLImplFactory *factory,
GLuint handle,
ArgTypes... args)
{
ResourceType *object = ImplT::AllocateNewObject(factory, handle, args...);
if (!mObjectMap.contains(handle))
......@@ -98,10 +113,6 @@ class TypedResourceManager : public ResourceManagerBase<HandleAllocatorType>
return object;
}
void reset(const Context *context) override;
ResourceMap<ResourceType> mObjectMap;
};
class BufferManager : public TypedResourceManager<Buffer, HandleAllocator, BufferManager>
......@@ -110,7 +121,7 @@ class BufferManager : public TypedResourceManager<Buffer, HandleAllocator, Buffe
GLuint createBuffer();
Buffer *getBuffer(GLuint handle) const;
Buffer *checkBufferAllocation(rx::GLImplFactory *factory, GLuint handle)
ANGLE_INLINE Buffer *checkBufferAllocation(rx::GLImplFactory *factory, GLuint handle)
{
return checkObjectAllocation(factory, handle);
}
......
......@@ -987,11 +987,6 @@ void State::setFragmentShaderDerivativeHint(GLenum hint)
// Ignore for now. It is valid for implementations to ignore hint.
}
bool State::isBindGeneratesResourceEnabled() const
{
return mBindGeneratesResource;
}
bool State::areClientArraysEnabled() const
{
return mClientArraysEnabled;
......
......@@ -162,7 +162,10 @@ class State : angle::NonCopyable
void setFragmentShaderDerivativeHint(GLenum hint);
// GL_CHROMIUM_bind_generates_resource
bool isBindGeneratesResourceEnabled() const;
bool isBindGeneratesResourceEnabled() const
{
return mBindGeneratesResource;
}
// GL_ANGLE_client_arrays
bool areClientArraysEnabled() const;
......
......@@ -359,19 +359,21 @@ void VertexArray::setVertexAttribPointer(const Context *context,
void VertexArray::setElementArrayBuffer(const Context *context, Buffer *buffer)
{
if (context->isCurrentVertexArray(this))
ASSERT(context->isCurrentVertexArray(this));
if (mState.mElementArrayBuffer.get())
{
if (mState.mElementArrayBuffer.get())
{
mState.mElementArrayBuffer->onNonTFBindingChanged(context, -1);
}
if (buffer)
{
buffer->onNonTFBindingChanged(context, 1);
}
mState.mElementArrayBuffer->onNonTFBindingChanged(context, -1);
}
if (buffer)
{
buffer->onNonTFBindingChanged(context, 1);
mElementArrayBufferObserverBinding.bind(buffer->getImplementation());
}
else
{
mElementArrayBufferObserverBinding.bind(nullptr);
}
mState.mElementArrayBuffer.set(context, buffer);
mElementArrayBufferObserverBinding.bind(buffer ? buffer->getImplementation() : nullptr);
mDirtyBits.set(DIRTY_BIT_ELEMENT_ARRAY_BUFFER);
}
......
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