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