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