Commit c4f27e4b by Jamie Madill Committed by Commit Bot

Texture: Pass ImageIndex to relevant methods.

The Vulkan back-end will be using this helper struct, so make it available everywhere. This cleans up a lot of the code for D3D. Potentially in the future we could generate these in the entry points if we supported packing multiple arguments into one. Also changes a few parameter types to GLint for compatibility. Also updates the Vulkan Texture implementation check the stored vk::Format on setImage changes. Bug: angleproject:2318 Change-Id: I57cea4a42483ab51859229517d783b58f206b8e7 Reviewed-on: https://chromium-review.googlesource.com/985203 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent 22f12fed
...@@ -108,7 +108,7 @@ TEST(ImageTest, RespecificationReleasesReferences) ...@@ -108,7 +108,7 @@ TEST(ImageTest, RespecificationReleasesReferences)
gl::PixelUnpackState defaultUnpackState; gl::PixelUnpackState defaultUnpackState;
EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _, _)) EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _))
.WillOnce(Return(gl::NoError())) .WillOnce(Return(gl::NoError()))
.RetiresOnSaturation(); .RetiresOnSaturation();
EXPECT_FALSE(texture EXPECT_FALSE(texture
...@@ -132,7 +132,7 @@ TEST(ImageTest, RespecificationReleasesReferences) ...@@ -132,7 +132,7 @@ TEST(ImageTest, RespecificationReleasesReferences)
// Respecify the texture and verify that the image releases its reference // Respecify the texture and verify that the image releases its reference
rx::MockImageImpl *imageImpl = static_cast<rx::MockImageImpl *>(image->getImplementation()); rx::MockImageImpl *imageImpl = static_cast<rx::MockImageImpl *>(image->getImplementation());
EXPECT_CALL(*imageImpl, orphan(_, _)).WillOnce(Return(gl::NoError())).RetiresOnSaturation(); EXPECT_CALL(*imageImpl, orphan(_, _)).WillOnce(Return(gl::NoError())).RetiresOnSaturation();
EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _, _)) EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _))
.WillOnce(Return(gl::NoError())) .WillOnce(Return(gl::NoError()))
.RetiresOnSaturation(); .RetiresOnSaturation();
......
...@@ -931,7 +931,7 @@ void Texture::signalDirty(const Context *context, InitState initState) ...@@ -931,7 +931,7 @@ void Texture::signalDirty(const Context *context, InitState initState)
Error Texture::setImage(const Context *context, Error Texture::setImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
const Extents &size, const Extents &size,
GLenum format, GLenum format,
...@@ -944,8 +944,10 @@ Error Texture::setImage(const Context *context, ...@@ -944,8 +944,10 @@ Error Texture::setImage(const Context *context,
ANGLE_TRY(releaseTexImageInternal(context)); ANGLE_TRY(releaseTexImageInternal(context));
ANGLE_TRY(orphanImages(context)); ANGLE_TRY(orphanImages(context));
ANGLE_TRY(mTexture->setImage(context, target, level, internalFormat, size, format, type, ImageIndex index = ImageIndex::MakeGeneric(target, level);
unpackState, pixels));
ANGLE_TRY(mTexture->setImage(context, index, internalFormat, size, format, type, unpackState,
pixels));
InitState initState = DetermineInitState(context, pixels); InitState initState = DetermineInitState(context, pixels);
mState.setImageDesc(target, level, ImageDesc(size, Format(internalFormat, type), initState)); mState.setImageDesc(target, level, ImageDesc(size, Format(internalFormat, type), initState));
...@@ -957,7 +959,7 @@ Error Texture::setImage(const Context *context, ...@@ -957,7 +959,7 @@ Error Texture::setImage(const Context *context,
Error Texture::setSubImage(const Context *context, Error Texture::setSubImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Box &area, const Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -967,13 +969,15 @@ Error Texture::setSubImage(const Context *context, ...@@ -967,13 +969,15 @@ Error Texture::setSubImage(const Context *context,
ANGLE_TRY(ensureSubImageInitialized(context, target, level, area)); ANGLE_TRY(ensureSubImageInitialized(context, target, level, area));
return mTexture->setSubImage(context, target, level, area, format, type, unpackState, pixels); ImageIndex index = ImageIndex::MakeGeneric(target, level);
return mTexture->setSubImage(context, index, area, format, type, unpackState, pixels);
} }
Error Texture::setCompressedImage(const Context *context, Error Texture::setCompressedImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
const Extents &size, const Extents &size,
size_t imageSize, size_t imageSize,
...@@ -985,8 +989,10 @@ Error Texture::setCompressedImage(const Context *context, ...@@ -985,8 +989,10 @@ Error Texture::setCompressedImage(const Context *context,
ANGLE_TRY(releaseTexImageInternal(context)); ANGLE_TRY(releaseTexImageInternal(context));
ANGLE_TRY(orphanImages(context)); ANGLE_TRY(orphanImages(context));
ANGLE_TRY(mTexture->setCompressedImage(context, target, level, internalFormat, size, ImageIndex index = ImageIndex::MakeGeneric(target, level);
unpackState, imageSize, pixels));
ANGLE_TRY(mTexture->setCompressedImage(context, index, internalFormat, size, unpackState,
imageSize, pixels));
InitState initState = DetermineInitState(context, pixels); InitState initState = DetermineInitState(context, pixels);
mState.setImageDesc(target, level, ImageDesc(size, Format(internalFormat), initState)); mState.setImageDesc(target, level, ImageDesc(size, Format(internalFormat), initState));
...@@ -998,7 +1004,7 @@ Error Texture::setCompressedImage(const Context *context, ...@@ -998,7 +1004,7 @@ Error Texture::setCompressedImage(const Context *context,
Error Texture::setCompressedSubImage(const Context *context, Error Texture::setCompressedSubImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Box &area, const Box &area,
GLenum format, GLenum format,
size_t imageSize, size_t imageSize,
...@@ -1008,13 +1014,15 @@ Error Texture::setCompressedSubImage(const Context *context, ...@@ -1008,13 +1014,15 @@ Error Texture::setCompressedSubImage(const Context *context,
ANGLE_TRY(ensureSubImageInitialized(context, target, level, area)); ANGLE_TRY(ensureSubImageInitialized(context, target, level, area));
return mTexture->setCompressedSubImage(context, target, level, area, format, unpackState, ImageIndex index = ImageIndex::MakeGeneric(target, level);
imageSize, pixels);
return mTexture->setCompressedSubImage(context, index, area, format, unpackState, imageSize,
pixels);
} }
Error Texture::copyImage(const Context *context, Error Texture::copyImage(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Rectangle &sourceArea, const Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
Framebuffer *source) Framebuffer *source)
...@@ -1032,7 +1040,9 @@ Error Texture::copyImage(const Context *context, ...@@ -1032,7 +1040,9 @@ Error Texture::copyImage(const Context *context,
Box destBox(0, 0, 0, sourceArea.width, sourceArea.height, 1); Box destBox(0, 0, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox)); ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox));
ANGLE_TRY(mTexture->copyImage(context, target, level, sourceArea, internalFormat, source)); ImageIndex index = ImageIndex::MakeGeneric(target, level);
ANGLE_TRY(mTexture->copyImage(context, index, sourceArea, internalFormat, source));
const InternalFormat &internalFormatInfo = const InternalFormat &internalFormatInfo =
GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE); GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE);
...@@ -1049,7 +1059,7 @@ Error Texture::copyImage(const Context *context, ...@@ -1049,7 +1059,7 @@ Error Texture::copyImage(const Context *context,
Error Texture::copySubImage(const Context *context, Error Texture::copySubImage(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Offset &destOffset, const Offset &destOffset,
const Rectangle &sourceArea, const Rectangle &sourceArea,
Framebuffer *source) Framebuffer *source)
...@@ -1062,15 +1072,17 @@ Error Texture::copySubImage(const Context *context, ...@@ -1062,15 +1072,17 @@ Error Texture::copySubImage(const Context *context,
Box destBox(destOffset.x, destOffset.y, destOffset.y, sourceArea.width, sourceArea.height, 1); Box destBox(destOffset.x, destOffset.y, destOffset.y, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox)); ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox));
return mTexture->copySubImage(context, target, level, destOffset, sourceArea, source); ImageIndex index = ImageIndex::MakeGeneric(target, level);
return mTexture->copySubImage(context, index, destOffset, sourceArea, source);
} }
Error Texture::copyTexture(const Context *context, Error Texture::copyTexture(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, GLint sourceLevel,
bool unpackFlipY, bool unpackFlipY,
bool unpackPremultiplyAlpha, bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
...@@ -1087,9 +1099,10 @@ Error Texture::copyTexture(const Context *context, ...@@ -1087,9 +1099,10 @@ Error Texture::copyTexture(const Context *context,
// Note: we don't have a way to notify which portions of the image changed currently. // Note: we don't have a way to notify which portions of the image changed currently.
ANGLE_TRY(source->ensureInitialized(context)); ANGLE_TRY(source->ensureInitialized(context));
ANGLE_TRY(mTexture->copyTexture(context, target, level, internalFormat, type, sourceLevel, ImageIndex index = ImageIndex::MakeGeneric(target, level);
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha,
source)); ANGLE_TRY(mTexture->copyTexture(context, index, internalFormat, type, sourceLevel, unpackFlipY,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha, source));
const auto &sourceDesc = const auto &sourceDesc =
source->mState.getImageDesc(NonCubeTextureTypeToTarget(source->getType()), 0); source->mState.getImageDesc(NonCubeTextureTypeToTarget(source->getType()), 0);
...@@ -1105,9 +1118,9 @@ Error Texture::copyTexture(const Context *context, ...@@ -1105,9 +1118,9 @@ Error Texture::copyTexture(const Context *context,
Error Texture::copySubTexture(const Context *context, Error Texture::copySubTexture(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Offset &destOffset, const Offset &destOffset,
size_t sourceLevel, GLint sourceLevel,
const Rectangle &sourceArea, const Rectangle &sourceArea,
bool unpackFlipY, bool unpackFlipY,
bool unpackPremultiplyAlpha, bool unpackPremultiplyAlpha,
...@@ -1122,7 +1135,9 @@ Error Texture::copySubTexture(const Context *context, ...@@ -1122,7 +1135,9 @@ Error Texture::copySubTexture(const Context *context,
Box destBox(destOffset.x, destOffset.y, destOffset.y, sourceArea.width, sourceArea.height, 1); Box destBox(destOffset.x, destOffset.y, destOffset.y, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox)); ANGLE_TRY(ensureSubImageInitialized(context, target, level, destBox));
return mTexture->copySubTexture(context, target, level, destOffset, sourceLevel, sourceArea, ImageIndex index = ImageIndex::MakeGeneric(target, level);
return mTexture->copySubTexture(context, index, destOffset, sourceLevel, sourceArea,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha, unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha,
source); source);
} }
......
...@@ -280,7 +280,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject ...@@ -280,7 +280,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject
Error setImage(const Context *context, Error setImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
const Extents &size, const Extents &size,
GLenum format, GLenum format,
...@@ -289,7 +289,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject ...@@ -289,7 +289,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject
Error setSubImage(const Context *context, Error setSubImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Box &area, const Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -298,7 +298,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject ...@@ -298,7 +298,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject
Error setCompressedImage(const Context *context, Error setCompressedImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
const Extents &size, const Extents &size,
size_t imageSize, size_t imageSize,
...@@ -306,7 +306,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject ...@@ -306,7 +306,7 @@ class Texture final : public egl::ImageSibling, public LabeledObject
Error setCompressedSubImage(const Context *context, Error setCompressedSubImage(const Context *context,
const PixelUnpackState &unpackState, const PixelUnpackState &unpackState,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Box &area, const Box &area,
GLenum format, GLenum format,
size_t imageSize, size_t imageSize,
...@@ -314,32 +314,32 @@ class Texture final : public egl::ImageSibling, public LabeledObject ...@@ -314,32 +314,32 @@ class Texture final : public egl::ImageSibling, public LabeledObject
Error copyImage(const Context *context, Error copyImage(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Rectangle &sourceArea, const Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
Framebuffer *source); Framebuffer *source);
Error copySubImage(const Context *context, Error copySubImage(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Offset &destOffset, const Offset &destOffset,
const Rectangle &sourceArea, const Rectangle &sourceArea,
Framebuffer *source); Framebuffer *source);
Error copyTexture(const Context *context, Error copyTexture(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, GLint sourceLevel,
bool unpackFlipY, bool unpackFlipY,
bool unpackPremultiplyAlpha, bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
Texture *source); Texture *source);
Error copySubTexture(const Context *context, Error copySubTexture(const Context *context,
TextureTarget target, TextureTarget target,
size_t level, GLint level,
const Offset &destOffset, const Offset &destOffset,
size_t sourceLevel, GLint sourceLevel,
const Rectangle &sourceArea, const Rectangle &sourceArea,
bool unpackFlipY, bool unpackFlipY,
bool unpackPremultiplyAlpha, bool unpackPremultiplyAlpha,
......
...@@ -25,8 +25,7 @@ gl::Error TextureImpl::onDestroy(const gl::Context *context) ...@@ -25,8 +25,7 @@ gl::Error TextureImpl::onDestroy(const gl::Context *context)
} }
gl::Error TextureImpl::copyTexture(const gl::Context *context, gl::Error TextureImpl::copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -40,8 +39,7 @@ gl::Error TextureImpl::copyTexture(const gl::Context *context, ...@@ -40,8 +39,7 @@ gl::Error TextureImpl::copyTexture(const gl::Context *context,
} }
gl::Error TextureImpl::copySubTexture(const gl::Context *context, gl::Error TextureImpl::copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
......
...@@ -49,8 +49,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -49,8 +49,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
virtual gl::Error onDestroy(const gl::Context *context); virtual gl::Error onDestroy(const gl::Context *context);
virtual gl::Error setImage(const gl::Context *context, virtual gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -58,8 +57,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -58,8 +57,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) = 0; const uint8_t *pixels) = 0;
virtual gl::Error setSubImage(const gl::Context *context, virtual gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -67,16 +65,14 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -67,16 +65,14 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
const uint8_t *pixels) = 0; const uint8_t *pixels) = 0;
virtual gl::Error setCompressedImage(const gl::Context *context, virtual gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) = 0; const uint8_t *pixels) = 0;
virtual gl::Error setCompressedSubImage(const gl::Context *context, virtual gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -84,21 +80,18 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -84,21 +80,18 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
const uint8_t *pixels) = 0; const uint8_t *pixels) = 0;
virtual gl::Error copyImage(const gl::Context *context, virtual gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) = 0; gl::Framebuffer *source) = 0;
virtual gl::Error copySubImage(const gl::Context *context, virtual gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) = 0; gl::Framebuffer *source) = 0;
virtual gl::Error copyTexture(const gl::Context *context, virtual gl::Error copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -107,8 +100,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl ...@@ -107,8 +100,7 @@ class TextureImpl : public FramebufferAttachmentObjectImpl
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source); const gl::Texture *source);
virtual gl::Error copySubTexture(const gl::Context *context, virtual gl::Error copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
......
...@@ -21,79 +21,71 @@ class MockTextureImpl : public TextureImpl ...@@ -21,79 +21,71 @@ class MockTextureImpl : public TextureImpl
public: public:
MockTextureImpl() : TextureImpl(mMockState), mMockState(gl::TextureType::_2D) {} MockTextureImpl() : TextureImpl(mMockState), mMockState(gl::TextureType::_2D) {}
virtual ~MockTextureImpl() { destructor(); } virtual ~MockTextureImpl() { destructor(); }
MOCK_METHOD9(setImage, MOCK_METHOD8(setImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
GLenum, GLenum,
const gl::Extents &, const gl::Extents &,
GLenum, GLenum,
GLenum, GLenum,
const gl::PixelUnpackState &, const gl::PixelUnpackState &,
const uint8_t *)); const uint8_t *));
MOCK_METHOD8(setSubImage, MOCK_METHOD7(setSubImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
const gl::Box &, const gl::Box &,
GLenum, GLenum,
GLenum, GLenum,
const gl::PixelUnpackState &, const gl::PixelUnpackState &,
const uint8_t *)); const uint8_t *));
MOCK_METHOD8(setCompressedImage, MOCK_METHOD7(setCompressedImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
GLenum, GLenum,
const gl::Extents &, const gl::Extents &,
const gl::PixelUnpackState &, const gl::PixelUnpackState &,
size_t, size_t,
const uint8_t *)); const uint8_t *));
MOCK_METHOD8(setCompressedSubImage, MOCK_METHOD7(setCompressedSubImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
const gl::Box &, const gl::Box &,
GLenum, GLenum,
const gl::PixelUnpackState &, const gl::PixelUnpackState &,
size_t, size_t,
const uint8_t *)); const uint8_t *));
MOCK_METHOD6(copyImage, MOCK_METHOD5(copyImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
const gl::Rectangle &, const gl::Rectangle &,
GLenum, GLenum,
gl::Framebuffer *)); gl::Framebuffer *));
MOCK_METHOD6(copySubImage, MOCK_METHOD5(copySubImage,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t,
const gl::Offset &, const gl::Offset &,
const gl::Rectangle &, const gl::Rectangle &,
gl::Framebuffer *)); gl::Framebuffer *));
MOCK_METHOD10(copyTexture, MOCK_METHOD9(copyTexture,
gl::Error(const gl::Context *, gl::Error(const gl::Context *,
gl::TextureTarget, const gl::ImageIndex &,
size_t, GLenum,
GLenum, GLenum,
GLenum, size_t,
size_t, bool,
bool, bool,
bool, bool,
bool, const gl::Texture *));
const gl::Texture *)); MOCK_METHOD9(copySubTexture,
MOCK_METHOD10(copySubTexture, gl::Error(const gl::Context *,
gl::Error(const gl::Context *, const gl::ImageIndex &,
gl::TextureTarget, const gl::Offset &,
size_t, size_t,
const gl::Offset &, const gl::Rectangle &,
size_t, bool,
const gl::Rectangle &, bool,
bool, bool,
bool, const gl::Texture *));
bool,
const gl::Texture *));
MOCK_METHOD2(copyCompressedTexture, gl::Error(const gl::Context *, const gl::Texture *source)); MOCK_METHOD2(copyCompressedTexture, gl::Error(const gl::Context *, const gl::Texture *source));
MOCK_METHOD5( MOCK_METHOD5(
setStorage, setStorage,
......
...@@ -821,8 +821,7 @@ bool TextureD3D_2D::isSRGB(GLint level) const ...@@ -821,8 +821,7 @@ bool TextureD3D_2D::isSRGB(GLint level) const
} }
gl::Error TextureD3D_2D::setImage(const gl::Context *context, gl::Error TextureD3D_2D::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -830,34 +829,32 @@ gl::Error TextureD3D_2D::setImage(const gl::Context *context, ...@@ -830,34 +829,32 @@ gl::Error TextureD3D_2D::setImage(const gl::Context *context,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2D && size.depth == 1); ASSERT(index.target == gl::TextureTarget::_2D && size.depth == 1);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
bool fastUnpacked = false; bool fastUnpacked = false;
GLint level = static_cast<GLint>(imageLevel);
ANGLE_TRY(redefineImage(context, level, internalFormatInfo.sizedInternalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormatInfo.sizedInternalFormat, size,
false));
gl::ImageIndex index = gl::ImageIndex::Make2D(level);
// Attempt a fast gpu copy of the pixel data to the surface // Attempt a fast gpu copy of the pixel data to the surface
gl::Buffer *unpackBuffer = gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
if (isFastUnpackable(unpackBuffer, internalFormatInfo.sizedInternalFormat) && if (isFastUnpackable(unpackBuffer, internalFormatInfo.sizedInternalFormat) &&
isLevelComplete(level)) isLevelComplete(index.mipIndex))
{ {
// Will try to create RT storage if it does not exist // Will try to create RT storage if it does not exist
RenderTargetD3D *destRenderTarget = nullptr; RenderTargetD3D *destRenderTarget = nullptr;
ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget)); ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget));
gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), 1); gl::Box destArea(0, 0, 0, getWidth(index.mipIndex), getHeight(index.mipIndex), 1);
ANGLE_TRY(fastUnpackPixels(context, unpack, pixels, destArea, ANGLE_TRY(fastUnpackPixels(context, unpack, pixels, destArea,
internalFormatInfo.sizedInternalFormat, type, destRenderTarget)); internalFormatInfo.sizedInternalFormat, type, destRenderTarget));
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[index.mipIndex]->markClean();
fastUnpacked = true; fastUnpacked = true;
} }
...@@ -871,29 +868,25 @@ gl::Error TextureD3D_2D::setImage(const gl::Context *context, ...@@ -871,29 +868,25 @@ gl::Error TextureD3D_2D::setImage(const gl::Context *context,
} }
gl::Error TextureD3D_2D::setSubImage(const gl::Context *context, gl::Error TextureD3D_2D::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2D && area.depth == 1 && area.z == 0); ASSERT(index.target == gl::TextureTarget::_2D && area.depth == 1 && area.z == 0);
GLint level = static_cast<GLint>(imageLevel);
gl::ImageIndex index = gl::ImageIndex::Make2D(level);
gl::Buffer *unpackBuffer = gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
if (isFastUnpackable(unpackBuffer, getInternalFormat(level)) && isLevelComplete(level)) GLenum mipFormat = getInternalFormat(index.mipIndex);
if (isFastUnpackable(unpackBuffer, mipFormat) && isLevelComplete(index.mipIndex))
{ {
RenderTargetD3D *renderTarget = nullptr; RenderTargetD3D *renderTarget = nullptr;
ANGLE_TRY(getRenderTarget(context, index, &renderTarget)); ANGLE_TRY(getRenderTarget(context, index, &renderTarget));
ASSERT(!mImageArray[level]->isDirty()); ASSERT(!mImageArray[index.mipIndex]->isDirty());
return fastUnpackPixels(context, unpack, pixels, area, getInternalFormat(level), type, return fastUnpackPixels(context, unpack, pixels, area, mipFormat, type, renderTarget);
renderTarget);
} }
else else
{ {
...@@ -902,55 +895,48 @@ gl::Error TextureD3D_2D::setSubImage(const gl::Context *context, ...@@ -902,55 +895,48 @@ gl::Error TextureD3D_2D::setSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_2D::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_2D::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2D && size.depth == 1); ASSERT(index.target == gl::TextureTarget::_2D && size.depth == 1);
GLint level = static_cast<GLint>(imageLevel);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
ANGLE_TRY(redefineImage(context, level, internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormat, size, false));
return setCompressedImageImpl(context, gl::ImageIndex::Make2D(level), unpack, pixels, 0); return setCompressedImageImpl(context, index, unpack, pixels, 0);
} }
gl::Error TextureD3D_2D::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_2D::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2D && area.depth == 1 && area.z == 0); ASSERT(index.target == gl::TextureTarget::_2D && area.depth == 1 && area.z == 0);
gl::ImageIndex index = gl::ImageIndex::Make2D(static_cast<GLint>(level));
ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0)); ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0));
return commitRegion(context, index, area); return commitRegion(context, index, area);
} }
gl::Error TextureD3D_2D::copyImage(const gl::Context *context, gl::Error TextureD3D_2D::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
ASSERT(target == gl::TextureTarget::_2D); ASSERT(index.target == gl::TextureTarget::_2D);
GLint level = static_cast<GLint>(imageLevel);
const gl::InternalFormat &internalFormatInfo = const gl::InternalFormat &internalFormatInfo =
gl::GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE); gl::GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE);
gl::Extents sourceExtents(origSourceArea.width, origSourceArea.height, 1); gl::Extents sourceExtents(origSourceArea.width, origSourceArea.height, 1);
ANGLE_TRY(redefineImage(context, level, internalFormatInfo.sizedInternalFormat, sourceExtents, ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormatInfo.sizedInternalFormat,
false)); sourceExtents, false));
gl::Extents fbSize = source->getReadColorbuffer()->getSize(); gl::Extents fbSize = source->getReadColorbuffer()->getSize();
...@@ -972,9 +958,8 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context, ...@@ -972,9 +958,8 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context,
origSourceArea.width * origSourceArea.height * internalFormatInfo.pixelBytes, &zero)); origSourceArea.width * origSourceArea.height * internalFormatInfo.pixelBytes, &zero));
gl::PixelUnpackState unpack; gl::PixelUnpackState unpack;
unpack.alignment = 1; unpack.alignment = 1;
ANGLE_TRY(setImage(context, target, imageLevel, internalFormat, sourceExtents, ANGLE_TRY(setImage(context, index, internalFormat, sourceExtents, internalFormatInfo.format,
internalFormatInfo.format, internalFormatInfo.type, unpack, internalFormatInfo.type, unpack, zero->data()));
zero->data()));
} }
gl::Rectangle sourceArea; gl::Rectangle sourceArea;
...@@ -985,25 +970,25 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context, ...@@ -985,25 +970,25 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context,
return gl::NoError(); return gl::NoError();
} }
gl::ImageIndex index = gl::ImageIndex::Make2D(level);
gl::Offset destOffset(sourceArea.x - origSourceArea.x, sourceArea.y - origSourceArea.y, 0); gl::Offset destOffset(sourceArea.x - origSourceArea.x, sourceArea.y - origSourceArea.y, 0);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path. // so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, destOffset, sourceArea, source)); ANGLE_TRY(mImageArray[index.mipIndex]->copyFromFramebuffer(context, destOffset, sourceArea,
source));
mDirtyImages = true; mDirtyImages = true;
} }
else else
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
if (sourceArea.width != 0 && sourceArea.height != 0 && isValidLevel(level)) if (sourceArea.width != 0 && sourceArea.height != 0 && isValidLevel(index.mipIndex))
{ {
ANGLE_TRY(updateStorageLevel(context, level)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
ANGLE_TRY(mRenderer->copyImage2D(context, source, sourceArea, internalFormat, ANGLE_TRY(mRenderer->copyImage2D(context, source, sourceArea, internalFormat,
destOffset, mTexStorage, level)); destOffset, mTexStorage, index.mipIndex));
} }
} }
...@@ -1011,13 +996,12 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context, ...@@ -1011,13 +996,12 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_2D::copySubImage(const gl::Context *context, gl::Error TextureD3D_2D::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Offset &origDestOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
ASSERT(target == gl::TextureTarget::_2D && origDestOffset.z == 0); ASSERT(index.target == gl::TextureTarget::_2D && origDestOffset.z == 0);
gl::Extents fbSize = source->getReadColorbuffer()->getSize(); gl::Extents fbSize = source->getReadColorbuffer()->getSize();
gl::Rectangle sourceArea; gl::Rectangle sourceArea;
...@@ -1032,26 +1016,24 @@ gl::Error TextureD3D_2D::copySubImage(const gl::Context *context, ...@@ -1032,26 +1016,24 @@ gl::Error TextureD3D_2D::copySubImage(const gl::Context *context,
// can only make our texture storage to a render target if level 0 is defined (with a width & height) and // can only make our texture storage to a render target if level 0 is defined (with a width & height) and
// the current level we're copying to is defined (with appropriate format, width & height) // the current level we're copying to is defined (with appropriate format, width & height)
GLint level = static_cast<GLint>(imageLevel);
gl::ImageIndex index = gl::ImageIndex::Make2D(level);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path. // so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, destOffset, sourceArea, source)); ANGLE_TRY(mImageArray[index.mipIndex]->copyFromFramebuffer(context, destOffset, sourceArea,
source));
mDirtyImages = true; mDirtyImages = true;
} }
else else
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
if (isValidLevel(level)) if (isValidLevel(index.mipIndex))
{ {
ANGLE_TRY(updateStorageLevel(context, level)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
ANGLE_TRY(mRenderer->copyImage2D(context, source, sourceArea, ANGLE_TRY(mRenderer->copyImage2D(context, source, sourceArea,
gl::GetUnsizedFormat(getBaseLevelInternalFormat()), gl::GetUnsizedFormat(getBaseLevelInternalFormat()),
destOffset, mTexStorage, level)); destOffset, mTexStorage, index.mipIndex));
} }
} }
...@@ -1059,8 +1041,7 @@ gl::Error TextureD3D_2D::copySubImage(const gl::Context *context, ...@@ -1059,8 +1041,7 @@ gl::Error TextureD3D_2D::copySubImage(const gl::Context *context,
} }
gl::Error TextureD3D_2D::copyTexture(const gl::Context *context, gl::Error TextureD3D_2D::copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -1069,33 +1050,31 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context, ...@@ -1069,33 +1050,31 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
ASSERT(target == gl::TextureTarget::_2D); ASSERT(index.target == gl::TextureTarget::_2D);
gl::TextureType sourceType = source->getType(); gl::TextureType sourceType = source->getType();
GLint destLevel = static_cast<GLint>(level);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
gl::Extents size( gl::Extents size(
static_cast<int>(source->getWidth(NonCubeTextureTypeToTarget(sourceType), sourceLevel)), static_cast<int>(source->getWidth(NonCubeTextureTypeToTarget(sourceType), sourceLevel)),
static_cast<int>(source->getHeight(NonCubeTextureTypeToTarget(sourceType), sourceLevel)), static_cast<int>(source->getHeight(NonCubeTextureTypeToTarget(sourceType), sourceLevel)),
1); 1);
ANGLE_TRY( ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormatInfo.sizedInternalFormat, size,
redefineImage(context, destLevel, internalFormatInfo.sizedInternalFormat, size, false)); false));
gl::Rectangle sourceRect(0, 0, size.width, size.height); gl::Rectangle sourceRect(0, 0, size.width, size.height);
gl::Offset destOffset(0, 0, 0); gl::Offset destOffset(0, 0, 0);
if (!isSRGB(destLevel) && canCreateRenderTargetForImage(gl::ImageIndex::Make2D(destLevel))) if (!isSRGB(index.mipIndex) && canCreateRenderTargetForImage(index))
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
ASSERT(isValidLevel(destLevel)); ASSERT(isValidLevel(index.mipIndex));
ANGLE_TRY(updateStorageLevel(context, destLevel)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
ANGLE_TRY(mRenderer->copyTexture( ANGLE_TRY(mRenderer->copyTexture(
context, source, static_cast<GLint>(sourceLevel), sourceRect, internalFormatInfo.format, context, source, static_cast<GLint>(sourceLevel), sourceRect, internalFormatInfo.format,
internalFormatInfo.type, destOffset, mTexStorage, target, destLevel, unpackFlipY, internalFormatInfo.type, destOffset, mTexStorage, index.target, index.mipIndex,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
} }
else else
{ {
...@@ -1104,9 +1083,8 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context, ...@@ -1104,9 +1083,8 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr; ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage)); ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
gl::ImageIndex destImageIndex = gl::ImageIndex::Make2D(static_cast<GLint>(destLevel));
ImageD3D *destImage = nullptr; ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, destImageIndex, &destImage)); ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
...@@ -1114,15 +1092,14 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context, ...@@ -1114,15 +1092,14 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context,
mDirtyImages = true; mDirtyImages = true;
gl::Box destRegion(destOffset, size); gl::Box destRegion(destOffset, size);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, index, destRegion));
} }
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context, gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -1131,22 +1108,20 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context, ...@@ -1131,22 +1108,20 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
ASSERT(target == gl::TextureTarget::_2D); ASSERT(index.target == gl::TextureTarget::_2D);
GLint destLevel = static_cast<GLint>(level); if (!isSRGB(index.mipIndex) && canCreateRenderTargetForImage(index))
if (!isSRGB(destLevel) && canCreateRenderTargetForImage(gl::ImageIndex::Make2D(destLevel)))
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
ASSERT(isValidLevel(destLevel)); ASSERT(isValidLevel(index.mipIndex));
ANGLE_TRY(updateStorageLevel(context, destLevel)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
const gl::InternalFormat &internalFormatInfo = const gl::InternalFormat &internalFormatInfo =
gl::GetSizedInternalFormatInfo(getInternalFormat(destLevel)); gl::GetSizedInternalFormatInfo(getInternalFormat(index.mipIndex));
ANGLE_TRY(mRenderer->copyTexture( ANGLE_TRY(mRenderer->copyTexture(
context, source, static_cast<GLint>(sourceLevel), sourceArea, internalFormatInfo.format, context, source, static_cast<GLint>(sourceLevel), sourceArea, internalFormatInfo.format,
internalFormatInfo.type, destOffset, mTexStorage, target, destLevel, unpackFlipY, internalFormatInfo.type, destOffset, mTexStorage, index.target, index.mipIndex,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
} }
else else
{ {
...@@ -1155,9 +1130,8 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context, ...@@ -1155,9 +1130,8 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr; ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage)); ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
gl::ImageIndex destImageIndex = gl::ImageIndex::Make2D(static_cast<GLint>(destLevel));
ImageD3D *destImage = nullptr; ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, destImageIndex, &destImage)); ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
...@@ -1165,7 +1139,7 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context, ...@@ -1165,7 +1139,7 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context,
mDirtyImages = true; mDirtyImages = true;
gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1); gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, index, destRegion));
} }
return gl::NoError(); return gl::NoError();
...@@ -1649,8 +1623,7 @@ gl::Error TextureD3D_Cube::setEGLImageTarget(const gl::Context *context, ...@@ -1649,8 +1623,7 @@ gl::Error TextureD3D_Cube::setEGLImageTarget(const gl::Context *context,
} }
gl::Error TextureD3D_Cube::setImage(const gl::Context *context, gl::Error TextureD3D_Cube::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -1661,17 +1634,14 @@ gl::Error TextureD3D_Cube::setImage(const gl::Context *context, ...@@ -1661,17 +1634,14 @@ gl::Error TextureD3D_Cube::setImage(const gl::Context *context,
ASSERT(size.depth == 1); ASSERT(size.depth == 1);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level)); ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), index.mipIndex,
ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), static_cast<GLint>(level),
internalFormatInfo.sizedInternalFormat, size, false)); internalFormatInfo.sizedInternalFormat, size, false));
return setImageImpl(context, index, type, unpack, pixels, 0); return setImageImpl(context, index, type, unpack, pixels, 0);
} }
gl::Error TextureD3D_Cube::setSubImage(const gl::Context *context, gl::Error TextureD3D_Cube::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -1679,14 +1649,11 @@ gl::Error TextureD3D_Cube::setSubImage(const gl::Context *context, ...@@ -1679,14 +1649,11 @@ gl::Error TextureD3D_Cube::setSubImage(const gl::Context *context,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(area.depth == 1 && area.z == 0); ASSERT(area.depth == 1 && area.z == 0);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level));
return TextureD3D::subImage(context, index, area, format, type, unpack, pixels, 0); return TextureD3D::subImage(context, index, area, format, type, unpack, pixels, 0);
} }
gl::Error TextureD3D_Cube::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_Cube::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -1696,18 +1663,14 @@ gl::Error TextureD3D_Cube::setCompressedImage(const gl::Context *context, ...@@ -1696,18 +1663,14 @@ gl::Error TextureD3D_Cube::setCompressedImage(const gl::Context *context,
ASSERT(size.depth == 1); ASSERT(size.depth == 1);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
size_t faceIndex = gl::CubeMapTextureTargetToFaceIndex(target); ANGLE_TRY(redefineImage(context, index.cubeMapFaceIndex(), index.mipIndex, internalFormat, size,
false));
ANGLE_TRY(redefineImage(context, static_cast<int>(faceIndex), static_cast<GLint>(level),
internalFormat, size, false));
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level));
return setCompressedImageImpl(context, index, unpack, pixels, 0); return setCompressedImageImpl(context, index, unpack, pixels, 0);
} }
gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -1716,28 +1679,23 @@ gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context, ...@@ -1716,28 +1679,23 @@ gl::Error TextureD3D_Cube::setCompressedSubImage(const gl::Context *context,
{ {
ASSERT(area.depth == 1 && area.z == 0); ASSERT(area.depth == 1 && area.z == 0);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, static_cast<GLint>(level));
ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0)); ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0));
return commitRegion(context, index, area); return commitRegion(context, index, area);
} }
gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToFaceIndex(target)); GLint faceIndex = index.cubeMapFaceIndex();
const gl::InternalFormat &internalFormatInfo = const gl::InternalFormat &internalFormatInfo =
gl::GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE); gl::GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE);
GLint level = static_cast<GLint>(imageLevel);
gl::Extents size(origSourceArea.width, origSourceArea.height, 1); gl::Extents size(origSourceArea.width, origSourceArea.height, 1);
ANGLE_TRY(redefineImage(context, faceIndex, level, internalFormatInfo.sizedInternalFormat, size, ANGLE_TRY(redefineImage(context, faceIndex, index.mipIndex,
false)); internalFormatInfo.sizedInternalFormat, size, false));
gl::Extents fbSize = source->getReadColorbuffer()->getSize(); gl::Extents fbSize = source->getReadColorbuffer()->getSize();
...@@ -1759,9 +1717,8 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1759,9 +1717,8 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
origSourceArea.width * origSourceArea.height * internalFormatInfo.pixelBytes, &zero)); origSourceArea.width * origSourceArea.height * internalFormatInfo.pixelBytes, &zero));
gl::PixelUnpackState unpack; gl::PixelUnpackState unpack;
unpack.alignment = 1; unpack.alignment = 1;
ANGLE_TRY(setImage(context, target, imageLevel, internalFormat, size, ANGLE_TRY(setImage(context, index, internalFormat, size, internalFormatInfo.format,
internalFormatInfo.format, internalFormatInfo.type, unpack, internalFormatInfo.type, unpack, zero->data()));
zero->data()));
} }
gl::Rectangle sourceArea; gl::Rectangle sourceArea;
...@@ -1772,15 +1729,14 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1772,15 +1729,14 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
return gl::NoError(); return gl::NoError();
} }
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
gl::Offset destOffset(sourceArea.x - origSourceArea.x, sourceArea.y - origSourceArea.y, 0); gl::Offset destOffset(sourceArea.x - origSourceArea.x, sourceArea.y - origSourceArea.y, 0);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path. // so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[faceIndex][level]->copyFromFramebuffer(context, destOffset, ANGLE_TRY(mImageArray[faceIndex][index.mipIndex]->copyFromFramebuffer(context, destOffset,
sourceArea, source)); sourceArea, source));
mDirtyImages = true; mDirtyImages = true;
} }
else else
...@@ -1789,11 +1745,12 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1789,11 +1745,12 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
ASSERT(size.width == size.height); ASSERT(size.width == size.height);
if (size.width > 0 && isValidFaceLevel(faceIndex, level)) if (size.width > 0 && isValidFaceLevel(faceIndex, index.mipIndex))
{ {
ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, level)); ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, index.mipIndex));
ANGLE_TRY(mRenderer->copyImageCube(context, source, sourceArea, internalFormat, ANGLE_TRY(mRenderer->copyImageCube(context, source, sourceArea, internalFormat,
destOffset, mTexStorage, target, level)); destOffset, mTexStorage, index.target,
index.mipIndex));
} }
} }
...@@ -1801,8 +1758,7 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context, ...@@ -1801,8 +1758,7 @@ gl::Error TextureD3D_Cube::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context, gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Offset &origDestOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -1817,28 +1773,25 @@ gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context, ...@@ -1817,28 +1773,25 @@ gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context,
const gl::Offset destOffset(origDestOffset.x + sourceArea.x - origSourceArea.x, const gl::Offset destOffset(origDestOffset.x + sourceArea.x - origSourceArea.x,
origDestOffset.y + sourceArea.y - origSourceArea.y, 0); origDestOffset.y + sourceArea.y - origSourceArea.y, 0);
int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToFaceIndex(target)); GLint faceIndex = index.cubeMapFaceIndex();
GLint level = static_cast<GLint>(imageLevel);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
// If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders, // If the zero max LOD workaround is active, then we can't sample from individual layers of the framebuffer in shaders,
// so we should use the non-rendering copy path. // so we should use the non-rendering copy path.
if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround) if (!canCreateRenderTargetForImage(index) || mRenderer->getWorkarounds().zeroMaxLodWorkaround)
{ {
ANGLE_TRY(mImageArray[faceIndex][level]->copyFromFramebuffer(context, destOffset, ANGLE_TRY(mImageArray[faceIndex][index.mipIndex]->copyFromFramebuffer(context, destOffset,
sourceArea, source)); sourceArea, source));
mDirtyImages = true; mDirtyImages = true;
} }
else else
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
if (isValidFaceLevel(faceIndex, level)) if (isValidFaceLevel(faceIndex, index.mipIndex))
{ {
ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, level)); ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, index.mipIndex));
ANGLE_TRY(mRenderer->copyImageCube(context, source, sourceArea, ANGLE_TRY(mRenderer->copyImageCube(
gl::GetUnsizedFormat(getBaseLevelInternalFormat()), context, source, sourceArea, gl::GetUnsizedFormat(getBaseLevelInternalFormat()),
destOffset, mTexStorage, target, level)); destOffset, mTexStorage, index.target, index.mipIndex));
} }
} }
...@@ -1846,8 +1799,7 @@ gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context, ...@@ -1846,8 +1799,7 @@ gl::Error TextureD3D_Cube::copySubImage(const gl::Context *context,
} }
gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context, gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -1856,33 +1808,31 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context, ...@@ -1856,33 +1808,31 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
ASSERT(gl::TextureTargetToType(target) == gl::TextureType::CubeMap); ASSERT(gl::TextureTargetToType(index.target) == gl::TextureType::CubeMap);
gl::TextureTarget sourceTarget = NonCubeTextureTypeToTarget(source->getType()); gl::TextureTarget sourceTarget = NonCubeTextureTypeToTarget(source->getType());
GLint destLevel = static_cast<GLint>(level); GLint faceIndex = index.cubeMapFaceIndex();
int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToFaceIndex(target));
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
gl::Extents size(static_cast<int>(source->getWidth(sourceTarget, sourceLevel)), gl::Extents size(static_cast<int>(source->getWidth(sourceTarget, sourceLevel)),
static_cast<int>(source->getHeight(sourceTarget, sourceLevel)), 1); static_cast<int>(source->getHeight(sourceTarget, sourceLevel)), 1);
ANGLE_TRY(redefineImage(context, faceIndex, destLevel, internalFormatInfo.sizedInternalFormat, ANGLE_TRY(redefineImage(context, faceIndex, index.mipIndex,
size, false)); internalFormatInfo.sizedInternalFormat, size, false));
gl::Rectangle sourceRect(0, 0, size.width, size.height); gl::Rectangle sourceRect(0, 0, size.width, size.height);
gl::Offset destOffset(0, 0, 0); gl::Offset destOffset(0, 0, 0);
if (!isSRGB(destLevel, faceIndex) && if (!isSRGB(index.mipIndex, faceIndex) && canCreateRenderTargetForImage(index))
canCreateRenderTargetForImage(gl::ImageIndex::MakeCube(target, destLevel)))
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
ASSERT(isValidFaceLevel(faceIndex, destLevel)); ASSERT(isValidFaceLevel(faceIndex, index.mipIndex));
ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, destLevel)); ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, index.mipIndex));
ANGLE_TRY(mRenderer->copyTexture( ANGLE_TRY(mRenderer->copyTexture(
context, source, static_cast<GLint>(sourceLevel), sourceRect, internalFormatInfo.format, context, source, static_cast<GLint>(sourceLevel), sourceRect, internalFormatInfo.format,
internalFormatInfo.type, destOffset, mTexStorage, target, destLevel, unpackFlipY, internalFormatInfo.type, destOffset, mTexStorage, index.target, index.mipIndex,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
} }
else else
{ {
...@@ -1891,10 +1841,8 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context, ...@@ -1891,10 +1841,8 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr; ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage)); ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
gl::ImageIndex destImageIndex =
gl::ImageIndex::MakeCube(target, static_cast<GLint>(destLevel));
ImageD3D *destImage = nullptr; ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, destImageIndex, &destImage)); ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
...@@ -1902,15 +1850,14 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context, ...@@ -1902,15 +1850,14 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context,
mDirtyImages = true; mDirtyImages = true;
gl::Box destRegion(destOffset, size); gl::Box destRegion(destOffset, size);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, index, destRegion));
} }
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context, gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -1919,24 +1866,22 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context, ...@@ -1919,24 +1866,22 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
ASSERT(gl::TextureTargetToType(target) == gl::TextureType::CubeMap); ASSERT(gl::TextureTargetToType(index.target) == gl::TextureType::CubeMap);
GLint destLevel = static_cast<GLint>(level); GLint faceIndex = index.cubeMapFaceIndex();
int faceIndex = static_cast<int>(gl::CubeMapTextureTargetToFaceIndex(target));
if (!isSRGB(destLevel, faceIndex) && if (!isSRGB(index.mipIndex, faceIndex) && canCreateRenderTargetForImage(index))
canCreateRenderTargetForImage(gl::ImageIndex::MakeCube(target, destLevel)))
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
ASSERT(isValidFaceLevel(faceIndex, destLevel)); ASSERT(isValidFaceLevel(faceIndex, index.mipIndex));
ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, destLevel)); ANGLE_TRY(updateStorageFaceLevel(context, faceIndex, index.mipIndex));
const gl::InternalFormat &internalFormatInfo = const gl::InternalFormat &internalFormatInfo =
gl::GetSizedInternalFormatInfo(getInternalFormat(destLevel, faceIndex)); gl::GetSizedInternalFormatInfo(getInternalFormat(index.mipIndex, faceIndex));
ANGLE_TRY(mRenderer->copyTexture( ANGLE_TRY(mRenderer->copyTexture(
context, source, static_cast<GLint>(sourceLevel), sourceArea, internalFormatInfo.format, context, source, static_cast<GLint>(sourceLevel), sourceArea, internalFormatInfo.format,
internalFormatInfo.type, destOffset, mTexStorage, target, destLevel, unpackFlipY, internalFormatInfo.type, destOffset, mTexStorage, index.target, index.mipIndex,
unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
} }
else else
{ {
...@@ -1945,10 +1890,8 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context, ...@@ -1945,10 +1890,8 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context,
ImageD3D *sourceImage = nullptr; ImageD3D *sourceImage = nullptr;
ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage)); ANGLE_TRY(sourceD3D->getImageAndSyncFromStorage(context, sourceImageIndex, &sourceImage));
gl::ImageIndex destImageIndex =
gl::ImageIndex::MakeCube(target, static_cast<GLint>(destLevel));
ImageD3D *destImage = nullptr; ImageD3D *destImage = nullptr;
ANGLE_TRY(getImageAndSyncFromStorage(context, destImageIndex, &destImage)); ANGLE_TRY(getImageAndSyncFromStorage(context, index, &destImage));
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
...@@ -1956,7 +1899,7 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context, ...@@ -1956,7 +1899,7 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context,
mDirtyImages = true; mDirtyImages = true;
gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1); gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, index, destRegion));
} }
return gl::NoError(); return gl::NoError();
...@@ -2415,8 +2358,7 @@ gl::Error TextureD3D_3D::setEGLImageTarget(const gl::Context *context, ...@@ -2415,8 +2358,7 @@ gl::Error TextureD3D_3D::setEGLImageTarget(const gl::Context *context,
} }
gl::Error TextureD3D_3D::setImage(const gl::Context *context, gl::Error TextureD3D_3D::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -2424,33 +2366,32 @@ gl::Error TextureD3D_3D::setImage(const gl::Context *context, ...@@ -2424,33 +2366,32 @@ gl::Error TextureD3D_3D::setImage(const gl::Context *context,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_3D); ASSERT(index.target == gl::TextureTarget::_3D);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat, type);
GLint level = static_cast<GLint>(imageLevel); ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormatInfo.sizedInternalFormat, size,
ANGLE_TRY(redefineImage(context, level, internalFormatInfo.sizedInternalFormat, size, false)); false));
bool fastUnpacked = false; bool fastUnpacked = false;
gl::ImageIndex index = gl::ImageIndex::Make3D(level);
// Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
gl::Buffer *unpackBuffer = gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
if (isFastUnpackable(unpackBuffer, internalFormatInfo.sizedInternalFormat) && !size.empty() && if (isFastUnpackable(unpackBuffer, internalFormatInfo.sizedInternalFormat) && !size.empty() &&
isLevelComplete(level)) isLevelComplete(index.mipIndex))
{ {
// Will try to create RT storage if it does not exist // Will try to create RT storage if it does not exist
RenderTargetD3D *destRenderTarget = nullptr; RenderTargetD3D *destRenderTarget = nullptr;
ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget)); ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget));
gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level)); gl::Box destArea(0, 0, 0, getWidth(index.mipIndex), getHeight(index.mipIndex),
getDepth(index.mipIndex));
ANGLE_TRY(fastUnpackPixels(context, unpack, pixels, destArea, ANGLE_TRY(fastUnpackPixels(context, unpack, pixels, destArea,
internalFormatInfo.sizedInternalFormat, type, destRenderTarget)); internalFormatInfo.sizedInternalFormat, type, destRenderTarget));
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[index.mipIndex]->markClean();
fastUnpacked = true; fastUnpacked = true;
} }
...@@ -2464,30 +2405,26 @@ gl::Error TextureD3D_3D::setImage(const gl::Context *context, ...@@ -2464,30 +2405,26 @@ gl::Error TextureD3D_3D::setImage(const gl::Context *context,
} }
gl::Error TextureD3D_3D::setSubImage(const gl::Context *context, gl::Error TextureD3D_3D::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_3D); ASSERT(index.target == gl::TextureTarget::_3D);
GLint level = static_cast<GLint>(imageLevel);
gl::ImageIndex index = gl::ImageIndex::Make3D(level);
// Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer // Attempt a fast gpu copy of the pixel data to the surface if the app bound an unpack buffer
gl::Buffer *unpackBuffer = gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
if (isFastUnpackable(unpackBuffer, getInternalFormat(level)) && isLevelComplete(level)) GLenum mipFormat = getInternalFormat(index.mipIndex);
if (isFastUnpackable(unpackBuffer, mipFormat) && isLevelComplete(index.mipIndex))
{ {
RenderTargetD3D *destRenderTarget = nullptr; RenderTargetD3D *destRenderTarget = nullptr;
ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget)); ANGLE_TRY(getRenderTarget(context, index, &destRenderTarget));
ASSERT(!mImageArray[level]->isDirty()); ASSERT(!mImageArray[index.mipIndex]->isDirty());
return fastUnpackPixels(context, unpack, pixels, area, getInternalFormat(level), type, return fastUnpackPixels(context, unpack, pixels, area, mipFormat, type, destRenderTarget);
destRenderTarget);
} }
else else
{ {
...@@ -2496,43 +2433,37 @@ gl::Error TextureD3D_3D::setSubImage(const gl::Context *context, ...@@ -2496,43 +2433,37 @@ gl::Error TextureD3D_3D::setSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_3D::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_3D::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_3D); ASSERT(index.target == gl::TextureTarget::_3D);
GLint level = static_cast<GLint>(imageLevel);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
ANGLE_TRY(redefineImage(context, level, internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormat, size, false));
gl::ImageIndex index = gl::ImageIndex::Make3D(level);
return setCompressedImageImpl(context, index, unpack, pixels, 0); return setCompressedImageImpl(context, index, unpack, pixels, 0);
} }
gl::Error TextureD3D_3D::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_3D::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_3D); ASSERT(index.target == gl::TextureTarget::_3D);
gl::ImageIndex index = gl::ImageIndex::Make3D(static_cast<GLint>(level));
ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0)); ANGLE_TRY(TextureD3D::subImageCompressed(context, index, area, format, unpack, pixels, 0));
return commitRegion(context, index, area); return commitRegion(context, index, area);
} }
gl::Error TextureD3D_3D::copyImage(const gl::Context *context, gl::Error TextureD3D_3D::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -2542,15 +2473,12 @@ gl::Error TextureD3D_3D::copyImage(const gl::Context *context, ...@@ -2542,15 +2473,12 @@ gl::Error TextureD3D_3D::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_3D::copySubImage(const gl::Context *context, gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
ASSERT(target == gl::TextureTarget::_3D); ASSERT(index.target == gl::TextureTarget::_3D);
GLint level = static_cast<GLint>(imageLevel);
gl::Extents fbSize = source->getReadColorbuffer()->getSize(); gl::Extents fbSize = source->getReadColorbuffer()->getSize();
gl::Rectangle clippedSourceArea; gl::Rectangle clippedSourceArea;
...@@ -2568,19 +2496,18 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context, ...@@ -2568,19 +2496,18 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
// date before the copy and then copy back to the storage afterwards if needed. // date before the copy and then copy back to the storage afterwards if needed.
// TODO: Investigate 3D blits in D3D11. // TODO: Investigate 3D blits in D3D11.
bool syncTexStorage = mTexStorage && isLevelComplete(level); bool syncTexStorage = mTexStorage && isLevelComplete(index.mipIndex);
if (syncTexStorage) if (syncTexStorage)
{ {
gl::ImageIndex index = gl::ImageIndex::Make3D(level); ANGLE_TRY(mImageArray[index.mipIndex]->copyFromTexStorage(context, index, mTexStorage));
ANGLE_TRY(mImageArray[level]->copyFromTexStorage(context, index, mTexStorage));
} }
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, clippedDestOffset, clippedSourceArea, ANGLE_TRY(mImageArray[index.mipIndex]->copyFromFramebuffer(context, clippedDestOffset,
source)); clippedSourceArea, source));
mDirtyImages = true; mDirtyImages = true;
if (syncTexStorage) if (syncTexStorage)
{ {
ANGLE_TRY(updateStorageLevel(context, level)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
} }
return gl::NoError(); return gl::NoError();
...@@ -2971,8 +2898,7 @@ gl::Error TextureD3D_2DArray::setEGLImageTarget(const gl::Context *context, ...@@ -2971,8 +2898,7 @@ gl::Error TextureD3D_2DArray::setEGLImageTarget(const gl::Context *context,
} }
gl::Error TextureD3D_2DArray::setImage(const gl::Context *context, gl::Error TextureD3D_2DArray::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -2980,12 +2906,11 @@ gl::Error TextureD3D_2DArray::setImage(const gl::Context *context, ...@@ -2980,12 +2906,11 @@ gl::Error TextureD3D_2DArray::setImage(const gl::Context *context,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2DArray); ASSERT(index.target == gl::TextureTarget::_2DArray);
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
GLint level = static_cast<GLint>(imageLevel); ANGLE_TRY(redefineImage(context, index.mipIndex, formatInfo.sizedInternalFormat, size, false));
ANGLE_TRY(redefineImage(context, level, formatInfo.sizedInternalFormat, size, false));
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, size.width, size.height, unpack.alignment, ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, size.width, size.height, unpack.alignment,
...@@ -2995,26 +2920,24 @@ gl::Error TextureD3D_2DArray::setImage(const gl::Context *context, ...@@ -2995,26 +2920,24 @@ gl::Error TextureD3D_2DArray::setImage(const gl::Context *context,
for (int i = 0; i < size.depth; i++) for (int i = 0; i < size.depth; i++)
{ {
const ptrdiff_t layerOffset = (inputDepthPitch * i); const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i); gl::ImageIndex layerIndex = gl::ImageIndex::Make2DArray(index.mipIndex, i);
ANGLE_TRY(setImageImpl(context, index, type, unpack, pixels, layerOffset)); ANGLE_TRY(setImageImpl(context, layerIndex, type, unpack, pixels, layerOffset));
} }
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context, gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2DArray); ASSERT(index.target == gl::TextureTarget::_2DArray);
GLint level = static_cast<GLint>(imageLevel);
const gl::InternalFormat &formatInfo = const gl::InternalFormat &formatInfo =
gl::GetInternalFormatInfo(getInternalFormat(level), type); gl::GetInternalFormatInfo(getInternalFormat(index.mipIndex), type);
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment, ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment,
unpack.rowLength, unpack.imageHeight), unpack.rowLength, unpack.imageHeight),
...@@ -3027,8 +2950,8 @@ gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context, ...@@ -3027,8 +2950,8 @@ gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context,
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1); gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer); gl::ImageIndex layerIndex = gl::ImageIndex::Make2DArray(index.mipIndex, layer);
ANGLE_TRY(TextureD3D::subImage(context, index, layerArea, format, type, unpack, pixels, ANGLE_TRY(TextureD3D::subImage(context, layerIndex, layerArea, format, type, unpack, pixels,
layerOffset)); layerOffset));
} }
...@@ -3036,19 +2959,17 @@ gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context, ...@@ -3036,19 +2959,17 @@ gl::Error TextureD3D_2DArray::setSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_2DArray::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_2DArray::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2DArray); ASSERT(index.target == gl::TextureTarget::_2DArray);
GLint level = static_cast<GLint>(imageLevel);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
ANGLE_TRY(redefineImage(context, level, internalFormat, size, false)); ANGLE_TRY(redefineImage(context, index.mipIndex, internalFormat, size, false));
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat); const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
...@@ -3060,23 +2981,22 @@ gl::Error TextureD3D_2DArray::setCompressedImage(const gl::Context *context, ...@@ -3060,23 +2981,22 @@ gl::Error TextureD3D_2DArray::setCompressedImage(const gl::Context *context,
{ {
const ptrdiff_t layerOffset = (inputDepthPitch * i); const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i); gl::ImageIndex layerIndex = gl::ImageIndex::Make2DArray(index.mipIndex, i);
ANGLE_TRY(setCompressedImageImpl(context, index, unpack, pixels, layerOffset)); ANGLE_TRY(setCompressedImageImpl(context, layerIndex, unpack, pixels, layerOffset));
} }
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_2DArray::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_2DArray::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == gl::TextureTarget::_2DArray); ASSERT(index.target == gl::TextureTarget::_2DArray);
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(format); const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(format);
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
...@@ -3091,18 +3011,17 @@ gl::Error TextureD3D_2DArray::setCompressedSubImage(const gl::Context *context, ...@@ -3091,18 +3011,17 @@ gl::Error TextureD3D_2DArray::setCompressedSubImage(const gl::Context *context,
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1); gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(static_cast<GLint>(level), layer); gl::ImageIndex layerIndex = gl::ImageIndex::Make2DArray(index.mipIndex, layer);
ANGLE_TRY(TextureD3D::subImageCompressed(context, index, layerArea, format, unpack, pixels, ANGLE_TRY(TextureD3D::subImageCompressed(context, layerIndex, layerArea, format, unpack,
layerOffset)); pixels, layerOffset));
ANGLE_TRY(commitRegion(context, index, layerArea)); ANGLE_TRY(commitRegion(context, layerIndex, layerArea));
} }
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureD3D_2DArray::copyImage(const gl::Context *context, gl::Error TextureD3D_2DArray::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -3112,16 +3031,12 @@ gl::Error TextureD3D_2DArray::copyImage(const gl::Context *context, ...@@ -3112,16 +3031,12 @@ gl::Error TextureD3D_2DArray::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context, gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
ASSERT(target == gl::TextureTarget::_2DArray); ASSERT(index.target == gl::TextureTarget::_2DArray);
GLint level = static_cast<GLint>(imageLevel);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, destOffset.z);
gl::Extents fbSize = source->getReadColorbuffer()->getSize(); gl::Extents fbSize = source->getReadColorbuffer()->getSize();
gl::Rectangle clippedSourceArea; gl::Rectangle clippedSourceArea;
...@@ -3137,7 +3052,7 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context, ...@@ -3137,7 +3052,7 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context,
if (!canCreateRenderTargetForImage(index)) if (!canCreateRenderTargetForImage(index))
{ {
gl::Offset destLayerOffset(clippedDestOffset.x, clippedDestOffset.y, 0); gl::Offset destLayerOffset(clippedDestOffset.x, clippedDestOffset.y, 0);
ANGLE_TRY(mImageArray[level][clippedDestOffset.z]->copyFromFramebuffer( ANGLE_TRY(mImageArray[index.mipIndex][clippedDestOffset.z]->copyFromFramebuffer(
context, destLayerOffset, clippedSourceArea, source)); context, destLayerOffset, clippedSourceArea, source));
mDirtyImages = true; mDirtyImages = true;
} }
...@@ -3145,13 +3060,13 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context, ...@@ -3145,13 +3060,13 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context,
{ {
ANGLE_TRY(ensureRenderTarget(context)); ANGLE_TRY(ensureRenderTarget(context));
if (isValidLevel(level)) if (isValidLevel(index.mipIndex))
{ {
ANGLE_TRY(updateStorageLevel(context, level)); ANGLE_TRY(updateStorageLevel(context, index.mipIndex));
ANGLE_TRY( ANGLE_TRY(
mRenderer->copyImage2DArray(context, source, clippedSourceArea, mRenderer->copyImage2DArray(context, source, clippedSourceArea,
gl::GetUnsizedFormat(getInternalFormat(getBaseLevel())), gl::GetUnsizedFormat(getInternalFormat(getBaseLevel())),
clippedDestOffset, mTexStorage, level)); clippedDestOffset, mTexStorage, index.mipIndex));
} }
} }
return gl::NoError(); return gl::NoError();
...@@ -3558,8 +3473,7 @@ GLsizei TextureD3D_External::getLayerCount(int level) const ...@@ -3558,8 +3473,7 @@ GLsizei TextureD3D_External::getLayerCount(int level) const
} }
gl::Error TextureD3D_External::setImage(const gl::Context *context, gl::Error TextureD3D_External::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -3573,8 +3487,7 @@ gl::Error TextureD3D_External::setImage(const gl::Context *context, ...@@ -3573,8 +3487,7 @@ gl::Error TextureD3D_External::setImage(const gl::Context *context,
} }
gl::Error TextureD3D_External::setSubImage(const gl::Context *context, gl::Error TextureD3D_External::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -3586,8 +3499,7 @@ gl::Error TextureD3D_External::setSubImage(const gl::Context *context, ...@@ -3586,8 +3499,7 @@ gl::Error TextureD3D_External::setSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -3599,8 +3511,7 @@ gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context, ...@@ -3599,8 +3511,7 @@ gl::Error TextureD3D_External::setCompressedImage(const gl::Context *context,
} }
gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -3612,8 +3523,7 @@ gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context, ...@@ -3612,8 +3523,7 @@ gl::Error TextureD3D_External::setCompressedSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_External::copyImage(const gl::Context *context, gl::Error TextureD3D_External::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -3623,8 +3533,7 @@ gl::Error TextureD3D_External::copyImage(const gl::Context *context, ...@@ -3623,8 +3533,7 @@ gl::Error TextureD3D_External::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_External::copySubImage(const gl::Context *context, gl::Error TextureD3D_External::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t imageLevel,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -3774,8 +3683,7 @@ ImageD3D *TextureD3D_2DMultisample::getImage(const gl::ImageIndex &index) const ...@@ -3774,8 +3683,7 @@ ImageD3D *TextureD3D_2DMultisample::getImage(const gl::ImageIndex &index) const
} }
gl::Error TextureD3D_2DMultisample::setImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -3788,8 +3696,7 @@ gl::Error TextureD3D_2DMultisample::setImage(const gl::Context *context, ...@@ -3788,8 +3696,7 @@ gl::Error TextureD3D_2DMultisample::setImage(const gl::Context *context,
} }
gl::Error TextureD3D_2DMultisample::setSubImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -3801,8 +3708,7 @@ gl::Error TextureD3D_2DMultisample::setSubImage(const gl::Context *context, ...@@ -3801,8 +3708,7 @@ gl::Error TextureD3D_2DMultisample::setSubImage(const gl::Context *context,
} }
gl::Error TextureD3D_2DMultisample::setCompressedImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -3814,8 +3720,7 @@ gl::Error TextureD3D_2DMultisample::setCompressedImage(const gl::Context *contex ...@@ -3814,8 +3720,7 @@ gl::Error TextureD3D_2DMultisample::setCompressedImage(const gl::Context *contex
} }
gl::Error TextureD3D_2DMultisample::setCompressedSubImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -3827,8 +3732,7 @@ gl::Error TextureD3D_2DMultisample::setCompressedSubImage(const gl::Context *con ...@@ -3827,8 +3732,7 @@ gl::Error TextureD3D_2DMultisample::setCompressedSubImage(const gl::Context *con
} }
gl::Error TextureD3D_2DMultisample::copyImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -3838,8 +3742,7 @@ gl::Error TextureD3D_2DMultisample::copyImage(const gl::Context *context, ...@@ -3838,8 +3742,7 @@ gl::Error TextureD3D_2DMultisample::copyImage(const gl::Context *context,
} }
gl::Error TextureD3D_2DMultisample::copySubImage(const gl::Context *context, gl::Error TextureD3D_2DMultisample::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
......
...@@ -205,8 +205,7 @@ class TextureD3D_2D : public TextureD3D ...@@ -205,8 +205,7 @@ class TextureD3D_2D : public TextureD3D
bool isSRGB(GLint level) const; bool isSRGB(GLint level) const;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -214,8 +213,7 @@ class TextureD3D_2D : public TextureD3D ...@@ -214,8 +213,7 @@ class TextureD3D_2D : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -223,16 +221,14 @@ class TextureD3D_2D : public TextureD3D ...@@ -223,16 +221,14 @@ class TextureD3D_2D : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -240,21 +236,18 @@ class TextureD3D_2D : public TextureD3D ...@@ -240,21 +236,18 @@ class TextureD3D_2D : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copyTexture(const gl::Context *context, gl::Error copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -263,8 +256,7 @@ class TextureD3D_2D : public TextureD3D ...@@ -263,8 +256,7 @@ class TextureD3D_2D : public TextureD3D
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) override; const gl::Texture *source) override;
gl::Error copySubTexture(const gl::Context *context, gl::Error copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -341,8 +333,7 @@ class TextureD3D_Cube : public TextureD3D ...@@ -341,8 +333,7 @@ class TextureD3D_Cube : public TextureD3D
bool isSRGB(GLint level, GLint layer) const; bool isSRGB(GLint level, GLint layer) const;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -350,8 +341,7 @@ class TextureD3D_Cube : public TextureD3D ...@@ -350,8 +341,7 @@ class TextureD3D_Cube : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -359,16 +349,14 @@ class TextureD3D_Cube : public TextureD3D ...@@ -359,16 +349,14 @@ class TextureD3D_Cube : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -376,21 +364,18 @@ class TextureD3D_Cube : public TextureD3D ...@@ -376,21 +364,18 @@ class TextureD3D_Cube : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copyTexture(const gl::Context *context, gl::Error copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -399,8 +384,7 @@ class TextureD3D_Cube : public TextureD3D ...@@ -399,8 +384,7 @@ class TextureD3D_Cube : public TextureD3D
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) override; const gl::Texture *source) override;
gl::Error copySubTexture(const gl::Context *context, gl::Error copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -478,8 +462,7 @@ class TextureD3D_3D : public TextureD3D ...@@ -478,8 +462,7 @@ class TextureD3D_3D : public TextureD3D
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -487,8 +470,7 @@ class TextureD3D_3D : public TextureD3D ...@@ -487,8 +470,7 @@ class TextureD3D_3D : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -496,16 +478,14 @@ class TextureD3D_3D : public TextureD3D ...@@ -496,16 +478,14 @@ class TextureD3D_3D : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -513,14 +493,12 @@ class TextureD3D_3D : public TextureD3D ...@@ -513,14 +493,12 @@ class TextureD3D_3D : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
...@@ -592,8 +570,7 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -592,8 +570,7 @@ class TextureD3D_2DArray : public TextureD3D
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -601,8 +578,7 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -601,8 +578,7 @@ class TextureD3D_2DArray : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -610,16 +586,14 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -610,16 +586,14 @@ class TextureD3D_2DArray : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -627,14 +601,12 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -627,14 +601,12 @@ class TextureD3D_2DArray : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
...@@ -703,8 +675,7 @@ class TextureD3D_External : public TextureD3D ...@@ -703,8 +675,7 @@ class TextureD3D_External : public TextureD3D
GLsizei getLayerCount(int level) const override; GLsizei getLayerCount(int level) const override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -712,8 +683,7 @@ class TextureD3D_External : public TextureD3D ...@@ -712,8 +683,7 @@ class TextureD3D_External : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -721,16 +691,14 @@ class TextureD3D_External : public TextureD3D ...@@ -721,16 +691,14 @@ class TextureD3D_External : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -738,14 +706,12 @@ class TextureD3D_External : public TextureD3D ...@@ -738,14 +706,12 @@ class TextureD3D_External : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
...@@ -800,8 +766,7 @@ class TextureD3D_2DMultisample : public TextureD3D ...@@ -800,8 +766,7 @@ class TextureD3D_2DMultisample : public TextureD3D
ImageD3D *getImage(const gl::ImageIndex &index) const override; ImageD3D *getImage(const gl::ImageIndex &index) const override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -809,8 +774,7 @@ class TextureD3D_2DMultisample : public TextureD3D ...@@ -809,8 +774,7 @@ class TextureD3D_2DMultisample : public TextureD3D
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -818,16 +782,14 @@ class TextureD3D_2DMultisample : public TextureD3D ...@@ -818,16 +782,14 @@ class TextureD3D_2DMultisample : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -835,14 +797,12 @@ class TextureD3D_2DMultisample : public TextureD3D ...@@ -835,14 +797,12 @@ class TextureD3D_2DMultisample : public TextureD3D
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
......
...@@ -141,8 +141,7 @@ TextureGL::~TextureGL() ...@@ -141,8 +141,7 @@ TextureGL::~TextureGL()
} }
gl::Error TextureGL::setImage(const gl::Context *context, gl::Error TextureGL::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -153,6 +152,9 @@ gl::Error TextureGL::setImage(const gl::Context *context, ...@@ -153,6 +152,9 @@ gl::Error TextureGL::setImage(const gl::Context *context,
const gl::Buffer *unpackBuffer = const gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpackBuffer && if (mWorkarounds.unpackOverlappingRowsSeparatelyUnpackBuffer && unpackBuffer &&
unpack.rowLength != 0 && unpack.rowLength < size.width) unpack.rowLength != 0 && unpack.rowLength < size.width)
{ {
...@@ -248,15 +250,14 @@ void TextureGL::reserveTexImageToBeFilled(gl::TextureTarget target, ...@@ -248,15 +250,14 @@ void TextureGL::reserveTexImageToBeFilled(gl::TextureTarget target,
} }
gl::Error TextureGL::setSubImage(const gl::Context *context, gl::Error TextureGL::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(TextureTargetToType(target) == getType()); ASSERT(TextureTargetToType(index.target) == getType());
const gl::Buffer *unpackBuffer = const gl::Buffer *unpackBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack); context->getGLState().getTargetBuffer(gl::BufferBinding::PixelUnpack);
...@@ -264,6 +265,9 @@ gl::Error TextureGL::setSubImage(const gl::Context *context, ...@@ -264,6 +265,9 @@ gl::Error TextureGL::setSubImage(const gl::Context *context,
nativegl::TexSubImageFormat texSubImageFormat = nativegl::TexSubImageFormat texSubImageFormat =
nativegl::GetTexSubImageFormat(mFunctions, mWorkarounds, format, type); nativegl::GetTexSubImageFormat(mFunctions, mWorkarounds, format, type);
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
ASSERT(getLevelInfo(target, level).lumaWorkaround.enabled == ASSERT(getLevelInfo(target, level).lumaWorkaround.enabled ==
GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled); GetLevelInfo(format, texSubImageFormat.format).lumaWorkaround.enabled);
...@@ -455,14 +459,15 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(const gl::Context *context, ...@@ -455,14 +459,15 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(const gl::Context *context,
} }
gl::Error TextureGL::setCompressedImage(const gl::Context *context, gl::Error TextureGL::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
ASSERT(TextureTargetToType(target) == getType()); ASSERT(TextureTargetToType(target) == getType());
nativegl::CompressedTexImageFormat compressedTexImageFormat = nativegl::CompressedTexImageFormat compressedTexImageFormat =
...@@ -495,14 +500,15 @@ gl::Error TextureGL::setCompressedImage(const gl::Context *context, ...@@ -495,14 +500,15 @@ gl::Error TextureGL::setCompressedImage(const gl::Context *context,
} }
gl::Error TextureGL::setCompressedSubImage(const gl::Context *context, gl::Error TextureGL::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) const uint8_t *pixels)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
ASSERT(TextureTargetToType(target) == getType()); ASSERT(TextureTargetToType(target) == getType());
nativegl::CompressedTexSubImageFormat compressedTexSubImageFormat = nativegl::CompressedTexSubImageFormat compressedTexSubImageFormat =
...@@ -535,12 +541,13 @@ gl::Error TextureGL::setCompressedSubImage(const gl::Context *context, ...@@ -535,12 +541,13 @@ gl::Error TextureGL::setCompressedSubImage(const gl::Context *context,
} }
gl::Error TextureGL::copyImage(const gl::Context *context, gl::Error TextureGL::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
GLenum type = GL_NONE; GLenum type = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &type)); ANGLE_TRY(source->getImplementationColorReadType(context, &type));
nativegl::CopyTexImageImageFormat copyTexImageFormat = nativegl::CopyTexImageImageFormat copyTexImageFormat =
...@@ -636,12 +643,13 @@ gl::Error TextureGL::copyImage(const gl::Context *context, ...@@ -636,12 +643,13 @@ gl::Error TextureGL::copyImage(const gl::Context *context,
} }
gl::Error TextureGL::copySubImage(const gl::Context *context, gl::Error TextureGL::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &origDestOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &origSourceArea, const gl::Rectangle &origSourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
// Clip source area to framebuffer. // Clip source area to framebuffer.
...@@ -695,8 +703,7 @@ gl::Error TextureGL::copySubImage(const gl::Context *context, ...@@ -695,8 +703,7 @@ gl::Error TextureGL::copySubImage(const gl::Context *context,
} }
gl::Error TextureGL::copyTexture(const gl::Context *context, gl::Error TextureGL::copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -705,6 +712,8 @@ gl::Error TextureGL::copyTexture(const gl::Context *context, ...@@ -705,6 +712,8 @@ gl::Error TextureGL::copyTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
const TextureGL *sourceGL = GetImplAs<TextureGL>(source); const TextureGL *sourceGL = GetImplAs<TextureGL>(source);
const gl::ImageDesc &sourceImageDesc = const gl::ImageDesc &sourceImageDesc =
sourceGL->mState.getImageDesc(NonCubeTextureTypeToTarget(source->getType()), sourceLevel); sourceGL->mState.getImageDesc(NonCubeTextureTypeToTarget(source->getType()), sourceLevel);
...@@ -719,8 +728,7 @@ gl::Error TextureGL::copyTexture(const gl::Context *context, ...@@ -719,8 +728,7 @@ gl::Error TextureGL::copyTexture(const gl::Context *context,
} }
gl::Error TextureGL::copySubTexture(const gl::Context *context, gl::Error TextureGL::copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
...@@ -729,6 +737,8 @@ gl::Error TextureGL::copySubTexture(const gl::Context *context, ...@@ -729,6 +737,8 @@ gl::Error TextureGL::copySubTexture(const gl::Context *context,
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) const gl::Texture *source)
{ {
gl::TextureTarget target = index.target;
size_t level = static_cast<size_t>(index.mipIndex);
const gl::InternalFormat &destFormatInfo = *mState.getImageDesc(target, level).format.info; const gl::InternalFormat &destFormatInfo = *mState.getImageDesc(target, level).format.info;
return copySubTextureHelper(context, target, level, destOffset, sourceLevel, sourceArea, return copySubTextureHelper(context, target, level, destOffset, sourceLevel, sourceArea,
destFormatInfo.format, destFormatInfo.type, unpackFlipY, destFormatInfo.format, destFormatInfo.type, unpackFlipY,
......
...@@ -64,8 +64,7 @@ class TextureGL : public TextureImpl ...@@ -64,8 +64,7 @@ class TextureGL : public TextureImpl
~TextureGL() override; ~TextureGL() override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -73,8 +72,7 @@ class TextureGL : public TextureImpl ...@@ -73,8 +72,7 @@ class TextureGL : public TextureImpl
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -82,16 +80,14 @@ class TextureGL : public TextureImpl ...@@ -82,16 +80,14 @@ class TextureGL : public TextureImpl
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -99,21 +95,18 @@ class TextureGL : public TextureImpl ...@@ -99,21 +95,18 @@ class TextureGL : public TextureImpl
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copyTexture(const gl::Context *context, gl::Error copyTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
GLenum type, GLenum type,
size_t sourceLevel, size_t sourceLevel,
...@@ -122,8 +115,7 @@ class TextureGL : public TextureImpl ...@@ -122,8 +115,7 @@ class TextureGL : public TextureImpl
bool unpackUnmultiplyAlpha, bool unpackUnmultiplyAlpha,
const gl::Texture *source) override; const gl::Texture *source) override;
gl::Error copySubTexture(const gl::Context *context, gl::Error copySubTexture(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
size_t sourceLevel, size_t sourceLevel,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
......
...@@ -23,8 +23,7 @@ TextureNULL::~TextureNULL() ...@@ -23,8 +23,7 @@ TextureNULL::~TextureNULL()
} }
gl::Error TextureNULL::setImage(const gl::Context *context, gl::Error TextureNULL::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -38,8 +37,7 @@ gl::Error TextureNULL::setImage(const gl::Context *context, ...@@ -38,8 +37,7 @@ gl::Error TextureNULL::setImage(const gl::Context *context,
} }
gl::Error TextureNULL::setSubImage(const gl::Context *context, gl::Error TextureNULL::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -50,8 +48,7 @@ gl::Error TextureNULL::setSubImage(const gl::Context *context, ...@@ -50,8 +48,7 @@ gl::Error TextureNULL::setSubImage(const gl::Context *context,
} }
gl::Error TextureNULL::setCompressedImage(const gl::Context *context, gl::Error TextureNULL::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -62,8 +59,7 @@ gl::Error TextureNULL::setCompressedImage(const gl::Context *context, ...@@ -62,8 +59,7 @@ gl::Error TextureNULL::setCompressedImage(const gl::Context *context,
} }
gl::Error TextureNULL::setCompressedSubImage(const gl::Context *context, gl::Error TextureNULL::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -74,8 +70,7 @@ gl::Error TextureNULL::setCompressedSubImage(const gl::Context *context, ...@@ -74,8 +70,7 @@ gl::Error TextureNULL::setCompressedSubImage(const gl::Context *context,
} }
gl::Error TextureNULL::copyImage(const gl::Context *context, gl::Error TextureNULL::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -84,8 +79,7 @@ gl::Error TextureNULL::copyImage(const gl::Context *context, ...@@ -84,8 +79,7 @@ gl::Error TextureNULL::copyImage(const gl::Context *context,
} }
gl::Error TextureNULL::copySubImage(const gl::Context *context, gl::Error TextureNULL::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
......
...@@ -22,8 +22,7 @@ class TextureNULL : public TextureImpl ...@@ -22,8 +22,7 @@ class TextureNULL : public TextureImpl
~TextureNULL() override; ~TextureNULL() override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -31,8 +30,7 @@ class TextureNULL : public TextureImpl ...@@ -31,8 +30,7 @@ class TextureNULL : public TextureImpl
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -40,16 +38,14 @@ class TextureNULL : public TextureImpl ...@@ -40,16 +38,14 @@ class TextureNULL : public TextureImpl
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -57,14 +53,12 @@ class TextureNULL : public TextureImpl ...@@ -57,14 +53,12 @@ class TextureNULL : public TextureImpl
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
......
...@@ -168,21 +168,16 @@ gl::Error TextureVk::onDestroy(const gl::Context *context) ...@@ -168,21 +168,16 @@ gl::Error TextureVk::onDestroy(const gl::Context *context)
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
mImage.release(renderer->getCurrentQueueSerial(), renderer); releaseImage(context, renderer);
renderer->releaseResource(*this, &mImageView);
renderer->releaseResource(*this, &mSampler); renderer->releaseResource(*this, &mSampler);
mStagingStorage.release(renderer); mStagingStorage.release(renderer);
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
return gl::NoError(); return gl::NoError();
} }
gl::Error TextureVk::setImage(const gl::Context *context, gl::Error TextureVk::setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -195,20 +190,18 @@ gl::Error TextureVk::setImage(const gl::Context *context, ...@@ -195,20 +190,18 @@ gl::Error TextureVk::setImage(const gl::Context *context,
VkDevice device = contextVk->getDevice(); VkDevice device = contextVk->getDevice();
// TODO(jmadill): support multi-level textures. // TODO(jmadill): support multi-level textures.
ASSERT(level == 0); ASSERT(index.mipIndex == 0);
// Convert internalFormat to sized internal format.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
if (mImage.valid()) if (mImage.valid())
{ {
const gl::ImageDesc &desc = mState.getImageDesc(target, level); const gl::ImageDesc &desc = mState.getImageDesc(index);
const vk::Format &vkFormat = renderer->getFormat(formatInfo.sizedInternalFormat);
// TODO(jmadill): Consider comparing stored vk::Format. if (desc.size != size || mImage.getFormat() != vkFormat)
if (desc.size != size ||
!gl::Format::SameSized(desc.format, gl::Format(internalFormat, type)))
{ {
mImage.release(renderer->getCurrentQueueSerial(), renderer); releaseImage(context, renderer);
renderer->releaseResource(*this, &mImageView);
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
} }
} }
...@@ -219,7 +212,7 @@ gl::Error TextureVk::setImage(const gl::Context *context, ...@@ -219,7 +212,7 @@ gl::Error TextureVk::setImage(const gl::Context *context,
} }
// TODO(jmadill): Cube map textures. http://anglebug.com/2318 // TODO(jmadill): Cube map textures. http://anglebug.com/2318
if (target != gl::TextureTarget::_2D) if (index.target != gl::TextureTarget::_2D)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
return gl::InternalError(); return gl::InternalError();
...@@ -258,8 +251,6 @@ gl::Error TextureVk::setImage(const gl::Context *context, ...@@ -258,8 +251,6 @@ gl::Error TextureVk::setImage(const gl::Context *context,
// Handle initial data. // Handle initial data.
if (pixels) if (pixels)
{ {
// Convert internalFormat to sized internal format.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
ANGLE_TRY(mStagingStorage.stageSubresourceUpdate(contextVk, size, formatInfo, unpack, type, ANGLE_TRY(mStagingStorage.stageSubresourceUpdate(contextVk, size, formatInfo, unpack, type,
pixels)); pixels));
} }
...@@ -268,8 +259,7 @@ gl::Error TextureVk::setImage(const gl::Context *context, ...@@ -268,8 +259,7 @@ gl::Error TextureVk::setImage(const gl::Context *context,
} }
gl::Error TextureVk::setSubImage(const gl::Context *context, gl::Error TextureVk::setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -285,8 +275,7 @@ gl::Error TextureVk::setSubImage(const gl::Context *context, ...@@ -285,8 +275,7 @@ gl::Error TextureVk::setSubImage(const gl::Context *context,
} }
gl::Error TextureVk::setCompressedImage(const gl::Context *context, gl::Error TextureVk::setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -298,8 +287,7 @@ gl::Error TextureVk::setCompressedImage(const gl::Context *context, ...@@ -298,8 +287,7 @@ gl::Error TextureVk::setCompressedImage(const gl::Context *context,
} }
gl::Error TextureVk::setCompressedSubImage(const gl::Context *context, gl::Error TextureVk::setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -311,8 +299,7 @@ gl::Error TextureVk::setCompressedSubImage(const gl::Context *context, ...@@ -311,8 +299,7 @@ gl::Error TextureVk::setCompressedSubImage(const gl::Context *context,
} }
gl::Error TextureVk::copyImage(const gl::Context *context, gl::Error TextureVk::copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -322,8 +309,7 @@ gl::Error TextureVk::copyImage(const gl::Context *context, ...@@ -322,8 +309,7 @@ gl::Error TextureVk::copyImage(const gl::Context *context,
} }
gl::Error TextureVk::copySubImage(const gl::Context *context, gl::Error TextureVk::copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) gl::Framebuffer *source)
...@@ -496,4 +482,11 @@ const vk::Sampler &TextureVk::getSampler() const ...@@ -496,4 +482,11 @@ const vk::Sampler &TextureVk::getSampler() const
return mSampler; return mSampler;
} }
void TextureVk::releaseImage(const gl::Context *context, RendererVk *renderer)
{
mImage.release(renderer->getCurrentQueueSerial(), renderer);
renderer->releaseResource(*this, &mImageView);
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
}
} // namespace rx } // namespace rx
...@@ -51,8 +51,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -51,8 +51,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
gl::Error onDestroy(const gl::Context *context) override; gl::Error onDestroy(const gl::Context *context) override;
gl::Error setImage(const gl::Context *context, gl::Error setImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
GLenum format, GLenum format,
...@@ -60,8 +59,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -60,8 +59,7 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setSubImage(const gl::Context *context, gl::Error setSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -69,16 +67,14 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -69,16 +67,14 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedImage(const gl::Context *context, gl::Error setCompressedImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
GLenum internalFormat, GLenum internalFormat,
const gl::Extents &size, const gl::Extents &size,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
size_t imageSize, size_t imageSize,
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error setCompressedSubImage(const gl::Context *context, gl::Error setCompressedSubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Box &area, const gl::Box &area,
GLenum format, GLenum format,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
...@@ -86,14 +82,12 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -86,14 +82,12 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const uint8_t *pixels) override; const uint8_t *pixels) override;
gl::Error copyImage(const gl::Context *context, gl::Error copyImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
GLenum internalFormat, GLenum internalFormat,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
gl::Error copySubImage(const gl::Context *context, gl::Error copySubImage(const gl::Context *context,
gl::TextureTarget target, const gl::ImageIndex &index,
size_t level,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override; gl::Framebuffer *source) override;
...@@ -144,6 +138,8 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -144,6 +138,8 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
vk::Error ensureImageInitialized(RendererVk *renderer); vk::Error ensureImageInitialized(RendererVk *renderer);
private: private:
void releaseImage(const gl::Context *context, RendererVk *renderer);
vk::ImageHelper mImage; vk::ImageHelper mImage;
vk::ImageView mImageView; vk::ImageView mImageView;
vk::Sampler mSampler; vk::Sampler mSampler;
......
...@@ -81,6 +81,7 @@ bool HasFullFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkFormat) ...@@ -81,6 +81,7 @@ bool HasFullFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkFormat)
HasFormatFeatureBits(kBitsDepth, formatProperties); HasFormatFeatureBits(kBitsDepth, formatProperties);
} }
// Format implementation.
Format::Format() Format::Format()
: internalFormat(GL_NONE), : internalFormat(GL_NONE),
textureFormatID(angle::Format::ID::NONE), textureFormatID(angle::Format::ID::NONE),
...@@ -102,6 +103,17 @@ const angle::Format &Format::bufferFormat() const ...@@ -102,6 +103,17 @@ const angle::Format &Format::bufferFormat() const
return angle::Format::Get(bufferFormatID); return angle::Format::Get(bufferFormatID);
} }
bool operator==(const Format &lhs, const Format &rhs)
{
return &lhs == &rhs;
}
bool operator!=(const Format &lhs, const Format &rhs)
{
return &lhs != &rhs;
}
// FormatTable implementation.
FormatTable::FormatTable() FormatTable::FormatTable()
{ {
} }
......
...@@ -49,6 +49,9 @@ struct Format final : private angle::NonCopyable ...@@ -49,6 +49,9 @@ struct Format final : private angle::NonCopyable
LoadFunctionMap loadFunctions; LoadFunctionMap loadFunctions;
}; };
bool operator==(const Format &lhs, const Format &rhs);
bool operator!=(const Format &lhs, const Format &rhs);
class FormatTable final : angle::NonCopyable class FormatTable final : angle::NonCopyable
{ {
public: public:
......
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