ImageIndex: Consolidate layer/cube face.
In terms of the Texture or Image resource, a cube face
refers to a layer of a 2D texture. This layer has a special
meaning for cube textures, but it is represented as a layer
with a layer index. Cube array textures are no different,
they just use a different indexing scheme for the array
layers.
This also cleans up the ImageIndex helper to have a class
structure with private data, and cleans up a few cases to
use generic Make functions and iterators where they were
setting properties of the index directly.
This will make it easier to have ImageIndexes address
entire levels of a Cube map in the future, and makes the
layer count logic in Vulkan cleaner.
Bug: angleproject:2318
Change-Id: Iea9842e233f974a9896282ca224cb001f7882bd1
Reviewed-on: https://chromium-review.googlesource.com/987525
Reviewed-by: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp
index 666c0ff..f2ec3a6 100644
--- a/src/libANGLE/Framebuffer.cpp
+++ b/src/libANGLE/Framebuffer.cpp
@@ -146,8 +146,8 @@
// ES3.1 (section 9.4) requires that the value of TEXTURE_FIXED_SAMPLE_LOCATIONS should be
// the same for all attached textures.
- bool fixedSampleloc = texture->getFixedSampleLocations(attachmentImageIndex.target,
- attachmentImageIndex.mipIndex);
+ bool fixedSampleloc = texture->getFixedSampleLocations(
+ attachmentImageIndex.getTarget(), attachmentImageIndex.getLevelIndex());
if (fixedSampleLocations->valid() && fixedSampleloc != fixedSampleLocations->value())
{
return false;
@@ -642,16 +642,16 @@
const Context *proxyContext = display->getProxyContext();
- setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_BACK, ImageIndex::MakeInvalid(),
- surface, FramebufferAttachment::kDefaultNumViews,
+ setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_BACK, ImageIndex(), surface,
+ FramebufferAttachment::kDefaultNumViews,
FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
if (surface->getConfig()->depthSize > 0)
{
- setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, ImageIndex::MakeInvalid(),
- surface, FramebufferAttachment::kDefaultNumViews,
+ setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_DEPTH, ImageIndex(), surface,
+ FramebufferAttachment::kDefaultNumViews,
FramebufferAttachment::kDefaultBaseViewIndex,
FramebufferAttachment::kDefaultMultiviewLayout,
FramebufferAttachment::kDefaultViewportOffsets);
@@ -659,11 +659,11 @@
if (surface->getConfig()->stencilSize > 0)
{
- setAttachmentImpl(
- proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_STENCIL, ImageIndex::MakeInvalid(), surface,
- FramebufferAttachment::kDefaultNumViews, FramebufferAttachment::kDefaultBaseViewIndex,
- FramebufferAttachment::kDefaultMultiviewLayout,
- FramebufferAttachment::kDefaultViewportOffsets);
+ setAttachmentImpl(proxyContext, GL_FRAMEBUFFER_DEFAULT, GL_STENCIL, ImageIndex(), surface,
+ FramebufferAttachment::kDefaultNumViews,
+ FramebufferAttachment::kDefaultBaseViewIndex,
+ FramebufferAttachment::kDefaultMultiviewLayout,
+ FramebufferAttachment::kDefaultViewportOffsets);
}
mState.mDrawBufferTypeMask.setIndex(getDrawbufferWriteType(0), 0);
}
@@ -1589,7 +1589,7 @@
}
else
{
- return ImageIndex::MakeInvalid();
+ return ImageIndex();
}
};
@@ -1599,14 +1599,14 @@
setAttachmentImpl(context, depth.type(), GL_DEPTH_ATTACHMENT,
getImageIndexIfTextureAttachment(depth), depth.getResource(), numViews,
baseViewIndex, multiviewLayout, viewportOffsets);
- setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(),
- nullptr, numViews, baseViewIndex, multiviewLayout, viewportOffsets);
+ setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex(), 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,
- numViews, baseViewIndex, multiviewLayout, viewportOffsets);
+ setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex(), nullptr, numViews,
+ baseViewIndex, multiviewLayout, viewportOffsets);
setAttachmentImpl(context, stencil.type(), GL_STENCIL_ATTACHMENT,
getImageIndexIfTextureAttachment(stencil), stencil.getResource(),
numViews, baseViewIndex, multiviewLayout, viewportOffsets);
@@ -1625,10 +1625,10 @@
}
else
{
- setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex::MakeInvalid(), nullptr,
- numViews, baseViewIndex, multiviewLayout, viewportOffsets);
- setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex::MakeInvalid(),
- nullptr, numViews, baseViewIndex, multiviewLayout, viewportOffsets);
+ setAttachmentImpl(context, GL_NONE, GL_DEPTH_ATTACHMENT, ImageIndex(), nullptr, numViews,
+ baseViewIndex, multiviewLayout, viewportOffsets);
+ setAttachmentImpl(context, GL_NONE, GL_STENCIL_ATTACHMENT, ImageIndex(), nullptr, numViews,
+ baseViewIndex, multiviewLayout, viewportOffsets);
}
}
@@ -1736,7 +1736,7 @@
void Framebuffer::resetAttachment(const Context *context, GLenum binding)
{
- setAttachment(context, GL_NONE, binding, ImageIndex::MakeInvalid(), nullptr);
+ setAttachment(context, GL_NONE, binding, ImageIndex(), nullptr);
}
Error Framebuffer::syncState(const Context *context)
@@ -1879,12 +1879,11 @@
if (readAttachment->isTextureWithId(copyTextureID))
{
const auto &imageIndex = readAttachment->getTextureImageIndex();
- if (imageIndex.mipIndex == copyTextureLevel)
+ if (imageIndex.getLevelIndex() == copyTextureLevel)
{
// Check 3D/Array texture layers.
- return imageIndex.layerIndex == ImageIndex::ENTIRE_LEVEL ||
- copyTextureLayer == ImageIndex::ENTIRE_LEVEL ||
- imageIndex.layerIndex == copyTextureLayer;
+ return !imageIndex.hasLayer() || copyTextureLayer == ImageIndex::kEntireLevel ||
+ imageIndex.getLayerIndex() == copyTextureLayer;
}
}
return false;