Commit c669bf52 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Optimize PBO copy from depth xor stencil src

If the buffer format of the PBO does not contain both depth and stencil, it already has packed data ready for upload, so this change allows the GPU path to be taken. Bug: angleproject:5315 Bug: b/172354898 Change-Id: I424c15951594f49ffc140f9cde9e7c73486512b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2526947Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 3f741f0d
...@@ -374,9 +374,20 @@ bool TextureVk::isFastUnpackPossible(const vk::Format &vkFormat, size_t offset) ...@@ -374,9 +374,20 @@ bool TextureVk::isFastUnpackPossible(const vk::Format &vkFormat, size_t offset)
// Conditions to determine if fast unpacking is possible // Conditions to determine if fast unpacking is possible
// 1. Image must be well defined to unpack directly to it // 1. Image must be well defined to unpack directly to it
// TODO(http://anglebug.com/4222) Create and stage a temp image instead // TODO(http://anglebug.com/4222) Create and stage a temp image instead
// 2. Can't perform a fast copy for emulated formats // 2. Can't perform a fast copy for depth/stencil, except from non-emulated depth or stencil
// to emulated depth/stencil. GL requires depth and stencil data to be packed, while Vulkan
// requires them to be separate.
// 2. Can't perform a fast copy for emulated formats, except from non-emulated depth or stencil
// to emulated depth/stencil.
// 3. vkCmdCopyBufferToImage requires byte offset to be a multiple of 4 // 3. vkCmdCopyBufferToImage requires byte offset to be a multiple of 4
return mImage->valid() && vkFormat.intendedFormatID == vkFormat.actualImageFormatID && const angle::Format &bufferFormat = vkFormat.actualBufferFormat(false);
const bool isCombinedDepthStencil = bufferFormat.depthBits > 0 && bufferFormat.stencilBits > 0;
const bool isDepthXorStencil = (bufferFormat.depthBits > 0 && bufferFormat.stencilBits == 0) ||
(bufferFormat.depthBits == 0 && bufferFormat.stencilBits > 0);
const bool isCompatibleDepth = vkFormat.intendedFormat().depthBits == bufferFormat.depthBits;
return mImage->valid() && !isCombinedDepthStencil &&
(vkFormat.intendedFormatID == vkFormat.actualImageFormatID ||
(isDepthXorStencil && isCompatibleDepth)) &&
(offset & (kBufferOffsetMultiple - 1)) == 0; (offset & (kBufferOffsetMultiple - 1)) == 0;
} }
...@@ -439,11 +450,9 @@ angle::Result TextureVk::setSubImageImpl(const gl::Context *context, ...@@ -439,11 +450,9 @@ angle::Result TextureVk::setSubImageImpl(const gl::Context *context,
// Note: cannot directly copy from a depth/stencil PBO. GL requires depth and stencil data // Note: cannot directly copy from a depth/stencil PBO. GL requires depth and stencil data
// to be packed, while Vulkan requires them to be separate. // to be packed, while Vulkan requires them to be separate.
const VkImageAspectFlags aspectFlags = vk::GetFormatAspectFlags(vkFormat.intendedFormat()); const VkImageAspectFlags aspectFlags = vk::GetFormatAspectFlags(vkFormat.intendedFormat());
const bool isCombinedDepthStencil =
(aspectFlags & kDepthStencilAspects) == kDepthStencilAspects;
if (!shouldUpdateBeStaged(gl::LevelIndex(index.getLevelIndex())) && if (!shouldUpdateBeStaged(gl::LevelIndex(index.getLevelIndex())) &&
isFastUnpackPossible(vkFormat, offsetBytes) && !isCombinedDepthStencil) isFastUnpackPossible(vkFormat, offsetBytes))
{ {
GLuint pixelSize = formatInfo.pixelBytes; GLuint pixelSize = formatInfo.pixelBytes;
GLuint blockWidth = formatInfo.compressedBlockWidth; GLuint blockWidth = formatInfo.compressedBlockWidth;
......
...@@ -2667,9 +2667,6 @@ TEST_P(Texture2DTestES3, TexImageWithStencilPBO) ...@@ -2667,9 +2667,6 @@ TEST_P(Texture2DTestES3, TexImageWithStencilPBO)
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_NV_pixel_buffer_object")); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_NV_pixel_buffer_object"));
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_storage")); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_storage"));
// http://anglebug.com/5313
ANGLE_SKIP_TEST_IF(IsVulkan() && (IsAndroid() || (IsWindows() && IsIntel())));
// http://anglebug.com/5315 // http://anglebug.com/5315
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX()); ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX());
......
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