2 * Copyright (c) 2007-2010 SlimDX Group
\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
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\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
24 #include "D3DCompilerException.h"
\r
26 #include "ShaderReflectionDC.h"
\r
27 #include "ShaderBytecodeDC.h"
\r
29 using namespace System;
\r
33 namespace D3DCompiler
\r
35 ShaderReflection::ShaderReflection( ShaderBytecode^ byteCode )
\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
42 Construct( result );
\r
44 D3D11_SHADER_DESC desc;
\r
45 InternalPointer->GetDesc( &desc );
\r
46 description = gcnew ShaderDescription( desc );
\r
49 ConstantBuffer^ ShaderReflection::GetConstantBuffer( int index )
\r
51 return gcnew ConstantBuffer( InternalPointer->GetConstantBufferByIndex( index ) );
\r
54 ConstantBuffer^ ShaderReflection::GetConstantBuffer( String^ name )
\r
56 array<unsigned char>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( name );
\r
57 pin_ptr<unsigned char> pinnedName = &nameBytes[0];
\r
59 return gcnew ConstantBuffer( InternalPointer->GetConstantBufferByName( reinterpret_cast<LPCSTR>(pinnedName) ) );
\r
62 ShaderParameterDescription ShaderReflection::GetInputParameterDescription( int index )
\r
64 D3D11_SIGNATURE_PARAMETER_DESC desc;
\r
66 HRESULT hr = InternalPointer->GetInputParameterDesc( index, &desc );
\r
69 return ShaderParameterDescription( desc );
\r
72 ShaderParameterDescription ShaderReflection::GetOutputParameterDescription( int index )
\r
74 D3D11_SIGNATURE_PARAMETER_DESC desc;
\r
76 HRESULT hr = InternalPointer->GetOutputParameterDesc( index, &desc );
\r
79 return ShaderParameterDescription( desc );
\r
82 ShaderParameterDescription ShaderReflection::GetPatchConstantParameterDescription( int index )
\r
84 D3D11_SIGNATURE_PARAMETER_DESC desc;
\r
86 HRESULT hr = InternalPointer->GetPatchConstantParameterDesc( index, &desc );
\r
89 return ShaderParameterDescription( desc );
\r
92 InputBindingDescription ShaderReflection::GetResourceBindingDescription( int index )
\r
94 D3D11_SHADER_INPUT_BIND_DESC desc;
\r
96 HRESULT hr = InternalPointer->GetResourceBindingDesc( index, &desc );
\r
99 return InputBindingDescription( desc );
\r
102 InputBindingDescription ShaderReflection::GetResourceBindingDescription( String^ name )
\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
108 HRESULT hr = InternalPointer->GetResourceBindingDescByName( reinterpret_cast<LPCSTR>(pinnedName), &desc );
\r
111 return InputBindingDescription( desc );
\r
114 Direct3D11::FeatureLevel ShaderReflection::MinimumFeatureLevel::get()
\r
116 D3D_FEATURE_LEVEL fl;
\r
117 InternalPointer->GetMinFeatureLevel( &fl );
\r
119 return static_cast<Direct3D11::FeatureLevel>( fl );
\r
122 InputPrimitive ShaderReflection::GeometryShaderInputPrimitive::get()
\r
124 return static_cast<InputPrimitive>( InternalPointer->GetGSInputPrimitive() );
\r
127 int ShaderReflection::BitwiseInstructionCount::get()
\r
129 return InternalPointer->GetBitwiseInstructionCount();
\r
132 int ShaderReflection::ConversionInstructionCount::get()
\r
134 return InternalPointer->GetConversionInstructionCount();
\r
137 int ShaderReflection::MoveInstructionCount::get()
\r
139 return InternalPointer->GetMovInstructionCount();
\r
142 int ShaderReflection::ConditionalMoveInstructionCount::get()
\r
144 return InternalPointer->GetMovcInstructionCount() ;
\r
147 int ShaderReflection::InterfaceSlotCount::get()
\r
149 return InternalPointer->GetNumInterfaceSlots();
\r
152 bool ShaderReflection::IsSampleFrequencyShader::get()
\r
154 return InternalPointer->IsSampleFrequencyShader() > 0;
\r