From c1746921878712d92f8c56586a3e12ea110e1e14 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Fri, 24 Jun 2022 14:12:39 +0000 Subject: [PATCH] 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 Commit-Queue: Stephen White Kokoro: Kokoro --- src/dawn/native/opengl/BufferGL.cpp | 24 ++++++++------ src/dawn/native/opengl/CommandBufferGL.cpp | 6 ++-- src/dawn/native/opengl/ComputePipelineGL.cpp | 7 +++-- src/dawn/native/opengl/DeviceGL.cpp | 12 ++++++- src/dawn/native/opengl/DeviceGL.h | 6 ++-- .../native/opengl/NativeSwapChainImplGL.cpp | 8 ++--- src/dawn/native/opengl/QueueGL.cpp | 4 +-- src/dawn/native/opengl/RenderPipelineGL.cpp | 9 +++--- src/dawn/native/opengl/SamplerGL.cpp | 6 ++-- src/dawn/native/opengl/ShaderModuleGL.cpp | 2 +- src/dawn/native/opengl/TextureGL.cpp | 31 +++++++++---------- .../tests/white_box/EGLImageWrappingTests.cpp | 4 +-- 12 files changed, 67 insertions(+), 52 deletions(-) diff --git a/src/dawn/native/opengl/BufferGL.cpp b/src/dawn/native/opengl/BufferGL.cpp index c05730bbdd..5fce54f6dd 100644 --- a/src/dawn/native/opengl/BufferGL.cpp +++ b/src/dawn/native/opengl/BufferGL.cpp @@ -39,21 +39,22 @@ ResultOrError> Buffer::CreateInternalBuffer(Device* device, 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 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 @@ void Buffer::InitializeToZero() { const uint64_t size = GetAllocatedSize(); Device* device = ToBackend(GetDevice()); + const OpenGLFunctions& gl = device->GetGL(); const std::vector 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 @@ bool Buffer::IsCPUWritableAtCreation() const { } 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::GetMappedPointerImpl() { } 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::UnmapImpl() { } 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 851413dffe..f0ea75b641 100644 --- a/src/dawn/native/opengl/CommandBufferGL.cpp +++ b/src/dawn/native/opengl/CommandBufferGL.cpp @@ -448,7 +448,7 @@ CommandBuffer::CommandBuffer(CommandEncoder* encoder, const CommandBufferDescrip : 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::Execute() { } 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::ExecuteComputePass() { } 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 35d2abda2f..08a7c89dde 100644 --- a/src/dawn/native/opengl/ComputePipelineGL.cpp +++ b/src/dawn/native/opengl/ComputePipelineGL.cpp @@ -29,16 +29,17 @@ ComputePipeline::~ComputePipeline() = default; 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 274cc1aed5..fbceac9108 100644 --- a/src/dawn/native/opengl/DeviceGL.cpp +++ b/src/dawn/native/opengl/DeviceGL.cpp @@ -46,7 +46,7 @@ ResultOrError> Device::Create(AdapterBase* adapter, 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 @@ MaybeError Device::Initialize(const DeviceDescriptor* descriptor) { } 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 @@ const GLFormat& Device::GetGLFormat(const Format& format) { } 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 @@ ResultOrError> Device::CreateTextureViewImpl( } 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 @@ MaybeError Device::ValidateEGLImageCanBeWrapped(const TextureDescriptor* descrip } 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 @@ MaybeError Device::TickImpl() { ResultOrError Device::CheckAndUpdateCompletedSerials() { ExecutionSerial fenceSerial{0}; + const OpenGLFunctions& gl = GetGL(); while (!mFencesInFlight.empty()) { auto [sync, tentativeSerial] = mFencesInFlight.front(); @@ -314,6 +319,7 @@ void Device::DestroyImpl() { } MaybeError Device::WaitForIdleForDestruction() { + const OpenGLFunctions& gl = GetGL(); gl.Finish(); DAWN_TRY(CheckPassedSerials()); ASSERT(mFencesInFlight.empty()); @@ -333,4 +339,8 @@ float Device::GetTimestampPeriodInNS() const { 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 d915895202..b80439f1bc 100644 --- a/src/dawn/native/opengl/DeviceGL.h +++ b/src/dawn/native/opengl/DeviceGL.h @@ -46,8 +46,8 @@ class Device final : public DeviceBase { 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 @@ class Device final : public DeviceBase { void DestroyImpl() override; MaybeError WaitForIdleForDestruction() override; + const OpenGLFunctions mGL; + std::queue> mFencesInFlight; GLFormatTable mFormatTable; diff --git a/src/dawn/native/opengl/NativeSwapChainImplGL.cpp b/src/dawn/native/opengl/NativeSwapChainImplGL.cpp index 409acf1ed7..05e377a076 100644 --- a/src/dawn/native/opengl/NativeSwapChainImplGL.cpp +++ b/src/dawn/native/opengl/NativeSwapChainImplGL.cpp @@ -24,13 +24,13 @@ NativeSwapChainImpl::NativeSwapChainImpl(Device* device, : 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 @@ DawnSwapChainError NativeSwapChainImpl::Configure(WGPUTextureFormat format, 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::GetNextTexture(DawnSwapChainNextTexture* } 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 68eb918ba7..38fec619a0 100644 --- a/src/dawn/native/opengl/QueueGL.cpp +++ b/src/dawn/native/opengl/QueueGL.cpp @@ -42,7 +42,7 @@ MaybeError Queue::WriteBufferImpl(BufferBase* buffer, 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 @@ MaybeError Queue::WriteTextureImpl(const ImageCopyTexture& destination, } 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 54b6ffba66..59927297fa 100644 --- a/src/dawn/native/opengl/RenderPipelineGL.cpp +++ b/src/dawn/native/opengl/RenderPipelineGL.cpp @@ -226,7 +226,8 @@ RenderPipeline::RenderPipeline(Device* device, const RenderPipelineDescriptor* d 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 @@ RenderPipeline::~RenderPipeline() = default; 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 @@ RenderPipeline::GetAttributesUsingVertexBuffer(VertexBufferSlot slot) const { } 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::CreateVAOForVertexState() { } 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 b40e1d6592..2f8c59b948 100644 --- a/src/dawn/native/opengl/SamplerGL.cpp +++ b/src/dawn/native/opengl/SamplerGL.cpp @@ -67,7 +67,7 @@ GLenum WrapMode(wgpu::AddressMode mode) { 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 @@ Sampler::~Sampler() = default; 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 @@ void Sampler::SetupGLSampler(GLuint sampler, 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 253600b6c3..735b4dfd78 100644 --- a/src/dawn/native/opengl/ShaderModuleGL.cpp +++ b/src/dawn/native/opengl/ShaderModuleGL.cpp @@ -95,7 +95,7 @@ ResultOrError ShaderModule::TranslateToGLSL(const char* entryPointN 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 88130bd8c6..6b47342071 100644 --- a/src/dawn/native/opengl/TextureGL.cpp +++ b/src/dawn/native/opengl/TextureGL.cpp @@ -83,12 +83,6 @@ GLenum TargetForTextureViewDimension(wgpu::TextureViewDimension dimension, 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 @@ void AllocateTexture(const OpenGLFunctions& gl, // 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 @@ Texture::~Texture() {} 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 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range, } 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 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range, } 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 @@ TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* desc 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 @@ TextureView::~TextureView() {} 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 @@ GLenum TextureView::GetGLTarget() const { } 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 @@ void TextureView::CopyIfNeeded() { } 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 @@ void TextureView::CopyIfNeeded() { 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 ee16eb350e..3b2b97e061 100644 --- a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp +++ b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp @@ -128,7 +128,7 @@ class EGLImageTestBase : public DawnTest { 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 @@ class EGLImageUsageTests : public EGLImageTestBase { 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;