diff --git a/src/dawn_native/CommandBuffer.cpp b/src/dawn_native/CommandBuffer.cpp index a2f5b2c224..3db3c5a977 100644 --- a/src/dawn_native/CommandBuffer.cpp +++ b/src/dawn_native/CommandBuffer.cpp @@ -46,9 +46,9 @@ namespace dawn_native { // overflows. uint64_t level = location.level; if (uint64_t(location.x) + uint64_t(location.width) > - (static_cast(texture->GetWidth()) >> level) || + (static_cast(texture->GetSize().width) >> level) || uint64_t(location.y) + uint64_t(location.height) > - (static_cast(texture->GetHeight()) >> level)) { + (static_cast(texture->GetSize().height) >> level)) { return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture"); } diff --git a/src/dawn_native/RenderPassDescriptor.cpp b/src/dawn_native/RenderPassDescriptor.cpp index 05486cc7b8..8a3fd6a1de 100644 --- a/src/dawn_native/RenderPassDescriptor.cpp +++ b/src/dawn_native/RenderPassDescriptor.cpp @@ -92,16 +92,16 @@ namespace dawn_native { if (this->mWidth == 0) { ASSERT(this->mHeight == 0); - this->mWidth = attachment->GetTexture()->GetWidth(); - this->mHeight = attachment->GetTexture()->GetHeight(); + this->mWidth = attachment->GetTexture()->GetSize().width; + this->mHeight = attachment->GetTexture()->GetSize().height; ASSERT(this->mWidth != 0 && this->mHeight != 0); return true; } ASSERT(this->mWidth != 0 && this->mHeight != 0); - return this->mWidth == attachment->GetTexture()->GetWidth() && - this->mHeight == attachment->GetTexture()->GetHeight(); + return this->mWidth == attachment->GetTexture()->GetSize().width && + this->mHeight == attachment->GetTexture()->GetSize().height; }; uint32_t attachmentCount = 0; diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index d6dd4d8da4..73de462214 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -90,9 +90,7 @@ namespace dawn_native { : mDevice(device), mDimension(descriptor->dimension), mFormat(descriptor->format), - mWidth(descriptor->size.width), - mHeight(descriptor->size.height), - mDepth(descriptor->size.depth), + mSize(descriptor->size), mArrayLayers(descriptor->arrayLayer), mNumMipLevels(descriptor->mipLevel), mUsage(descriptor->usage) { @@ -108,14 +106,8 @@ namespace dawn_native { dawn::TextureFormat TextureBase::GetFormat() const { return mFormat; } - uint32_t TextureBase::GetWidth() const { - return mWidth; - } - uint32_t TextureBase::GetHeight() const { - return mHeight; - } - uint32_t TextureBase::GetDepth() const { - return mDepth; + const Extent3D& TextureBase::GetSize() const { + return mSize; } uint32_t TextureBase::GetArrayLayers() const { return mArrayLayers; diff --git a/src/dawn_native/Texture.h b/src/dawn_native/Texture.h index 1628a784e2..ddc2152bf4 100644 --- a/src/dawn_native/Texture.h +++ b/src/dawn_native/Texture.h @@ -44,9 +44,7 @@ namespace dawn_native { dawn::TextureDimension GetDimension() const; dawn::TextureFormat GetFormat() const; - uint32_t GetWidth() const; - uint32_t GetHeight() const; - uint32_t GetDepth() const; + const Extent3D& GetSize() const; uint32_t GetArrayLayers() const; uint32_t GetNumMipLevels() const; dawn::TextureUsageBit GetUsage() const; @@ -60,7 +58,7 @@ namespace dawn_native { dawn::TextureDimension mDimension; dawn::TextureFormat mFormat; - uint32_t mWidth, mHeight, mDepth; + Extent3D mSize; uint32_t mArrayLayers; uint32_t mNumMipLevels; dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None; diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index da2e2bfe97..205f5cf764 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -112,8 +112,11 @@ namespace dawn_native { namespace d3d12 { D3D12_RESOURCE_DESC resourceDescriptor; resourceDescriptor.Dimension = D3D12TextureDimension(GetDimension()); resourceDescriptor.Alignment = 0; - resourceDescriptor.Width = GetWidth(); - resourceDescriptor.Height = GetHeight(); + + const Extent3D& size = GetSize(); + resourceDescriptor.Width = size.width; + resourceDescriptor.Height = size.height; + resourceDescriptor.DepthOrArraySize = GetDepthOrArraySize(); resourceDescriptor.MipLevels = static_cast(GetNumMipLevels()); resourceDescriptor.Format = D3D12TextureFormat(GetFormat()); diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index 0713dfb870..213df8f11a 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -74,9 +74,12 @@ namespace dawn_native { namespace metal { desc.textureType = MetalTextureType(GetDimension(), GetArrayLayers()); desc.usage = MetalTextureUsage(GetUsage()); desc.pixelFormat = MetalPixelFormat(GetFormat()); - desc.width = GetWidth(); - desc.height = GetHeight(); - desc.depth = GetDepth(); + + const Extent3D& size = GetSize(); + desc.width = size.width; + desc.height = size.height; + desc.depth = size.depth; + desc.mipmapLevelCount = GetNumMipLevels(); desc.arrayLength = GetArrayLayers(); desc.storageMode = MTLStorageModePrivate; diff --git a/src/dawn_native/opengl/TextureGL.cpp b/src/dawn_native/opengl/TextureGL.cpp index fdc85ffff5..b0bc81caa1 100644 --- a/src/dawn_native/opengl/TextureGL.cpp +++ b/src/dawn_native/opengl/TextureGL.cpp @@ -77,8 +77,8 @@ namespace dawn_native { namespace opengl { : TextureBase(device, descriptor), mHandle(handle) { mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers()); - uint32_t width = GetWidth(); - uint32_t height = GetHeight(); + uint32_t width = GetSize().width; + uint32_t height = GetSize().height; uint32_t levels = GetNumMipLevels(); uint32_t arrayLayers = GetArrayLayers(); diff --git a/src/dawn_native/vulkan/TextureVk.cpp b/src/dawn_native/vulkan/TextureVk.cpp index 353e2431d7..11521a3957 100644 --- a/src/dawn_native/vulkan/TextureVk.cpp +++ b/src/dawn_native/vulkan/TextureVk.cpp @@ -181,6 +181,10 @@ namespace dawn_native { namespace vulkan { return VK_IMAGE_ASPECT_COLOR_BIT; } + VkExtent3D VulkanExtent3D(const Extent3D& extent) { + return {extent.width, extent.height, extent.depth}; + } + } // namespace // Converts Dawn texture format to Vulkan formats. @@ -246,7 +250,7 @@ namespace dawn_native { namespace vulkan { createInfo.flags = 0; createInfo.imageType = VulkanImageType(GetDimension()); createInfo.format = VulkanImageFormat(GetFormat()); - createInfo.extent = VkExtent3D{GetWidth(), GetHeight(), GetDepth()}; + createInfo.extent = VulkanExtent3D(GetSize()); createInfo.mipLevels = GetNumMipLevels(); createInfo.arrayLayers = GetArrayLayers(); createInfo.samples = VK_SAMPLE_COUNT_1_BIT;