Commit 2274b652 by Jamie Madill Committed by Commit Bot

StateManager11: Cache impl objects.

Also requires putting the Framebuffer ID in the shared state object. Bug: angleproject:2575 Change-Id: I68e3af839a85798e01050560a67624a165d3ed2c Reviewed-on: https://chromium-review.googlesource.com/1067119 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 683d65f8
...@@ -252,7 +252,8 @@ bool IsClearBufferMaskedOut(const Context *context, GLenum buffer) ...@@ -252,7 +252,8 @@ bool IsClearBufferMaskedOut(const Context *context, GLenum buffer)
// This constructor is only used for default framebuffers. // This constructor is only used for default framebuffers.
FramebufferState::FramebufferState() FramebufferState::FramebufferState()
: mLabel(), : mId(0),
mLabel(),
mColorAttachments(1), mColorAttachments(1),
mDrawBufferStates(1, GL_BACK), mDrawBufferStates(1, GL_BACK),
mReadBufferState(GL_BACK), mReadBufferState(GL_BACK),
...@@ -268,8 +269,9 @@ FramebufferState::FramebufferState() ...@@ -268,8 +269,9 @@ FramebufferState::FramebufferState()
mEnabledDrawBuffers.set(0); mEnabledDrawBuffers.set(0);
} }
FramebufferState::FramebufferState(const Caps &caps) FramebufferState::FramebufferState(const Caps &caps, GLuint id)
: mLabel(), : mId(id),
mLabel(),
mColorAttachments(caps.maxColorAttachments), mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE), mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT), mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
...@@ -281,6 +283,7 @@ FramebufferState::FramebufferState(const Caps &caps) ...@@ -281,6 +283,7 @@ FramebufferState::FramebufferState(const Caps &caps)
mDefaultLayers(0), mDefaultLayers(0),
mWebGLDepthStencilConsistent(true) mWebGLDepthStencilConsistent(true)
{ {
ASSERT(mId != 0);
ASSERT(mDrawBufferStates.size() > 0); ASSERT(mDrawBufferStates.size() > 0);
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT; mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
} }
...@@ -613,14 +616,12 @@ Box FramebufferState::getDimensions() const ...@@ -613,14 +616,12 @@ Box FramebufferState::getDimensions() const
} }
Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id) Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id)
: mState(caps), : mState(caps, id),
mImpl(factory->createFramebuffer(mState)), mImpl(factory->createFramebuffer(mState)),
mId(id),
mCachedStatus(), mCachedStatus(),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT), mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT) mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
{ {
ASSERT(mId != 0);
ASSERT(mImpl != nullptr); ASSERT(mImpl != nullptr);
ASSERT(mState.mColorAttachments.size() == static_cast<size_t>(caps.maxColorAttachments)); ASSERT(mState.mColorAttachments.size() == static_cast<size_t>(caps.maxColorAttachments));
...@@ -634,7 +635,6 @@ Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id ...@@ -634,7 +635,6 @@ Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id
Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface) Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
: mState(), : mState(),
mImpl(surface->getImplementation()->createDefaultFramebuffer(mState)), mImpl(surface->getImplementation()->createDefaultFramebuffer(mState)),
mId(0),
mCachedStatus(GL_FRAMEBUFFER_COMPLETE), mCachedStatus(GL_FRAMEBUFFER_COMPLETE),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT), mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT) mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
...@@ -673,7 +673,6 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface) ...@@ -673,7 +673,6 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
Framebuffer::Framebuffer(rx::GLImplFactory *factory) Framebuffer::Framebuffer(rx::GLImplFactory *factory)
: mState(), : mState(),
mImpl(factory->createFramebuffer(mState)), mImpl(factory->createFramebuffer(mState)),
mId(0),
mCachedStatus(GL_FRAMEBUFFER_UNDEFINED_OES), mCachedStatus(GL_FRAMEBUFFER_UNDEFINED_OES),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT), mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT) mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
...@@ -972,7 +971,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const ...@@ -972,7 +971,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const
void Framebuffer::invalidateCompletenessCache() void Framebuffer::invalidateCompletenessCache()
{ {
if (mId != 0) if (mState.mId != 0)
{ {
mCachedStatus.reset(); mCachedStatus.reset();
} }
...@@ -983,7 +982,7 @@ GLenum Framebuffer::checkStatus(const Context *context) ...@@ -983,7 +982,7 @@ GLenum Framebuffer::checkStatus(const Context *context)
// The default framebuffer is always complete except when it is surfaceless in which // The default framebuffer is always complete except when it is surfaceless in which
// case it is always unsupported. We return early because the default framebuffer may // case it is always unsupported. We return early because the default framebuffer may
// not be subject to the same rules as application FBOs. ie, it could have 0x0 size. // not be subject to the same rules as application FBOs. ie, it could have 0x0 size.
if (mId == 0) if (mState.mId == 0)
{ {
ASSERT(mCachedStatus.valid()); ASSERT(mCachedStatus.valid());
ASSERT(mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE || ASSERT(mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE ||
...@@ -1017,7 +1016,7 @@ GLenum Framebuffer::checkStatusWithGLFrontEnd(const Context *context) ...@@ -1017,7 +1016,7 @@ GLenum Framebuffer::checkStatusWithGLFrontEnd(const Context *context)
{ {
const ContextState &state = context->getContextState(); const ContextState &state = context->getContextState();
ASSERT(mId != 0); ASSERT(mState.mId != 0);
bool hasAttachments = false; bool hasAttachments = false;
Optional<unsigned int> colorbufferSize; Optional<unsigned int> colorbufferSize;
...@@ -1762,7 +1761,7 @@ void Framebuffer::onSubjectStateChange(const Context *context, ...@@ -1762,7 +1761,7 @@ void Framebuffer::onSubjectStateChange(const Context *context,
// Only reset the cached status if this is not the default framebuffer. The default framebuffer // Only reset the cached status if this is not the default framebuffer. The default framebuffer
// will still use this channel to mark itself dirty. // will still use this channel to mark itself dirty.
if (mId != 0) if (mState.mId != 0)
{ {
// TOOD(jmadill): Make this only update individual attachments to do less work. // TOOD(jmadill): Make this only update individual attachments to do less work.
mCachedStatus.reset(); mCachedStatus.reset();
...@@ -1799,7 +1798,7 @@ bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const ...@@ -1799,7 +1798,7 @@ bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const
const Program *program = state.getProgram(); const Program *program = state.getProgram();
// TODO(jmadill): Default framebuffer feedback loops. // TODO(jmadill): Default framebuffer feedback loops.
if (mId == 0) if (mState.mId == 0)
{ {
return false; return false;
} }
...@@ -1861,7 +1860,7 @@ bool Framebuffer::formsCopyingFeedbackLoopWith(GLuint copyTextureID, ...@@ -1861,7 +1860,7 @@ bool Framebuffer::formsCopyingFeedbackLoopWith(GLuint copyTextureID,
GLint copyTextureLevel, GLint copyTextureLevel,
GLint copyTextureLayer) const GLint copyTextureLayer) const
{ {
if (mId == 0) if (mState.mId == 0)
{ {
// It seems impossible to form a texture copying feedback loop with the default FBO. // It seems impossible to form a texture copying feedback loop with the default FBO.
return false; return false;
......
...@@ -53,7 +53,7 @@ class FramebufferState final : angle::NonCopyable ...@@ -53,7 +53,7 @@ class FramebufferState final : angle::NonCopyable
{ {
public: public:
FramebufferState(); FramebufferState();
explicit FramebufferState(const Caps &caps); explicit FramebufferState(const Caps &caps, GLuint id);
~FramebufferState(); ~FramebufferState();
const std::string &getLabel(); const std::string &getLabel();
...@@ -99,6 +99,8 @@ class FramebufferState final : angle::NonCopyable ...@@ -99,6 +99,8 @@ class FramebufferState final : angle::NonCopyable
const std::vector<Offset> *getViewportOffsets() const; const std::vector<Offset> *getViewportOffsets() const;
GLint getBaseViewIndex() const; GLint getBaseViewIndex() const;
GLuint id() const { return mId; }
private: private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const; const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
const FramebufferAttachment *getWebGLDepthAttachment() const; const FramebufferAttachment *getWebGLDepthAttachment() const;
...@@ -106,6 +108,7 @@ class FramebufferState final : angle::NonCopyable ...@@ -106,6 +108,7 @@ class FramebufferState final : angle::NonCopyable
friend class Framebuffer; friend class Framebuffer;
GLuint mId;
std::string mLabel; std::string mLabel;
std::vector<FramebufferAttachment> mColorAttachments; std::vector<FramebufferAttachment> mColorAttachments;
...@@ -152,7 +155,7 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject ...@@ -152,7 +155,7 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
rx::FramebufferImpl *getImplementation() const { return mImpl; } rx::FramebufferImpl *getImplementation() const { return mImpl; }
GLuint id() const { return mId; } GLuint id() const { return mState.mId; }
void setAttachment(const Context *context, void setAttachment(const Context *context,
GLenum type, GLenum type,
...@@ -386,7 +389,6 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject ...@@ -386,7 +389,6 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
FramebufferState mState; FramebufferState mState;
rx::FramebufferImpl *mImpl; rx::FramebufferImpl *mImpl;
GLuint mId;
Optional<GLenum> mCachedStatus; Optional<GLenum> mCachedStatus;
std::vector<angle::ObserverBinding> mDirtyColorAttachmentBindings; std::vector<angle::ObserverBinding> mDirtyColorAttachmentBindings;
......
...@@ -98,6 +98,8 @@ class ProgramImpl : angle::NonCopyable ...@@ -98,6 +98,8 @@ class ProgramImpl : angle::NonCopyable
{ {
} }
const gl::ProgramState &getState() const { return mState; }
protected: protected:
const gl::ProgramState &mState; const gl::ProgramState &mState;
}; };
......
...@@ -43,6 +43,8 @@ class VertexArrayImpl : angle::NonCopyable ...@@ -43,6 +43,8 @@ class VertexArrayImpl : angle::NonCopyable
virtual void destroy(const gl::Context *context) {} virtual void destroy(const gl::Context *context) {}
virtual ~VertexArrayImpl() {} virtual ~VertexArrayImpl() {}
const gl::VertexArrayState &getState() const { return mState; }
protected: protected:
const gl::VertexArrayState &mState; const gl::VertexArrayState &mState;
}; };
......
...@@ -44,11 +44,10 @@ void RenderStateCache::clear() ...@@ -44,11 +44,10 @@ void RenderStateCache::clear()
// static // static
d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *context, d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *context,
const gl::Framebuffer *framebuffer, FramebufferD3D *framebufferD3D,
const gl::BlendState &blendState) const gl::BlendState &blendState)
{ {
d3d11::BlendStateKey key; d3d11::BlendStateKey key;
FramebufferD3D *framebufferD3D = GetImplAs<FramebufferD3D>(framebuffer);
const gl::AttachmentList &colorbuffers = framebufferD3D->getColorAttachmentsForRender(context); const gl::AttachmentList &colorbuffers = framebufferD3D->getColorAttachmentsForRender(context);
const UINT8 blendStateMask = const UINT8 blendStateMask =
gl_d3d11::ConvertColorMask(blendState.colorMaskRed, blendState.colorMaskGreen, gl_d3d11::ConvertColorMask(blendState.colorMaskRed, blendState.colorMaskGreen,
......
...@@ -61,6 +61,7 @@ struct hash<gl::SamplerState> ...@@ -61,6 +61,7 @@ struct hash<gl::SamplerState>
namespace rx namespace rx
{ {
class FramebufferD3D;
class Renderer11; class Renderer11;
class RenderStateCache : angle::NonCopyable class RenderStateCache : angle::NonCopyable
...@@ -72,7 +73,7 @@ class RenderStateCache : angle::NonCopyable ...@@ -72,7 +73,7 @@ class RenderStateCache : angle::NonCopyable
void clear(); void clear();
static d3d11::BlendStateKey GetBlendStateKey(const gl::Context *context, static d3d11::BlendStateKey GetBlendStateKey(const gl::Context *context,
const gl::Framebuffer *framebuffer, FramebufferD3D *framebufferD3D,
const gl::BlendState &blendState); const gl::BlendState &blendState);
gl::Error getBlendState(Renderer11 *renderer, gl::Error getBlendState(Renderer11 *renderer,
const d3d11::BlendStateKey &key, const d3d11::BlendStateKey &key,
......
...@@ -18,14 +18,15 @@ ...@@ -18,14 +18,15 @@
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/d3d11/InputLayoutCache.h" #include "libANGLE/renderer/d3d/d3d11/InputLayoutCache.h"
#include "libANGLE/renderer/d3d/d3d11/Query11.h" #include "libANGLE/renderer/d3d/d3d11/Query11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
namespace rx namespace rx
{ {
class Buffer11; class Buffer11;
class Framebuffer11;
struct RenderTargetDesc; struct RenderTargetDesc;
struct Renderer11DeviceCaps; struct Renderer11DeviceCaps;
class VertexArray11;
class ShaderConstants11 : angle::NonCopyable class ShaderConstants11 : angle::NonCopyable
{ {
...@@ -261,11 +262,10 @@ class StateManager11 final : angle::NonCopyable ...@@ -261,11 +262,10 @@ class StateManager11 final : angle::NonCopyable
bool unsetConflictingSRVs(gl::ShaderType shaderType, bool unsetConflictingSRVs(gl::ShaderType shaderType,
uintptr_t resource, uintptr_t resource,
const gl::ImageIndex *index); const gl::ImageIndex *index);
void unsetConflictingAttachmentResources(const gl::FramebufferAttachment *attachment, void unsetConflictingAttachmentResources(const gl::FramebufferAttachment &attachment,
ID3D11Resource *resource); ID3D11Resource *resource);
gl::Error syncBlendState(const gl::Context *context, gl::Error syncBlendState(const gl::Context *context,
const gl::Framebuffer *framebuffer,
const gl::BlendState &blendState, const gl::BlendState &blendState,
const gl::ColorF &blendColor, const gl::ColorF &blendColor,
unsigned int sampleMask); unsigned int sampleMask);
...@@ -281,7 +281,7 @@ class StateManager11 final : angle::NonCopyable ...@@ -281,7 +281,7 @@ class StateManager11 final : angle::NonCopyable
void checkPresentPath(const gl::Context *context); void checkPresentPath(const gl::Context *context);
gl::Error syncFramebuffer(const gl::Context *context, gl::Framebuffer *framebuffer); gl::Error syncFramebuffer(const gl::Context *context);
gl::Error syncProgram(const gl::Context *context, gl::PrimitiveMode drawMode); gl::Error syncProgram(const gl::Context *context, gl::PrimitiveMode drawMode);
gl::Error syncTextures(const gl::Context *context); gl::Error syncTextures(const gl::Context *context);
...@@ -308,16 +308,17 @@ class StateManager11 final : angle::NonCopyable ...@@ -308,16 +308,17 @@ class StateManager11 final : angle::NonCopyable
gl::Error clearUAVs(gl::ShaderType shaderType, size_t rangeStart, size_t rangeEnd); gl::Error clearUAVs(gl::ShaderType shaderType, size_t rangeStart, size_t rangeEnd);
void handleMultiviewDrawFramebufferChange(const gl::Context *context); void handleMultiviewDrawFramebufferChange(const gl::Context *context);
gl::Error syncCurrentValueAttribs(const gl::State &glState); gl::Error syncCurrentValueAttribs(
const std::vector<gl::VertexAttribCurrentValueData> &currentValues);
gl::Error generateSwizzle(const gl::Context *context, gl::Texture *texture); gl::Error generateSwizzle(const gl::Context *context, gl::Texture *texture);
gl::Error generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type); gl::Error generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type);
gl::Error generateSwizzles(const gl::Context *context); gl::Error generateSwizzles(const gl::Context *context);
gl::Error applyDriverUniforms(const ProgramD3D &programD3D); gl::Error applyDriverUniforms();
gl::Error applyUniforms(ProgramD3D *programD3D); gl::Error applyUniforms();
gl::Error syncUniformBuffers(const gl::Context *context, ProgramD3D *programD3D); gl::Error syncUniformBuffers(const gl::Context *context);
gl::Error syncTransformFeedbackBuffers(const gl::Context *context); gl::Error syncTransformFeedbackBuffers(const gl::Context *context);
// These are currently only called internally. // These are currently only called internally.
...@@ -344,9 +345,7 @@ class StateManager11 final : angle::NonCopyable ...@@ -344,9 +345,7 @@ class StateManager11 final : angle::NonCopyable
UINT offset); UINT offset);
void applyVertexBufferChanges(); void applyVertexBufferChanges();
bool setPrimitiveTopologyInternal(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); bool setPrimitiveTopologyInternal(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology);
void syncPrimitiveTopology(const gl::State &glState, void syncPrimitiveTopology(const gl::State &glState, gl::PrimitiveMode currentDrawMode);
ProgramD3D *programD3D,
gl::PrimitiveMode currentDrawMode);
// Not handled by an internal dirty bit because it isn't synced on drawArrays calls. // Not handled by an internal dirty bit because it isn't synced on drawArrays calls.
gl::Error applyIndexBuffer(const gl::Context *context, gl::Error applyIndexBuffer(const gl::Context *context,
...@@ -575,6 +574,11 @@ class StateManager11 final : angle::NonCopyable ...@@ -575,6 +574,11 @@ class StateManager11 final : angle::NonCopyable
Serial mAppliedTFSerial; Serial mAppliedTFSerial;
Serial mEmptySerial; Serial mEmptySerial;
// These objects are cached to avoid having to query the impls.
ProgramD3D *mProgramD3D;
VertexArray11 *mVertexArray11;
Framebuffer11 *mFramebuffer11;
}; };
} // namespace rx } // namespace rx
......
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