/// <summary> /// Creates a new directly-bound descriptor root parameter /// </summary> /// <param name="type">The type of the descriptor to bind. This must either be <see cref="RootParameterType.ConstantBufferView"/>, /// <see cref="RootParameterType.ShaderResourceView"/>, or <see cref="RootParameterType.UnorderedAccessView"/></param> /// <param name="shaderRegister">The shader register to bind this parameter to</param> /// <param name="registerSpace">The space to bind this parameter in</param> /// <param name="visibility">Indicates which shaders have access to this parameter</param> /// <returns>A new <see cref="RootParameter"/> representing a directly-bound descriptor</returns> public static RootParameter CreateDescriptor(RootParameterType type, uint shaderRegister, uint registerSpace, ShaderVisibility visibility = ShaderVisibility.All) { Debug.Assert(type is RootParameterType.ConstantBufferView or RootParameterType.ShaderResourceView or RootParameterType.UnorderedAccessView); return(new RootParameter(type, new D3D12_ROOT_DESCRIPTOR1 { ShaderRegister = shaderRegister, RegisterSpace = registerSpace }, visibility)); }
private RootParameter(D3D12_ROOT_CONSTANTS constants, ShaderVisibility visibility) { Type = RootParameterType.DwordConstants; Visibility = visibility; DescriptorTable = default; Descriptor = default; Constants = constants; }
private RootParameter(RootParameterType type, D3D12_ROOT_DESCRIPTOR1 descriptor, ShaderVisibility visibility) { Type = type; Visibility = visibility; DescriptorTable = default; Descriptor = descriptor; Constants = default; }
private RootParameter(D3D12_DESCRIPTOR_RANGE1[] descriptorTable, ShaderVisibility visibility) { Type = RootParameterType.DescriptorTable; Visibility = visibility; DescriptorTable = descriptorTable; Descriptor = default; Constants = default; }
/// <summary> /// Initializes a new instance of the <see cref="RootParameter"/> struct. /// </summary> /// <param name="rootDescriptor">The root descriptor.</param> /// <param name="type">The type.</param> /// <param name="visibility">The visibility.</param> /// <exception cref="System.ArgumentException">type</exception> public RootParameter1(ShaderVisibility visibility, RootDescriptor1 rootDescriptor, RootParameterType type) : this() { if(type == RootParameterType.Constant32Bits || type == RootParameterType.DescriptorTable) { throw new ArgumentException(string.Format("Cannot this type [{0}] for a RootDescriptor", type), "type"); } native.ParameterType = type; Descriptor = rootDescriptor; ShaderVisibility = visibility; }
public static string GetRegisterName(this RootParameterType type) { switch (type) { case RootParameterType._32BitConstants: case RootParameterType.Cbv: return("b"); case RootParameterType.Srv: return("t"); case RootParameterType.Uav: return("u"); default: throw new InvalidOperationException($"Register name not supported for Root Parameter Type {type}"); } }
public RootParameter(RootParameterType parameterType, RootDescriptor rootDescriptor, ShaderVisibility visibility) { NativeRootParameter = new RootParameter1((Vortice.Direct3D12.RootParameterType)parameterType, Unsafe.As <RootDescriptor, RootDescriptor1>(ref rootDescriptor), (Vortice.Direct3D12.ShaderVisibility)visibility); }
/// <summary> /// Initializes a new instance of the <see cref="RootParameter"/> struct. /// </summary> /// <param name="rootDescriptor">The root descriptor.</param> /// <param name="type">The type.</param> /// <param name="visibility">The visibility.</param> /// <exception cref="System.ArgumentException">type</exception> public RootParameter1(ShaderVisibility visibility, RootDescriptor1 rootDescriptor, RootParameterType type) : this() { if (type == RootParameterType.Constant32Bits || type == RootParameterType.DescriptorTable) { throw new ArgumentException(string.Format("Cannot this type [{0}] for a RootDescriptor", type), "type"); } native.ParameterType = type; Descriptor = rootDescriptor; ShaderVisibility = visibility; }