Fix GLTextureWrappingTests: create a second GL device.
It turns out that the existing tests still pass even if the relevant ANGLE extension is not requested in ContextEGL. The reason is that the tests were using the test's native::opengl::Device to create a GL texture, wrap it and send it back to the same device (and same EGL context). This works even without the extension, since the GL texture IDs match.
A better idea (stolen from VulkanImageWrappingTests) is to create a second native::opengl::Device and create textures in its context. That way, the texture IDs will be unknown to the main Device unless the extension is requested.
Bug: chromium:1414566
Change-Id: I134a5a8cb3724c8a6ccb65a26e328ea75b763c35
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/145560
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/dawn/tests/white_box/GLTextureWrappingTests.cpp b/src/dawn/tests/white_box/GLTextureWrappingTests.cpp
index 16289f7..f0ca12b 100644
--- a/src/dawn/tests/white_box/GLTextureWrappingTests.cpp
+++ b/src/dawn/tests/white_box/GLTextureWrappingTests.cpp
@@ -70,6 +70,10 @@
DawnTest::SetUp();
DAWN_TEST_UNSUPPORTED_IF(!SupportsFeatures({wgpu::FeatureName::ANGLETextureSharing}));
DAWN_TEST_UNSUPPORTED_IF(UsesWire());
+
+ // Create a second GL device from which we can vend textures.
+ mSecondDevice = CreateDevice();
+ mSecondDeviceGL = native::opengl::ToBackend(native::FromAPI(mSecondDevice.Get()));
}
public:
@@ -80,9 +84,7 @@
GLenum type,
void* data,
size_t size) {
- native::opengl::Device* openglDevice =
- native::opengl::ToBackend(native::FromAPI(device.Get()));
- const native::opengl::OpenGLFunctions& gl = openglDevice->GetGL();
+ const native::opengl::OpenGLFunctions& gl = mSecondDeviceGL->GetGL();
GLuint tex;
gl.GenTextures(1, &tex);
gl.BindTexture(GL_TEXTURE_2D, tex);
@@ -97,6 +99,10 @@
return wgpu::Texture::Acquire(
native::opengl::WrapExternalGLTexture(device.Get(), &externDesc));
}
+
+ protected:
+ native::opengl::Device* mSecondDeviceGL;
+ wgpu::Device mSecondDevice;
};
// A small fixture used to initialize default data for the GLTexture validation tests.
@@ -248,9 +254,7 @@
GLenum glType,
void* data,
size_t dataSize) {
- native::opengl::Device* openglDevice =
- native::opengl::ToBackend(native::FromAPI(device.Get()));
- const native::opengl::OpenGLFunctions& gl = openglDevice->GetGL();
+ const native::opengl::OpenGLFunctions& gl = mSecondDeviceGL->GetGL();
// Get a texture view for the GL texture.
wgpu::TextureDescriptor textureDescriptor;