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"
23 class DeviceAttachmentsD3D11 final
{
24 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DeviceAttachmentsD3D11
);
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
; }
63 explicit DeviceAttachmentsD3D11(ID3D11Device
* device
);
64 ~DeviceAttachmentsD3D11();
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
);
85 // Only used during initialization.
86 RefPtr
<ID3D11Device
> mDevice
;
90 nsCString mInitFailureId
;
94 } // namespace mozilla
96 #endif // mozilla_gfx_layers_d3d11_DeviceAttachmentsD3D11_h