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