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)
// This constructor is only used for default framebuffers.
FramebufferState::FramebufferState()
: mLabel(),
: mId(0),
mLabel(),
mColorAttachments(1),
mDrawBufferStates(1, GL_BACK),
mReadBufferState(GL_BACK),
......@@ -268,8 +269,9 @@ FramebufferState::FramebufferState()
mEnabledDrawBuffers.set(0);
}
FramebufferState::FramebufferState(const Caps &caps)
: mLabel(),
FramebufferState::FramebufferState(const Caps &caps, GLuint id)
: mId(id),
mLabel(),
mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT),
......@@ -281,6 +283,7 @@ FramebufferState::FramebufferState(const Caps &caps)
mDefaultLayers(0),
mWebGLDepthStencilConsistent(true)
{
ASSERT(mId != 0);
ASSERT(mDrawBufferStates.size() > 0);
mDrawBufferStates[0] = GL_COLOR_ATTACHMENT0_EXT;
}
......@@ -613,14 +616,12 @@ Box FramebufferState::getDimensions() const
}
Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id)
: mState(caps),
: mState(caps, id),
mImpl(factory->createFramebuffer(mState)),
mId(id),
mCachedStatus(),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
{
ASSERT(mId != 0);
ASSERT(mImpl != nullptr);
ASSERT(mState.mColorAttachments.size() == static_cast<size_t>(caps.maxColorAttachments));
......@@ -634,7 +635,6 @@ Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id
Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
: mState(),
mImpl(surface->getImplementation()->createDefaultFramebuffer(mState)),
mId(0),
mCachedStatus(GL_FRAMEBUFFER_COMPLETE),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
......@@ -673,7 +673,6 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
Framebuffer::Framebuffer(rx::GLImplFactory *factory)
: mState(),
mImpl(factory->createFramebuffer(mState)),
mId(0),
mCachedStatus(GL_FRAMEBUFFER_UNDEFINED_OES),
mDirtyDepthAttachmentBinding(this, DIRTY_BIT_DEPTH_ATTACHMENT),
mDirtyStencilAttachmentBinding(this, DIRTY_BIT_STENCIL_ATTACHMENT)
......@@ -972,7 +971,7 @@ bool Framebuffer::usingExtendedDrawBuffers() const
void Framebuffer::invalidateCompletenessCache()
{
if (mId != 0)
if (mState.mId != 0)
{
mCachedStatus.reset();
}
......@@ -983,7 +982,7 @@ GLenum Framebuffer::checkStatus(const Context *context)
// 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
// 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.value() == GL_FRAMEBUFFER_COMPLETE ||
......@@ -1017,7 +1016,7 @@ GLenum Framebuffer::checkStatusWithGLFrontEnd(const Context *context)
{
const ContextState &state = context->getContextState();
ASSERT(mId != 0);
ASSERT(mState.mId != 0);
bool hasAttachments = false;
Optional<unsigned int> colorbufferSize;
......@@ -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
// 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.
mCachedStatus.reset();
......@@ -1799,7 +1798,7 @@ bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const
const Program *program = state.getProgram();
// TODO(jmadill): Default framebuffer feedback loops.
if (mId == 0)
if (mState.mId == 0)
{
return false;
}
......@@ -1861,7 +1860,7 @@ bool Framebuffer::formsCopyingFeedbackLoopWith(GLuint copyTextureID,
GLint copyTextureLevel,
GLint copyTextureLayer) const
{
if (mId == 0)
if (mState.mId == 0)
{
// It seems impossible to form a texture copying feedback loop with the default FBO.
return false;
......
......@@ -53,7 +53,7 @@ class FramebufferState final : angle::NonCopyable
{
public:
FramebufferState();
explicit FramebufferState(const Caps &caps);
explicit FramebufferState(const Caps &caps, GLuint id);
~FramebufferState();
const std::string &getLabel();
......@@ -99,6 +99,8 @@ class FramebufferState final : angle::NonCopyable
const std::vector<Offset> *getViewportOffsets() const;
GLint getBaseViewIndex() const;
GLuint id() const { return mId; }
private:
const FramebufferAttachment *getWebGLDepthStencilAttachment() const;
const FramebufferAttachment *getWebGLDepthAttachment() const;
......@@ -106,6 +108,7 @@ class FramebufferState final : angle::NonCopyable
friend class Framebuffer;
GLuint mId;
std::string mLabel;
std::vector<FramebufferAttachment> mColorAttachments;
......@@ -152,7 +155,7 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
rx::FramebufferImpl *getImplementation() const { return mImpl; }
GLuint id() const { return mId; }
GLuint id() const { return mState.mId; }
void setAttachment(const Context *context,
GLenum type,
......@@ -386,7 +389,6 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
FramebufferState mState;
rx::FramebufferImpl *mImpl;
GLuint mId;
Optional<GLenum> mCachedStatus;
std::vector<angle::ObserverBinding> mDirtyColorAttachmentBindings;
......
......@@ -98,6 +98,8 @@ class ProgramImpl : angle::NonCopyable
{
}
const gl::ProgramState &getState() const { return mState; }
protected:
const gl::ProgramState &mState;
};
......
......@@ -43,6 +43,8 @@ class VertexArrayImpl : angle::NonCopyable
virtual void destroy(const gl::Context *context) {}
virtual ~VertexArrayImpl() {}
const gl::VertexArrayState &getState() const { return mState; }
protected:
const gl::VertexArrayState &mState;
};
......
......@@ -44,11 +44,10 @@ void RenderStateCache::clear()
// static
d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *context,
const gl::Framebuffer *framebuffer,
FramebufferD3D *framebufferD3D,
const gl::BlendState &blendState)
{
d3d11::BlendStateKey key;
FramebufferD3D *framebufferD3D = GetImplAs<FramebufferD3D>(framebuffer);
const gl::AttachmentList &colorbuffers = framebufferD3D->getColorAttachmentsForRender(context);
const UINT8 blendStateMask =
gl_d3d11::ConvertColorMask(blendState.colorMaskRed, blendState.colorMaskGreen,
......
......@@ -61,6 +61,7 @@ struct hash<gl::SamplerState>
namespace rx
{
class FramebufferD3D;
class Renderer11;
class RenderStateCache : angle::NonCopyable
......@@ -72,7 +73,7 @@ class RenderStateCache : angle::NonCopyable
void clear();
static d3d11::BlendStateKey GetBlendStateKey(const gl::Context *context,
const gl::Framebuffer *framebuffer,
FramebufferD3D *framebufferD3D,
const gl::BlendState &blendState);
gl::Error getBlendState(Renderer11 *renderer,
const d3d11::BlendStateKey &key,
......
......@@ -18,14 +18,15 @@
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/d3d11/InputLayoutCache.h"
#include "libANGLE/renderer/d3d/d3d11/Query11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
namespace rx
{
class Buffer11;
class Framebuffer11;
struct RenderTargetDesc;
struct Renderer11DeviceCaps;
class VertexArray11;
class ShaderConstants11 : angle::NonCopyable
{
......@@ -261,11 +262,10 @@ class StateManager11 final : angle::NonCopyable
bool unsetConflictingSRVs(gl::ShaderType shaderType,
uintptr_t resource,
const gl::ImageIndex *index);
void unsetConflictingAttachmentResources(const gl::FramebufferAttachment *attachment,
void unsetConflictingAttachmentResources(const gl::FramebufferAttachment &attachment,
ID3D11Resource *resource);
gl::Error syncBlendState(const gl::Context *context,
const gl::Framebuffer *framebuffer,
const gl::BlendState &blendState,
const gl::ColorF &blendColor,
unsigned int sampleMask);
......@@ -281,7 +281,7 @@ class StateManager11 final : angle::NonCopyable
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 syncTextures(const gl::Context *context);
......@@ -308,16 +308,17 @@ class StateManager11 final : angle::NonCopyable
gl::Error clearUAVs(gl::ShaderType shaderType, size_t rangeStart, size_t rangeEnd);
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 generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type);
gl::Error generateSwizzles(const gl::Context *context);
gl::Error applyDriverUniforms(const ProgramD3D &programD3D);
gl::Error applyUniforms(ProgramD3D *programD3D);
gl::Error applyDriverUniforms();
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);
// These are currently only called internally.
......@@ -344,9 +345,7 @@ class StateManager11 final : angle::NonCopyable
UINT offset);
void applyVertexBufferChanges();
bool setPrimitiveTopologyInternal(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology);
void syncPrimitiveTopology(const gl::State &glState,
ProgramD3D *programD3D,
gl::PrimitiveMode currentDrawMode);
void syncPrimitiveTopology(const gl::State &glState, gl::PrimitiveMode currentDrawMode);
// Not handled by an internal dirty bit because it isn't synced on drawArrays calls.
gl::Error applyIndexBuffer(const gl::Context *context,
......@@ -575,6 +574,11 @@ class StateManager11 final : angle::NonCopyable
Serial mAppliedTFSerial;
Serial mEmptySerial;
// These objects are cached to avoid having to query the impls.
ProgramD3D *mProgramD3D;
VertexArray11 *mVertexArray11;
Framebuffer11 *mFramebuffer11;
};
} // 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