Commit d75dd26c by Jamie Madill Committed by Commit Bot

Make ImageSibling inherit from FramebufferAttachment.

Only currently Renderbuffers and Textures can be bound with images. This makes the relationship explicit, and also ensures that an image sibling can determine if it's been initialized or not, which is important for the robust resource init extension with Textures and EGLImages. BUG=angleproject:1635 Change-Id: Ie05319cfbfda50f1497cab3f0b9ca64e1bff8955 Reviewed-on: https://chromium-review.googlesource.com/469154Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 151d5de6
......@@ -110,39 +110,12 @@ Image::Image(rx::EGLImplFactory *factory,
const AttributeMap &attribs)
: RefCountObject(0),
mState(target, buffer, attribs),
mImplementation(factory->createImage(mState, target, attribs)),
mFormat(gl::Format::Invalid()),
mWidth(0),
mHeight(0),
mSamples(0)
mImplementation(factory->createImage(mState, target, attribs))
{
ASSERT(mImplementation != nullptr);
ASSERT(buffer != nullptr);
mState.source->addImageSource(this);
if (IsTextureTarget(target))
{
gl::Texture *texture = rx::GetAs<gl::Texture>(mState.source.get());
GLenum textureTarget = egl_gl::EGLImageTargetToGLTextureTarget(target);
size_t level = attribs.get(EGL_GL_TEXTURE_LEVEL_KHR, 0);
mFormat = texture->getFormat(textureTarget, level);
mWidth = texture->getWidth(textureTarget, level);
mHeight = texture->getHeight(textureTarget, level);
mSamples = 0;
}
else if (IsRenderbufferTarget(target))
{
gl::Renderbuffer *renderbuffer = rx::GetAs<gl::Renderbuffer>(mState.source.get());
mFormat = renderbuffer->getFormat();
mWidth = renderbuffer->getWidth();
mHeight = renderbuffer->getHeight();
mSamples = renderbuffer->getSamples();
}
else
{
UNREACHABLE();
}
}
Image::~Image()
......@@ -187,22 +160,22 @@ gl::Error Image::orphanSibling(ImageSibling *sibling)
const gl::Format &Image::getFormat() const
{
return mFormat;
return mState.source->getAttachmentFormat(GL_NONE, mState.imageIndex);
}
size_t Image::getWidth() const
{
return mWidth;
return mState.source->getAttachmentSize(mState.imageIndex).width;
}
size_t Image::getHeight() const
{
return mHeight;
return mState.source->getAttachmentSize(mState.imageIndex).height;
}
size_t Image::getSamples() const
{
return mSamples;
return mState.source->getAttachmentSamples(mState.imageIndex);
}
rx::ImageImpl *Image::getImplementation() const
......
......@@ -12,7 +12,7 @@
#include "common/angleutils.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/Error.h"
#include "libANGLE/ImageIndex.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/formatutils.h"
......@@ -28,7 +28,10 @@ namespace egl
{
class Image;
class ImageSibling : public RefCountObject
// Only currently Renderbuffers and Textures can be bound with images. This makes the relationship
// explicit, and also ensures that an image sibling can determine if it's been initialized or not,
// which is important for the robust resource init extension with Textures and EGLImages.
class ImageSibling : public RefCountObject, public gl::FramebufferAttachmentObject
{
public:
ImageSibling(GLuint id);
......@@ -93,13 +96,7 @@ class Image final : public RefCountObject
gl::Error orphanSibling(ImageSibling *sibling);
ImageState mState;
rx::ImageImpl *mImplementation;
gl::Format mFormat;
size_t mWidth;
size_t mHeight;
size_t mSamples;
};
} // namespace egl
......
......@@ -28,7 +28,6 @@ namespace gl
// attachment point.
class Renderbuffer final : public egl::ImageSibling,
public gl::FramebufferAttachmentObject,
public LabeledObject
{
public:
......
......@@ -175,7 +175,6 @@ bool operator==(const TextureState &a, const TextureState &b);
bool operator!=(const TextureState &a, const TextureState &b);
class Texture final : public egl::ImageSibling,
public FramebufferAttachmentObject,
public LabeledObject
{
public:
......
......@@ -27,23 +27,9 @@ EGLImageD3D::EGLImageD3D(const egl::ImageState &state,
EGLenum target,
const egl::AttributeMap &attribs,
RendererD3D *renderer)
: ImageImpl(state), mRenderer(renderer), mAttachmentBuffer(nullptr), mRenderTarget(nullptr)
: ImageImpl(state), mRenderer(renderer), mRenderTarget(nullptr)
{
ASSERT(renderer != nullptr);
if (egl::IsTextureTarget(target))
{
mAttachmentBuffer = GetImplAs<TextureD3D>(GetAs<gl::Texture>(mState.source.get()));
}
else if (egl::IsRenderbufferTarget(target))
{
mAttachmentBuffer =
GetImplAs<RenderbufferD3D>(GetAs<gl::Renderbuffer>(mState.source.get()));
}
else
{
UNREACHABLE();
}
}
EGLImageD3D::~EGLImageD3D()
......@@ -68,10 +54,11 @@ gl::Error EGLImageD3D::orphan(egl::ImageSibling *sibling)
gl::Error EGLImageD3D::getRenderTarget(RenderTargetD3D **outRT) const
{
if (mAttachmentBuffer)
if (mState.source.get())
{
ASSERT(!mRenderTarget);
FramebufferAttachmentRenderTarget *rt = nullptr;
ANGLE_TRY(mAttachmentBuffer->getAttachmentRenderTarget(GL_NONE, mState.imageIndex, &rt));
ANGLE_TRY(mState.source->getAttachmentRenderTarget(GL_NONE, mState.imageIndex, &rt));
*outRT = static_cast<RenderTargetD3D *>(rt);
return gl::NoError();
}
......@@ -86,7 +73,6 @@ gl::Error EGLImageD3D::getRenderTarget(RenderTargetD3D **outRT) const
gl::Error EGLImageD3D::copyToLocalRendertarget()
{
ASSERT(mState.source.get() != nullptr);
ASSERT(mAttachmentBuffer != nullptr);
ASSERT(mRenderTarget == nullptr);
RenderTargetD3D *curRenderTarget = nullptr;
......@@ -95,9 +81,6 @@ gl::Error EGLImageD3D::copyToLocalRendertarget()
// This only currently applies do D3D11, where it invalidates FBOs with this Image attached.
curRenderTarget->signalDirty();
// Clear the source image buffers
mAttachmentBuffer = nullptr;
return mRenderer->createRenderTargetCopy(curRenderTarget, &mRenderTarget);
}
} // namespace rx
......@@ -43,9 +43,6 @@ class EGLImageD3D final : public ImageImpl
gl::Error copyToLocalRendertarget();
RendererD3D *mRenderer;
FramebufferAttachmentObjectImpl *mAttachmentBuffer;
RenderTargetD3D *mRenderTarget;
};
} // 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