OpenGL: Make Device::gl private.

Make Device::gl private, and rename it to mGL. Change all accesses to
use Device::GetGL() accessor.

This is a precursor to adding native EGLContext support to
Dawn.

Bug: dawn:810
Change-Id: I3793d83644a70bafc6bea8b423c1a7c76beb248d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94560
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/opengl/BufferGL.cpp b/src/dawn/native/opengl/BufferGL.cpp
index c05730b..5fce54f 100644
--- a/src/dawn/native/opengl/BufferGL.cpp
+++ b/src/dawn/native/opengl/BufferGL.cpp
@@ -39,21 +39,22 @@
 
 Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
     : BufferBase(device, descriptor) {
+    const OpenGLFunctions& gl = device->GetGL();
     // Allocate at least 4 bytes so clamped accesses are always in bounds.
     mAllocatedSize = std::max(GetSize(), uint64_t(4u));
 
-    device->gl.GenBuffers(1, &mBuffer);
-    device->gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
+    gl.GenBuffers(1, &mBuffer);
+    gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
 
     // The buffers with mappedAtCreation == true will be initialized in
     // BufferBase::MapAtCreation().
     if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting) &&
         !descriptor->mappedAtCreation) {
         std::vector<uint8_t> clearValues(mAllocatedSize, 1u);
-        device->gl.BufferData(GL_ARRAY_BUFFER, mAllocatedSize, clearValues.data(), GL_STATIC_DRAW);
+        gl.BufferData(GL_ARRAY_BUFFER, mAllocatedSize, clearValues.data(), GL_STATIC_DRAW);
     } else {
         // Buffers start zeroed if you pass nullptr to glBufferData.
-        device->gl.BufferData(GL_ARRAY_BUFFER, mAllocatedSize, nullptr, GL_STATIC_DRAW);
+        gl.BufferData(GL_ARRAY_BUFFER, mAllocatedSize, nullptr, GL_STATIC_DRAW);
     }
 }
 
@@ -112,10 +113,11 @@
 
     const uint64_t size = GetAllocatedSize();
     Device* device = ToBackend(GetDevice());
+    const OpenGLFunctions& gl = device->GetGL();
 
     const std::vector<uint8_t> clearValues(size, 0u);
-    device->gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
-    device->gl.BufferSubData(GL_ARRAY_BUFFER, 0, size, clearValues.data());
+    gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
+    gl.BufferSubData(GL_ARRAY_BUFFER, 0, size, clearValues.data());
     device->IncrementLazyClearCountForTesting();
 
     SetIsDataInitialized();
@@ -128,14 +130,14 @@
 }
 
 MaybeError Buffer::MapAtCreationImpl() {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
     mMappedData = gl.MapBufferRange(GL_ARRAY_BUFFER, 0, GetSize(), GL_MAP_WRITE_BIT);
     return {};
 }
 
 MaybeError Buffer::MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     // It is an error to map an empty range in OpenGL. We always have at least a 4-byte buffer
     // so we extend the range to be 4 bytes.
@@ -171,7 +173,7 @@
 }
 
 void Buffer::UnmapImpl() {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
     gl.UnmapBuffer(GL_ARRAY_BUFFER);
@@ -179,8 +181,10 @@
 }
 
 void Buffer::DestroyImpl() {
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
+
     BufferBase::DestroyImpl();
-    ToBackend(GetDevice())->gl.DeleteBuffers(1, &mBuffer);
+    gl.DeleteBuffers(1, &mBuffer);
     mBuffer = 0;
 }
 
