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.
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");
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<UINT16>(GetNumMipLevels());
resourceDescriptor.Format = D3D12TextureFormat(GetFormat());

View File

@ -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;

View File

@ -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();

View File

@ -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;