• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2012 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 // Renderer11.h: Defines a back-end specific class for the D3D11 renderer.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_H_
10 #define LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_H_
11 
12 #include "common/angleutils.h"
13 #include "common/mathutil.h"
14 #include "libANGLE/AttributeMap.h"
15 #include "libANGLE/angletypes.h"
16 #include "libANGLE/renderer/d3d/HLSLCompiler.h"
17 #include "libANGLE/renderer/d3d/ProgramD3D.h"
18 #include "libANGLE/renderer/d3d/RenderTargetD3D.h"
19 #include "libANGLE/renderer/d3d/RendererD3D.h"
20 #include "libANGLE/renderer/d3d/d3d11/DebugAnnotator11.h"
21 #include "libANGLE/renderer/d3d/d3d11/RenderStateCache.h"
22 #include "libANGLE/renderer/d3d/d3d11/ResourceManager11.h"
23 #include "libANGLE/renderer/d3d/d3d11/StateManager11.h"
24 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
25 
26 namespace gl
27 {
28 class FramebufferAttachment;
29 class ImageIndex;
30 }  // namespace gl
31 
32 namespace rx
33 {
34 class Blit11;
35 class Buffer11;
36 class Clear11;
37 class Context11;
38 class IndexDataManager;
39 struct PackPixelsParams;
40 class PixelTransfer11;
41 class RenderTarget11;
42 class StreamingIndexBufferInterface;
43 class Trim11;
44 class VertexDataManager;
45 
46 struct Renderer11DeviceCaps
47 {
48     Renderer11DeviceCaps();
49 
50     D3D_FEATURE_LEVEL featureLevel;
51     bool supportsDXGI1_2;                         // Support for DXGI 1.2
52     bool supportsClearView;                       // Support for ID3D11DeviceContext1::ClearView
53     bool supportsConstantBufferOffsets;           // Support for Constant buffer offset
54     bool supportsVpRtIndexWriteFromVertexShader;  // VP/RT can be selected in the Vertex Shader
55                                                   // stage.
56     bool supportsMultisampledDepthStencilSRVs;   // D3D feature level 10.0 no longer allows creation
57                                                  // of textures with both the bind SRV and DSV flags
58                                                  // when multisampled.  Textures will need to be
59                                                  // resolved before reading. crbug.com/656989
60     bool supportsTypedUAVLoadAdditionalFormats;  //
61     // https://learn.microsoft.com/en-us/windows/win32/direct3d11/typed-unordered-access-view-loads
62     bool supportsUAVLoadStoreCommonFormats;  // Do the common additional formats support load/store?
63     bool supportsRasterizerOrderViews;
64     bool allowES3OnFL10_0;
65     UINT B5G6R5support;     // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G6R5_UNORM
66     UINT B5G6R5maxSamples;  // Maximum number of samples supported by DXGI_FORMAT_B5G6R5_UNORM
67     UINT B4G4R4A4support;  // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM
68     UINT B4G4R4A4maxSamples;  // Maximum number of samples supported by DXGI_FORMAT_B4G4R4A4_UNORM
69     UINT B5G5R5A1support;  // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G5R5A1_UNORM
70     UINT B5G5R5A1maxSamples;  // Maximum number of samples supported by DXGI_FORMAT_B5G5R5A1_UNORM
71     Optional<LARGE_INTEGER> driverVersion;  // Four-part driver version number.
72 };
73 
74 enum
75 {
76     MAX_VERTEX_UNIFORM_VECTORS_D3D11   = 1024,
77     MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
78 };
79 
80 class Renderer11 : public RendererD3D
81 {
82   public:
83     explicit Renderer11(egl::Display *display);
84     ~Renderer11() override;
85 
86     egl::Error initialize() override;
87     bool resetDevice() override;
88 
89     egl::ConfigSet generateConfigs() override;
90     void generateDisplayExtensions(egl::DisplayExtensions *outExtensions) const override;
91 
92     ContextImpl *createContext(const gl::State &state, gl::ErrorSet *errorSet) override;
93 
94     angle::Result flush(Context11 *context11);
95     angle::Result finish(Context11 *context11);
96 
97     bool isValidNativeWindow(EGLNativeWindowType window) const override;
98     NativeWindowD3D *createNativeWindow(EGLNativeWindowType window,
99                                         const egl::Config *config,
100                                         const egl::AttributeMap &attribs) const override;
101 
102     SwapChainD3D *createSwapChain(NativeWindowD3D *nativeWindow,
103                                   HANDLE shareHandle,
104                                   IUnknown *d3dTexture,
105                                   GLenum backBufferFormat,
106                                   GLenum depthBufferFormat,
107                                   EGLint orientation,
108                                   EGLint samples) override;
109     egl::Error getD3DTextureInfo(const egl::Config *configuration,
110                                  IUnknown *d3dTexture,
111                                  const egl::AttributeMap &attribs,
112                                  EGLint *width,
113                                  EGLint *height,
114                                  GLsizei *samples,
115                                  gl::Format *glFormat,
116                                  const angle::Format **angleFormat,
117                                  UINT *arraySlice) const override;
118     egl::Error validateShareHandle(const egl::Config *config,
119                                    HANDLE shareHandle,
120                                    const egl::AttributeMap &attribs) const override;
121 
122     // lost device
123     bool testDeviceLost() override;
124     bool testDeviceResettable() override;
125 
126     DeviceIdentifier getAdapterIdentifier() const override;
127 
128     unsigned int getReservedVertexUniformVectors() const;
129     unsigned int getReservedFragmentUniformVectors() const;
130     gl::ShaderMap<unsigned int> getReservedShaderUniformBuffers() const;
131 
132     bool getShareHandleSupport() const;
133 
134     int getMajorShaderModel() const override;
135     int getMinorShaderModel() const override;
136     std::string getShaderModelSuffix() const override;
137 
138     // Pixel operations
139     angle::Result copyImage2D(const gl::Context *context,
140                               const gl::Framebuffer *framebuffer,
141                               const gl::Rectangle &sourceRect,
142                               GLenum destFormat,
143                               const gl::Offset &destOffset,
144                               TextureStorage *storage,
145                               GLint level) override;
146     angle::Result copyImageCube(const gl::Context *context,
147                                 const gl::Framebuffer *framebuffer,
148                                 const gl::Rectangle &sourceRect,
149                                 GLenum destFormat,
150                                 const gl::Offset &destOffset,
151                                 TextureStorage *storage,
152                                 gl::TextureTarget target,
153                                 GLint level) override;
154     angle::Result copyImage3D(const gl::Context *context,
155                               const gl::Framebuffer *framebuffer,
156                               const gl::Rectangle &sourceRect,
157                               GLenum destFormat,
158                               const gl::Offset &destOffset,
159                               TextureStorage *storage,
160                               GLint level) override;
161     angle::Result copyImage2DArray(const gl::Context *context,
162                                    const gl::Framebuffer *framebuffer,
163                                    const gl::Rectangle &sourceRect,
164                                    GLenum destFormat,
165                                    const gl::Offset &destOffset,
166                                    TextureStorage *storage,
167                                    GLint level) override;
168 
169     angle::Result copyTexture(const gl::Context *context,
170                               const gl::Texture *source,
171                               GLint sourceLevel,
172                               gl::TextureTarget srcTarget,
173                               const gl::Box &sourceBox,
174                               GLenum destFormat,
175                               GLenum destType,
176                               const gl::Offset &destOffset,
177                               TextureStorage *storage,
178                               gl::TextureTarget destTarget,
179                               GLint destLevel,
180                               bool unpackFlipY,
181                               bool unpackPremultiplyAlpha,
182                               bool unpackUnmultiplyAlpha) override;
183     angle::Result copyCompressedTexture(const gl::Context *context,
184                                         const gl::Texture *source,
185                                         GLint sourceLevel,
186                                         TextureStorage *storage,
187                                         GLint destLevel) override;
188 
189     // RenderTarget creation
190     angle::Result createRenderTarget(const gl::Context *context,
191                                      int width,
192                                      int height,
193                                      GLenum format,
194                                      GLsizei samples,
195                                      RenderTargetD3D **outRT) override;
196     angle::Result createRenderTargetCopy(const gl::Context *context,
197                                          RenderTargetD3D *source,
198                                          RenderTargetD3D **outRT) override;
199 
200     // Shader operations
201     angle::Result loadExecutable(d3d::Context *context,
202                                  const uint8_t *function,
203                                  size_t length,
204                                  gl::ShaderType type,
205                                  const std::vector<D3DVarying> &streamOutVaryings,
206                                  bool separatedOutputBuffers,
207                                  ShaderExecutableD3D **outExecutable) override;
208     angle::Result compileToExecutable(d3d::Context *context,
209                                       gl::InfoLog &infoLog,
210                                       const std::string &shaderHLSL,
211                                       gl::ShaderType type,
212                                       const std::vector<D3DVarying> &streamOutVaryings,
213                                       bool separatedOutputBuffers,
214                                       const CompilerWorkaroundsD3D &workarounds,
215                                       ShaderExecutableD3D **outExectuable) override;
216     angle::Result ensureHLSLCompilerInitialized(d3d::Context *context) override;
217 
218     UniformStorageD3D *createUniformStorage(size_t storageSize) override;
219 
220     // Image operations
221     ImageD3D *createImage() override;
222     ExternalImageSiblingImpl *createExternalImageSibling(const gl::Context *context,
223                                                          EGLenum target,
224                                                          EGLClientBuffer buffer,
225                                                          const egl::AttributeMap &attribs) override;
226     angle::Result generateMipmap(const gl::Context *context,
227                                  ImageD3D *dest,
228                                  ImageD3D *source) override;
229     angle::Result generateMipmapUsingD3D(const gl::Context *context,
230                                          TextureStorage *storage,
231                                          const gl::TextureState &textureState) override;
232     angle::Result copyImage(const gl::Context *context,
233                             ImageD3D *dest,
234                             ImageD3D *source,
235                             const gl::Box &sourceBox,
236                             const gl::Offset &destOffset,
237                             bool unpackFlipY,
238                             bool unpackPremultiplyAlpha,
239                             bool unpackUnmultiplyAlpha) override;
240 
241     TextureStorage *createTextureStorage2D(SwapChainD3D *swapChain,
242                                            const std::string &label) override;
243     TextureStorage *createTextureStorageEGLImage(EGLImageD3D *eglImage,
244                                                  RenderTargetD3D *renderTargetD3D,
245                                                  const std::string &label) override;
246     TextureStorage *createTextureStorageExternal(egl::Stream *stream,
247                                                  const egl::Stream::GLTextureDescription &desc,
248                                                  const std::string &label) override;
249     TextureStorage *createTextureStorage2D(GLenum internalformat,
250                                            BindFlags bindFlags,
251                                            GLsizei width,
252                                            GLsizei height,
253                                            int levels,
254                                            const std::string &label,
255                                            bool hintLevelZeroOnly) override;
256     TextureStorage *createTextureStorageCube(GLenum internalformat,
257                                              BindFlags bindFlags,
258                                              int size,
259                                              int levels,
260                                              bool hintLevelZeroOnly,
261                                              const std::string &label) override;
262     TextureStorage *createTextureStorage3D(GLenum internalformat,
263                                            BindFlags bindFlags,
264                                            GLsizei width,
265                                            GLsizei height,
266                                            GLsizei depth,
267                                            int levels,
268                                            const std::string &label) override;
269     TextureStorage *createTextureStorage2DArray(GLenum internalformat,
270                                                 BindFlags bindFlags,
271                                                 GLsizei width,
272                                                 GLsizei height,
273                                                 GLsizei depth,
274                                                 int levels,
275                                                 const std::string &label) override;
276     TextureStorage *createTextureStorage2DMultisample(GLenum internalformat,
277                                                       GLsizei width,
278                                                       GLsizei height,
279                                                       int levels,
280                                                       int samples,
281                                                       bool fixedSampleLocations,
282                                                       const std::string &label) override;
283 
284     TextureStorage *createTextureStorageBuffer(const gl::OffsetBindingPointer<gl::Buffer> &buffer,
285                                                GLenum internalFormat,
286                                                const std::string &label) override;
287     TextureStorage *createTextureStorage2DMultisampleArray(GLenum internalformat,
288                                                            GLsizei width,
289                                                            GLsizei height,
290                                                            GLsizei depth,
291                                                            int levels,
292                                                            int samples,
293                                                            bool fixedSampleLocations,
294                                                            const std::string &label) override;
295 
296     VertexBuffer *createVertexBuffer() override;
297     IndexBuffer *createIndexBuffer() override;
298 
299     // Stream Creation
300     StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
301                                                        const egl::AttributeMap &attribs) override;
302 
303     // D3D11-renderer specific methods
getDevice()304     ID3D11Device *getDevice() { return mDevice.Get(); }
getDevice1()305     ID3D11Device1 *getDevice1() { return mDevice1.Get(); }
306     void *getD3DDevice() override;
getDeviceContext()307     ID3D11DeviceContext *getDeviceContext() { return mDeviceContext.Get(); }
getDeviceContext1IfSupported()308     ID3D11DeviceContext1 *getDeviceContext1IfSupported() { return mDeviceContext1.Get(); }
getDxgiFactory()309     IDXGIFactory *getDxgiFactory() { return mDxgiFactory.Get(); }
310 
311     angle::Result getBlendState(const gl::Context *context,
312                                 const d3d11::BlendStateKey &key,
313                                 const d3d11::BlendState **outBlendState);
314     angle::Result getRasterizerState(const gl::Context *context,
315                                      const gl::RasterizerState &rasterState,
316                                      bool scissorEnabled,
317                                      ID3D11RasterizerState **outRasterizerState);
318     angle::Result getDepthStencilState(const gl::Context *context,
319                                        const gl::DepthStencilState &dsState,
320                                        const d3d11::DepthStencilState **outDSState);
321     angle::Result getSamplerState(const gl::Context *context,
322                                   const gl::SamplerState &samplerState,
323                                   ID3D11SamplerState **outSamplerState);
324     UINT getSampleDescQuality(GLuint supportedSamples) const;
325 
getBlitter()326     Blit11 *getBlitter() { return mBlit; }
getClearer()327     Clear11 *getClearer() { return mClear; }
328     DebugAnnotatorContext11 *getDebugAnnotatorContext();
329 
330     // Buffer-to-texture and Texture-to-buffer copies
331     bool supportsFastCopyBufferToTexture(GLenum internalFormat) const override;
332     angle::Result fastCopyBufferToTexture(const gl::Context *context,
333                                           const gl::PixelUnpackState &unpack,
334                                           gl::Buffer *unpackBuffer,
335                                           unsigned int offset,
336                                           RenderTargetD3D *destRenderTarget,
337                                           GLenum destinationFormat,
338                                           GLenum sourcePixelsType,
339                                           const gl::Box &destArea) override;
340 
341     angle::Result packPixels(const gl::Context *context,
342                              const TextureHelper11 &textureHelper,
343                              const PackPixelsParams &params,
344                              uint8_t *pixelsOut);
345 
346     bool getLUID(LUID *adapterLuid) const override;
347     VertexConversionType getVertexConversionType(angle::FormatID vertexFormatID) const override;
348     GLenum getVertexComponentType(angle::FormatID vertexFormatID) const override;
349 
350     // Warning: you should ensure binding really matches attrib.bindingIndex before using this
351     // function.
352     angle::Result getVertexSpaceRequired(const gl::Context *context,
353                                          const gl::VertexAttribute &attrib,
354                                          const gl::VertexBinding &binding,
355                                          size_t count,
356                                          GLsizei instances,
357                                          GLuint baseInstance,
358                                          unsigned int *bytesRequiredOut) const override;
359 
360     angle::Result readFromAttachment(const gl::Context *context,
361                                      const gl::FramebufferAttachment &srcAttachment,
362                                      const gl::Rectangle &sourceArea,
363                                      GLenum format,
364                                      GLenum type,
365                                      GLuint outputPitch,
366                                      const gl::PixelPackState &pack,
367                                      uint8_t *pixels);
368 
369     angle::Result blitRenderbufferRect(const gl::Context *context,
370                                        const gl::Rectangle &readRect,
371                                        const gl::Rectangle &drawRect,
372                                        UINT readLayer,
373                                        UINT drawLayer,
374                                        RenderTargetD3D *readRenderTarget,
375                                        RenderTargetD3D *drawRenderTarget,
376                                        GLenum filter,
377                                        const gl::Rectangle *scissor,
378                                        bool colorBlit,
379                                        bool depthBlit,
380                                        bool stencilBlit);
381 
382     bool isES3Capable() const;
getRenderer11DeviceCaps()383     const Renderer11DeviceCaps &getRenderer11DeviceCaps() const { return mRenderer11DeviceCaps; }
384 
385     RendererClass getRendererClass() const override;
getStateManager()386     StateManager11 *getStateManager() { return &mStateManager; }
387 
388     void onSwap();
389     void onBufferCreate(const Buffer11 *created);
390     void onBufferDelete(const Buffer11 *deleted);
391 
392     DeviceImpl *createEGLDevice() override;
393 
394     angle::Result drawArrays(const gl::Context *context,
395                              gl::PrimitiveMode mode,
396                              GLint firstVertex,
397                              GLsizei vertexCount,
398                              GLsizei instanceCount,
399                              GLuint baseInstance,
400                              bool isInstancedDraw);
401     angle::Result drawElements(const gl::Context *context,
402                                gl::PrimitiveMode mode,
403                                GLint startVertex,
404                                GLsizei indexCount,
405                                gl::DrawElementsType indexType,
406                                const void *indices,
407                                GLsizei instanceCount,
408                                GLint baseVertex,
409                                GLuint baseInstance,
410                                bool isInstancedDraw);
411     angle::Result drawArraysIndirect(const gl::Context *context, const void *indirect);
412     angle::Result drawElementsIndirect(const gl::Context *context, const void *indirect);
413 
414     // Necessary hack for default framebuffers in D3D.
415     FramebufferImpl *createDefaultFramebuffer(const gl::FramebufferState &state) override;
416 
417     angle::Result getScratchMemoryBuffer(Context11 *context11,
418                                          size_t requestedSize,
419                                          angle::MemoryBuffer **bufferOut);
420 
421     gl::Version getMaxSupportedESVersion() const override;
422     gl::Version getMaxConformantESVersion() const override;
423 
424     angle::Result dispatchCompute(const gl::Context *context,
425                                   GLuint numGroupsX,
426                                   GLuint numGroupsY,
427                                   GLuint numGroupsZ);
428     angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect);
429 
430     angle::Result createStagingTexture(const gl::Context *context,
431                                        ResourceType textureType,
432                                        const d3d11::Format &formatSet,
433                                        const gl::Extents &size,
434                                        StagingAccess readAndWriteAccess,
435                                        TextureHelper11 *textureOut);
436 
437     template <typename DescT, typename ResourceT>
allocateResource(d3d::Context * context,const DescT & desc,ResourceT * resourceOut)438     angle::Result allocateResource(d3d::Context *context, const DescT &desc, ResourceT *resourceOut)
439     {
440         return mResourceManager11.allocate(context, this, &desc, nullptr, resourceOut);
441     }
442 
443     template <typename DescT, typename InitDataT, typename ResourceT>
allocateResource(d3d::Context * context,const DescT & desc,InitDataT * initData,ResourceT * resourceOut)444     angle::Result allocateResource(d3d::Context *context,
445                                    const DescT &desc,
446                                    InitDataT *initData,
447                                    ResourceT *resourceOut)
448     {
449         return mResourceManager11.allocate(context, this, &desc, initData, resourceOut);
450     }
451 
452     template <typename InitDataT, typename ResourceT>
allocateResourceNoDesc(d3d::Context * context,InitDataT * initData,ResourceT * resourceOut)453     angle::Result allocateResourceNoDesc(d3d::Context *context,
454                                          InitDataT *initData,
455                                          ResourceT *resourceOut)
456     {
457         return mResourceManager11.allocate(context, this, nullptr, initData, resourceOut);
458     }
459 
460     template <typename DescT>
allocateTexture(d3d::Context * context,const DescT & desc,const d3d11::Format & format,TextureHelper11 * textureOut)461     angle::Result allocateTexture(d3d::Context *context,
462                                   const DescT &desc,
463                                   const d3d11::Format &format,
464                                   TextureHelper11 *textureOut)
465     {
466         return allocateTexture(context, desc, format, nullptr, textureOut);
467     }
468 
469     angle::Result allocateTexture(d3d::Context *context,
470                                   const D3D11_TEXTURE2D_DESC &desc,
471                                   const d3d11::Format &format,
472                                   const D3D11_SUBRESOURCE_DATA *initData,
473                                   TextureHelper11 *textureOut);
474 
475     angle::Result allocateTexture(d3d::Context *context,
476                                   const D3D11_TEXTURE3D_DESC &desc,
477                                   const d3d11::Format &format,
478                                   const D3D11_SUBRESOURCE_DATA *initData,
479                                   TextureHelper11 *textureOut);
480 
481     angle::Result clearRenderTarget(const gl::Context *context,
482                                     RenderTargetD3D *renderTarget,
483                                     const gl::ColorF &clearColorValue,
484                                     const float clearDepthValue,
485                                     const unsigned int clearStencilValue) override;
486 
487     bool canSelectViewInVertexShader() const override;
488 
489     angle::Result mapResource(const gl::Context *context,
490                               ID3D11Resource *resource,
491                               UINT subResource,
492                               D3D11_MAP mapType,
493                               UINT mapFlags,
494                               D3D11_MAPPED_SUBRESOURCE *mappedResource);
495 
496     angle::Result getIncompleteTexture(const gl::Context *context,
497                                        gl::TextureType type,
498                                        gl::Texture **textureOut) override;
499 
500     void setGlobalDebugAnnotator() override;
501 
502     std::string getRendererDescription() const override;
503     std::string getVendorString() const override;
504     std::string getVersionString(bool includeFullVersion) const override;
505 
506   private:
507     void generateCaps(gl::Caps *outCaps,
508                       gl::TextureCapsMap *outTextureCaps,
509                       gl::Extensions *outExtensions,
510                       gl::Limitations *outLimitations,
511                       ShPixelLocalStorageOptions *outPLSOptions) const override;
512 
513     void initializeFeatures(angle::FeaturesD3D *features) const override;
514 
515     void initializeFrontendFeatures(angle::FrontendFeatures *features) const override;
516 
517     angle::Result drawLineLoop(const gl::Context *context,
518                                GLuint count,
519                                gl::DrawElementsType type,
520                                const void *indices,
521                                int baseVertex,
522                                int instances);
523     angle::Result drawTriangleFan(const gl::Context *context,
524                                   GLuint count,
525                                   gl::DrawElementsType type,
526                                   const void *indices,
527                                   int baseVertex,
528                                   int instances);
529 
530     angle::Result resolveMultisampledTexture(const gl::Context *context,
531                                              RenderTarget11 *renderTarget,
532                                              bool depth,
533                                              bool stencil,
534                                              TextureHelper11 *textureOut);
535 
536     void populateRenderer11DeviceCaps();
537 
538     void updateHistograms();
539 
540     angle::Result copyImageInternal(const gl::Context *context,
541                                     const gl::Framebuffer *framebuffer,
542                                     const gl::Rectangle &sourceRect,
543                                     GLenum destFormat,
544                                     const gl::Offset &destOffset,
545                                     RenderTargetD3D *destRenderTarget);
546 
547     gl::SupportedSampleSet generateSampleSetForEGLConfig(
548         const gl::TextureCaps &colorBufferFormatCaps,
549         const gl::TextureCaps &depthStencilBufferFormatCaps) const;
550 
551     HRESULT callD3D11CreateDevice(PFN_D3D11_CREATE_DEVICE createDevice, bool debug);
552     HRESULT callD3D11On12CreateDevice(PFN_D3D12_CREATE_DEVICE createDevice12,
553                                       PFN_D3D11ON12_CREATE_DEVICE createDevice11on12,
554                                       bool debug);
555     egl::Error initializeDXGIAdapter();
556     egl::Error initializeD3DDevice();
557     egl::Error initializeDevice();
558     egl::Error initializeAdapterFromDevice();
559     void releaseDeviceResources();
560     void release();
561 
562     d3d11::ANGLED3D11DeviceType getDeviceType() const;
563 
564     // Make sure that the raw buffer is the latest buffer.
565     angle::Result markRawBufferUsage(const gl::Context *context);
566     angle::Result markTypedBufferUsage(const gl::Context *context);
567     angle::Result markTransformFeedbackUsage(const gl::Context *context);
568     angle::Result drawWithGeometryShaderAndTransformFeedback(Context11 *context11,
569                                                              gl::PrimitiveMode mode,
570                                                              UINT instanceCount,
571                                                              UINT vertexCount);
572 
573     HMODULE mD3d11Module;
574     HMODULE mD3d12Module;
575     HMODULE mDCompModule;
576     std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels;
577     D3D_DRIVER_TYPE mRequestedDriverType;
578     bool mCreateDebugDevice;
579     bool mCreatedWithDeviceEXT;
580 
581     HLSLCompiler mCompiler;
582 
583     RenderStateCache mStateCache;
584 
585     StateManager11 mStateManager;
586 
587     StreamingIndexBufferInterface *mLineLoopIB;
588     StreamingIndexBufferInterface *mTriangleFanIB;
589 
590     // Texture copy resources
591     Blit11 *mBlit;
592     PixelTransfer11 *mPixelTransfer;
593 
594     // Masked clear resources
595     Clear11 *mClear;
596 
597     // Perform trim for D3D resources
598     Trim11 *mTrim;
599 
600     // Sync query
601     d3d11::Query mSyncQuery;
602 
603     // Created objects state tracking
604     std::set<const Buffer11 *> mAliveBuffers;
605 
606     double mLastHistogramUpdateTime;
607 
608     angle::ComPtr<ID3D12Device> mDevice12;
609     angle::ComPtr<ID3D12CommandQueue> mCommandQueue;
610 
611     angle::ComPtr<ID3D11Device> mDevice;
612     angle::ComPtr<ID3D11Device1> mDevice1;
613     Renderer11DeviceCaps mRenderer11DeviceCaps;
614     angle::ComPtr<ID3D11DeviceContext> mDeviceContext;
615     angle::ComPtr<ID3D11DeviceContext1> mDeviceContext1;
616     angle::ComPtr<ID3D11DeviceContext3> mDeviceContext3;
617     angle::ComPtr<IDXGIAdapter> mDxgiAdapter;
618     DXGI_ADAPTER_DESC mAdapterDescription;
619     char mDescription[128];
620     angle::ComPtr<IDXGIFactory> mDxgiFactory;
621     angle::ComPtr<ID3D11Debug> mDebug;
622 
623     std::vector<GLuint> mScratchIndexDataBuffer;
624 
625     angle::ScratchBuffer mScratchMemoryBuffer;
626 
627     DebugAnnotatorContext11 mAnnotatorContext;
628 
629     mutable Optional<bool> mSupportsShareHandles;
630     ResourceManager11 mResourceManager11;
631 
632     TextureHelper11 mCachedResolveTexture;
633 };
634 
635 }  // namespace rx
636 #endif  // LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_H_
637