OSDN Git Service

#36897 [DTXC] MIDIインポート機能の呼び出し口を、ファイルメニュー内にも配置。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d11 / DepthStencilViewDescription11.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
6 * of this software and associated documentation files (the "Software"), to deal\r
7 * in the Software without restriction, including without limitation the rights\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
9 * copies of the Software, and to permit persons to whom the Software is\r
10 * furnished to do so, subject to the following conditions:\r
11\r
12 * The above copyright notice and this permission notice shall be included in\r
13 * all copies or substantial portions of the Software.\r
14\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
21 * THE SOFTWARE.\r
22 */\r
23 \r
24 #include <d3d11.h>\r
25 \r
26 #include "DepthStencilViewDescription11.h"\r
27 \r
28 namespace SlimDX\r
29 {\r
30 namespace Direct3D11\r
31 {\r
32         DepthStencilViewDescription::DepthStencilViewDescription( const D3D11_DEPTH_STENCIL_VIEW_DESC& native )\r
33         {\r
34                 Format = static_cast<DXGI::Format>( native.Format );\r
35                 Dimension = static_cast<DepthStencilViewDimension>( native.ViewDimension );\r
36                 Flags = static_cast<DepthStencilViewFlags>( native.Flags );\r
37 \r
38                 switch( Dimension )\r
39                 {\r
40                         case DepthStencilViewDimension::Texture1D:\r
41                                 MipSlice = native.Texture1D.MipSlice;\r
42                                 break;\r
43 \r
44                         case DepthStencilViewDimension::Texture1DArray:\r
45                                 ArraySize = native.Texture1DArray.ArraySize;\r
46                                 FirstArraySlice = native.Texture1DArray.FirstArraySlice;\r
47                                 MipSlice = native.Texture1DArray.MipSlice;\r
48                                 break;\r
49 \r
50                         case DepthStencilViewDimension::Texture2D:\r
51                                 MipSlice = native.Texture2D.MipSlice;\r
52                                 break;\r
53 \r
54                         case DepthStencilViewDimension::Texture2DArray:\r
55                                 ArraySize = native.Texture2DArray.ArraySize;\r
56                                 FirstArraySlice = native.Texture2DArray.FirstArraySlice;\r
57                                 MipSlice = native.Texture2DArray.MipSlice;\r
58                                 break;\r
59 \r
60                         case DepthStencilViewDimension::Texture2DMultisampled:\r
61                                 // Nothing to do here.\r
62                                 break;\r
63 \r
64                         case DepthStencilViewDimension::Texture2DMultisampledArray:\r
65                                 ArraySize = native.Texture2DMSArray.ArraySize;\r
66                                 FirstArraySlice = native.Texture2DMSArray.FirstArraySlice;\r
67                                 break;\r
68 \r
69                         default:\r
70                                 break;\r
71                 }\r
72         }\r
73         \r
74         D3D11_DEPTH_STENCIL_VIEW_DESC DepthStencilViewDescription::CreateNativeVersion()\r
75         {\r
76                 D3D11_DEPTH_STENCIL_VIEW_DESC native;\r
77                 native.Format = static_cast<DXGI_FORMAT>( Format );\r
78                 native.ViewDimension = static_cast<D3D11_DSV_DIMENSION>( Dimension );\r
79                 native.Flags = static_cast<UINT>( Flags );\r
80 \r
81                 switch( Dimension )\r
82                 {\r
83                         case DepthStencilViewDimension::Texture1D:\r
84                                 native.Texture1D.MipSlice = MipSlice;\r
85                                 break;\r
86 \r
87                         case DepthStencilViewDimension::Texture1DArray:\r
88                                 native.Texture1DArray.ArraySize = ArraySize;\r
89                                 native.Texture1DArray.FirstArraySlice = FirstArraySlice;\r
90                                 native.Texture1DArray.MipSlice = MipSlice;\r
91                                 break;\r
92 \r
93                         case DepthStencilViewDimension::Texture2D:\r
94                                 native.Texture2D.MipSlice = MipSlice;\r
95                                 break;\r
96 \r
97                         case DepthStencilViewDimension::Texture2DArray:\r
98                                 native.Texture2DArray.ArraySize = ArraySize;\r
99                                 native.Texture2DArray.FirstArraySlice = FirstArraySlice;\r
100                                 native.Texture2DArray.MipSlice = MipSlice;\r
101                                 break;\r
102 \r
103                         case DepthStencilViewDimension::Texture2DMultisampled:\r
104                                 // Nothing to do here.\r
105                                 break;\r
106 \r
107                         case DepthStencilViewDimension::Texture2DMultisampledArray:\r
108                                 native.Texture2DMSArray.ArraySize = ArraySize;\r
109                                 native.Texture2DMSArray.FirstArraySlice = FirstArraySlice;\r
110                                 break;\r
111 \r
112                         default:\r
113                                 break;\r
114                 }\r
115                 \r
116                 return native;\r
117         }\r
118 \r
119         bool DepthStencilViewDescription::operator == ( DepthStencilViewDescription left, DepthStencilViewDescription right )\r
120         {\r
121                 return DepthStencilViewDescription::Equals( left, right );\r
122         }\r
123 \r
124         bool DepthStencilViewDescription::operator != ( DepthStencilViewDescription left, DepthStencilViewDescription right )\r
125         {\r
126                 return !DepthStencilViewDescription::Equals( left, right );\r
127         }\r
128 \r
129         int DepthStencilViewDescription::GetHashCode()\r
130         {\r
131                 return Format.GetHashCode() + Dimension.GetHashCode() + MipSlice.GetHashCode()\r
132                          + FirstArraySlice.GetHashCode() + ArraySize.GetHashCode() + Flags.GetHashCode();\r
133         }\r
134 \r
135         bool DepthStencilViewDescription::Equals( Object^ value )\r
136         {\r
137                 if( value == nullptr )\r
138                         return false;\r
139 \r
140                 if( value->GetType() != GetType() )\r
141                         return false;\r
142 \r
143                 return Equals( safe_cast<DepthStencilViewDescription>( value ) );\r
144         }\r
145 \r
146         bool DepthStencilViewDescription::Equals( DepthStencilViewDescription value )\r
147         {\r
148                 return ( Format == value.Format && Dimension == value.Dimension && MipSlice == value.MipSlice\r
149                          && FirstArraySlice == value.FirstArraySlice && ArraySize == value.ArraySize && Flags == value.Flags );\r
150         }\r
151 \r
152         bool DepthStencilViewDescription::Equals( DepthStencilViewDescription% value1, DepthStencilViewDescription% value2 )\r
153         {\r
154                 return ( value1.Format == value2.Format && value1.Dimension == value2.Dimension && value1.MipSlice == value2.MipSlice\r
155                          && value1.FirstArraySlice == value2.FirstArraySlice && value1.ArraySize == value2.ArraySize && value1.Flags == value2.Flags );\r
156         }\r
157 }\r
158 }\r