/// <summary> /// Creates a new instance of <see cref="StaticSampler"/> /// </summary> public StaticSampler(Sampler sampler, uint shaderRegister, uint registerSpace, ShaderVisibility visibility) { Sampler = sampler; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; Visibility = visibility; }
/// <summary> /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct. /// </summary> /// <param name="samplerDescription">Sampler description</param> /// <param name="shaderVisibility">The shader visibility.</param> /// <param name="shaderRegister">The shader register.</param> /// <param name="registerSpace">The register space.</param> public StaticSamplerDescription(SamplerDescription samplerDescription, ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) : this() { ShaderVisibility = shaderVisibility; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; // Unlike regular samplers, static samplers only support three possible border colors: opaque white, opaque black, and transparent. // So if the sampler has a border color that matches one of those exactly, we can convert it; otherwise it's left as the default (transparent). if (samplerDescription.BorderColor == Colors.White) { BorderColor = StaticBorderColor.OpaqueWhite; } else if (samplerDescription.BorderColor == Colors.Black) { BorderColor = StaticBorderColor.OpaqueBlack; } else { BorderColor = StaticBorderColor.TransparentBlack; } Filter = samplerDescription.Filter; AddressU = samplerDescription.AddressU; AddressV = samplerDescription.AddressV; AddressW = samplerDescription.AddressW; MinLOD = samplerDescription.MinLOD; MaxLOD = samplerDescription.MaxLOD; MipLODBias = samplerDescription.MipLODBias; MaxAnisotropy = samplerDescription.MaxAnisotropy; ComparisonFunction = samplerDescription.ComparisonFunction; }
/// <summary> /// The InitAsBufferUAV /// </summary> /// <param name="register">The <see cref="int"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitAsBufferUAV(int register, ShaderVisibility visibility = ShaderVisibility.All) { var buffer = new RootDescriptor1 { RegisterSpace = 0, ShaderRegister = register, Flags = RootDescriptorFlags.None }; Parameter = new RootParameter1(visibility, buffer, RootParameterType.UnorderedAccessView); }
private RootParameter(D3D12_DESCRIPTOR_RANGE1[] descriptorTable, ShaderVisibility visibility) { Type = RootParameterType.DescriptorTable; Visibility = visibility; DescriptorTable = descriptorTable; Descriptor = default; Constants = default; }
private RootParameter(RootParameterType type, D3D12_ROOT_DESCRIPTOR1 descriptor, ShaderVisibility visibility) { Type = type; Visibility = visibility; DescriptorTable = default; Descriptor = descriptor; Constants = default; }
private RootParameter(D3D12_ROOT_CONSTANTS constants, ShaderVisibility visibility) { Type = RootParameterType.DwordConstants; Visibility = visibility; DescriptorTable = default; Descriptor = default; Constants = constants; }
/// <summary> /// The InitAsConstantBuffer /// </summary> /// <param name="register">The <see cref="int"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitAsConstantBuffer(int register, ShaderVisibility visibility = ShaderVisibility.All) { var cbuffer = new RootDescriptor1 { RegisterSpace = 0, ShaderRegister = register, Flags = RootDescriptorFlags.None }; Parameter = new RootParameter1(visibility, cbuffer, RootParameterType.ConstantBufferView); }
/// <summary> /// Creates a new descriptor table root parameter /// </summary> /// <returns>A new <see cref="RootParameter"/> representing a descriptor table</returns> public static RootParameter CreateDescriptorTable( DescriptorRangeType type, uint baseShaderRegister, uint descriptorCount, uint registerSpace, uint offsetInDescriptorsFromTableStart = DescriptorRangeParameter.AppendAfterLastDescriptor, ShaderVisibility visibility = ShaderVisibility.All ) => CreateDescriptorTable(new DescriptorRangeParameter(type, baseShaderRegister, descriptorCount, registerSpace, offsetInDescriptorsFromTableStart), visibility);
Boolean InitAsBufferUAV(Int32 register, ShaderVisibility visibility = ShaderVisibility.All) { if (m_RootParameter != null) { return(false); } m_RootParameter = new RootParameter(visibility, new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, register)); return(true); }
Boolean InitAsConstants(Int32 register, Int32 numDWORDs, ShaderVisibility visibility = ShaderVisibility.All) { if (m_RootParameter != null) { return(false); } m_RootParameter = new RootParameter(visibility, new RootConstants(register, 0, numDWORDs)); return(true); }
/// <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; }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct. /// </summary> /// <param name="shaderVisibility">The shader visibility.</param> /// <param name="shaderRegister">The shader register.</param> /// <param name="registerSpace">The register space.</param> public StaticSamplerDescription(ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) : this() { ShaderVisibility = shaderVisibility; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; Filter = Filter.MinMagMipLinear; AddressU = TextureAddressMode.Clamp; AddressV = TextureAddressMode.Clamp; AddressW = TextureAddressMode.Clamp; MinLOD = -float.MaxValue; MaxLOD = float.MaxValue; MipLODBias = 0.0f; MaxAnisotropy = 16; ComparisonFunc = Comparison.Never; }
/// <summary> /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct. /// </summary> /// <param name="shaderVisibility">The shader visibility.</param> /// <param name="shaderRegister">The shader register.</param> /// <param name="registerSpace">The register space.</param> public StaticSamplerDescription(ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) : this() { ShaderVisibility = shaderVisibility; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; Filter = Filter.MinMagMipLinear; AddressU = TextureAddressMode.Clamp; AddressV = TextureAddressMode.Clamp; AddressW = TextureAddressMode.Clamp; MinLOD = -float.MaxValue; MaxLOD = float.MaxValue; MipLODBias = 0.0f; MaxAnisotropy = 16; ComparisonFunc = Comparison.Never; BorderColor = StaticBorderColor.TransparentBlack; }
/// <summary> /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct. /// </summary> /// <param name="shaderVisibility">The shader visibility.</param> /// <param name="shaderRegister">The shader register.</param> /// <param name="registerSpace">The register space.</param> public StaticSamplerDescription(ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) { Filter = Filter.MinMagMipLinear; AddressU = TextureAddressMode.Clamp; AddressV = TextureAddressMode.Clamp; AddressW = TextureAddressMode.Clamp; MipLODBias = 0.0f; MaxAnisotropy = 1; ComparisonFunction = ComparisonFunction.Never; BorderColor = StaticBorderColor.TransparentBlack; MinLOD = float.MinValue; MaxLOD = float.MaxValue; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; ShaderVisibility = shaderVisibility; }
/// <summary> /// Initializes a new instance of the <see cref="StaticSamplerDescription"/> struct. /// </summary> /// <param name="samplerDescription">Sampler description</param> /// <param name="shaderVisibility">The shader visibility.</param> /// <param name="shaderRegister">The shader register.</param> /// <param name="registerSpace">The register space.</param> public StaticSamplerDescription(SamplerDescription samplerDescription, ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) : this() { ShaderVisibility = shaderVisibility; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; BorderColor = StaticBorderColor.TransparentBlack; Filter = samplerDescription.Filter; AddressU = samplerDescription.AddressU; AddressV = samplerDescription.AddressV; AddressW = samplerDescription.AddressW; MinLOD = samplerDescription.MinLOD; MaxLOD = samplerDescription.MaxLOD; MipLODBias = samplerDescription.MipLODBias; MaxAnisotropy = samplerDescription.MaxAnisotropy; ComparisonFunction = samplerDescription.ComparisonFunction; }
/// <summary> /// Creates a new descriptor table root parameter /// </summary> /// <param name="ranges">The <see cref="DescriptorRange"/>s to bind</param> /// <param name="visibility">Indicates which shaders have access to this parameter</param> /// <returns>A new <see cref="RootParameter"/> representing a descriptor table</returns> public static RootParameter CreateDescriptorTable(DescriptorRange[] ranges, ShaderVisibility visibility = ShaderVisibility.All) { // do NOT make this a not pinned array. RootSignature.TranslateRootParameters relies on it var d3d12Ranges = GC.AllocateArray <D3D12_DESCRIPTOR_RANGE>(ranges.Length, pinned: true); for (var i = 0; i < ranges.Length; i++) { var range = ranges[i]; d3d12Ranges[i] = new D3D12_DESCRIPTOR_RANGE( (D3D12_DESCRIPTOR_RANGE_TYPE)range.Type, range.DescriptorCount, range.BaseShaderRegister, range.RegisterSpace, range.DescriptorOffset ); } return(new RootParameter(d3d12Ranges, visibility)); }
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> /// Creates a new descriptor table root parameter /// </summary> /// <param name="range">The <see cref="DescriptorRangeParameter"/> to bind</param> /// <param name="visibility">Indicates which shaders have access to this parameter</param> /// <returns>A new <see cref="RootParameter"/> representing a descriptor table</returns> public static RootParameter CreateDescriptorTable(DescriptorRangeParameter range, ShaderVisibility visibility = ShaderVisibility.All) => CreateDescriptorTable(new[] { range }, visibility);
public RootParameter(RootDescriptorTable descriptorTable, ShaderVisibility visibility) { NativeRootParameter = new RootParameter1(new RootDescriptorTable1(descriptorTable.Ranges.Select(r => Unsafe.As <DescriptorRange, DescriptorRange1>(ref r)).ToArray()), (Vortice.Direct3D12.ShaderVisibility)visibility); }
/// <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)); }
Boolean InitAsDescriptorRange(DescriptorRangeType type, Int32 register, Int32 counts, ShaderVisibility visibility = ShaderVisibility.All) { if (m_RootParameter != null) { return(false); } m_RootParameter = new RootParameter(visibility, new DescriptorRange(type, counts, register)); return(true); }
public Boolean InitStaticSampler(Int32 register, H1SamplerDescription samplerDesc, ShaderVisibility visibility) { if (m_NumInitializedStaticSamplers > m_NumSamplers) { return(false); // there are no available to initialize static samplers } StaticSamplerDescription staticSamplerDesc = m_SamplerArray[m_NumInitializedStaticSamplers]; staticSamplerDesc = new StaticSamplerDescription(visibility, register, 0); // initialize static sampler description staticSamplerDesc.Filter = H1RHIDefinitionHelper.ConvertToFilter(samplerDesc.Filter); staticSamplerDesc.AddressU = H1RHIDefinitionHelper.ConvertToTextureAddressMode(samplerDesc.AddressU); staticSamplerDesc.AddressV = H1RHIDefinitionHelper.ConvertToTextureAddressMode(samplerDesc.AddressV); staticSamplerDesc.AddressW = H1RHIDefinitionHelper.ConvertToTextureAddressMode(samplerDesc.AddressW); staticSamplerDesc.MipLODBias = samplerDesc.MipLODBias; staticSamplerDesc.MaxAnisotropy = samplerDesc.MaxAnisotropy; staticSamplerDesc.ComparisonFunc = H1RHIDefinitionHelper.ConvertToComparisonFunc(samplerDesc.ComparisonFunc); staticSamplerDesc.BorderColor = StaticBorderColor.OpaqueWhite; staticSamplerDesc.MinLOD = samplerDesc.MinLOD; staticSamplerDesc.MaxLOD = samplerDesc.MaxLOD; if (staticSamplerDesc.AddressU == TextureAddressMode.Border || staticSamplerDesc.AddressV == TextureAddressMode.Border || staticSamplerDesc.AddressW == TextureAddressMode.Border) { //@TODO - warning for the case, different border color with 'samplerDesc' } return(true); }
/// <summary> /// Creates a new constant values root parameter to fit a certain type /// </summary> /// <typeparam name="T">The type to create a constant root parameter for</typeparam> /// <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 set of constants</returns> public static RootParameter CreateConstants <T>(uint shaderRegister, uint registerSpace, ShaderVisibility visibility = ShaderVisibility.All) => CreateConstants(Num32BitValues <T>(), shaderRegister, registerSpace, visibility);
public RootParameter(RootConstants rootConstants, ShaderVisibility visibility) { NativeRootParameter = new RootParameter1(Unsafe.As <RootConstants, Vortice.Direct3D12.RootConstants>(ref rootConstants), (Vortice.Direct3D12.ShaderVisibility)visibility); }
/// <summary> /// Initializes a new instance of the <see cref="RootParameter1"/> struct. /// </summary> /// <param name="rootConstants">The root constants.</param> /// <param name="visibility">The shader visibility.</param> public RootParameter1(ShaderVisibility visibility, RootConstants rootConstants) : this() { Constants = rootConstants; ShaderVisibility = visibility; }
/// <summary> /// The InitAsConstants /// </summary> /// <param name="register">The <see cref="int"/></param> /// <param name="numDwords">The <see cref="int"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitAsConstants(int register, int numDwords, ShaderVisibility visibility = ShaderVisibility.All) { var constant = new RootConstants(register, 0, numDwords); Parameter = new RootParameter1(visibility, constant); }
/// <summary> /// Initializes a new instance of the <see cref="RootParameter"/> struct. /// </summary> /// <param name="descriptorTable">The descriptor table.</param> /// <param name="visibility">The shader visibility.</param> public RootParameter1(ShaderVisibility visibility, params DescriptorRange[] descriptorTable) : this() { DescriptorTable = descriptorTable; ShaderVisibility = visibility; }
/// <summary> /// The InitAsDescriptorTable /// </summary> /// <param name="rangeCount">The <see cref="int"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitAsDescriptorTable(int rangeCount, ShaderVisibility visibility) { var ranges = new List <DescriptorRange>(rangeCount); Parameter = new RootParameter1(visibility, ranges.ToArray()); }
/// <summary> /// The InitStaticSampler /// </summary> /// <param name="register">The <see cref="int"/></param> /// <param name="nonstaticSamplerDesc">The <see cref="SamplerStateDescription"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitStaticSampler(int register, SamplerStateDescription nonstaticSamplerDesc, ShaderVisibility visibility = ShaderVisibility.All) { Debug.Assert(InitializedStaticSamplersCount < SamplersCount); ref var staticSamplerDesc = ref SamplerArray[InitializedStaticSamplersCount++];
/// <summary> /// Creates a new constant values root parameter /// </summary> /// <param name="num32bitValues">The size, in 32 bit values, of all the constants combined</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 set of constants</returns> public static RootParameter CreateConstants(uint num32bitValues, uint shaderRegister, uint registerSpace, ShaderVisibility visibility = ShaderVisibility.All) => new RootParameter(new D3D12_ROOT_CONSTANTS { Num32BitValues = num32bitValues, ShaderRegister = shaderRegister, RegisterSpace = registerSpace }, visibility);
/// <summary> /// The InitAsDescriptorRange /// </summary> /// <param name="type">The <see cref="DescriptorRangeType"/></param> /// <param name="register">The <see cref="int"/></param> /// <param name="count">The <see cref="int"/></param> /// <param name="visibility">The <see cref="ShaderVisibility"/></param> public void InitAsDescriptorRange(DescriptorRangeType type, int register, int count, ShaderVisibility visibility = ShaderVisibility.All) { InitAsDescriptorTable(1, visibility); SetTableRange(0, type, register, count, 0); }