Don't store unnessary SubresourceRange members in TextureBase

This is preparatory change for a subsequent CL that will deprecate
TextureDescriptor::arrayLayerCount in favor of size.depth.

Bug: dawn:157
Bug: dawn:22
Change-Id: Id64556dc81056fbe7751073ffe9872026c145e77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23102
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-06-12 16:51:51 +00:00 committed by Commit Bot service account
parent 5c9f7af77d
commit f87b62a904
2 changed files with 17 additions and 11 deletions

View File

@ -337,6 +337,12 @@ namespace dawn_native {
} }
} }
// static
SubresourceRange SubresourceRange::SingleSubresource(uint32_t baseMipLevel,
uint32_t baseArrayLayer) {
return {baseMipLevel, 1, baseArrayLayer, 1};
}
// TextureBase // TextureBase
TextureBase::TextureBase(DeviceBase* device, TextureBase::TextureBase(DeviceBase* device,
@ -346,7 +352,8 @@ namespace dawn_native {
mDimension(descriptor->dimension), mDimension(descriptor->dimension),
mFormat(device->GetValidInternalFormat(descriptor->format)), mFormat(device->GetValidInternalFormat(descriptor->format)),
mSize(descriptor->size), mSize(descriptor->size),
mRange({0, descriptor->mipLevelCount, 0, descriptor->arrayLayerCount}), mArrayLayerCount(descriptor->arrayLayerCount),
mMipLevelCount(descriptor->mipLevelCount),
mSampleCount(descriptor->sampleCount), mSampleCount(descriptor->sampleCount),
mUsage(descriptor->usage), mUsage(descriptor->usage),
mState(state) { mState(state) {
@ -387,15 +394,15 @@ namespace dawn_native {
} }
uint32_t TextureBase::GetArrayLayers() const { uint32_t TextureBase::GetArrayLayers() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRange.layerCount; return mArrayLayerCount;
} }
uint32_t TextureBase::GetNumMipLevels() const { uint32_t TextureBase::GetNumMipLevels() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRange.levelCount; return mMipLevelCount;
} }
const SubresourceRange& TextureBase::GetAllSubresources() const { SubresourceRange TextureBase::GetAllSubresources() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRange; return {0, mMipLevelCount, 0, mArrayLayerCount};
} }
uint32_t TextureBase::GetSampleCount() const { uint32_t TextureBase::GetSampleCount() const {
ASSERT(!IsError()); ASSERT(!IsError());
@ -403,7 +410,7 @@ namespace dawn_native {
} }
uint32_t TextureBase::GetSubresourceCount() const { uint32_t TextureBase::GetSubresourceCount() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRange.levelCount * mRange.layerCount; return mMipLevelCount * mArrayLayerCount;
} }
wgpu::TextureUsage TextureBase::GetUsage() const { wgpu::TextureUsage TextureBase::GetUsage() const {
ASSERT(!IsError()); ASSERT(!IsError());

View File

@ -47,9 +47,7 @@ namespace dawn_native {
uint32_t baseArrayLayer; uint32_t baseArrayLayer;
uint32_t layerCount; uint32_t layerCount;
static SubresourceRange SingleSubresource(uint32_t baseMipLevel, uint32_t baseArrayLayer) { static SubresourceRange SingleSubresource(uint32_t baseMipLevel, uint32_t baseArrayLayer);
return {baseMipLevel, 1, baseArrayLayer, 1};
}
}; };
class TextureBase : public ObjectBase { class TextureBase : public ObjectBase {
@ -65,7 +63,7 @@ namespace dawn_native {
const Extent3D& GetSize() const; const Extent3D& GetSize() const;
uint32_t GetArrayLayers() const; uint32_t GetArrayLayers() const;
uint32_t GetNumMipLevels() const; uint32_t GetNumMipLevels() const;
const SubresourceRange& GetAllSubresources() const; SubresourceRange GetAllSubresources() const;
uint32_t GetSampleCount() const; uint32_t GetSampleCount() const;
uint32_t GetSubresourceCount() const; uint32_t GetSubresourceCount() const;
wgpu::TextureUsage GetUsage() const; wgpu::TextureUsage GetUsage() const;
@ -102,7 +100,8 @@ namespace dawn_native {
// TODO(cwallez@chromium.org): This should be deduplicated in the Device // TODO(cwallez@chromium.org): This should be deduplicated in the Device
const Format& mFormat; const Format& mFormat;
Extent3D mSize; Extent3D mSize;
SubresourceRange mRange; uint32_t mArrayLayerCount;
uint32_t mMipLevelCount;
uint32_t mSampleCount; uint32_t mSampleCount;
wgpu::TextureUsage mUsage = wgpu::TextureUsage::None; wgpu::TextureUsage mUsage = wgpu::TextureUsage::None;
TextureState mState; TextureState mState;