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, ...@@ -3113,7 +3113,23 @@ void Context::framebufferTextureMultiviewSideBySideANGLE(GLenum target,
GLsizei numViews, GLsizei numViews,
const GLint *viewportOffsets) 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) void Context::drawBuffers(GLsizei n, const GLenum *bufs)
......
...@@ -461,18 +461,28 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface) ...@@ -461,18 +461,28 @@ Framebuffer::Framebuffer(const egl::Display *display, egl::Surface *surface)
const Context *proxyContext = display->getProxyContext(); const Context *proxyContext = display->getProxyContext();
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_BACK, gl::ImageIndex::MakeInvalid(), 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) if (surface->getConfig()->depthSize > 0)
{ {
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, setAttachmentImpl(
gl::ImageIndex::MakeInvalid(), surface); proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, gl::ImageIndex::MakeInvalid(), surface,
FramebufferAttachment::kDefaultNumViews, FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
} }
if (surface->getConfig()->stencilSize > 0) if (surface->getConfig()->stencilSize > 0)
{ {
setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_STENCIL, 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, ...@@ -1131,10 +1141,28 @@ void Framebuffer::setAttachment(const Context *context,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource) 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. // Context may be null in unit tests.
if (!context || !context->isWebGL1()) if (!context || !context->isWebGL1())
{ {
setAttachmentImpl(context, type, binding, textureIndex, resource); setAttachmentImpl(context, type, binding, textureIndex, resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
return; return;
} }
...@@ -1143,25 +1171,49 @@ void Framebuffer::setAttachment(const Context *context, ...@@ -1143,25 +1171,49 @@ void Framebuffer::setAttachment(const Context *context,
case GL_DEPTH_STENCIL: case GL_DEPTH_STENCIL:
case GL_DEPTH_STENCIL_ATTACHMENT: case GL_DEPTH_STENCIL_ATTACHMENT:
mState.mWebGLDepthStencilAttachment.attach(context, type, binding, textureIndex, mState.mWebGLDepthStencilAttachment.attach(context, type, binding, textureIndex,
resource); resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
break; break;
case GL_DEPTH: case GL_DEPTH:
case GL_DEPTH_ATTACHMENT: 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; break;
case GL_STENCIL: case GL_STENCIL:
case GL_STENCIL_ATTACHMENT: 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; break;
default: default:
setAttachmentImpl(context, type, binding, textureIndex, resource); setAttachmentImpl(context, type, binding, textureIndex, resource, numViews,
baseViewIndex, multiviewLayout, viewportOffsets);
return; return;
} }
commitWebGL1DepthStencilIfConsistent(context); commitWebGL1DepthStencilIfConsistent(context, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
} }
void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context) 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,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{ {
int count = 0; int count = 0;
...@@ -1198,34 +1250,38 @@ void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context) ...@@ -1198,34 +1250,38 @@ void Framebuffer::commitWebGL1DepthStencilIfConsistent(const Context *context)
{ {
const auto &depth = mState.mWebGLDepthAttachment; const auto &depth = mState.mWebGLDepthAttachment;
setAttachmentImpl(context, depth.type(), GL_DEPTH_ATTACHMENT, 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(), setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(),
nullptr); nullptr, numViews, baseViewIndex, multiviewLayout, viewportOffsets);
} }
else if (mState.mWebGLStencilAttachment.isAttached()) else if (mState.mWebGLStencilAttachment.isAttached())
{ {
const auto &stencil = mState.mWebGLStencilAttachment; const auto &stencil = mState.mWebGLStencilAttachment;
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), nullptr,
nullptr); numViews, baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, stencil.type(), GL_STENCIL_ATTACHMENT, setAttachmentImpl(context, stencil.type(), GL_STENCIL_ATTACHMENT,
getImageIndexIfTextureAttachment(stencil), stencil.getResource()); getImageIndexIfTextureAttachment(stencil), stencil.getResource(),
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
} }
else if (mState.mWebGLDepthStencilAttachment.isAttached()) else if (mState.mWebGLDepthStencilAttachment.isAttached())
{ {
const auto &depthStencil = mState.mWebGLDepthStencilAttachment; const auto &depthStencil = mState.mWebGLDepthStencilAttachment;
setAttachmentImpl(context, depthStencil.type(), GL_DEPTH_ATTACHMENT, setAttachmentImpl(context, depthStencil.type(), GL_DEPTH_ATTACHMENT,
getImageIndexIfTextureAttachment(depthStencil), getImageIndexIfTextureAttachment(depthStencil),
depthStencil.getResource()); depthStencil.getResource(), numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
setAttachmentImpl(context, depthStencil.type(), GL_STENCIL_ATTACHMENT, setAttachmentImpl(context, depthStencil.type(), GL_STENCIL_ATTACHMENT,
getImageIndexIfTextureAttachment(depthStencil), getImageIndexIfTextureAttachment(depthStencil),
depthStencil.getResource()); depthStencil.getResource(), numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
} }
else else
{ {
setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), nullptr,
nullptr); numViews, baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(), 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, ...@@ -1233,7 +1289,11 @@ void Framebuffer::setAttachmentImpl(const Context *context,
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource) FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{ {
switch (binding) switch (binding)
{ {
...@@ -1254,28 +1314,33 @@ void Framebuffer::setAttachmentImpl(const Context *context, ...@@ -1254,28 +1314,33 @@ void Framebuffer::setAttachmentImpl(const Context *context,
updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT, updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_DEPTH_ATTACHMENT,
&mDirtyDepthAttachmentBinding, type, binding, textureIndex, &mDirtyDepthAttachmentBinding, type, binding, textureIndex,
attachmentObj); attachmentObj, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT, updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT,
&mDirtyStencilAttachmentBinding, type, binding, textureIndex, &mDirtyStencilAttachmentBinding, type, binding, textureIndex,
attachmentObj); attachmentObj, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
return; return;
} }
case GL_DEPTH: case GL_DEPTH:
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
updateAttachment(context, &mState.mDepthAttachment, DIRTY_BIT_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; break;
case GL_STENCIL: case GL_STENCIL:
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT, updateAttachment(context, &mState.mStencilAttachment, DIRTY_BIT_STENCIL_ATTACHMENT,
&mDirtyStencilAttachmentBinding, type, binding, textureIndex, &mDirtyStencilAttachmentBinding, type, binding, textureIndex, resource,
resource); numViews, baseViewIndex, multiviewLayout, viewportOffsets);
break; break;
case GL_BACK: 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); mDirtyBits.set(DIRTY_BIT_COLOR_ATTACHMENT_0);
// No need for a resource binding for the default FBO, it's always complete. // No need for a resource binding for the default FBO, it's always complete.
break; break;
...@@ -1287,7 +1352,8 @@ void Framebuffer::setAttachmentImpl(const Context *context, ...@@ -1287,7 +1352,8 @@ void Framebuffer::setAttachmentImpl(const Context *context,
size_t dirtyBit = DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex; size_t dirtyBit = DIRTY_BIT_COLOR_ATTACHMENT_0 + colorIndex;
updateAttachment(context, &mState.mColorAttachments[colorIndex], dirtyBit, updateAttachment(context, &mState.mColorAttachments[colorIndex], dirtyBit,
&mDirtyColorAttachmentBindings[colorIndex], type, binding, &mDirtyColorAttachmentBindings[colorIndex], type, binding,
textureIndex, resource); textureIndex, resource, numViews, baseViewIndex, multiviewLayout,
viewportOffsets);
// TODO(jmadill): ASSERT instead of checking the attachment exists in // TODO(jmadill): ASSERT instead of checking the attachment exists in
// formsRenderingFeedbackLoopWith // formsRenderingFeedbackLoopWith
...@@ -1305,9 +1371,14 @@ void Framebuffer::updateAttachment(const Context *context, ...@@ -1305,9 +1371,14 @@ void Framebuffer::updateAttachment(const Context *context,
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource) FramebufferAttachmentObject *resource,
{ GLsizei numViews,
attachment->attach(context, type, binding, textureIndex, resource); GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{
attachment->attach(context, type, binding, textureIndex, resource, numViews, baseViewIndex,
multiviewLayout, viewportOffsets);
mDirtyBits.set(dirtyBit); mDirtyBits.set(dirtyBit);
BindResourceChannel(onDirtyBinding, resource); BindResourceChannel(onDirtyBinding, resource);
} }
......
...@@ -148,6 +148,13 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -148,6 +148,13 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource); 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 resetAttachment(const Context *context, GLenum binding);
void detachTexture(const Context *context, GLuint texture); void detachTexture(const Context *context, GLuint texture);
...@@ -292,13 +299,29 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -292,13 +299,29 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLuint matchId, GLuint matchId,
size_t dirtyBit); size_t dirtyBit);
GLenum checkStatusImpl(const Context *context); 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, void setAttachmentImpl(const Context *context,
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource); FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
void updateAttachment(const Context *context, void updateAttachment(const Context *context,
FramebufferAttachment *attachment, FramebufferAttachment *attachment,
size_t dirtyBit, size_t dirtyBit,
...@@ -306,7 +329,11 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver ...@@ -306,7 +329,11 @@ class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource); FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
FramebufferState mState; FramebufferState mState;
rx::FramebufferImpl *mImpl; rx::FramebufferImpl *mImpl;
......
...@@ -23,6 +23,11 @@ namespace gl ...@@ -23,6 +23,11 @@ namespace gl
////// FramebufferAttachment::Target Implementation ////// ////// 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() FramebufferAttachment::Target::Target()
: mBinding(GL_NONE), : mBinding(GL_NONE),
mTextureIndex(ImageIndex::MakeInvalid()) mTextureIndex(ImageIndex::MakeInvalid())
...@@ -53,9 +58,9 @@ FramebufferAttachment::Target &FramebufferAttachment::Target::operator=(const Ta ...@@ -53,9 +58,9 @@ FramebufferAttachment::Target &FramebufferAttachment::Target::operator=(const Ta
FramebufferAttachment::FramebufferAttachment() FramebufferAttachment::FramebufferAttachment()
: mType(GL_NONE), : mType(GL_NONE),
mResource(nullptr), mResource(nullptr),
mNumViews(1), mNumViews(kDefaultNumViews),
mMultiviewLayout(GL_NONE), mMultiviewLayout(kDefaultMultiviewLayout),
mBaseViewIndex(0), mBaseViewIndex(kDefaultBaseViewIndex),
mViewportOffsets(1u) mViewportOffsets(1u)
{ {
} }
...@@ -65,13 +70,10 @@ FramebufferAttachment::FramebufferAttachment(const Context *context, ...@@ -65,13 +70,10 @@ FramebufferAttachment::FramebufferAttachment(const Context *context,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource) FramebufferAttachmentObject *resource)
: mResource(nullptr), : mResource(nullptr)
mNumViews(1),
mMultiviewLayout(GL_NONE),
mBaseViewIndex(0),
mViewportOffsets(1u)
{ {
attach(context, type, binding, textureIndex, resource); attach(context, type, binding, textureIndex, resource, kDefaultNumViews, kDefaultBaseViewIndex,
kDefaultMultiviewLayout, kDefaultViewportOffsets);
} }
FramebufferAttachment::FramebufferAttachment(FramebufferAttachment &&other) FramebufferAttachment::FramebufferAttachment(FramebufferAttachment &&other)
...@@ -105,9 +107,9 @@ void FramebufferAttachment::detach(const Context *context) ...@@ -105,9 +107,9 @@ void FramebufferAttachment::detach(const Context *context)
mResource->onDetach(context); mResource->onDetach(context);
mResource = nullptr; mResource = nullptr;
} }
mNumViews = 1; mNumViews = kDefaultNumViews;
mMultiviewLayout = GL_NONE; mMultiviewLayout = kDefaultMultiviewLayout;
mBaseViewIndex = 0; mBaseViewIndex = kDefaultBaseViewIndex;
mViewportOffsets.resize(1u); mViewportOffsets.resize(1u);
mViewportOffsets[0] = Offset(); mViewportOffsets[0] = Offset();
...@@ -119,7 +121,11 @@ void FramebufferAttachment::attach(const Context *context, ...@@ -119,7 +121,11 @@ void FramebufferAttachment::attach(const Context *context,
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource) FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets)
{ {
if (resource == nullptr) if (resource == nullptr)
{ {
...@@ -129,6 +135,14 @@ void FramebufferAttachment::attach(const Context *context, ...@@ -129,6 +135,14 @@ void FramebufferAttachment::attach(const Context *context,
mType = type; mType = type;
mTarget = Target(binding, textureIndex); 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); resource->onAttach(context);
if (mResource != nullptr) if (mResource != nullptr)
......
...@@ -70,7 +70,11 @@ class FramebufferAttachment final ...@@ -70,7 +70,11 @@ class FramebufferAttachment final
GLenum type, GLenum type,
GLenum binding, GLenum binding,
const ImageIndex &textureIndex, const ImageIndex &textureIndex,
FramebufferAttachmentObject *resource); FramebufferAttachmentObject *resource,
GLsizei numViews,
GLuint baseViewIndex,
GLenum multiviewLayout,
const GLint *viewportOffsets);
// Helper methods // Helper methods
GLuint getRedSize() const; GLuint getRedSize() const;
...@@ -125,6 +129,11 @@ class FramebufferAttachment final ...@@ -125,6 +129,11 @@ class FramebufferAttachment final
bool operator==(const FramebufferAttachment &other) const; bool operator==(const FramebufferAttachment &other) const;
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: private:
gl::Error getRenderTargetImpl(const Context *context, gl::Error getRenderTargetImpl(const Context *context,
rx::FramebufferAttachmentRenderTarget **rtOut) const; rx::FramebufferAttachmentRenderTarget **rtOut) const;
......
...@@ -226,4 +226,50 @@ TEST_P(FramebufferMultiviewTest, ExtensionNotAvailableCheck) ...@@ -226,4 +226,50 @@ TEST_P(FramebufferMultiviewTest, ExtensionNotAvailableCheck)
EXPECT_GL_ERROR(GL_INVALID_OPERATION); 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()); 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