OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / d3dcompiler / ShaderReflectionDC.cpp
1 /*\r
2 * Copyright (c) 2007-2010 SlimDX Group\r
3\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
5 * of this software and associated documentation files (the "Software"), to deal\r
6 * in the Software without restriction, including without limitation the rights\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
8 * copies of the Software, and to permit persons to whom the Software is\r
9 * furnished to do so, subject to the following conditions:\r
10\r
11 * The above copyright notice and this permission notice shall be included in\r
12 * all copies or substantial portions of the Software.\r
13\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
20 * THE SOFTWARE.\r
21 */\r
22 #include "stdafx.h"\r
23 \r
24 #include "D3DCompilerException.h"\r
25 \r
26 #include "ShaderReflectionDC.h"\r
27 #include "ShaderBytecodeDC.h"\r
28 \r
29 using namespace System;\r
30 \r
31 namespace SlimDX\r
32 {\r
33 namespace D3DCompiler\r
34 {\r
35         ShaderReflection::ShaderReflection( ShaderBytecode^ byteCode )\r
36         {\r
37                 ID3D11ShaderReflection* result = 0;\r
38                 HRESULT hr = D3DReflect( byteCode->InternalPointer->GetBufferPointer(), byteCode->InternalPointer->GetBufferSize(), IID_ID3D11ShaderReflection, reinterpret_cast<void**>( &result ) );\r
39                 if( RECORD_D3DC( hr ).IsFailure )\r
40                         throw gcnew D3DCompilerException( Result::Last );\r
41 \r
42                 Construct( result );\r
43 \r
44                 D3D11_SHADER_DESC desc;\r
45                 InternalPointer->GetDesc( &desc );\r
46                 description = gcnew ShaderDescription( desc );\r
47         }\r
48 \r
49         ConstantBuffer^ ShaderReflection::GetConstantBuffer( int index )\r
50         {\r
51                 return gcnew ConstantBuffer( InternalPointer->GetConstantBufferByIndex( index ) );\r
52         }\r
53 \r
54         ConstantBuffer^ ShaderReflection::GetConstantBuffer( String^ name )\r
55         {\r
56                 array<unsigned char>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( name );\r
57                 pin_ptr<unsigned char> pinnedName = &nameBytes[0];\r
58 \r
59                 return gcnew ConstantBuffer( InternalPointer->GetConstantBufferByName( reinterpret_cast<LPCSTR>(pinnedName) ) );\r
60         }\r
61 \r
62         ShaderParameterDescription ShaderReflection::GetInputParameterDescription( int index )\r
63         {\r
64                 D3D11_SIGNATURE_PARAMETER_DESC desc;\r
65 \r
66                 HRESULT hr = InternalPointer->GetInputParameterDesc( index, &desc );\r
67                 RECORD_D3DC( hr );\r
68 \r
69                 return ShaderParameterDescription( desc );\r
70         }\r
71 \r
72         ShaderParameterDescription ShaderReflection::GetOutputParameterDescription( int index )\r
73         {\r
74                 D3D11_SIGNATURE_PARAMETER_DESC desc;\r
75 \r
76                 HRESULT hr = InternalPointer->GetOutputParameterDesc( index, &desc );\r
77                 RECORD_D3DC( hr );\r
78 \r
79                 return ShaderParameterDescription( desc );\r
80         }\r
81 \r
82         ShaderParameterDescription ShaderReflection::GetPatchConstantParameterDescription( int index )\r
83         {\r
84                 D3D11_SIGNATURE_PARAMETER_DESC desc;\r
85 \r
86                 HRESULT hr = InternalPointer->GetPatchConstantParameterDesc( index, &desc );\r
87                 RECORD_D3DC( hr );\r
88 \r
89                 return ShaderParameterDescription( desc );\r
90         }\r
91 \r
92         InputBindingDescription ShaderReflection::GetResourceBindingDescription( int index )\r
93         {\r
94                 D3D11_SHADER_INPUT_BIND_DESC desc;\r
95 \r
96                 HRESULT hr = InternalPointer->GetResourceBindingDesc( index, &desc );\r
97                 RECORD_D3DC( hr );\r
98 \r
99                 return InputBindingDescription( desc );\r
100         }\r
101 \r
102         InputBindingDescription ShaderReflection::GetResourceBindingDescription( String^ name )\r
103         {\r
104                 D3D11_SHADER_INPUT_BIND_DESC desc;\r
105                 array<unsigned char>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( name );\r
106                 pin_ptr<unsigned char> pinnedName = &nameBytes[0];\r
107 \r
108                 HRESULT hr = InternalPointer->GetResourceBindingDescByName( reinterpret_cast<LPCSTR>(pinnedName), &desc );\r
109                 RECORD_D3DC( hr );\r
110 \r
111                 return InputBindingDescription( desc );\r
112         }\r
113 \r
114         Direct3D11::FeatureLevel ShaderReflection::MinimumFeatureLevel::get()\r
115         {\r
116                 D3D_FEATURE_LEVEL fl;\r
117                 InternalPointer->GetMinFeatureLevel( &fl );\r
118 \r
119                 return static_cast<Direct3D11::FeatureLevel>( fl );\r
120         }\r
121 \r
122         InputPrimitive ShaderReflection::GeometryShaderInputPrimitive::get()\r
123         {\r
124                 return static_cast<InputPrimitive>( InternalPointer->GetGSInputPrimitive() );\r
125         }\r
126         \r
127         int ShaderReflection::BitwiseInstructionCount::get()\r
128         {\r
129                 return InternalPointer->GetBitwiseInstructionCount();\r
130         }\r
131         \r
132         int ShaderReflection::ConversionInstructionCount::get()\r
133         {\r
134                 return InternalPointer->GetConversionInstructionCount();\r
135         }\r
136         \r
137         int ShaderReflection::MoveInstructionCount::get()\r
138         {\r
139                 return InternalPointer->GetMovInstructionCount();\r
140         }\r
141         \r
142         int ShaderReflection::ConditionalMoveInstructionCount::get()\r
143         {\r
144                 return InternalPointer->GetMovcInstructionCount() ;\r
145         }\r
146         \r
147         int ShaderReflection::InterfaceSlotCount::get()\r
148         {\r
149                 return InternalPointer->GetNumInterfaceSlots();\r
150         }\r
151         \r
152         bool ShaderReflection::IsSampleFrequencyShader::get()\r
153         {\r
154                 return InternalPointer->IsSampleFrequencyShader() > 0;\r
155         }\r
156 }\r
157 }