diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp index 11dbae3c33..3a39ffaf3a 100644 --- a/src/dawn_native/Texture.cpp +++ b/src/dawn_native/Texture.cpp @@ -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(DeviceBase* device, @@ -346,7 +352,8 @@ namespace dawn_native { mDimension(descriptor->dimension), mFormat(device->GetValidInternalFormat(descriptor->format)), mSize(descriptor->size), - mRange({0, descriptor->mipLevelCount, 0, descriptor->arrayLayerCount}), + mArrayLayerCount(descriptor->arrayLayerCount), + mMipLevelCount(descriptor->mipLevelCount), mSampleCount(descriptor->sampleCount), mUsage(descriptor->usage), mState(state) { @@ -387,15 +394,15 @@ namespace dawn_native { } uint32_t TextureBase::GetArrayLayers() const { ASSERT(!IsError()); - return mRange.layerCount; + return mArrayLayerCount; } uint32_t TextureBase::GetNumMipLevels() const { ASSERT(!IsError()); - return mRange.levelCount; + return mMipLevelCount; } - const SubresourceRange& TextureBase::GetAllSubresources() const { + SubresourceRange TextureBase::GetAllSubresources() const { ASSERT(!IsError()); - return mRange; + return {0, mMipLevelCount, 0, mArrayLayerCount}; } uint32_t TextureBase::GetSampleCount() const { ASSERT(!IsError()); @@ -403,7 +410,7 @@ namespace dawn_native { } uint32_t TextureBase::GetSubresourceCount() const { ASSERT(!IsError()); - return mRange.levelCount * mRange.layerCount; + return mMipLevelCount * mArrayLayerCount; } wgpu::TextureUsage TextureBase::GetUsage() const { ASSERT(!IsError()); diff --git a/src/dawn_native/Texture.h b/src/dawn_native/Texture.h index 4765c1d1b5..964a1ac29c 100644 --- a/src/dawn_native/Texture.h +++ b/src/dawn_native/Texture.h @@ -47,9 +47,7 @@ namespace dawn_native { uint32_t baseArrayLayer; uint32_t layerCount; - static SubresourceRange SingleSubresource(uint32_t baseMipLevel, uint32_t baseArrayLayer) { - return {baseMipLevel, 1, baseArrayLayer, 1}; - } + static SubresourceRange SingleSubresource(uint32_t baseMipLevel, uint32_t baseArrayLayer); }; class TextureBase : public ObjectBase { @@ -65,7 +63,7 @@ namespace dawn_native { const Extent3D& GetSize() const; uint32_t GetArrayLayers() const; uint32_t GetNumMipLevels() const; - const SubresourceRange& GetAllSubresources() const; + SubresourceRange GetAllSubresources() const; uint32_t GetSampleCount() const; uint32_t GetSubresourceCount() const; wgpu::TextureUsage GetUsage() const; @@ -102,7 +100,8 @@ namespace dawn_native { // TODO(cwallez@chromium.org): This should be deduplicated in the Device const Format& mFormat; Extent3D mSize; - SubresourceRange mRange; + uint32_t mArrayLayerCount; + uint32_t mMipLevelCount; uint32_t mSampleCount; wgpu::TextureUsage mUsage = wgpu::TextureUsage::None; TextureState mState;