diff --git a/src/dawn/native/opengl/CommandBufferGL.cpp b/src/dawn/native/opengl/CommandBufferGL.cpp
index 851413d..f0ea75b 100644
--- a/src/dawn/native/opengl/CommandBufferGL.cpp
+++ b/src/dawn/native/opengl/CommandBufferGL.cpp
@@ -448,7 +448,7 @@
     : CommandBufferBase(encoder, descriptor) {}
 
 MaybeError CommandBuffer::Execute() {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     auto LazyClearSyncScope = [](const SyncScopeResourceUsage& scope) {
         for (size_t i = 0; i < scope.textures.size(); i++) {
@@ -767,7 +767,7 @@
 }
 
 MaybeError CommandBuffer::ExecuteComputePass() {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     ComputePipeline* lastPipeline = nullptr;
     BindGroupTracker bindGroupTracker = {};
 
@@ -844,7 +844,7 @@
 }
 
 MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     GLuint fbo = 0;
 
     // Create the framebuffer used for this render pass and calls the correct glDrawBuffers
diff --git a/src/dawn/native/opengl/ComputePipelineGL.cpp b/src/dawn/native/opengl/ComputePipelineGL.cpp
index 35d2abd..08a7c89 100644
--- a/src/dawn/native/opengl/ComputePipelineGL.cpp
+++ b/src/dawn/native/opengl/ComputePipelineGL.cpp
@@ -29,16 +29,17 @@
 
 void ComputePipeline::DestroyImpl() {
     ComputePipelineBase::DestroyImpl();
-    DeleteProgram(ToBackend(GetDevice())->gl);
+    DeleteProgram(ToBackend(GetDevice())->GetGL());
 }
 
 MaybeError ComputePipeline::Initialize() {
-    DAWN_TRY(InitializeBase(ToBackend(GetDevice())->gl, ToBackend(GetLayout()), GetAllStages()));
+    DAWN_TRY(
+        InitializeBase(ToBackend(GetDevice())->GetGL(), ToBackend(GetLayout()), GetAllStages()));
     return {};
 }
 
 void ComputePipeline::ApplyNow() {
-    PipelineGL::ApplyNow(ToBackend(GetDevice())->gl);
+    PipelineGL::ApplyNow(ToBackend(GetDevice())->GetGL());
 }
 
 }  // namespace dawn::native::opengl
diff --git a/src/dawn/native/opengl/DeviceGL.cpp b/src/dawn/native/opengl/DeviceGL.cpp
index 274cc1a..fbceac9 100644
--- a/src/dawn/native/opengl/DeviceGL.cpp
+++ b/src/dawn/native/opengl/DeviceGL.cpp
@@ -46,7 +46,7 @@
 Device::Device(AdapterBase* adapter,
                const DeviceDescriptor* descriptor,
                const OpenGLFunctions& functions)
-    : DeviceBase(adapter, descriptor), gl(functions) {}
+    : DeviceBase(adapter, descriptor), mGL(functions) {}
 
 Device::~Device() {
     Destroy();
@@ -60,6 +60,7 @@
 }
 
 void Device::InitTogglesFromDriver() {
+    const OpenGLFunctions& gl = GetGL();
     bool supportsBaseVertex = gl.IsAtLeastGLES(3, 2) || gl.IsAtLeastGL(3, 2);
 
     bool supportsBaseInstance = gl.IsAtLeastGLES(3, 2) || gl.IsAtLeastGL(4, 2);
@@ -124,6 +125,7 @@
 }
 
 GLenum Device::GetBGRAInternalFormat() const {
+    const OpenGLFunctions& gl = GetGL();
     if (gl.IsGLExtensionSupported("GL_EXT_texture_format_BGRA8888") ||
         gl.IsGLExtensionSupported("GL_APPLE_texture_format_BGRA8888")) {
         return GL_BGRA8_EXT;
@@ -195,6 +197,7 @@
 }
 
 void Device::SubmitFenceSync() {
+    const OpenGLFunctions& gl = GetGL();
     GLsync sync = gl.FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
     IncrementLastSubmittedCommandSerial();
     mFencesInFlight.emplace(sync, GetLastSubmittedCommandSerial());
@@ -224,6 +227,7 @@
 }
 TextureBase* Device::CreateTextureWrappingEGLImage(const ExternalImageDescriptor* descriptor,
                                                    ::EGLImage image) {
+    const OpenGLFunctions& gl = GetGL();
     const TextureDescriptor* textureDescriptor = FromAPI(descriptor->cTextureDescriptor);
 
     if (ConsumedError(ValidateTextureDescriptor(this, textureDescriptor))) {
@@ -264,6 +268,7 @@
 
 ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
     ExecutionSerial fenceSerial{0};
+    const OpenGLFunctions& gl = GetGL();
     while (!mFencesInFlight.empty()) {
         auto [sync, tentativeSerial] = mFencesInFlight.front();
 
@@ -314,6 +319,7 @@
 }
 
 MaybeError Device::WaitForIdleForDestruction() {
+    const OpenGLFunctions& gl = GetGL();
     gl.Finish();
     DAWN_TRY(CheckPassedSerials());
     ASSERT(mFencesInFlight.empty());
@@ -333,4 +339,8 @@
     return 1.0f;
 }
 
+const OpenGLFunctions& Device::GetGL() const {
+    return mGL;
+}
+
 }  // namespace dawn::native::opengl
diff --git a/src/dawn/native/opengl/DeviceGL.h b/src/dawn/native/opengl/DeviceGL.h
index d915895..b80439f 100644
--- a/src/dawn/native/opengl/DeviceGL.h
+++ b/src/dawn/native/opengl/DeviceGL.h
@@ -46,8 +46,8 @@
 
     MaybeError Initialize(const DeviceDescriptor* descriptor);
 
-    // Contains all the OpenGL entry points, glDoFoo is called via device->gl.DoFoo.
-    const OpenGLFunctions gl;
+    // Contains all the OpenGL entry points, glDoFoo is called via gl.DoFoo.
+    const OpenGLFunctions& GetGL() const;
 
     const GLFormat& GetGLFormat(const Format& format);
 
@@ -121,6 +121,8 @@
     void DestroyImpl() override;
     MaybeError WaitForIdleForDestruction() override;
 
+    const OpenGLFunctions mGL;
+
     std::queue<std::pair<GLsync, ExecutionSerial>> mFencesInFlight;
 
     GLFormatTable mFormatTable;
diff --git a/src/dawn/native/opengl/NativeSwapChainImplGL.cpp b/src/dawn/native/opengl/NativeSwapChainImplGL.cpp
index 409acf1..05e377a 100644
--- a/src/dawn/native/opengl/NativeSwapChainImplGL.cpp
+++ b/src/dawn/native/opengl/NativeSwapChainImplGL.cpp
@@ -24,13 +24,13 @@
     : mPresentCallback(present), mPresentUserdata(presentUserdata), mDevice(device) {}
 
 NativeSwapChainImpl::~NativeSwapChainImpl() {
-    const OpenGLFunctions& gl = mDevice->gl;
+    const OpenGLFunctions& gl = mDevice->GetGL();
     gl.DeleteTextures(1, &mBackTexture);
     gl.DeleteFramebuffers(1, &mBackFBO);
 }
 
 void NativeSwapChainImpl::Init(DawnWSIContextGL* /*context*/) {
-    const OpenGLFunctions& gl = mDevice->gl;
+    const OpenGLFunctions& gl = mDevice->GetGL();
     gl.GenTextures(1, &mBackTexture);
     gl.BindTexture(GL_TEXTURE_2D, mBackTexture);
     gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
@@ -53,7 +53,7 @@
     mWidth = width;
     mHeight = height;
 
-    const OpenGLFunctions& gl = mDevice->gl;
+    const OpenGLFunctions& gl = mDevice->GetGL();
     gl.BindTexture(GL_TEXTURE_2D, mBackTexture);
     // Reallocate the texture
     gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
@@ -67,7 +67,7 @@
 }
 
 DawnSwapChainError NativeSwapChainImpl::Present() {
-    const OpenGLFunctions& gl = mDevice->gl;
+    const OpenGLFunctions& gl = mDevice->GetGL();
     gl.BindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
     gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
     gl.Scissor(0, 0, mWidth, mHeight);
diff --git a/src/dawn/native/opengl/QueueGL.cpp b/src/dawn/native/opengl/QueueGL.cpp
index 68eb918..38fec61 100644
--- a/src/dawn/native/opengl/QueueGL.cpp
+++ b/src/dawn/native/opengl/QueueGL.cpp
@@ -42,7 +42,7 @@
                                   uint64_t bufferOffset,
                                   const void* data,
                                   size_t size) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     ToBackend(buffer)->EnsureDataInitializedAsDestination(bufferOffset, size);
 
@@ -70,7 +70,7 @@
     } else {
         ToBackend(destination.texture)->EnsureSubresourceContentInitialized(range);
     }
-    DoTexSubImage(ToBackend(GetDevice())->gl, textureCopy, data, dataLayout, writeSizePixel);
+    DoTexSubImage(ToBackend(GetDevice())->GetGL(), textureCopy, data, dataLayout, writeSizePixel);
     ToBackend(destination.texture)->Touch();
     return {};
 }
diff --git a/src/dawn/native/opengl/RenderPipelineGL.cpp b/src/dawn/native/opengl/RenderPipelineGL.cpp
index 54b6ffb..5992729 100644
--- a/src/dawn/native/opengl/RenderPipelineGL.cpp
+++ b/src/dawn/native/opengl/RenderPipelineGL.cpp
@@ -226,7 +226,8 @@
       mGlPrimitiveTopology(GLPrimitiveTopology(GetPrimitiveTopology())) {}
 
 MaybeError RenderPipeline::Initialize() {
-    DAWN_TRY(InitializeBase(ToBackend(GetDevice())->gl, ToBackend(GetLayout()), GetAllStages()));
+    DAWN_TRY(
+        InitializeBase(ToBackend(GetDevice())->GetGL(), ToBackend(GetLayout()), GetAllStages()));
     CreateVAOForVertexState();
     return {};
 }
@@ -235,7 +236,7 @@
 
 void RenderPipeline::DestroyImpl() {
     RenderPipelineBase::DestroyImpl();
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     gl.DeleteVertexArrays(1, &mVertexArrayObject);
     gl.BindVertexArray(0);
     DeleteProgram(gl);
@@ -252,7 +253,7 @@
 }
 
 void RenderPipeline::CreateVAOForVertexState() {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     gl.GenVertexArrays(1, &mVertexArrayObject);
     gl.BindVertexArray(mVertexArrayObject);
@@ -284,7 +285,7 @@
 }
 
 void RenderPipeline::ApplyNow(PersistentPipelineState& persistentPipelineState) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     PipelineGL::ApplyNow(gl);
 
     ASSERT(mVertexArrayObject);
diff --git a/src/dawn/native/opengl/SamplerGL.cpp b/src/dawn/native/opengl/SamplerGL.cpp
index b40e1d6..2f8c59b 100644
--- a/src/dawn/native/opengl/SamplerGL.cpp
+++ b/src/dawn/native/opengl/SamplerGL.cpp
@@ -67,7 +67,7 @@
 
 Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
     : SamplerBase(device, descriptor) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     gl.GenSamplers(1, &mFilteringHandle);
     SetupGLSampler(mFilteringHandle, descriptor, false);
@@ -80,7 +80,7 @@
 
 void Sampler::DestroyImpl() {
     SamplerBase::DestroyImpl();
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
     gl.DeleteSamplers(1, &mFilteringHandle);
     gl.DeleteSamplers(1, &mNonFilteringHandle);
 }
@@ -89,7 +89,7 @@
                              const SamplerDescriptor* descriptor,
                              bool forceNearest) {
     Device* device = ToBackend(GetDevice());
-    const OpenGLFunctions& gl = device->gl;
+    const OpenGLFunctions& gl = device->GetGL();
 
     if (forceNearest) {
         gl.SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index 253600b..735b4df 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -95,7 +95,7 @@
     tint::Program program;
     DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, GetTintProgram(), transformInputs,
                                            nullptr, nullptr));
