mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-17 04:41:23 +00:00
Implement 3D texture copies on Vulkan
Bug: dawn:781 Change-Id: I5a1b3cc906b2bcb89c0ba3b202bacd16e012efe8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50241 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
67851d9021
commit
d066d17ef6
@ -69,33 +69,56 @@ namespace dawn_native { namespace vulkan {
|
|||||||
const Texture* dstTexture = ToBackend(dstCopy.texture.Get());
|
const Texture* dstTexture = ToBackend(dstCopy.texture.Get());
|
||||||
|
|
||||||
VkImageCopy region;
|
VkImageCopy region;
|
||||||
|
|
||||||
// TODO(jiawei.shao@intel.com): support 1D and 3D textures
|
|
||||||
ASSERT(srcTexture->GetDimension() == wgpu::TextureDimension::e2D &&
|
|
||||||
dstTexture->GetDimension() == wgpu::TextureDimension::e2D);
|
|
||||||
region.srcSubresource.aspectMask = VulkanAspectMask(aspect);
|
region.srcSubresource.aspectMask = VulkanAspectMask(aspect);
|
||||||
region.srcSubresource.mipLevel = srcCopy.mipLevel;
|
region.srcSubresource.mipLevel = srcCopy.mipLevel;
|
||||||
region.srcSubresource.baseArrayLayer = srcCopy.origin.z;
|
region.dstSubresource.aspectMask = VulkanAspectMask(aspect);
|
||||||
region.srcSubresource.layerCount = copySize.depthOrArrayLayers;
|
region.dstSubresource.mipLevel = dstCopy.mipLevel;
|
||||||
|
|
||||||
|
bool has3DTextureInCopy = false;
|
||||||
|
|
||||||
region.srcOffset.x = srcCopy.origin.x;
|
region.srcOffset.x = srcCopy.origin.x;
|
||||||
region.srcOffset.y = srcCopy.origin.y;
|
region.srcOffset.y = srcCopy.origin.y;
|
||||||
|
switch (srcTexture->GetDimension()) {
|
||||||
|
case wgpu::TextureDimension::e2D:
|
||||||
|
region.srcSubresource.baseArrayLayer = srcCopy.origin.z;
|
||||||
|
region.srcSubresource.layerCount = copySize.depthOrArrayLayers;
|
||||||
region.srcOffset.z = 0;
|
region.srcOffset.z = 0;
|
||||||
|
break;
|
||||||
region.dstSubresource.aspectMask = VulkanAspectMask(aspect);
|
case wgpu::TextureDimension::e3D:
|
||||||
region.dstSubresource.mipLevel = dstCopy.mipLevel;
|
has3DTextureInCopy = true;
|
||||||
region.dstSubresource.baseArrayLayer = dstCopy.origin.z;
|
region.srcSubresource.baseArrayLayer = 0;
|
||||||
region.dstSubresource.layerCount = copySize.depthOrArrayLayers;
|
region.srcSubresource.layerCount = 1;
|
||||||
|
region.srcOffset.z = srcCopy.origin.z;
|
||||||
|
break;
|
||||||
|
case wgpu::TextureDimension::e1D:
|
||||||
|
// TODO(jiawei.shao@intel.com): support 1D textures
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
region.dstOffset.x = dstCopy.origin.x;
|
region.dstOffset.x = dstCopy.origin.x;
|
||||||
region.dstOffset.y = dstCopy.origin.y;
|
region.dstOffset.y = dstCopy.origin.y;
|
||||||
|
switch (dstTexture->GetDimension()) {
|
||||||
|
case wgpu::TextureDimension::e2D:
|
||||||
|
region.dstSubresource.baseArrayLayer = dstCopy.origin.z;
|
||||||
|
region.dstSubresource.layerCount = copySize.depthOrArrayLayers;
|
||||||
region.dstOffset.z = 0;
|
region.dstOffset.z = 0;
|
||||||
|
break;
|
||||||
|
case wgpu::TextureDimension::e3D:
|
||||||
|
has3DTextureInCopy = true;
|
||||||
|
region.dstSubresource.baseArrayLayer = 0;
|
||||||
|
region.dstSubresource.layerCount = 1;
|
||||||
|
region.dstOffset.z = dstCopy.origin.z;
|
||||||
|
break;
|
||||||
|
case wgpu::TextureDimension::e1D:
|
||||||
|
// TODO(jiawei.shao@intel.com): support 1D textures
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(HasSameTextureCopyExtent(srcCopy, dstCopy, copySize));
|
ASSERT(HasSameTextureCopyExtent(srcCopy, dstCopy, copySize));
|
||||||
Extent3D imageExtent = ComputeTextureCopyExtent(dstCopy, copySize);
|
Extent3D imageExtent = ComputeTextureCopyExtent(dstCopy, copySize);
|
||||||
region.extent.width = imageExtent.width;
|
region.extent.width = imageExtent.width;
|
||||||
region.extent.height = imageExtent.height;
|
region.extent.height = imageExtent.height;
|
||||||
region.extent.depth = 1;
|
region.extent.depth = has3DTextureInCopy ? copySize.depthOrArrayLayers : 1;
|
||||||
|
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
@ -526,7 +549,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
ComputeBufferImageCopyRegion(src, dst, copy->copySize);
|
ComputeBufferImageCopyRegion(src, dst, copy->copySize);
|
||||||
VkImageSubresourceLayers subresource = region.imageSubresource;
|
VkImageSubresourceLayers subresource = region.imageSubresource;
|
||||||
|
|
||||||
ASSERT(dst.texture->GetDimension() == wgpu::TextureDimension::e2D);
|
ASSERT(dst.texture->GetDimension() != wgpu::TextureDimension::e1D);
|
||||||
SubresourceRange range =
|
SubresourceRange range =
|
||||||
GetSubresourcesAffectedByCopy(copy->destination, copy->copySize);
|
GetSubresourcesAffectedByCopy(copy->destination, copy->copySize);
|
||||||
|
|
||||||
@ -564,7 +587,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
VkBufferImageCopy region =
|
VkBufferImageCopy region =
|
||||||
ComputeBufferImageCopyRegion(dst, src, copy->copySize);
|
ComputeBufferImageCopyRegion(dst, src, copy->copySize);
|
||||||
|
|
||||||
ASSERT(src.texture->GetDimension() == wgpu::TextureDimension::e2D);
|
ASSERT(src.texture->GetDimension() != wgpu::TextureDimension::e1D);
|
||||||
SubresourceRange range =
|
SubresourceRange range =
|
||||||
GetSubresourcesAffectedByCopy(copy->source, copy->copySize);
|
GetSubresourcesAffectedByCopy(copy->source, copy->copySize);
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
VkBufferImageCopy region = ComputeBufferImageCopyRegion(src, *dst, copySizePixels);
|
VkBufferImageCopy region = ComputeBufferImageCopyRegion(src, *dst, copySizePixels);
|
||||||
VkImageSubresourceLayers subresource = region.imageSubresource;
|
VkImageSubresourceLayers subresource = region.imageSubresource;
|
||||||
|
|
||||||
ASSERT(dst->texture->GetDimension() == wgpu::TextureDimension::e2D);
|
ASSERT(dst->texture->GetDimension() != wgpu::TextureDimension::e1D);
|
||||||
SubresourceRange range = GetSubresourcesAffectedByCopy(*dst, copySizePixels);
|
SubresourceRange range = GetSubresourcesAffectedByCopy(*dst, copySizePixels);
|
||||||
|
|
||||||
if (IsCompleteSubresourceCopiedTo(dst->texture.Get(), copySizePixels,
|
if (IsCompleteSubresourceCopiedTo(dst->texture.Get(), copySizePixels,
|
||||||
|
@ -986,9 +986,6 @@ namespace dawn_native { namespace vulkan {
|
|||||||
ASSERT(imageBarriers != nullptr);
|
ASSERT(imageBarriers != nullptr);
|
||||||
const Format& format = GetFormat();
|
const Format& format = GetFormat();
|
||||||
|
|
||||||
// This transitions assume it is a 2D texture
|
|
||||||
ASSERT(GetDimension() == wgpu::TextureDimension::e2D);
|
|
||||||
|
|
||||||
wgpu::TextureUsage allLastUsages = wgpu::TextureUsage::None;
|
wgpu::TextureUsage allLastUsages = wgpu::TextureUsage::None;
|
||||||
mSubresourceLastUsages.Update(
|
mSubresourceLastUsages.Update(
|
||||||
range, [&](const SubresourceRange& range, wgpu::TextureUsage* lastUsage) {
|
range, [&](const SubresourceRange& range, wgpu::TextureUsage* lastUsage) {
|
||||||
|
@ -139,8 +139,22 @@ namespace dawn_native { namespace vulkan {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case wgpu::TextureDimension::e3D: {
|
||||||
|
region.imageOffset.x = textureCopy.origin.x;
|
||||||
|
region.imageOffset.y = textureCopy.origin.y;
|
||||||
|
region.imageOffset.z = textureCopy.origin.z;
|
||||||
|
|
||||||
|
region.imageSubresource.baseArrayLayer = 0;
|
||||||
|
region.imageSubresource.layerCount = 1;
|
||||||
|
|
||||||
|
Extent3D imageExtent = ComputeTextureCopyExtent(textureCopy, copySize);
|
||||||
|
region.imageExtent.width = imageExtent.width;
|
||||||
|
region.imageExtent.height = imageExtent.height;
|
||||||
|
region.imageExtent.depth = imageExtent.depthOrArrayLayers;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case wgpu::TextureDimension::e1D:
|
case wgpu::TextureDimension::e1D:
|
||||||
case wgpu::TextureDimension::e3D:
|
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -968,9 +968,9 @@ TEST_P(CopyTests_T2B, Texture2DArrayRegionWithOffsetEvenRowsPerImage) {
|
|||||||
|
|
||||||
// Test that copying whole 3D texture in one texture-to-buffer-copy works.
|
// Test that copying whole 3D texture in one texture-to-buffer-copy works.
|
||||||
TEST_P(CopyTests_T2B, Texture3DFull) {
|
TEST_P(CopyTests_T2B, Texture3DFull) {
|
||||||
// TODO(yunchao.he@intel.com): implement 3D texture copy on Vulkan, Metal, OpenGL and OpenGLES
|
// TODO(yunchao.he@intel.com): implement 3D texture copy on Metal, OpenGL and OpenGLES
|
||||||
// backend.
|
// backend.
|
||||||
DAWN_SKIP_TEST_IF(IsVulkan() || IsMetal() || IsOpenGL() || IsOpenGLES());
|
DAWN_SKIP_TEST_IF(IsMetal() || IsOpenGL() || IsOpenGLES());
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
@ -985,9 +985,9 @@ TEST_P(CopyTests_T2B, Texture3DFull) {
|
|||||||
|
|
||||||
// Test that copying a range of texture 3D depths in one texture-to-buffer-copy works.
|
// Test that copying a range of texture 3D depths in one texture-to-buffer-copy works.
|
||||||
TEST_P(CopyTests_T2B, Texture3DSubRegion) {
|
TEST_P(CopyTests_T2B, Texture3DSubRegion) {
|
||||||
// TODO(yunchao.he@intel.com): implement 3D texture copy on Vulkan, Metal, OpenGL and OpenGLES
|
// TODO(yunchao.he@intel.com): implement 3D texture copy on Metal, OpenGL and OpenGLES
|
||||||
// backend.
|
// backend.
|
||||||
DAWN_SKIP_TEST_IF(IsVulkan() || IsMetal() || IsOpenGL() || IsOpenGLES());
|
DAWN_SKIP_TEST_IF(IsMetal() || IsOpenGL() || IsOpenGLES());
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
@ -1445,9 +1445,9 @@ TEST_P(CopyTests_B2T, Texture2DArrayRegionWithOffsetEvenRowsPerImage) {
|
|||||||
|
|
||||||
// Test that copying whole texture 3D in one buffer-to-texture-copy works.
|
// Test that copying whole texture 3D in one buffer-to-texture-copy works.
|
||||||
TEST_P(CopyTests_B2T, Texture3DFull) {
|
TEST_P(CopyTests_B2T, Texture3DFull) {
|
||||||
// TODO(yunchao.he@intel.com): implement 3D texture copy on Vulkan, Metal, OpenGL and OpenGLES
|
// TODO(yunchao.he@intel.com): implement 3D texture copy on Metal, OpenGL and OpenGLES
|
||||||
// backend.
|
// backend.
|
||||||
DAWN_SKIP_TEST_IF(IsVulkan() || IsMetal() || IsOpenGL() || IsOpenGLES());
|
DAWN_SKIP_TEST_IF(IsMetal() || IsOpenGL() || IsOpenGLES());
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
@ -1462,9 +1462,9 @@ TEST_P(CopyTests_B2T, Texture3DFull) {
|
|||||||
|
|
||||||
// Test that copying a range of texture 3D Depths in one texture-to-buffer-copy works.
|
// Test that copying a range of texture 3D Depths in one texture-to-buffer-copy works.
|
||||||
TEST_P(CopyTests_B2T, Texture3DSubRegion) {
|
TEST_P(CopyTests_B2T, Texture3DSubRegion) {
|
||||||
// TODO(yunchao.he@intel.com): implement 3D texture copy on Vulkan, Metal, OpenGL and OpenGLES
|
// TODO(yunchao.he@intel.com): implement 3D texture copy on Metal, OpenGL and OpenGLES
|
||||||
// backend.
|
// backend.
|
||||||
DAWN_SKIP_TEST_IF(IsVulkan() || IsMetal() || IsOpenGL() || IsOpenGLES());
|
DAWN_SKIP_TEST_IF(IsMetal() || IsOpenGL() || IsOpenGLES());
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
@ -1799,9 +1799,9 @@ TEST_P(CopyTests_T2T, CopyFromNonZeroMipLevelWithTexelBlockSizeLessThan4Bytes) {
|
|||||||
|
|
||||||
// Test that copying whole 3D texture in one texture-to-texture-copy works.
|
// Test that copying whole 3D texture in one texture-to-texture-copy works.
|
||||||
TEST_P(CopyTests_T2T, Texture3DFull) {
|
TEST_P(CopyTests_T2T, Texture3DFull) {
|
||||||
// TODO(yunchao.he@intel.com): implement 3D texture copy on Vulkan, Metal, OpenGL and OpenGLES
|
// TODO(yunchao.he@intel.com): implement 3D texture copy, Metal, OpenGL and OpenGLES
|
||||||
// backend.
|
// backend.
|
||||||
DAWN_SKIP_TEST_IF(IsVulkan() || IsMetal() || IsOpenGL() || IsOpenGLES());
|
DAWN_SKIP_TEST_IF(IsMetal() || IsOpenGL() || IsOpenGLES());
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user