• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 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 // DisplayVk.h:
7 //    Defines the class interface for DisplayVk, implementing DisplayImpl.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_VULKAN_DISPLAYVK_H_
11 #define LIBANGLE_RENDERER_VULKAN_DISPLAYVK_H_
12 
13 #include "common/MemoryBuffer.h"
14 #include "libANGLE/renderer/DisplayImpl.h"
15 #include "libANGLE/renderer/vulkan/vk_utils.h"
16 
17 namespace rx
18 {
19 class RendererVk;
20 
21 class ShareGroupVk : public ShareGroupImpl
22 {
23   private:
24 };
25 
26 class DisplayVk : public DisplayImpl, public vk::Context
27 {
28   public:
29     DisplayVk(const egl::DisplayState &state);
30     ~DisplayVk() override;
31 
32     egl::Error initialize(egl::Display *display) override;
33     void terminate() override;
34 
35     egl::Error makeCurrent(egl::Surface *drawSurface,
36                            egl::Surface *readSurface,
37                            gl::Context *context) override;
38 
39     bool testDeviceLost() override;
40     egl::Error restoreLostDevice(const egl::Display *display) override;
41 
42     std::string getVendorString() const override;
43 
44     DeviceImpl *createDevice() override;
45 
46     egl::Error waitClient(const gl::Context *context) override;
47     egl::Error waitNative(const gl::Context *context, EGLint engine) override;
48 
49     SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
50                                      EGLNativeWindowType window,
51                                      const egl::AttributeMap &attribs) override;
52     SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
53                                       const egl::AttributeMap &attribs) override;
54     SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
55                                                EGLenum buftype,
56                                                EGLClientBuffer clientBuffer,
57                                                const egl::AttributeMap &attribs) override;
58     SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
59                                      NativePixmapType nativePixmap,
60                                      const egl::AttributeMap &attribs) override;
61 
62     ImageImpl *createImage(const egl::ImageState &state,
63                            const gl::Context *context,
64                            EGLenum target,
65                            const egl::AttributeMap &attribs) override;
66 
67     ContextImpl *createContext(const gl::State &state,
68                                gl::ErrorSet *errorSet,
69                                const egl::Config *configuration,
70                                const gl::Context *shareContext,
71                                const egl::AttributeMap &attribs) override;
72 
73     StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
74                                                        const egl::AttributeMap &attribs) override;
75 
76     EGLSyncImpl *createSync(const egl::AttributeMap &attribs) override;
77 
78     gl::Version getMaxSupportedESVersion() const override;
79     gl::Version getMaxConformantESVersion() const override;
80 
81     virtual const char *getWSIExtension() const = 0;
82     virtual const char *getWSILayer() const;
83 
84     // Determine if a config with given formats and sample counts is supported.  This callback may
85     // modify the config to add or remove platform specific attributes such as nativeVisualID before
86     // returning a bool to indicate if the config should be supported.
87     virtual bool checkConfigSupport(egl::Config *config) = 0;
88 
89     ANGLE_NO_DISCARD bool getScratchBuffer(size_t requestedSizeBytes,
90                                            angle::MemoryBuffer **scratchBufferOut) const;
getScratchBuffer()91     angle::ScratchBuffer *getScratchBuffer() const { return &mScratchBuffer; }
92 
93     void handleError(VkResult result,
94                      const char *file,
95                      const char *function,
96                      unsigned int line) override;
97 
98     // TODO(jmadill): Remove this once refactor is done. http://anglebug.com/3041
99     egl::Error getEGLError(EGLint errorCode);
100 
101     void populateFeatureList(angle::FeatureList *features) override;
102 
103     bool isRobustResourceInitEnabled() const override;
104 
105     ShareGroupImpl *createShareGroup() override;
106 
107   protected:
108     void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
109 
110   private:
111     virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
112                                                EGLNativeWindowType window) = 0;
113     void generateCaps(egl::Caps *outCaps) const override;
114 
115     virtual angle::Result waitNativeImpl();
116 
117     mutable angle::ScratchBuffer mScratchBuffer;
118 
119     std::string mStoredErrorString;
120     bool mHasSurfaceWithRobustInit;
121 };
122 
123 }  // namespace rx
124 
125 #endif  // LIBANGLE_RENDERER_VULKAN_DISPLAYVK_H_
126