-    const OpenGLVersion& version = ToBackend(GetDevice())->gl.GetVersion();
+    const OpenGLVersion& version = ToBackend(GetDevice())->GetGL().GetVersion();
 
     tint::writer::glsl::Options tintOptions;
     using Version = tint::writer::glsl::Version;
diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp
index 88130bd..6b47342 100644
--- a/src/dawn/native/opengl/TextureGL.cpp
+++ b/src/dawn/native/opengl/TextureGL.cpp
@@ -83,12 +83,6 @@
     UNREACHABLE();
 }
 
-GLuint GenTexture(const OpenGLFunctions& gl) {
-    GLuint handle = 0;
-    gl.GenTextures(1, &handle);
-    return handle;
-}
-
 bool RequiresCreatingNewTextureView(const TextureBase* texture,
                                     const TextureViewDescriptor* textureViewDescriptor) {
     constexpr wgpu::TextureUsage kShaderUsageNeedsView =
@@ -179,9 +173,10 @@
 // Texture
 
 Texture::Texture(Device* device, const TextureDescriptor* descriptor)
-    : Texture(device, descriptor, GenTexture(device->gl), TextureState::OwnedInternal) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    : Texture(device, descriptor, 0, TextureState::OwnedInternal) {
+    const OpenGLFunctions& gl = device->GetGL();
 
+    gl.GenTextures(1, &mHandle);
     uint32_t levels = GetNumMipLevels();
 
     const GLFormat& glFormat = GetGLFormat();
@@ -221,7 +216,8 @@
 void Texture::DestroyImpl() {
     TextureBase::DestroyImpl();
     if (GetTextureState() == TextureState::OwnedInternal) {
-        ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
+        const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
+        gl.DeleteTextures(1, &mHandle);
         mHandle = 0;
     }
 }
@@ -246,7 +242,7 @@
     }
 
     Device* device = ToBackend(GetDevice());
-    const OpenGLFunctions& gl = device->gl;
+    const OpenGLFunctions& gl = device->GetGL();
 
     uint8_t clearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0 : 1;
     float fClearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0.f : 1.f;
@@ -534,7 +530,7 @@
                 }
 
                 textureCopy.origin.z = layer;
