Commit 5dae57b0 by Martin Radev Committed by Commit Bot

Save side-by-side function arguments into attachment's state

Handle glFramebufferTextureMultiviewSideBySideANGLE calls by saving the arguments into the attachment's state. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: Idc5441d673b48640f47415b07b2854fbdf566c8d Reviewed-on: https://chromium-review.googlesource.com/574915 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 137032d9
......@@ -3113,7 +3113,23 @@ void Context::framebufferTextureMultiviewSideBySideANGLE(GLenum target,
GLsizei numViews,
const GLint *viewportOffsets)
{
UNIMPLEMENTED();
Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target);
ASSERT(framebuffer);
if (texture != 0)
{
Texture *textureObj = getTexture(texture);
ImageIndex index = ImageIndex::Make2D(level);
framebuffer->setAttachmentMultiviewSideBySide(this, GL_TEXTURE, attachment, index,
textureObj, numViews, viewportOffsets);
}
else
{
framebuffer->resetAttachment(this, attachment);
}
mGLState.setObjectDirty(target);
}
void Context::drawBuffers(GLsizei n, const GLenum *bufs)
......
......@@ -461,18 +461,28 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
const Context *proxyContext = display->getProxyContext();
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_BACK, gl::ImageIndex::MakeInvalid(),
surface);
surface, FramebufferAttachment::kDefaultNumViews,
FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
if (surface->getConfig()->depthSize > 0)
{
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH,
gl::ImageIndex::MakeInvalid(), surface);
setAttachmentImpl(
proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(), surface,
FramebufferAttachment::kDefaultNumViews, FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
}
if (surface->getConfig()->stencilSize > 0)
{
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_STENCIL,
gl::ImageIndex::MakeInvalid(), surface);
gl::ImageIndex::MakeInvalid(), surface,
FramebufferAttachment::kDefaultNumViews,
FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
}
}
......@@ -1131,10 +1141,28 @@ void Framebuffer::setAttachment(const Context *context,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
{
setAttachment(context, type, binding, textureIndex, resource,
FramebufferAttachment::kDefaultNumViews,
FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
}
void Framebuffer::setAttachment(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
// Context may be null in unit tests.
if (!context || !context->isWebGL1())
{
setAttachmentImpl(context, type, binding, textureIndex, resource);
setAttachmentImpl(context, type, binding, textureIndex, resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
return;
}
......@@ -1143,25 +1171,49 @@ void Framebuffer::setAttachment(const Context *context,
case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT:
mState.mWebGLDepthStencilAttachment.attach(context, type, binding, textureIndex,
resource);
resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
break;
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
mState.mWebGLDepthAttachment.attach(context, type, binding, textureIndex, resource);
mState.mWebGLDepthAttachment.attach(context, type, binding, textureIndex, resource,
numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
break;
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
mState.mWebGLStencilAttachment.attach(context, type, binding, textureIndex, resource);
mState.mWebGLStencilAttachment.attach(context, type, binding, textureIndex, resource,
numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
break;
default:
setAttachmentImpl(context, type, binding, textureIndex, resource);
setAttachmentImpl(context, type, binding, textureIndex, resource, numViews,
baseViewIndex, multiviewLayout, viewportOffsets);
return;
}
commitWebGL1DepthStencilIfConsistent(context);
commitWebGL1DepthStencilIfConsistent(context, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
}
void Framebuffer::setAttachmentMultiviewSideBySide(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
GLsizei numViews,
const GLint *viewportOffsets)
{
setAttachment(context, type, binding, textureIndex, resource, numViews,
FramebufferAttachment::kDefaultBaseViewIndex,
GL_FRAMEBUFFER_MULTIVIEW_SIDE_BY_SIDE_ANGLE, viewportOffsets);
}
void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context)
void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
int count = 0;
......@@ -1198,34 +1250,38 @@ void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context)
{
const auto &depth = mState.mWebGLDepthAttachment;
setAttachmentImpl(context, depth.type(), GL_DEPTH_ATTACHMENT,
getImageIndexIfTextureAttachment(depth), depth.getResource());
getImageIndexIfTextureAttachment(depth), depth.getResource(), numViews,
baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(),
nullptr);
nullptr, numViews, baseViewIndex, multiviewLayout, viewportOffsets);
}
else if (mState.mWebGLStencilAttachment.isAttached())
{
const auto &stencil = mState.mWebGLStencilAttachment;
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(),
nullptr);
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), nullptr,
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, stencil.type(), GL_STENCIL_ATTACHMENT,
getImageIndexIfTextureAttachment(stencil), stencil.getResource());
getImageIndexIfTextureAttachment(stencil), stencil.getResource(),
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
}
else if (mState.mWebGLDepthStencilAttachment.isAttached())
{
const auto &depthStencil = mState.mWebGLDepthStencilAttachment;
setAttachmentImpl(context, depthStencil.type(), GL_DEPTH_ATTACHMENT,
getImageIndexIfTextureAttachment(depthStencil),
depthStencil.getResource());
depthStencil.getResource(), numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
setAttachmentImpl(context, depthStencil.type(), GL_STENCIL_ATTACHMENT,
getImageIndexIfTextureAttachment(depthStencil),
depthStencil.getResource());
depthStencil.getResource(), numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
}
else
{
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(),
nullptr);
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), nullptr,
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(),
nullptr);
nullptr, numViews, baseViewIndex, multiviewLayout, viewportOffsets);
}
}
......@@ -1233,7 +1289,11 @@ void Framebuffer::setAttachmentImpl(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
switch (binding)
{
......@@ -1254,28 +1314,33 @@ void Framebuffer::setAttachmentImpl(const Context *context,
updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT,
&mDirtyDepthAttachmentBinding, type, binding, textureIndex,
attachmentObj);
attachmentObj, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT,
&mDirtyStencilAttachmentBinding, type, binding, textureIndex,
attachmentObj);
attachmentObj, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
return;
}
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT,
&mDirtyDepthAttachmentBinding, type, binding, textureIndex, resource);
&mDirtyDepthAttachmentBinding, type, binding, textureIndex, resource,
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
break;
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT,
&mDirtyStencilAttachmentBinding, type, binding, textureIndex,
resource);
&mDirtyStencilAttachmentBinding, type, binding, textureIndex, resource,
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
break;
case GL_BACK:
mState.mColorAttachments[0].attach(context, type, binding, textureIndex, resource);
mState.mColorAttachments[0].attach(context, type, binding, textureIndex, resource,
numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
mDirtyBits.set(DIRTY_BIT_COLOR_ATTACHMENT_0);
// No need for a resource binding for the default FBO, it's always complete.
break;
......@@ -1287,7 +1352,8 @@ void Framebuffer::setAttachmentImpl(const Context *context,
size_t dirtyBit = DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex;
updateAttachment(context, &mState.mColorAttachments[colorIndex], dirtyBit,
&mDirtyColorAttachmentBindings[colorIndex], type, binding,
textureIndex, resource);
textureIndex, resource, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
// TODO(jmadill): ASSERT instead of checking the attachment exists in
// formsRenderingFeedbackLoopWith
......@@ -1305,9 +1371,14 @@ void Framebuffer::updateAttachment(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
{
attachment->attach(context, type, binding, textureIndex, resource);
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
attachment->attach(context, type, binding, textureIndex, resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
mDirtyBits.set(dirtyBit);
BindResourceChannel(onDirtyBinding, resource);
}
......
......@@ -148,6 +148,13 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource);
void setAttachmentMultiviewSideBySide(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
GLsizei numViews,
const GLint *viewportOffsets);
void resetAttachment(const Context *context, GLenum binding);
void detachTexture(const Context *context, GLuint texture);
......@@ -292,13 +299,29 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLuint matchId,
size_t dirtyBit);
GLenum checkStatusImpl(const Context *context);
void commitWebGL1DepthStencilIfConsistent(const Context *context);
void setAttachment(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
void commitWebGL1DepthStencilIfConsistent(const Context *context,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
void setAttachmentImpl(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource);
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
void updateAttachment(const Context *context,
FramebufferAttachment *attachment,
size_t dirtyBit,
......@@ -306,7 +329,11 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource);
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
FramebufferState mState;
rx::FramebufferImpl *mImpl;
......
......@@ -23,6 +23,11 @@ namespace gl
////// FramebufferAttachment::Target Implementation //////
const GLint FramebufferAttachment::kDefaultNumViews = 1;
const GLenum FramebufferAttachment::kDefaultMultiviewLayout = GL_NONE;
const GLint FramebufferAttachment::kDefaultBaseViewIndex = 0;
const GLint FramebufferAttachment::kDefaultViewportOffsets[2] = {0};
FramebufferAttachment::Target::Target()
: mBinding(GL_NONE),
mTextureIndex(ImageIndex::MakeInvalid())
......@@ -53,9 +58,9 @@ FramebufferAttachment::Target &FramebufferAttachment::Target::operator=(const Ta
FramebufferAttachment::FramebufferAttachment()
: mType(GL_NONE),
mResource(nullptr),
mNumViews(1),
mMultiviewLayout(GL_NONE),
mBaseViewIndex(0),
mNumViews(kDefaultNumViews),
mMultiviewLayout(kDefaultMultiviewLayout),
mBaseViewIndex(kDefaultBaseViewIndex),
mViewportOffsets(1u)
{
}
......@@ -65,13 +70,10 @@ FramebufferAttachment::FramebufferAttachment(const Context *context,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
: mResource(nullptr),
mNumViews(1),
mMultiviewLayout(GL_NONE),
mBaseViewIndex(0),
mViewportOffsets(1u)
: mResource(nullptr)
{
attach(context, type, binding, textureIndex, resource);
attach(context, type, binding, textureIndex, resource, kDefaultNumViews, kDefaultBaseViewIndex,
kDefaultMultiviewLayout, kDefaultViewportOffsets);
}
FramebufferAttachment::FramebufferAttachment(FramebufferAttachment &&other)
......@@ -105,9 +107,9 @@ void FramebufferAttachment::detach(const Context *context)
mResource->onDetach(context);
mResource = nullptr;
}
mNumViews = 1;
mMultiviewLayout = GL_NONE;
mBaseViewIndex = 0;
mNumViews = kDefaultNumViews;
mMultiviewLayout = kDefaultMultiviewLayout;
mBaseViewIndex = kDefaultBaseViewIndex;
mViewportOffsets.resize(1u);
mViewportOffsets[0] = Offset();
......@@ -119,7 +121,11 @@ void FramebufferAttachment::attach(const Context *context,
GLenum type,
GLenum binding,
const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource)
FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
if (resource == nullptr)
{
......@@ -129,6 +135,14 @@ void FramebufferAttachment::attach(const Context *context,
mType = type;
mTarget = Target(binding, textureIndex);
mNumViews = numViews;
mBaseViewIndex = baseViewIndex;
mMultiviewLayout = multiviewLayout;
mViewportOffsets.resize(numViews);
for (size_t i = 0u; i < mViewportOffsets.size(); ++i)
{
mViewportOffsets[i] = Offset(viewportOffsets[i * 2u], viewportOffsets[i * 2u + 1u], 0);
}
resource->onAttach(context);
if (mResource != nullptr)
......
......@@ -70,7 +70,11 @@ class FramebufferAttachment final
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;
......@@ -125,6 +129,11 @@ class FramebufferAttachment final
bool operator==(const FramebufferAttachment &other) const;
bool operator!=(const FramebufferAttachment &other) const;
static const GLint kDefaultNumViews;
static const GLenum kDefaultMultiviewLayout;
static const GLint kDefaultBaseViewIndex;
static const GLint kDefaultViewportOffsets[2];
private:
gl::Error getRenderTargetImpl(const Context *context,
rx::FramebufferAttachmentRenderTarget **rtOut) const;
......
......@@ -226,4 +226,50 @@ TEST_P(FramebufferMultiviewTest, ExtensionNotAvailableCheck)
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test that glFramebufferTextureMultiviewSideBySideANGLE modifies the internal multiview state.
TEST_P(FramebufferMultiviewTest, ModifySideBySideState)
{
if (!requestMultiviewExtension())
{
return;
}
const GLint viewportOffsets[4] = {0, 0, 1, 2};
createTexture2D();
glFramebufferTextureMultiviewSideBySideANGLE(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTexture2D,
0, 2, &viewportOffsets[0]);
ASSERT_GL_NO_ERROR();
GLint numViews = -1;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_ANGLE,
&numViews);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(2, numViews);
GLint baseViewIndex = -1;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_ANGLE,
&baseViewIndex);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(0, baseViewIndex);
GLint multiviewLayout = GL_NONE;
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_MULTIVIEW_LAYOUT_ANGLE,
&multiviewLayout);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(GL_FRAMEBUFFER_MULTIVIEW_SIDE_BY_SIDE_ANGLE, multiviewLayout);
GLint internalViewportOffsets[4] = {-1};
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_VIEWPORT_OFFSETS_ANGLE,
&internalViewportOffsets[0]);
ASSERT_GL_NO_ERROR();
for (size_t i = 0u; i < 4u; ++i)
{
EXPECT_EQ(viewportOffsets[i], internalViewportOffsets[i]);
}
}
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewTest, ES3_OPENGL());
\ No newline at end of file
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