OpenGL: fix mip subset selection.
Fix mip subset selection through glTexParameter() calls.
Also disable the copy workaround for miplevels. This workaround is not
correct, since we allow a single mip subset via glTexParameters(), and
it is caught at bind time. We cannot determine that at this level, so
remove the workaround for now.
(All of this workaround should eventually be removed.)
Bug: dawn:2283
Change-Id: I20ccc4125f06b384f8e01699e8221bd463c1bae5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/166801
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp
index 4da7659..9ea3607 100644
--- a/src/dawn/native/opengl/CommandBufferGL.cpp
+++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -355,6 +355,9 @@
break;
}
}
+ gl.TexParameteri(target, GL_TEXTURE_BASE_LEVEL, view->GetBaseMipLevel());
+ gl.TexParameteri(target, GL_TEXTURE_MAX_LEVEL,
+ view->GetBaseMipLevel() + view->GetLevelCount() - 1);
}
// Some texture builtin function data needs emulation to update into the
diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp
index d001fa7..179d0bd 100644
--- a/src/dawn/native/opengl/TextureGL.cpp
+++ b/src/dawn/native/opengl/TextureGL.cpp
@@ -128,10 +128,6 @@
return true;
}
- if (texture->GetNumMipLevels() != textureViewDescriptor->mipLevelCount) {
- return true;
- }
-
if (ToBackend(texture)->GetGLFormat().format == GL_DEPTH_STENCIL &&
(texture->GetUsage() & wgpu::TextureUsage::TextureBinding) != 0 &&
textureViewDescriptor->aspect == wgpu::TextureAspect::StencilOnly) {
@@ -255,11 +251,6 @@
MaybeError Texture::ClearTexture(const SubresourceRange& range,
TextureBase::ClearValue clearValue) {
- // TODO(crbug.com/dawn/850): initialize the textures with compressed formats.
- if (GetFormat().isCompressed) {
- return {};
- }
-
Device* device = ToBackend(GetDevice());
const OpenGLFunctions& gl = device->GetGL();
diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp
index 58aaae2..d111a27 100644
--- a/src/dawn/tests/end2end/TextureViewTests.cpp
+++ b/src/dawn/tests/end2end/TextureViewTests.cpp
@@ -464,6 +464,7 @@
// Test sampling from a 2D array texture view created on a mipmap level of a 2D array texture.
TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnOneLevelOf2DArrayTexture) {
+ DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode());
Texture2DArrayViewTest(6, 6, 2, 4);
}