-                DoTexSubImage(ToBackend(GetDevice())->gl, textureCopy, 0, dataLayout, mipSize);
+                DoTexSubImage(gl, textureCopy, 0, dataLayout, mipSize);
             }
         }
         gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
@@ -571,9 +567,9 @@
     if (!RequiresCreatingNewTextureView(texture, descriptor)) {
         mHandle = ToBackend(texture)->GetHandle();
     } else {
-        const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+        const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
         if (gl.IsAtLeastGL(4, 3)) {
-            mHandle = GenTexture(gl);
+            gl.GenTextures(1, &mHandle);
             const Texture* textureGL = ToBackend(texture);
             gl.TextureView(mHandle, mTarget, textureGL->GetHandle(), GetInternalFormat(),
                            descriptor->baseMipLevel, descriptor->mipLevelCount,
@@ -592,7 +588,8 @@
 void TextureView::DestroyImpl() {
     TextureViewBase::DestroyImpl();
     if (mOwnsHandle) {
-        ToBackend(GetDevice())->gl.DeleteTextures(1, &mHandle);
+        const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
+        gl.DeleteTextures(1, &mHandle);
     }
 }
 
@@ -606,7 +603,7 @@
 }
 
 void TextureView::BindToFramebuffer(GLenum target, GLenum attachment) {
-    const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
+    const OpenGLFunctions& gl = ToBackend(GetDevice())->GetGL();
 
     // Use the base texture where possible to minimize the amount of copying required on GLES.
     bool useOwnView = GetFormat().format != GetTexture()->GetFormat().format &&
@@ -648,7 +645,7 @@
     }
 
     Device* device = ToBackend(GetDevice());
-    const OpenGLFunctions& gl = device->gl;
+    const OpenGLFunctions& gl = device->GetGL();
     uint32_t srcLevel = GetBaseMipLevel();
     uint32_t numLevels = GetLevelCount();
 
@@ -657,7 +654,7 @@
     Extent3D size{width, height, GetLayerCount()};
 
     if (mHandle == 0) {
-        mHandle = GenTexture(gl);
+        gl.GenTextures(1, &mHandle);
         gl.BindTexture(mTarget, mHandle);
         AllocateTexture(gl, mTarget, texture->GetSampleCount(), numLevels, GetInternalFormat(),
                         size);
diff --git a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
index ee16eb3..3b2b97e 100644
--- a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
+++ b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
@@ -128,7 +128,7 @@
                                   size_t size) {
         dawn::native::opengl::Device* openglDevice =
             dawn::native::opengl::ToBackend(dawn::native::FromAPI(device.Get()));
-        const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->gl;
+        const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->GetGL();
         GLuint tex;
         gl.GenTextures(1, &tex);
         gl.BindTexture(GL_TEXTURE_2D, tex);
@@ -300,7 +300,7 @@
                      size_t dataSize) {
         dawn::native::opengl::Device* openglDevice =
             dawn::native::opengl::ToBackend(dawn::native::FromAPI(device.Get()));
-        const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->gl;
+        const dawn::native::opengl::OpenGLFunctions& gl = openglDevice->GetGL();
 
         // Get a texture view for the eglImage
         wgpu::TextureDescriptor textureDescriptor;