mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Fix computation of mipmap sizes used in validation
The width and height of the mipmaps level > 0 weren't computed correctly. Size of mip level of a texture should be greater than 0. BUG=dawn:176 TEST=dawn_unittests --gtest_filter=CopyCommandTest*.CopyNonSquareTexture Change-Id: I730aef3fd8c036567f824cd707d1ea1a69b132c0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8242 Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
6fa398e682
commit
41c24ee4eb
@@ -39,9 +39,10 @@ namespace dawn_native {
|
||||
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
||||
const Extent3D copySize,
|
||||
const uint32_t mipLevel) {
|
||||
if (texture->GetSize().depth == copySize.depth &&
|
||||
(texture->GetSize().width >> mipLevel) == copySize.width &&
|
||||
(texture->GetSize().height >> mipLevel) == copySize.height) {
|
||||
Extent3D extent = texture->GetMipLevelSize(mipLevel);
|
||||
|
||||
if (extent.depth == copySize.depth && extent.width == copySize.width &&
|
||||
extent.height == copySize.height) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -47,24 +47,12 @@ namespace dawn_native {
|
||||
// overflows.
|
||||
uint64_t level = textureCopy.level;
|
||||
|
||||
uint32_t widthAtLevel = texture->GetSize().width >> level;
|
||||
uint32_t heightAtLevel = texture->GetSize().height >> level;
|
||||
|
||||
// Compressed Textures will have paddings if their width or height is not a multiple of
|
||||
// 4 at non-zero mipmap levels.
|
||||
const Format& textureFormat = texture->GetFormat();
|
||||
if (textureFormat.isCompressed) {
|
||||
// TODO(jiawei.shao@intel.com): check if there are any overflows.
|
||||
uint32_t blockWidth = textureFormat.blockWidth;
|
||||
uint32_t blockHeight = textureFormat.blockHeight;
|
||||
widthAtLevel = (widthAtLevel + blockWidth - 1) / blockWidth * blockWidth;
|
||||
heightAtLevel = (heightAtLevel + blockHeight - 1) / blockHeight * blockHeight;
|
||||
}
|
||||
Extent3D extent = texture->GetMipLevelSize(level);
|
||||
|
||||
if (uint64_t(textureCopy.origin.x) + uint64_t(copySize.width) >
|
||||
static_cast<uint64_t>(widthAtLevel) ||
|
||||
static_cast<uint64_t>(extent.width) ||
|
||||
uint64_t(textureCopy.origin.y) + uint64_t(copySize.height) >
|
||||
static_cast<uint64_t>(heightAtLevel)) {
|
||||
static_cast<uint64_t>(extent.height)) {
|
||||
return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture");
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +497,25 @@ namespace dawn_native {
|
||||
return mSampleCount > 1;
|
||||
}
|
||||
|
||||
Extent3D TextureBase::GetMipLevelSize(uint64_t level) const {
|
||||
Extent3D extent;
|
||||
extent.width = std::max(mSize.width >> level, 1u);
|
||||
extent.height = std::max(mSize.height >> level, 1u);
|
||||
extent.depth = std::max(mSize.depth >> level, 1u);
|
||||
|
||||
// Compressed Textures will have paddings if their width or height is not a multiple of
|
||||
// 4 at non-zero mipmap levels.
|
||||
if (mFormat.isCompressed) {
|
||||
// TODO(jiawei.shao@intel.com): check if there are any overflows.
|
||||
uint32_t blockWidth = mFormat.blockWidth;
|
||||
uint32_t blockHeight = mFormat.blockHeight;
|
||||
extent.width = (extent.width + blockWidth - 1) / blockWidth * blockWidth;
|
||||
extent.height = (extent.height + blockHeight - 1) / blockHeight * blockHeight;
|
||||
}
|
||||
|
||||
return extent;
|
||||
}
|
||||
|
||||
TextureViewBase* TextureBase::CreateDefaultView() {
|
||||
TextureViewDescriptor descriptor = {};
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ namespace dawn_native {
|
||||
|
||||
bool IsMultisampledTexture() const;
|
||||
|
||||
Extent3D GetMipLevelSize(uint64_t level) const;
|
||||
|
||||
// Dawn API
|
||||
TextureViewBase* CreateDefaultView();
|
||||
TextureViewBase* CreateView(const TextureViewDescriptor* descriptor);
|
||||
|
||||
Reference in New Issue
Block a user