Commit cd83b608 by Brandon Schade Committed by Commit Bot

Use ImageHelper staging buffers for copyImageDataToBuffer

Revert change from using context staging buffers for copyImageDataToBuffer. There are scenarios where the staging buffer will become invalid before flushing the staged update. Added a test for this case. Bug: angleproject:5092 Test: angle_end2end_tests --gtest_filter=*ETC1CompressedImageDraws* Change-Id: I41c457fda919938600c20336f65836952d73748a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2425250Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 9e2953c2
...@@ -4902,10 +4902,10 @@ angle::Result ImageHelper::copyImageDataToBuffer(ContextVk *contextVk, ...@@ -4902,10 +4902,10 @@ angle::Result ImageHelper::copyImageDataToBuffer(ContextVk *contextVk,
// Allocate staging buffer data from context // Allocate staging buffer data from context
VkBuffer bufferHandle; VkBuffer bufferHandle;
size_t alignment = mStagingBuffer.getAlignment(); size_t alignment = mStagingBuffer.getAlignment();
ANGLE_TRY(contextVk->getStagingBuffer()->allocateWithAlignment( ANGLE_TRY(mStagingBuffer.allocateWithAlignment(contextVk, *bufferSize, alignment, outDataPtr,
contextVk, *bufferSize, alignment, outDataPtr, &bufferHandle, &(*bufferOffsetsOut)[0], &bufferHandle, &(*bufferOffsetsOut)[0],
nullptr)); nullptr));
*bufferOut = contextVk->getStagingBuffer()->getCurrentBuffer(); *bufferOut = mStagingBuffer.getCurrentBuffer();
LevelIndex sourceLevelVk = toVkLevel(sourceLevelGL); LevelIndex sourceLevelVk = toVkLevel(sourceLevelGL);
......
...@@ -7856,6 +7856,91 @@ TEST_P(ETC1CompressedTextureTest, ETC1CompressedImageNPOT) ...@@ -7856,6 +7856,91 @@ TEST_P(ETC1CompressedTextureTest, ETC1CompressedImageNPOT)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Define two NPOT compressed textures, set MAX_LEVEL, draw, and swap buffers
// with the two textures. This used to cause release of staging buffers
// that have not been flushed.
TEST_P(ETC1CompressedTextureTest, ETC1CompressedImageDraws)
{
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_compressed_ETC1_RGB8_sub_texture"));
const GLuint width = 384u;
const GLuint height = 384u;
// round up to the nearest block size
const GLsizei imageSize = width * height / 2;
uint8_t data[imageSize] = {0};
setWindowWidth(width);
setWindowHeight(height);
const GLuint smallerWidth = 384u;
const GLuint smallerHeight = 320u;
// round up to the nearest block size
const GLsizei smallerImageSize = smallerWidth * smallerHeight / 2;
// Setup primary Texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, smallerWidth, smallerHeight, 0,
smallerImageSize, data);
ASSERT_GL_NO_ERROR();
glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_ETC1_RGB8_OES, 192, 160, 0, 15360, data);
ASSERT_GL_NO_ERROR();
GLTexture largerTexture;
glBindTexture(GL_TEXTURE_2D, largerTexture);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, width, height, 0, imageSize, data);
ASSERT_GL_NO_ERROR();
glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_ETC1_RGB8_OES, 192, 192, 0, 18432, data);
ASSERT_GL_NO_ERROR();
glBindTexture(GL_TEXTURE_2D, mTexture2D);
glUseProgram(mProgram);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
swapBuffers();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
swapBuffers();
glBindTexture(GL_TEXTURE_2D, largerTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
swapBuffers();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
swapBuffers();
glBindTexture(GL_TEXTURE_2D, mTexture2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
drawQuad(mProgram, "position", 0.5f);
swapBuffers();
ASSERT_GL_NO_ERROR();
}
// Fully-define a compressed texture and draw; then decrease MAX_LEVEL and draw; then increase // Fully-define a compressed texture and draw; then decrease MAX_LEVEL and draw; then increase
// MAX_LEVEL and draw. This used to cause Vulkan validation errors. // MAX_LEVEL and draw. This used to cause Vulkan validation errors.
TEST_P(ETC1CompressedTextureTest, ETC1ShrinkThenGrowMaxLevels) TEST_P(ETC1CompressedTextureTest, ETC1ShrinkThenGrowMaxLevels)
......
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