1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 /* Copyright (C) 2011-2013, Nye Liu <nyet@nyet.org>
7    Copyright (C) 2011-2013, Kissaki <kissaki@gmx.de>
8 
9    All rights reserved.
10 
11    Redistribution and use in source and binary forms, with or without
12    modification, are permitted provided that the following conditions
13    are met:
14 
15    - Redistributions of source code must retain the above copyright notice,
16      this list of conditions and the following disclaimer.
17    - Redistributions in binary form must reproduce the above copyright notice,
18      this list of conditions and the following disclaimer in the documentation
19      and/or other materials provided with the distribution.
20    - Neither the name of the Mumble Developers nor the names of its
21      contributors may be used to endorse or promote products derived from this
22      software without specific prior written permission.
23 
24    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
28    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 
37 #ifndef MUMBLE_D11STATEBLOCK_H_
38 #define MUMBLE_D11STATEBLOCK_H_
39 
40 // File contains the D11StateBlock class and a function D11CreateStateBlock.
41 
42 #include <d3d11.h>
43 
44 class D11StateBlock;
45 
46 void D11CreateStateBlock(ID3D11DeviceContext *, D11StateBlock **);
47 
48 class D11StateBlock {
49 	public:
50 		D11StateBlock(ID3D11DeviceContext *);
51 		~D11StateBlock();
52 
53 		void Capture();
54 		void Apply();
55 		void ReleaseObjects();
56 		void ReleaseAllDeviceObjects();
57 
58 	private:
59 		ID3D11DeviceContext *pDeviceContext;
60 
61 		ID3D11RasterizerState *pRasterizerState;
62 		UINT uiNumViewports;
63 		D3D11_VIEWPORT pViewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
64 
65 		ID3D11RenderTargetView *pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
66 		ID3D11DepthStencilView *pDepthStencilView;
67 
68 		ID3D11BlendState *pBlendState;
69 		float fBlendFactor[4];
70 		UINT32 uiSampleMask;
71 
72 		ID3D11InputLayout *pInputLayout;
73 
74 		ID3D11Buffer *pIndexBuffer;
75 		DXGI_FORMAT Format;
76 		UINT uiOffset;
77 
78 		D3D11_PRIMITIVE_TOPOLOGY Topology;
79 
80 		ID3D11Buffer *pVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
81 		UINT uiStrides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
82 		UINT uiOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
83 };
84 
85 #endif /* !D11STATEBLOCK_H_ */
86