// Copyright (c) 2010-2014 SharpDX - SharpDX Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace SharpDX.D3DCompiler
{
public partial class FunctionReflection
{
///
/// Returns all constant buffers provided by this function
///
/// All references to that represents the constant buffers.
public ConstantBuffer[] ConstantBuffers
{
get
{
var result = new ConstantBuffer[this.Description.ConstantBuffers];
for (int i = 0; i < result.Length; i++)
{
result[i] = this.GetConstantBufferByIndex(i);
}
return result;
}
}
///
/// Returns all function parameters
///
/// All references to that represents the function parameters.
public FunctionParameterReflection[] Parameters
{
get
{
var result = new FunctionParameterReflection[this.Description.FunctionParameterCount];
for (int i = 0; i < result.Length; i++)
{
result[i] = this.GetFunctionParameter(i);
}
return result;
}
}
///
/// Returns reflection for function return parameter
///
/// Thrown if function has no return value (void)
public FunctionParameterReflection ReturnParameter
{
get
{
if (!this.Description.HasReturn)
{
throw new ArgumentException("Function has no return parameter, check function.Description.HasReturn before to call this function");
}
return this.GetFunctionParameter(-1);
}
}
///
/// Gets a description of how a resource is bound to a function.
///
///
A zero-based resource index.
/// A reference to a structure that describes input binding of the resource.
///
/// A shader consists of executable code (the compiled HLSL functions) and a set of resources that supply the shader with input data. GetResourceBindingDesc gets info about how one resource in the set is bound as an input to the shader. The ResourceIndex parameter specifies the index for the resource.
///
///
/// dn280551
/// HRESULT ID3D11FunctionReflection::GetResourceBindingDesc([In] unsigned int ResourceIndex,[Out] D3D11_SHADER_INPUT_BIND_DESC* pDesc)
/// ID3D11FunctionReflection::GetResourceBindingDesc
public InputBindingDescription GetResourceBindingDescription(int index)
{
InputBindingDescription result;
this.GetResourceBindingDescription(index, out result);
return result;
}
///
/// Gets a description of how a resource is bound to a function.
///
/// Resource name.
/// A reference to a structure that describes input binding of the resource.
///
/// A shader consists of executable code (the compiled HLSL functions) and a set of resources that supply the shader with input data. GetResourceBindingDesc gets info about how one resource in the set is bound as an input to the shader. The ResourceIndex parameter specifies the index for the resource.
///
///
/// dn280551
/// HRESULT ID3D11FunctionReflection::GetResourceBindingDesc([In] unsigned int ResourceIndex,[Out] D3D11_SHADER_INPUT_BIND_DESC* pDesc)
/// ID3D11FunctionReflection::GetResourceBindingDesc
public InputBindingDescription GetResourceBindingDescription(string name)
{
InputBindingDescription result;
this.GetResourceBindingDescByName(name, out result);
return result;
}
///
/// Returns all resource bindings attached to this resource
///
public InputBindingDescription[] ResourceBindings
{
get
{
InputBindingDescription[] result = new InputBindingDescription[this.Description.BoundResources];
for (int i = 0; i < result.Length;i++)
{
this.GetResourceBindingDescription(i, out result[i]);
}
return result;
}
}
}
}