OpenGL: Use the correct size to lazy-clear mips
We would incorrectly use the size of the first mip level to clear non-zero mip levels. This was found while enabling debug output in the OpenGL backend. BUG=dawn:190 Change-Id: I29a87b87057d425d1c131d11afdc7ca4716607c8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9202 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
9dffe11696
commit
fefb3ab120
|
@ -408,7 +408,7 @@ namespace dawn_native {
|
|||
return mSampleCount > 1;
|
||||
}
|
||||
|
||||
Extent3D TextureBase::GetMipLevelVirtualSize(uint64_t level) const {
|
||||
Extent3D TextureBase::GetMipLevelVirtualSize(uint32_t level) const {
|
||||
Extent3D extent;
|
||||
extent.width = std::max(mSize.width >> level, 1u);
|
||||
extent.height = std::max(mSize.height >> level, 1u);
|
||||
|
@ -416,7 +416,7 @@ namespace dawn_native {
|
|||
return extent;
|
||||
}
|
||||
|
||||
Extent3D TextureBase::GetMipLevelPhysicalSize(uint64_t level) const {
|
||||
Extent3D TextureBase::GetMipLevelPhysicalSize(uint32_t level) const {
|
||||
Extent3D extent = GetMipLevelVirtualSize(level);
|
||||
|
||||
// Compressed Textures will have paddings if their width or height is not a multiple of
|
||||
|
|
|
@ -75,8 +75,8 @@ namespace dawn_native {
|
|||
// size is the one with paddings if necessary, which is always a multiple of the block size
|
||||
// and used in texture copying. The virtual size is the one without paddings, which is not
|
||||
// required to be a multiple of the block size and used in texture sampling.
|
||||
Extent3D GetMipLevelPhysicalSize(uint64_t level) const;
|
||||
Extent3D GetMipLevelVirtualSize(uint64_t level) const;
|
||||
Extent3D GetMipLevelPhysicalSize(uint32_t level) const;
|
||||
Extent3D GetMipLevelVirtualSize(uint32_t level) const;
|
||||
|
||||
// Dawn API
|
||||
TextureViewBase* CreateDefaultView();
|
||||
|
|
|
@ -245,9 +245,10 @@ namespace dawn_native { namespace opengl {
|
|||
} else {
|
||||
auto formatInfo = GetGLFormatInfo(GetFormat().format);
|
||||
for (GLint level = baseMipLevel; level < baseMipLevel + levelCount; ++level) {
|
||||
gl.ClearTexSubImage(mHandle, level, 0, 0, baseArrayLayer, GetSize().width,
|
||||
GetSize().height, layerCount, formatInfo.format,
|
||||
formatInfo.type, nullptr);
|
||||
Extent3D mipSize = GetMipLevelPhysicalSize(level);
|
||||
gl.ClearTexSubImage(mHandle, level, 0, 0, baseArrayLayer, mipSize.width,
|
||||
mipSize.height, layerCount, formatInfo.format, formatInfo.type,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
SetIsSubresourceContentInitialized(baseMipLevel, levelCount, baseArrayLayer, layerCount);
|
||||
|
|
Loading…
Reference in New Issue