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)
......
...@@ -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