Bug 1919083 - [ci] Enable os-integration variant for more suites, r=jmaher
[gecko.git] / gfx / layers / d3d11 / DeviceAttachmentsD3D11.h
blob4837dc76f115756be0c563b6a8830e35127dbd8a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_gfx_layers_d3d11_DeviceAttachmentsD3D11_h
8 #define mozilla_gfx_layers_d3d11_DeviceAttachmentsD3D11_h
10 #include "mozilla/EnumeratedArray.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/gfx/DeviceManagerDx.h"
13 #include "mozilla/layers/CompositorTypes.h"
14 #include "mozilla/layers/SyncObject.h"
15 #include <d3d11.h>
16 #include <dxgi1_2.h>
18 namespace mozilla {
19 namespace layers {
21 struct ShaderBytes;
23 class DeviceAttachmentsD3D11 final {
24 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DeviceAttachmentsD3D11);
26 public:
27 static RefPtr<DeviceAttachmentsD3D11> Create(ID3D11Device* aDevice);
29 bool IsValid() const { return mInitialized; }
30 const nsCString& GetFailureId() const {
31 MOZ_ASSERT(!IsValid());
32 return mInitFailureId;
35 RefPtr<ID3D11InputLayout> mInputLayout;
37 RefPtr<ID3D11Buffer> mVertexBuffer;
39 RefPtr<ID3D11VertexShader> mVSQuadShader;
41 RefPtr<ID3D11PixelShader> mSolidColorShader;
42 RefPtr<ID3D11PixelShader> mRGBAShader;
43 RefPtr<ID3D11PixelShader> mRGBShader;
44 RefPtr<ID3D11PixelShader> mYCbCrShader;
45 RefPtr<ID3D11PixelShader> mNV12Shader;
46 RefPtr<ID3D11Buffer> mPSConstantBuffer;
47 RefPtr<ID3D11Buffer> mVSConstantBuffer;
48 RefPtr<ID3D11RasterizerState> mRasterizerState;
49 RefPtr<ID3D11SamplerState> mLinearSamplerState;
50 RefPtr<ID3D11SamplerState> mPointSamplerState;
52 RefPtr<ID3D11BlendState> mPremulBlendState;
53 RefPtr<ID3D11BlendState> mPremulCopyState;
54 RefPtr<ID3D11BlendState> mNonPremulBlendState;
55 RefPtr<ID3D11BlendState> mDisabledBlendState;
57 RefPtr<SyncObjectHost> mSyncObject;
59 void SetDeviceReset() { mDeviceReset = true; }
60 bool IsDeviceReset() const { return mDeviceReset; }
62 private:
63 explicit DeviceAttachmentsD3D11(ID3D11Device* device);
64 ~DeviceAttachmentsD3D11();
66 bool Initialize();
67 bool CreateShaders();
68 bool InitSyncObject();
70 void InitVertexShader(const ShaderBytes& aShader,
71 RefPtr<ID3D11VertexShader>& aDest) {
72 InitVertexShader(aShader, getter_AddRefs(aDest));
74 void InitPixelShader(const ShaderBytes& aShader,
75 RefPtr<ID3D11PixelShader>& aDest) {
76 InitPixelShader(aShader, getter_AddRefs(aDest));
79 void InitVertexShader(const ShaderBytes& aShader, ID3D11VertexShader** aOut);
80 void InitPixelShader(const ShaderBytes& aShader, ID3D11PixelShader** aOut);
82 bool Failed(HRESULT hr, const char* aContext);
84 private:
85 // Only used during initialization.
86 RefPtr<ID3D11Device> mDevice;
87 bool mContinueInit;
88 bool mInitialized;
89 bool mDeviceReset;
90 nsCString mInitFailureId;
93 } // namespace layers
94 } // namespace mozilla
96 #endif // mozilla_gfx_layers_d3d11_DeviceAttachmentsD3D11_h