diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index 528d29a9ab..d10c675d30 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -71,9 +71,10 @@ namespace dawn_native { namespace metal { return MTLTextureTypeCube; case wgpu::TextureViewDimension::CubeArray: return MTLTextureTypeCubeArray; + case wgpu::TextureViewDimension::e3D: + return MTLTextureType3D; case wgpu::TextureViewDimension::e1D: - case wgpu::TextureViewDimension::e3D: case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); } @@ -333,9 +334,12 @@ namespace dawn_native { namespace metal { } } break; + case wgpu::TextureDimension::e3D: + ASSERT(mtlDesc.sampleCount == 1); + mtlDesc.textureType = MTLTextureType3D; + break; case wgpu::TextureDimension::e1D: - case wgpu::TextureDimension::e3D: UNREACHABLE(); } diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index 00d2604656..5582d97979 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -39,9 +39,10 @@ namespace dawn_native { namespace opengl { return GL_TEXTURE_2D; } } + case wgpu::TextureDimension::e3D: + return GL_TEXTURE_3D; case wgpu::TextureDimension::e1D: - case wgpu::TextureDimension::e3D: UNREACHABLE(); } } @@ -62,9 +63,10 @@ namespace dawn_native { namespace opengl { return GL_TEXTURE_CUBE_MAP; case wgpu::TextureViewDimension::CubeArray: return GL_TEXTURE_CUBE_MAP_ARRAY; + case wgpu::TextureViewDimension::e3D: + return GL_TEXTURE_3D; case wgpu::TextureViewDimension::e1D: - case wgpu::TextureViewDimension::e3D: case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); } @@ -153,9 +155,14 @@ namespace dawn_native { namespace opengl { } } break; + case wgpu::TextureDimension::e3D: + ASSERT(!IsMultisampledTexture()); + ASSERT(arrayLayers == 1); + gl.TexStorage3D(mTarget, levels, glFormat.internalFormat, width, height, + GetDepth()); + break; case wgpu::TextureDimension::e1D: - case wgpu::TextureDimension::e3D: UNREACHABLE(); } diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index d8abfe9c1d..a60efc3a2f 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -45,9 +45,10 @@ namespace dawn_native { namespace vulkan { return VK_IMAGE_VIEW_TYPE_CUBE; case wgpu::TextureViewDimension::CubeArray: return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; + case wgpu::TextureViewDimension::e3D: + return VK_IMAGE_VIEW_TYPE_3D; case wgpu::TextureViewDimension::e1D: - case wgpu::TextureViewDimension::e3D: case wgpu::TextureViewDimension::Undefined: UNREACHABLE(); } @@ -201,8 +202,13 @@ namespace dawn_native { namespace vulkan { info->arrayLayers = size.depth; break; - case wgpu::TextureDimension::e1D: case wgpu::TextureDimension::e3D: + info->imageType = VK_IMAGE_TYPE_3D; + info->extent = {size.width, size.height, size.depth}; + info->arrayLayers = 1; + break; + + case wgpu::TextureDimension::e1D: UNREACHABLE(); } } diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp index 383a600608..19649d6e83 100644 --- a/src/tests/end2end/TextureViewTests.cpp +++ b/src/tests/end2end/TextureViewTests.cpp @@ -701,4 +701,9 @@ TEST_P(TextureView3DTest, BasicTest) { wgpu::TextureView view = texture.CreateView(); } -DAWN_INSTANTIATE_TEST(TextureView3DTest, D3D12Backend()); +DAWN_INSTANTIATE_TEST(TextureView3DTest, + D3D12Backend(), + MetalBackend(), + OpenGLBackend(), + OpenGLESBackend(), + VulkanBackend());