TextureBase: return size as an Extent3D to match dawn.json

BUG=dawn:13

Change-Id: I1104cb2038e0e77814b036868c50030fc8186bf8
Reviewed-on: https://dawn-review.googlesource.com/1522
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn_native/CommandBuffer.cpp b/src/dawn_native/CommandBuffer.cpp
index a2f5b2c..3db3c5a 100644
--- a/src/dawn_native/CommandBuffer.cpp
+++ b/src/dawn_native/CommandBuffer.cpp
@@ -46,9 +46,9 @@
             // overflows.
             uint64_t level = location.level;
             if (uint64_t(location.x) + uint64_t(location.width) >
-                    (static_cast<uint64_t>(texture->GetWidth()) >> level) ||
+                    (static_cast<uint64_t>(texture->GetSize().width) >> level) ||
                 uint64_t(location.y) + uint64_t(location.height) >
-                    (static_cast<uint64_t>(texture->GetHeight()) >> level)) {
+                    (static_cast<uint64_t>(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 05486cc..8a3fd6a 100644
--- a/src/dawn_native/RenderPassDescriptor.cpp
+++ b/src/dawn_native/RenderPassDescriptor.cpp
@@ -92,16 +92,16 @@
             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 d6dd4d8..73de462 100644
--- a/src/dawn_native/Texture.cpp
+++ b/src/dawn_native/Texture.cpp
@@ -90,9 +90,7 @@
         : 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 @@
     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 1628a78..ddc2152 100644
--- a/src/dawn_native/Texture.h
+++ b/src/dawn_native/Texture.h
@@ -44,9 +44,7 @@
 
         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 @@
 
         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 da2e2bf..205f5cf 100644
--- a/src/dawn_native/d3d12/TextureD3D12.cpp
+++ b/src/dawn_native/d3d12/TextureD3D12.cpp
@@ -112,8 +112,11 @@
         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<UINT16>(GetNumMipLevels());
         resourceDescriptor.Format = D3D12TextureFormat(GetFormat());
diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm
index 0713dfb..213df8f 100644
--- a/src/dawn_native/metal/TextureMTL.mm
+++ b/src/dawn_native/metal/TextureMTL.mm
@@ -74,9 +74,12 @@
         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 fdc85ff..b0bc81c 100644
--- a/src/dawn_native/opengl/TextureGL.cpp
+++ b/src/dawn_native/opengl/TextureGL.cpp
@@ -77,8 +77,8 @@
         : 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 353e243..11521a3 100644
--- a/src/dawn_native/vulkan/TextureVk.cpp
+++ b/src/dawn_native/vulkan/TextureVk.cpp
@@ -181,6 +181,10 @@
             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 @@
         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;