Fix a bug for texture subresource
Texture subresource total number is wrongly calculated. This change fixed the tiny bug. Bug: dawn:157 Change-Id: Id6dad7e60fa9fe63dac3567814486d3f9dfcee9e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21902 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
9b54466be4
commit
8d6b021a2a
|
@ -44,15 +44,15 @@ namespace dawn_native {
|
||||||
textureUsage.usage |= usage;
|
textureUsage.usage |= usage;
|
||||||
|
|
||||||
// Set usages for subresources
|
// Set usages for subresources
|
||||||
uint32_t subresourceCount =
|
uint32_t subresourceCount = texture->GetSubresourceCount();
|
||||||
texture->GetSubresourceIndex(texture->GetNumMipLevels(), texture->GetArrayLayers());
|
|
||||||
if (!textureUsage.subresourceUsages.size()) {
|
if (!textureUsage.subresourceUsages.size()) {
|
||||||
textureUsage.subresourceUsages =
|
textureUsage.subresourceUsages =
|
||||||
std::vector<wgpu::TextureUsage>(subresourceCount, wgpu::TextureUsage::None);
|
std::vector<wgpu::TextureUsage>(subresourceCount, wgpu::TextureUsage::None);
|
||||||
}
|
}
|
||||||
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount; ++mipLevel) {
|
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
||||||
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
++arrayLayer) {
|
||||||
++arrayLayer) {
|
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount;
|
||||||
|
++mipLevel) {
|
||||||
uint32_t subresourceIndex = texture->GetSubresourceIndex(mipLevel, arrayLayer);
|
uint32_t subresourceIndex = texture->GetSubresourceIndex(mipLevel, arrayLayer);
|
||||||
textureUsage.subresourceUsages[subresourceIndex] |= usage;
|
textureUsage.subresourceUsages[subresourceIndex] |= usage;
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,7 @@ namespace dawn_native {
|
||||||
PassTextureUsage& passTextureUsage = mTextureUsages[texture];
|
PassTextureUsage& passTextureUsage = mTextureUsages[texture];
|
||||||
passTextureUsage.usage |= textureUsage.usage;
|
passTextureUsage.usage |= textureUsage.usage;
|
||||||
|
|
||||||
uint32_t subresourceCount =
|
uint32_t subresourceCount = texture->GetSubresourceCount();
|
||||||
texture->GetSubresourceIndex(texture->GetNumMipLevels(), texture->GetArrayLayers());
|
|
||||||
ASSERT(textureUsage.subresourceUsages.size() == subresourceCount);
|
ASSERT(textureUsage.subresourceUsages.size() == subresourceCount);
|
||||||
if (!passTextureUsage.subresourceUsages.size()) {
|
if (!passTextureUsage.subresourceUsages.size()) {
|
||||||
passTextureUsage.subresourceUsages = textureUsage.subresourceUsages;
|
passTextureUsage.subresourceUsages = textureUsage.subresourceUsages;
|
||||||
|
|
|
@ -351,8 +351,7 @@ namespace dawn_native {
|
||||||
mSampleCount(descriptor->sampleCount),
|
mSampleCount(descriptor->sampleCount),
|
||||||
mUsage(descriptor->usage),
|
mUsage(descriptor->usage),
|
||||||
mState(state) {
|
mState(state) {
|
||||||
uint32_t subresourceCount =
|
uint32_t subresourceCount = GetSubresourceCount();
|
||||||
GetSubresourceIndex(descriptor->mipLevelCount, descriptor->arrayLayerCount);
|
|
||||||
mIsSubresourceContentInitializedAtIndex = std::vector<bool>(subresourceCount, false);
|
mIsSubresourceContentInitializedAtIndex = std::vector<bool>(subresourceCount, false);
|
||||||
|
|
||||||
// Add readonly storage usage if the texture has a storage usage. The validation rules in
|
// Add readonly storage usage if the texture has a storage usage. The validation rules in
|
||||||
|
@ -399,6 +398,10 @@ namespace dawn_native {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mSampleCount;
|
return mSampleCount;
|
||||||
}
|
}
|
||||||
|
uint32_t TextureBase::GetSubresourceCount() const {
|
||||||
|
ASSERT(!IsError());
|
||||||
|
return mMipLevelCount * mArrayLayerCount;
|
||||||
|
}
|
||||||
wgpu::TextureUsage TextureBase::GetUsage() const {
|
wgpu::TextureUsage TextureBase::GetUsage() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mUsage;
|
return mUsage;
|
||||||
|
@ -423,9 +426,10 @@ namespace dawn_native {
|
||||||
uint32_t baseArrayLayer,
|
uint32_t baseArrayLayer,
|
||||||
uint32_t layerCount) const {
|
uint32_t layerCount) const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount; ++mipLevel) {
|
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
||||||
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
++arrayLayer) {
|
||||||
++arrayLayer) {
|
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount;
|
||||||
|
++mipLevel) {
|
||||||
uint32_t subresourceIndex = GetSubresourceIndex(mipLevel, arrayLayer);
|
uint32_t subresourceIndex = GetSubresourceIndex(mipLevel, arrayLayer);
|
||||||
ASSERT(subresourceIndex < mIsSubresourceContentInitializedAtIndex.size());
|
ASSERT(subresourceIndex < mIsSubresourceContentInitializedAtIndex.size());
|
||||||
if (!mIsSubresourceContentInitializedAtIndex[subresourceIndex]) {
|
if (!mIsSubresourceContentInitializedAtIndex[subresourceIndex]) {
|
||||||
|
@ -442,9 +446,10 @@ namespace dawn_native {
|
||||||
uint32_t baseArrayLayer,
|
uint32_t baseArrayLayer,
|
||||||
uint32_t layerCount) {
|
uint32_t layerCount) {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount; ++mipLevel) {
|
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
||||||
for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount;
|
++arrayLayer) {
|
||||||
++arrayLayer) {
|
for (uint32_t mipLevel = baseMipLevel; mipLevel < baseMipLevel + levelCount;
|
||||||
|
++mipLevel) {
|
||||||
uint32_t subresourceIndex = GetSubresourceIndex(mipLevel, arrayLayer);
|
uint32_t subresourceIndex = GetSubresourceIndex(mipLevel, arrayLayer);
|
||||||
ASSERT(subresourceIndex < mIsSubresourceContentInitializedAtIndex.size());
|
ASSERT(subresourceIndex < mIsSubresourceContentInitializedAtIndex.size());
|
||||||
mIsSubresourceContentInitializedAtIndex[subresourceIndex] = isInitialized;
|
mIsSubresourceContentInitializedAtIndex[subresourceIndex] = isInitialized;
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace dawn_native {
|
||||||
uint32_t GetArrayLayers() const;
|
uint32_t GetArrayLayers() const;
|
||||||
uint32_t GetNumMipLevels() const;
|
uint32_t GetNumMipLevels() const;
|
||||||
uint32_t GetSampleCount() const;
|
uint32_t GetSampleCount() const;
|
||||||
|
uint32_t GetSubresourceCount() const;
|
||||||
wgpu::TextureUsage GetUsage() const;
|
wgpu::TextureUsage GetUsage() const;
|
||||||
TextureState GetTextureState() const;
|
TextureState GetTextureState() const;
|
||||||
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
|
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
|
||||||
|
|
Loading…
Reference in New Issue