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>
This commit is contained in:
Corentin Wallez 2018-09-18 12:51:42 +00:00 committed by Commit Bot service account
parent 29353d6ee3
commit cd5e5756fd
8 changed files with 29 additions and 29 deletions

View File

@ -46,9 +46,9 @@ namespace dawn_native {
// overflows. // overflows.
uint64_t level = location.level; uint64_t level = location.level;
if (uint64_t(location.x) + uint64_t(location.width) > 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) > 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"); return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture");
} }

View File

@ -92,16 +92,16 @@ namespace dawn_native {
if (this->mWidth == 0) { if (this->mWidth == 0) {
ASSERT(this->mHeight == 0); ASSERT(this->mHeight == 0);
this->mWidth = attachment->GetTexture()->GetWidth(); this->mWidth = attachment->GetTexture()->GetSize().width;
this->mHeight = attachment->GetTexture()->GetHeight(); this->mHeight = attachment->GetTexture()->GetSize().height;
ASSERT(this->mWidth != 0 && this->mHeight != 0); ASSERT(this->mWidth != 0 && this->mHeight != 0);
return true; return true;
} }
ASSERT(this->mWidth != 0 && this->mHeight != 0); ASSERT(this->mWidth != 0 && this->mHeight != 0);
return this->mWidth == attachment->GetTexture()->GetWidth() && return this->mWidth == attachment->GetTexture()->GetSize().width &&
this->mHeight == attachment->GetTexture()->GetHeight(); this->mHeight == attachment->GetTexture()->GetSize().height;
}; };
uint32_t attachmentCount = 0; uint32_t attachmentCount = 0;

View File

