• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2024 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // DisplayWgpu.h:
7 //    Defines the class interface for DisplayWgpu, implementing DisplayImpl.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_WGPU_DISPLAYWGPU_H_
11 #define LIBANGLE_RENDERER_WGPU_DISPLAYWGPU_H_
12 
13 #include <dawn/native/DawnNative.h>
14 #include <dawn/webgpu_cpp.h>
15 
16 #include "libANGLE/renderer/DisplayImpl.h"
17 #include "libANGLE/renderer/ShareGroupImpl.h"
18 
19 namespace rx
20 {
21 class ShareGroupWgpu : public ShareGroupImpl
22 {
23   public:
ShareGroupWgpu(const egl::ShareGroupState & state)24     ShareGroupWgpu(const egl::ShareGroupState &state) : ShareGroupImpl(state) {}
25 };
26 
27 class AllocationTrackerWgpu;
28 
29 class DisplayWgpu : public DisplayImpl
30 {
31   public:
32     DisplayWgpu(const egl::DisplayState &state);
33     ~DisplayWgpu() override;
34 
35     egl::Error initialize(egl::Display *display) override;
36     void terminate() override;
37 
38     egl::Error makeCurrent(egl::Display *display,
39                            egl::Surface *drawSurface,
40                            egl::Surface *readSurface,
41                            gl::Context *context) override;
42 
43     egl::ConfigSet generateConfigs() override;
44 
45     bool testDeviceLost() override;
46     egl::Error restoreLostDevice(const egl::Display *display) override;
47 
48     bool isValidNativeWindow(EGLNativeWindowType window) const override;
49 
50     std::string getRendererDescription() override;
51     std::string getVendorString() override;
52     std::string getVersionString(bool includeFullVersion) override;
53 
54     DeviceImpl *createDevice() override;
55 
56     egl::Error waitClient(const gl::Context *context) override;
57     egl::Error waitNative(const gl::Context *context, EGLint engine) override;
58     gl::Version getMaxSupportedESVersion() const override;
59     gl::Version getMaxConformantESVersion() const override;
60     Optional<gl::Version> getMaxSupportedDesktopVersion() const override;
61 
62     SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
63                                      EGLNativeWindowType window,
64                                      const egl::AttributeMap &attribs) override;
65     SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
66                                       const egl::AttributeMap &attribs) override;
67     SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
68                                                EGLenum buftype,
69                                                EGLClientBuffer buffer,
70                                                const egl::AttributeMap &attribs) override;
71     SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
72                                      NativePixmapType nativePixmap,
73                                      const egl::AttributeMap &attribs) override;
74 
75     ImageImpl *createImage(const egl::ImageState &state,
76                            const gl::Context *context,
77                            EGLenum target,
78                            const egl::AttributeMap &attribs) override;
79 
80     ContextImpl *createContext(const gl::State &state,
81                                gl::ErrorSet *errorSet,
82                                const egl::Config *configuration,
83                                const gl::Context *shareContext,
84                                const egl::AttributeMap &attribs) override;
85 
86     StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
87                                                        const egl::AttributeMap &attribs) override;
88 
89     ShareGroupImpl *createShareGroup(const egl::ShareGroupState &state) override;
90 
populateFeatureList(angle::FeatureList * features)91     void populateFeatureList(angle::FeatureList *features) override {}
92 
getDevice()93     wgpu::Device &getDevice() { return mDevice; }
getQueue()94     wgpu::Queue &getQueue() { return mQueue; }
95     wgpu::Instance getInstance() const;
96 
97   private:
98     void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
99     void generateCaps(egl::Caps *outCaps) const override;
100 
101     egl::Error createWgpuDevice();
102 
103     std::unique_ptr<dawn::native::Instance> mInstance;
104     wgpu::Device mDevice;
105     wgpu::Queue mQueue;
106 };
107 
108 }  // namespace rx
109 
110 #endif  // LIBANGLE_RENDERER_WGPU_DISPLAYWGPU_H_
111