summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h')
-rw-r--r--src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h186
1 files changed, 109 insertions, 77 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h b/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h
index 33196f5c61..5c0553a1d4 100644
--- a/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h
+++ b/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.h
@@ -15,6 +15,7 @@
#include "libANGLE/angletypes.h"
#include "libANGLE/Error.h"
#include "libANGLE/ImageIndex.h"
+#include "libANGLE/signal_utils.h"
namespace egl
{
@@ -38,9 +39,20 @@ class FramebufferAttachmentObjectImpl;
namespace gl
{
class FramebufferAttachmentObject;
+struct Format;
class Renderbuffer;
class Texture;
+enum class InitState
+{
+ MayNeedInit,
+ Initialized,
+};
+
+using OnAttachmentDirtyBinding = angle::ChannelBinding<size_t, InitState>;
+using OnAttachmentDirtyChannel = angle::BroadcastChannel<size_t, InitState>;
+using OnAttachmentDirtyReceiver = angle::SignalReceiver<size_t, InitState>;
+
// FramebufferAttachment implements a GL framebuffer attachment.
// Attachments are "light" containers, which store pointers to ref-counted GL objects.
// We support GL texture (2D/3D/Cube/2D array) and renderbuffer object attachments.
@@ -52,43 +64,27 @@ class FramebufferAttachment final
public:
FramebufferAttachment();
- FramebufferAttachment(GLenum type,
+ FramebufferAttachment(const Context *context,
+ GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource);
- FramebufferAttachment(const FramebufferAttachment &other);
- FramebufferAttachment &operator=(const FramebufferAttachment &other);
+ FramebufferAttachment(FramebufferAttachment &&other);
+ FramebufferAttachment &operator=(FramebufferAttachment &&other);
~FramebufferAttachment();
- // A framebuffer attachment points to one of three types of resources: Renderbuffers,
- // Textures and egl::Surface. The "Target" struct indicates which part of the
- // object an attachment references. For the three types:
- // - a Renderbuffer has a unique renderable target, and needs no target index
- // - a Texture has targets for every image and uses an ImageIndex
- // - a Surface has targets for Color and Depth/Stencil, and uses the attachment binding
- class Target
- {
- public:
- Target();
- Target(GLenum binding, const ImageIndex &imageIndex);
- Target(const Target &other);
- Target &operator=(const Target &other);
-
- GLenum binding() const { return mBinding; }
- const ImageIndex &textureIndex() const { return mTextureIndex; }
-
- private:
- GLenum mBinding;
- ImageIndex mTextureIndex;
- };
-
- void detach();
- void attach(GLenum type,
+ void detach(const Context *context);
+ void attach(const Context *context,
+ GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
- FramebufferAttachmentObject *resource);
+ FramebufferAttachmentObject *resource,
+ GLsizei numViews,
+ GLuint baseViewIndex,
+ GLenum multiviewLayout,
+ const GLint *viewportOffsets);
// Helper methods
GLuint getRedSize() const;
@@ -111,12 +107,16 @@ class FramebufferAttachment final
GLenum cubeMapFace() const;
GLint mipLevel() const;
GLint layer() const;
+ GLsizei getNumViews() const;
+ GLenum getMultiviewLayout() const;
+ GLint getBaseViewIndex() const;
+ const std::vector<Offset> &getMultiviewViewportOffsets() const;
// The size of the underlying resource the attachment points to. The 'depth' value will
// correspond to a 3D texture depth or the layer count of a 2D array texture. For Surfaces and
// Renderbuffers, it will always be 1.
Extents getSize() const;
- GLenum getInternalFormat() const;
+ const Format &getFormat() const;
GLsizei getSamples() const;
GLenum type() const { return mType; }
bool isAttached() const { return mType != GL_NONE; }
@@ -124,95 +124,127 @@ class FramebufferAttachment final
Renderbuffer *getRenderbuffer() const;
Texture *getTexture() const;
const egl::Surface *getSurface() const;
+ FramebufferAttachmentObject *getResource() const;
+ InitState initState() const;
+ Error initializeContents(const Context *context);
+ void setInitState(InitState initState) const;
// "T" must be static_castable from FramebufferAttachmentRenderTarget
template <typename T>
- gl::Error getRenderTarget(T **rtOut) const
+ gl::Error getRenderTarget(const Context *context, T **rtOut) const
{
- // Cast through the pointer-to-pointer type
- rx::FramebufferAttachmentRenderTarget *rtPtr = nullptr;
- gl::Error error = getRenderTarget(&rtPtr);
- *rtOut = static_cast<T*>(rtPtr);
- return error;
+ static_assert(std::is_base_of<rx::FramebufferAttachmentRenderTarget, T>(),
+ "Invalid RenderTarget class.");
+ return getRenderTargetImpl(
+ context, reinterpret_cast<rx::FramebufferAttachmentRenderTarget **>(rtOut));
}
+ bool operator==(const FramebufferAttachment &other) const;
+ bool operator!=(const FramebufferAttachment &other) const;
+
+ static std::vector<Offset> GetDefaultViewportOffsetVector();
+ static const GLsizei kDefaultNumViews;
+ static const GLenum kDefaultMultiviewLayout;
+ static const GLint kDefaultBaseViewIndex;
+ static const GLint kDefaultViewportOffsets[2];
+
private:
- gl::Error getRenderTarget(rx::FramebufferAttachmentRenderTarget **rtOut) const;
+ gl::Error getRenderTargetImpl(const Context *context,
+ rx::FramebufferAttachmentRenderTarget **rtOut) const;
+
+ // A framebuffer attachment points to one of three types of resources: Renderbuffers,
+ // Textures and egl::Surface. The "Target" struct indicates which part of the
+ // object an attachment references. For the three types:
+ // - a Renderbuffer has a unique renderable target, and needs no target index
+ // - a Texture has targets for every image and uses an ImageIndex
+ // - a Surface has targets for Color and Depth/Stencil, and uses the attachment binding
+ class Target
+ {
+ public:
+ Target();
+ Target(GLenum binding, const ImageIndex &imageIndex);
+ Target(const Target &other);
+ Target &operator=(const Target &other);
+
+ GLenum binding() const { return mBinding; }
+ const ImageIndex &textureIndex() const { return mTextureIndex; }
+
+ private:
+ GLenum mBinding;
+ ImageIndex mTextureIndex;
+ };
GLenum mType;
Target mTarget;
FramebufferAttachmentObject *mResource;
+ GLsizei mNumViews;
+ GLenum mMultiviewLayout;
+ GLint mBaseViewIndex;
+ std::vector<Offset> mViewportOffsets;
};
// A base class for objects that FBO Attachments may point to.
class FramebufferAttachmentObject
{
public:
- FramebufferAttachmentObject() {}
- virtual ~FramebufferAttachmentObject() {}
+ FramebufferAttachmentObject();
+ virtual ~FramebufferAttachmentObject();
- virtual Extents getAttachmentSize(const FramebufferAttachment::Target &target) const = 0;
- virtual GLenum getAttachmentInternalFormat(const FramebufferAttachment::Target &target) const = 0;
- virtual GLsizei getAttachmentSamples(const FramebufferAttachment::Target &target) const = 0;
+ virtual Extents getAttachmentSize(const ImageIndex &imageIndex) const = 0;
+ virtual const Format &getAttachmentFormat(GLenum binding,
+ const ImageIndex &imageIndex) const = 0;
+ virtual GLsizei getAttachmentSamples(const ImageIndex &imageIndex) const = 0;
- virtual void onAttach() = 0;
- virtual void onDetach() = 0;
+ virtual void onAttach(const Context *context) = 0;
+ virtual void onDetach(const Context *context) = 0;
virtual GLuint getId() const = 0;
- Error getAttachmentRenderTarget(const FramebufferAttachment::Target &target,
+ // These are used for robust resource initialization.
+ virtual InitState initState(const ImageIndex &imageIndex) const = 0;
+ virtual void setInitState(const ImageIndex &imageIndex, InitState initState) = 0;
+
+ Error getAttachmentRenderTarget(const Context *context,
+ GLenum binding,
+ const ImageIndex &imageIndex,
rx::FramebufferAttachmentRenderTarget **rtOut) const;
+ Error initializeContents(const Context *context, const ImageIndex &imageIndex);
+
+ OnAttachmentDirtyChannel *getDirtyChannel();
+
protected:
virtual rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const = 0;
+
+ OnAttachmentDirtyChannel mDirtyChannel;
};
inline Extents FramebufferAttachment::getSize() const
{
- return mResource->getAttachmentSize(mTarget);
+ ASSERT(mResource);
+ return mResource->getAttachmentSize(mTarget.textureIndex());
}
-inline GLenum FramebufferAttachment::getInternalFormat() const
+inline const Format &FramebufferAttachment::getFormat() const
{
- return mResource->getAttachmentInternalFormat(mTarget);
+ ASSERT(mResource);
+ return mResource->getAttachmentFormat(mTarget.binding(), mTarget.textureIndex());
}
inline GLsizei FramebufferAttachment::getSamples() const
{
- return mResource->getAttachmentSamples(mTarget);
-}
-
-inline gl::Error FramebufferAttachment::getRenderTarget(rx::FramebufferAttachmentRenderTarget **rtOut) const
-{
- return mResource->getAttachmentRenderTarget(mTarget, rtOut);
+ ASSERT(mResource);
+ return mResource->getAttachmentSamples(mTarget.textureIndex());
}
-} // namespace gl
-
-namespace rx
-{
-
-class FramebufferAttachmentObjectImpl : angle::NonCopyable
-{
- public:
- FramebufferAttachmentObjectImpl() {}
- virtual ~FramebufferAttachmentObjectImpl() {}
-
- virtual gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
- FramebufferAttachmentRenderTarget **rtOut) = 0;
-};
-
-} // namespace rx
-
-namespace gl
-{
-
-inline Error FramebufferAttachmentObject::getAttachmentRenderTarget(
- const FramebufferAttachment::Target &target,
+inline gl::Error FramebufferAttachment::getRenderTargetImpl(
+ const Context *context,
rx::FramebufferAttachmentRenderTarget **rtOut) const
{
- return getAttachmentImpl()->getAttachmentRenderTarget(target, rtOut);
+ ASSERT(mResource);
+ return mResource->getAttachmentRenderTarget(context, mTarget.binding(), mTarget.textureIndex(),
+ rtOut);
}
-}
+} // namespace gl
#endif // LIBANGLE_FRAMEBUFFERATTACHMENT_H_