• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 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 
7 // DisplayD3D.h: D3D implementation of egl::Display
8 
9 #ifndef LIBANGLE_RENDERER_D3D_DISPLAYD3D_H_
10 #define LIBANGLE_RENDERER_D3D_DISPLAYD3D_H_
11 
12 #include "libANGLE/Device.h"
13 #include "libANGLE/renderer/DisplayImpl.h"
14 
15 #include "libANGLE/renderer/d3d/RendererD3D.h"
16 
17 namespace rx
18 {
19 class ShareGroupD3D : public ShareGroupImpl
20 {};
21 
22 class DisplayD3D : public DisplayImpl, public d3d::Context
23 {
24   public:
25     DisplayD3D(const egl::DisplayState &state);
26 
27     egl::Error initialize(egl::Display *display) override;
28     void terminate() override;
29 
30     // Surface creation
31     SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
32                                      EGLNativeWindowType window,
33                                      const egl::AttributeMap &attribs) override;
34     SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
35                                       const egl::AttributeMap &attribs) override;
36     SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
37                                                EGLenum buftype,
38                                                EGLClientBuffer clientBuffer,
39                                                const egl::AttributeMap &attribs) override;
40     SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
41                                      NativePixmapType nativePixmap,
42                                      const egl::AttributeMap &attribs) override;
43 
44     ImageImpl *createImage(const egl::ImageState &state,
45                            const gl::Context *context,
46                            EGLenum target,
47                            const egl::AttributeMap &attribs) override;
48 
49     ContextImpl *createContext(const gl::State &state,
50                                gl::ErrorSet *errorSet,
51                                const egl::Config *configuration,
52                                const gl::Context *shareContext,
53                                const egl::AttributeMap &attribs) override;
54 
55     StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
56                                                        const egl::AttributeMap &attribs) override;
57 
58     ExternalImageSiblingImpl *createExternalImageSibling(const gl::Context *context,
59                                                          EGLenum target,
60                                                          EGLClientBuffer buffer,
61                                                          const egl::AttributeMap &attribs) override;
62 
63     ShareGroupImpl *createShareGroup() override;
64 
65     egl::Error makeCurrent(egl::Display *display,
66                            egl::Surface *drawSurface,
67                            egl::Surface *readSurface,
68                            gl::Context *context) override;
69 
70     egl::ConfigSet generateConfigs() override;
71 
72     bool testDeviceLost() override;
73     egl::Error restoreLostDevice(const egl::Display *display) override;
74 
75     bool isValidNativeWindow(EGLNativeWindowType window) const override;
76     egl::Error validateClientBuffer(const egl::Config *configuration,
77                                     EGLenum buftype,
78                                     EGLClientBuffer clientBuffer,
79                                     const egl::AttributeMap &attribs) const override;
80     egl::Error validateImageClientBuffer(const gl::Context *context,
81                                          EGLenum target,
82                                          EGLClientBuffer clientBuffer,
83                                          const egl::AttributeMap &attribs) const override;
84 
85     DeviceImpl *createDevice() override;
86 
87     std::string getRendererDescription() override;
88     std::string getVendorString() override;
89     std::string getVersionString() override;
90 
91     egl::Error waitClient(const gl::Context *context) override;
92     egl::Error waitNative(const gl::Context *context, EGLint engine) override;
93     gl::Version getMaxSupportedESVersion() const override;
94     gl::Version getMaxConformantESVersion() const override;
95 
96     void handleResult(HRESULT hr,
97                       const char *message,
98                       const char *file,
99                       const char *function,
100                       unsigned int line) override;
101 
getStoredErrorString()102     const std::string &getStoredErrorString() const { return mStoredErrorString; }
103 
104     void populateFeatureList(angle::FeatureList *features) override;
105 
106   private:
107     void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
108     void generateCaps(egl::Caps *outCaps) const override;
109 
110     egl::Display *mDisplay;
111 
112     rx::RendererD3D *mRenderer;
113     std::string mStoredErrorString;
114 };
115 
116 // Possible reasons RendererD3D initialize can fail
117 enum D3D11InitError
118 {
119     // The renderer loaded successfully
120     D3D11_INIT_SUCCESS = 0,
121     // Failed to load the ANGLE & D3D compiler libraries
122     D3D11_INIT_COMPILER_ERROR,
123     // Failed to load a necessary DLL (non-compiler)
124     D3D11_INIT_MISSING_DEP,
125     // CreateDevice returned E_INVALIDARG
126     D3D11_INIT_CREATEDEVICE_INVALIDARG,
127     // CreateDevice failed with an error other than invalid arg
128     D3D11_INIT_CREATEDEVICE_ERROR,
129     // DXGI 1.2 required but not found
130     D3D11_INIT_INCOMPATIBLE_DXGI,
131     // Other initialization error
132     D3D11_INIT_OTHER_ERROR,
133     // CreateDevice returned E_FAIL
134     D3D11_INIT_CREATEDEVICE_FAIL,
135     // CreateDevice returned E_NOTIMPL
136     D3D11_INIT_CREATEDEVICE_NOTIMPL,
137     // CreateDevice returned E_OUTOFMEMORY
138     D3D11_INIT_CREATEDEVICE_OUTOFMEMORY,
139     // CreateDevice returned DXGI_ERROR_INVALID_CALL
140     D3D11_INIT_CREATEDEVICE_INVALIDCALL,
141     // CreateDevice returned DXGI_ERROR_SDK_COMPONENT_MISSING
142     D3D11_INIT_CREATEDEVICE_COMPONENTMISSING,
143     // CreateDevice returned DXGI_ERROR_WAS_STILL_DRAWING
144     D3D11_INIT_CREATEDEVICE_WASSTILLDRAWING,
145     // CreateDevice returned DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
146     D3D11_INIT_CREATEDEVICE_NOTAVAILABLE,
147     // CreateDevice returned DXGI_ERROR_DEVICE_HUNG
148     D3D11_INIT_CREATEDEVICE_DEVICEHUNG,
149     // CreateDevice returned NULL
150     D3D11_INIT_CREATEDEVICE_NULL,
151     NUM_D3D11_INIT_ERRORS
152 };
153 
154 enum D3D9InitError
155 {
156     D3D9_INIT_SUCCESS = 0,
157     // Failed to load the D3D or ANGLE compiler
158     D3D9_INIT_COMPILER_ERROR,
159     // Failed to load a necessary DLL
160     D3D9_INIT_MISSING_DEP,
161     // Device creation error
162     D3D9_INIT_CREATE_DEVICE_ERROR,
163     // System does not meet minimum shader spec
164     D3D9_INIT_UNSUPPORTED_VERSION,
165     // System does not support stretchrect from textures
166     D3D9_INIT_UNSUPPORTED_STRETCHRECT,
167     // A call returned out of memory or device lost
168     D3D9_INIT_OUT_OF_MEMORY,
169     // Other unspecified error
170     D3D9_INIT_OTHER_ERROR,
171     NUM_D3D9_INIT_ERRORS
172 };
173 
174 }  // namespace rx
175 
176 #endif  // LIBANGLE_RENDERER_D3D_DISPLAYD3D_H_
177