Commit 4c6b4794 by Charlie Lao Committed by Commit Bot

Vulkan: TexSubImage3D using PBO should use correct layerCount

The layerCount for 3D texture and 2DArray should be 1 if it does not have layers. Bug: b/170657065 Change-Id: I974ddda7c0eaa92da8033f15c682820e3d4eb32a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2466616Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
parent 336202d7
...@@ -181,13 +181,13 @@ void GetRenderTargetLayerCountAndIndex(vk::ImageHelper *image, ...@@ -181,13 +181,13 @@ void GetRenderTargetLayerCountAndIndex(vk::ImageHelper *image,
case gl::TextureType::_3D: case gl::TextureType::_3D:
*layerIndex = index.hasLayer() ? index.getLayerIndex() : 0; *layerIndex = index.hasLayer() ? index.getLayerIndex() : 0;
*layerCount = image->getExtents().depth; *layerCount = index.hasLayer() ? image->getExtents().depth : 1;
return; return;
case gl::TextureType::_2DArray: case gl::TextureType::_2DArray:
case gl::TextureType::_2DMultisampleArray: case gl::TextureType::_2DMultisampleArray:
*layerIndex = index.hasLayer() ? index.getLayerIndex() : 0; *layerIndex = index.hasLayer() ? index.getLayerIndex() : 0;
*layerCount = image->getLayerCount(); *layerCount = index.hasLayer() ? image->getLayerCount() : 1;
return; return;
default: default:
......
...@@ -6986,6 +6986,43 @@ TEST_P(Texture3DTestES3, FormatRedefinitionBug) ...@@ -6986,6 +6986,43 @@ TEST_P(Texture3DTestES3, FormatRedefinitionBug)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test glTexSubImage using PBO to 3D texture that expose the regression bug
// https://issuetracker.google.com/170657065
TEST_P(Texture3DTestES3, TexSubImageWithPBO)
{
GLTexture tex;
GLuint pbo;
glGenBuffers(1, &pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
std::vector<uint8_t> pixelData(128 * 128 * 8 * 4, 0x1f);
glBufferData(GL_PIXEL_UNPACK_BUFFER, 128 * 128 * 8 * 4, pixelData.data(), GL_STATIC_DRAW);
glBindTexture(GL_TEXTURE_3D, tex.get());
glTexStorage3D(GL_TEXTURE_3D, 8, GL_RGBA8, 128, 128, 8);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 128, 128, 8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 1, 0, 0, 0, 64, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 2, 0, 0, 0, 32, 32, 2, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 3, 0, 0, 0, 16, 16, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 4, 0, 0, 0, 8, 8, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 5, 0, 0, 0, 4, 4, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 6, 0, 0, 0, 2, 2, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 7, 0, 0, 0, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 128, 128, 8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 1, 0, 0, 0, 64, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_3D, 2, 0, 0, 0, 32, 32, 2, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
ASSERT_GL_NO_ERROR();
drawQuad(mProgram, "position", 0.5f);
ASSERT_GL_NO_ERROR();
}
// Test basic pixel unpack buffer OOB checks when uploading to a 2D or 3D texture // Test basic pixel unpack buffer OOB checks when uploading to a 2D or 3D texture
TEST_P(Texture3DTestES3, BasicUnpackBufferOOB) TEST_P(Texture3DTestES3, BasicUnpackBufferOOB)
{ {
......
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