Commit 99cffe5d by Tim Van Patten Committed by Commit Bot

Vulkan: Fix glCopyTexSubImage3D()

Update glCopyTexSubImage3D() to account for the requirements necessary for VK_IMAGE_TYPE_3D. Bug: angleproject:3765 Test: KHR-GLES2.texture_3d.copy_sub_image.rgba8 Test: angle_end2end_tests CopyTexImageTestES3 Change-Id: Ife3d768323d0cfe2a53e5ae4c47a0747d65981bc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1730637Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 7e48c9eb
...@@ -395,8 +395,10 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context, ...@@ -395,8 +395,10 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context,
// If negative offsets are given, clippedSourceArea ensures we don't read from those offsets. // If negative offsets are given, clippedSourceArea ensures we don't read from those offsets.
// However, that changes the sourceOffset->destOffset mapping. Here, destOffset is shifted by // However, that changes the sourceOffset->destOffset mapping. Here, destOffset is shifted by
// the same amount as clipped to correct the error. // the same amount as clipped to correct the error.
VkImageType imageType = gl_vk::GetImageType(mState.getType());
int zOffset = (imageType == VK_IMAGE_TYPE_3D) ? destOffset.z : 0;
const gl::Offset modifiedDestOffset(destOffset.x + clippedSourceArea.x - sourceArea.x, const gl::Offset modifiedDestOffset(destOffset.x + clippedSourceArea.x - sourceArea.x,
destOffset.y + clippedSourceArea.y - sourceArea.y, 0); destOffset.y + clippedSourceArea.y - sourceArea.y, zOffset);
RenderTargetVk *colorReadRT = framebufferVk->getColorReadRenderTarget(); RenderTargetVk *colorReadRT = framebufferVk->getColorReadRenderTarget();
...@@ -578,6 +580,13 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -578,6 +580,13 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
destSubresource.mipLevel = level; destSubresource.mipLevel = level;
destSubresource.baseArrayLayer = baseLayer; destSubresource.baseArrayLayer = baseLayer;
VkImageType imageType = gl_vk::GetImageType(mState.getType());
if (imageType == VK_IMAGE_TYPE_3D)
{
destSubresource.baseArrayLayer = 0;
destSubresource.layerCount = 1;
}
vk::ImageHelper::Copy(srcImage, mImage, srcOffset, destOffset, extents, srcSubresource, vk::ImageHelper::Copy(srcImage, mImage, srcOffset, destOffset, extents, srcSubresource,
destSubresource, commandBuffer); destSubresource, commandBuffer);
} }
...@@ -610,7 +619,9 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -610,7 +619,9 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
srcSubresource, destSubresource, commandBuffer); srcSubresource, destSubresource, commandBuffer);
// Stage the copy for when the image storage is actually created. // Stage the copy for when the image storage is actually created.
mImage->stageSubresourceUpdateFromImage(stagingImage.release(), index, destOffset, extents); VkImageType imageType = gl_vk::GetImageType(mState.getType());
mImage->stageSubresourceUpdateFromImage(stagingImage.release(), index, destOffset, extents,
imageType);
onStagingBufferChange(); onStagingBufferChange();
} }
...@@ -705,9 +716,10 @@ angle::Result TextureVk::copySubImageImplWithDraw(ContextVk *contextVk, ...@@ -705,9 +716,10 @@ angle::Result TextureVk::copySubImageImplWithDraw(ContextVk *contextVk,
} }
// Stage the copy for when the image storage is actually created. // Stage the copy for when the image storage is actually created.
mImage->stageSubresourceUpdateFromImage( VkImageType imageType = gl_vk::GetImageType(mState.getType());
stagingImage.release(), index, destOffset, mImage->stageSubresourceUpdateFromImage(stagingImage.release(), index, destOffset,
gl::Extents(sourceArea.width, sourceArea.height, 1)); gl::Extents(sourceArea.width, sourceArea.height, 1),
imageType);
onStagingBufferChange(); onStagingBufferChange();
} }
......
...@@ -2366,15 +2366,33 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer( ...@@ -2366,15 +2366,33 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer(
void ImageHelper::stageSubresourceUpdateFromImage(vk::ImageHelper *image, void ImageHelper::stageSubresourceUpdateFromImage(vk::ImageHelper *image,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Extents &glExtents) const gl::Extents &glExtents,
const VkImageType imageType)
{ {
VkImageCopy copyToImage = {}; VkImageCopy copyToImage = {};
copyToImage.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copyToImage.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copyToImage.srcSubresource.layerCount = index.getLayerCount(); copyToImage.srcSubresource.layerCount = index.getLayerCount();
copyToImage.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copyToImage.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copyToImage.dstSubresource.mipLevel = index.getLevelIndex(); copyToImage.dstSubresource.mipLevel = index.getLevelIndex();
copyToImage.dstSubresource.baseArrayLayer = index.hasLayer() ? index.getLayerIndex() : 0;
copyToImage.dstSubresource.layerCount = index.getLayerCount(); if (imageType == VK_IMAGE_TYPE_3D)
{
// These values must be set explicitly to follow the Vulkan spec:
// https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkImageCopy.html
// If either of the calling command’s srcImage or dstImage parameters are of VkImageType
// VK_IMAGE_TYPE_3D, the baseArrayLayer and layerCount members of the corresponding
// subresource must be 0 and 1, respectively
copyToImage.dstSubresource.baseArrayLayer = 0;
copyToImage.dstSubresource.layerCount = 1;
// Preserve the assumption that destOffset.z == "dstSubresource.baseArrayLayer"
ASSERT(destOffset.z == (index.hasLayer() ? index.getLayerIndex() : 0));
}
else
{
copyToImage.dstSubresource.baseArrayLayer = index.hasLayer() ? index.getLayerIndex() : 0;
copyToImage.dstSubresource.layerCount = index.getLayerCount();
}
gl_vk::GetOffset(destOffset, &copyToImage.dstOffset); gl_vk::GetOffset(destOffset, &copyToImage.dstOffset);
gl_vk::GetExtent(glExtents, &copyToImage.extent); gl_vk::GetExtent(glExtents, &copyToImage.extent);
......
...@@ -791,7 +791,8 @@ class ImageHelper final : public CommandGraphResource ...@@ -791,7 +791,8 @@ class ImageHelper final : public CommandGraphResource
void stageSubresourceUpdateFromImage(vk::ImageHelper *image, void stageSubresourceUpdateFromImage(vk::ImageHelper *image,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Extents &glExtents); const gl::Extents &glExtents,
const VkImageType imageType);
// Stage a clear operation to a clear value based on WebGL requirements. // Stage a clear operation to a clear value based on WebGL requirements.
void stageSubresourceRobustClear(const gl::ImageIndex &index, const angle::Format &format); void stageSubresourceRobustClear(const gl::ImageIndex &index, const angle::Format &format);
......
...@@ -35,8 +35,9 @@ ...@@ -35,8 +35,9 @@
// 3d texture framebuffer tests // 3d texture framebuffer tests
3188 VULKAN : KHR-GLES2.texture_3d.framebuffer_texture.rgba8 = SKIP 3188 VULKAN : KHR-GLES2.texture_3d.framebuffer_texture.rgba8 = SKIP
// Unclear what is happening here, failing to validate a 2D texture format // GL_RGBA8 is not supported in GLES2
3190 VULKAN : KHR-GLES2.texture_3d.copy_sub_image.rgba8 = SKIP // GL_OES_rgb8_rgba8 only enables GL_RGBA8 for render buffers (not textures)
3797 VULKAN : KHR-GLES2.texture_3d.copy_sub_image.rgba8 = FAIL
// Compressed texture tests on Android // Compressed texture tests on Android
3190 VULKAN PIXEL2 : KHR-GLES2.texture_3d.compressed_texture.rgba_astc_* = SKIP 3190 VULKAN PIXEL2 : KHR-GLES2.texture_3d.compressed_texture.rgba_astc_* = SKIP
......
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