webgpu/dawn/include/dawn/native/OpenGLBackend.h
 1// Copyright 2018 The Dawn Authors
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
16#define INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_
17
18using EGLDisplay = void*;
19using EGLImage = void*;
20using GLuint = unsigned int;
21
22#include "dawn/native/DawnNative.h"
23#include "dawn/webgpu_cpp_chained_struct.h"
24
25namespace dawn::native::opengl {
26
27// Can be chained in WGPURequestAdapterOptions
28struct DAWN_NATIVE_EXPORT RequestAdapterOptionsGetGLProc : wgpu::ChainedStruct {
29    RequestAdapterOptionsGetGLProc();
30
31    void* (*getProc)(const char*);
32    EGLDisplay display;
33};
34
35struct DAWN_NATIVE_EXPORT PhysicalDeviceDiscoveryOptions
36    : public PhysicalDeviceDiscoveryOptionsBase {
37    explicit PhysicalDeviceDiscoveryOptions(WGPUBackendType type);
38
39    void* (*getProc)(const char*);
40    EGLDisplay display;
41};
42
43struct DAWN_NATIVE_EXPORT ExternalImageDescriptorEGLImage : ExternalImageDescriptor {
44  public:
45    ExternalImageDescriptorEGLImage();
46
47    ::EGLImage image;
48};
49
50DAWN_NATIVE_EXPORT WGPUTexture
51WrapExternalEGLImage(WGPUDevice device, const ExternalImageDescriptorEGLImage* descriptor);
52
53struct DAWN_NATIVE_EXPORT ExternalImageDescriptorGLTexture : ExternalImageDescriptor {
54  public:
55    ExternalImageDescriptorGLTexture();
56
57    GLuint texture;
58};
59
60DAWN_NATIVE_EXPORT WGPUTexture
61WrapExternalGLTexture(WGPUDevice device, const ExternalImageDescriptorGLTexture* descriptor);
62
63}  // namespace dawn::native::opengl
64
65#endif  // INCLUDE_DAWN_NATIVE_OPENGLBACKEND_H_