@ -90,9 +90,7 @@ namespace dawn_native {
: mDevice(device), : mDevice(device),
mDimension(descriptor->dimension), mDimension(descriptor->dimension),
mFormat(descriptor->format), mFormat(descriptor->format),
mWidth(descriptor->size.width), mSize(descriptor->size),
mHeight(descriptor->size.height),
mDepth(descriptor->size.depth),
mArrayLayers(descriptor->arrayLayer), mArrayLayers(descriptor->arrayLayer),
mNumMipLevels(descriptor->mipLevel), mNumMipLevels(descriptor->mipLevel),
mUsage(descriptor->usage) { mUsage(descriptor->usage) {
@ -108,14 +106,8 @@ namespace dawn_native {
dawn::TextureFormat TextureBase::GetFormat() const { dawn::TextureFormat TextureBase::GetFormat() const {
return mFormat; return mFormat;
} }
uint32_t TextureBase::GetWidth() const { const Extent3D& TextureBase::GetSize() const {
return mWidth; return mSize;
}
uint32_t TextureBase::GetHeight() const {
return mHeight;
}
uint32_t TextureBase::GetDepth() const {
return mDepth;
} }
uint32_t TextureBase::GetArrayLayers() const { uint32_t TextureBase::GetArrayLayers() const {
return mArrayLayers; return mArrayLayers;

View File

@ -44,9 +44,7 @@ namespace dawn_native {
dawn::TextureDimension GetDimension() const; dawn::TextureDimension GetDimension() const;
dawn::TextureFormat GetFormat() const; dawn::TextureFormat GetFormat() const;
uint32_t GetWidth() const; const Extent3D& GetSize() const;
uint32_t GetHeight() const;
uint32_t GetDepth() const;
uint32_t GetArrayLayers() const; uint32_t GetArrayLayers() const;
uint32_t GetNumMipLevels() const; uint32_t GetNumMipLevels() const;
dawn::TextureUsageBit GetUsage() const; dawn::TextureUsageBit GetUsage() const;
@ -60,7 +58,7 @@ namespace dawn_native {
dawn::TextureDimension mDimension; dawn::TextureDimension mDimension;
dawn::TextureFormat mFormat; dawn::TextureFormat mFormat;
uint32_t mWidth, mHeight, mDepth; Extent3D mSize;
uint32_t mArrayLayers; uint32_t mArrayLayers;
uint32_t mNumMipLevels; uint32_t mNumMipLevels;
dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None; dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None;

View File

@ -112,8 +112,11 @@ namespace dawn_native { namespace d3d12 {
D3D12_RESOURCE_DESC resourceDescriptor; D3D12_RESOURCE_DESC resourceDescriptor;
resourceDescriptor.Dimension = D3D12TextureDimension(GetDimension()); resourceDescriptor.Dimension = D3D12TextureDimension(GetDimension());
resourceDescriptor.Alignment = 0; 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.DepthOrArraySize = GetDepthOrArraySize();
resourceDescriptor.MipLevels = static_cast<UINT16>(GetNumMipLevels()); resourceDescriptor.MipLevels = static_cast<UINT16>(GetNumMipLevels());
resourceDescriptor.Format = D3D12TextureFormat(GetFormat()); resourceDescriptor.Format = D3D12TextureFormat(GetFormat());

View File

@ -74,9 +74,12 @@ namespace dawn_native { namespace metal {
desc.textureType = MetalTextureType(GetDimension(), GetArrayLayers()); desc.textureType = MetalTextureType(GetDimension(), GetArrayLayers());
desc.usage = MetalTextureUsage(GetUsage()); desc.usage = MetalTextureUsage(GetUsage());
desc.pixelFormat = MetalPixelFormat(GetFormat()); desc.pixelFormat = MetalPixelFormat(GetFormat());
desc.width = GetWidth();
desc.height = GetHeight(); const Extent3D& size = GetSize();
desc.depth = GetDepth(); desc.width = size.width;
desc.height = size.height;
desc.depth = size.depth;
desc.mipmapLevelCount = GetNumMipLevels(); desc.mipmapLevelCount = GetNumMipLevels();
desc.arrayLength = GetArrayLayers(); desc.arrayLength = GetArrayLayers();
desc.storageMode = MTLStorageModePrivate; desc.storageMode = MTLStorageModePrivate;

View File

@ -77,8 +77,8 @@ namespace dawn_native { namespace opengl {
: TextureBase(device, descriptor), mHandle(handle) { : TextureBase(device, descriptor), mHandle(handle) {
mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers()); mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers());
uint32_t width = GetWidth(); uint32_t width = GetSize().width;
uint32_t height = GetHeight(); uint32_t height = GetSize().height;
uint32_t levels = GetNumMipLevels(); uint32_t levels = GetNumMipLevels();
uint32_t arrayLayers = GetArrayLayers(); uint32_t arrayLayers = GetArrayLayers();

View File

@ -181,6 +181,10 @@ namespace dawn_native { namespace vulkan {
return VK_IMAGE_ASPECT_COLOR_BIT; return VK_IMAGE_ASPECT_COLOR_BIT;
} }
VkExtent3D VulkanExtent3D(const Extent3D& extent) {
return {extent.width, extent.height, extent.depth};
}
} // namespace } // namespace
// Converts Dawn texture format to Vulkan formats. // Converts Dawn texture format to Vulkan formats.
@ -246,7 +250,7 @@ namespace dawn_native { namespace vulkan {
createInfo.flags = 0; createInfo.flags = 0;
createInfo.imageType = VulkanImageType(GetDimension()); createInfo.imageType = VulkanImageType(GetDimension());
createInfo.format = VulkanImageFormat(GetFormat()); createInfo.format = VulkanImageFormat(GetFormat());
createInfo.extent = VkExtent3D{GetWidth(), GetHeight(), GetDepth()}; createInfo.extent = VulkanExtent3D(GetSize());
createInfo.mipLevels = GetNumMipLevels(); createInfo.mipLevels = GetNumMipLevels();
createInfo.arrayLayers = GetArrayLayers(); createInfo.arrayLayers = GetArrayLayers();
createInfo.samples = VK_SAMPLE_COUNT_1_BIT; createInfo.samples = VK_SAMPLE_COUNT_1_BIT;