예제 #1
0
 /// <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));
 }
예제 #2
0
 private RootParameter(D3D12_ROOT_CONSTANTS constants, ShaderVisibility visibility)
 {
     Type            = RootParameterType.DwordConstants;
     Visibility      = visibility;
     DescriptorTable = default;
     Descriptor      = default;
     Constants       = constants;
 }
예제 #3
0
 private RootParameter(RootParameterType type, D3D12_ROOT_DESCRIPTOR1 descriptor, ShaderVisibility visibility)
 {
     Type            = type;
     Visibility      = visibility;
     DescriptorTable = default;
     Descriptor      = descriptor;
     Constants       = default;
 }
예제 #4
0
 private RootParameter(D3D12_DESCRIPTOR_RANGE1[] descriptorTable, ShaderVisibility visibility)
 {
     Type            = RootParameterType.DescriptorTable;
     Visibility      = visibility;
     DescriptorTable = descriptorTable;
     Descriptor      = default;
     Constants       = default;
 }
예제 #5
0
        /// <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;
        }
예제 #6
0
        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}");
            }
        }
예제 #7
0
 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);
 }
예제 #8
0
        /// <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;
        }