public void Initialize() { // Pipeline state. var testShaderPath = "../../../../../Resources/Engine/MipMap.hlsl"; ComputeShader = ShaderBytecode.CompileFromFile(testShaderPath, "GenerateMipMaps", "cs_5_0"); // Root parameters. var rootParameters = new RootParameter[] { new RootParameter(ShaderVisibility.All, new RootConstants(0, 0, 2)), new RootParameter(ShaderVisibility.Pixel, new DescriptorRange() { RangeType = DescriptorRangeType.ShaderResourceView, DescriptorCount = 1, OffsetInDescriptorsFromTableStart = int.MinValue, // D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND BaseShaderRegister = 0 }), new RootParameter(ShaderVisibility.Pixel, new DescriptorRange() { RangeType = DescriptorRangeType.UnorderedAccessView, BaseShaderRegister = 0, OffsetInDescriptorsFromTableStart = int.MinValue, // D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND DescriptorCount = 1 }), }; var staticSamplers = new StaticSamplerDescription[] { new StaticSamplerDescription() { Filter = Filter.MinMagLinearMipPoint, AddressUVW = TextureAddressMode.Clamp, MipLODBias = 0f, ComparisonFunc = Comparison.Never, MinLOD = 0f, MaxLOD = float.MaxValue, MaxAnisotropy = 0, BorderColor = StaticBorderColor.OpaqueBlack, ShaderRegister = 0, RegisterSpace = 0, ShaderVisibility = ShaderVisibility.All } }; var rootSignatureDescription = new RootSignatureDescription( RootSignatureFlags.AllowInputAssemblerInputLayout, rootParameters, staticSamplers); RootSignature = RootSignature.Create(Device, rootSignatureDescription); Layout = new DescriptorLayout( DescriptorLayout.EntryType.ConstantBufferShaderResourceOrUnorderedAccessView, DescriptorLayout.EntryType.ConstantBufferShaderResourceOrUnorderedAccessView); }
public void Initialize() { // Pipeline state. var testShaderPath = "../../../../../Resources/Engine/Forward/Standard.hlsl"; VertexShader = ShaderBytecode.CompileFromFile(testShaderPath, "VSMain", "vs_5_0"); PixelShader = ShaderBytecode.CompileFromFile(testShaderPath, "PSMain", "ps_5_0"); // Root parameters. var rootParameters = new RootParameter[] { new RootParameter(ShaderVisibility.All, new DescriptorRange() { RangeType = DescriptorRangeType.ConstantBufferView, BaseShaderRegister = 0, OffsetInDescriptorsFromTableStart = int.MinValue, DescriptorCount = 1, }), new RootParameter(ShaderVisibility.Pixel, new DescriptorRange() { RangeType = DescriptorRangeType.ShaderResourceView, DescriptorCount = 1, OffsetInDescriptorsFromTableStart = int.MinValue, BaseShaderRegister = 0 }), new RootParameter(ShaderVisibility.Pixel, new DescriptorRange() { RangeType = DescriptorRangeType.Sampler, BaseShaderRegister = 0, DescriptorCount = 1 }), }; var rootSignatureDescription = new RootSignatureDescription(RootSignatureFlags.AllowInputAssemblerInputLayout, rootParameters); RootSignature = RootSignature.Create(Device, rootSignatureDescription); Layout = new DescriptorLayout( DescriptorLayout.EntryType.ConstantBufferShaderResourceOrUnorderedAccessView, DescriptorLayout.EntryType.ConstantBufferShaderResourceOrUnorderedAccessView, DescriptorLayout.EntryType.SamplerState); }
private void InitDescriptorLayouts() { _descriptorLayouts["_PROJECTION"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Vertex, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_VIEW"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Vertex, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_MODEL"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Vertex, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_MRT"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { //albedo new DescriptorBindingInfo { DescriptorType = VkDescriptorType.CombinedImageSampler, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 0 }, //normal new DescriptorBindingInfo { DescriptorType = VkDescriptorType.CombinedImageSampler, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 1 }, //position new DescriptorBindingInfo { DescriptorType = VkDescriptorType.CombinedImageSampler, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 2 }, //detail new DescriptorBindingInfo { DescriptorType = VkDescriptorType.CombinedImageSampler, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 3 } } ); _descriptorLayouts["_CAMERA"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_LIGHT"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_UI"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.UniformBuffer, ShaderStageFlags = VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 0 } } ); _descriptorLayouts["_UI_TEXTURE"] = new DescriptorLayout( _graphicsService.PrimaryDevice, new List <DescriptorBindingInfo> { new DescriptorBindingInfo { DescriptorType = VkDescriptorType.CombinedImageSampler, ShaderStageFlags = VkShaderStageFlags.Fragment, DescriptorCounts = 1, Index = 0 } } ); }