コード例 #1
0
        public RootSignature(GraphicsDevice device, RootSignatureDescription description)
        {
            GraphicsDevice = device;

            RootSignatureDescription1 nativeDescription = new RootSignatureDescription1((Vortice.Direct3D12.RootSignatureFlags)description.Flags)
            {
                Parameters     = description.Parameters?.Select(p => Unsafe.As <RootParameter, RootParameter1>(ref p)).ToArray(),
                StaticSamplers = description.StaticSamplers?.Select(s => Unsafe.As <StaticSamplerDescription, Vortice.Direct3D12.StaticSamplerDescription>(ref s)).ToArray()
            };

            NativeRootSignature = GraphicsDevice.NativeDevice.CreateRootSignature(new VersionedRootSignatureDescription(nativeDescription));
        }
コード例 #2
0
        public ID3D12RootSignature CreateRootSignature()
        {
            int cbvShaderRegister = 0;

            List <RootParameter1> rootParameters = new List <RootParameter1>
            {
                new RootParameter1(new RootConstants(cbvShaderRegister++, 0, 1), ShaderVisibility.All),
                new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvShaderRegister++)), ShaderVisibility.All),
                new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvShaderRegister++)), ShaderVisibility.All),
                new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvShaderRegister++)), ShaderVisibility.All),
                new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvShaderRegister++)), ShaderVisibility.All),
                new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.Sampler, 1, 0)), ShaderVisibility.All)
            };

            List <DescriptorRange1> shaderResourceRootDescriptorRanges = new List <DescriptorRange1>();

            if (ConstantBufferViews.Count > 0)
            {
                shaderResourceRootDescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, ConstantBufferViews.Count, cbvShaderRegister));
            }

            if (ShaderResourceViews.Count > 0)
            {
                shaderResourceRootDescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.ShaderResourceView, ShaderResourceViews.Count, 0));
            }

            if (UnorderedAccessViews.Count > 0)
            {
                shaderResourceRootDescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.UnorderedAccessView, UnorderedAccessViews.Count, 0));
            }

            if (shaderResourceRootDescriptorRanges.Count > 0)
            {
                rootParameters.Add(new RootParameter1(new RootDescriptorTable1(shaderResourceRootDescriptorRanges.ToArray()), ShaderVisibility.All));
            }

            if (Samplers.Count > 0)
            {
                rootParameters.Add(new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.Sampler, Samplers.Count, 1)), ShaderVisibility.All));
            }

            RootSignatureDescription1 rootSignatureDescription = new RootSignatureDescription1(
                RootSignatureFlags.AllowInputAssemblerInputLayout, rootParameters.ToArray());

            return(GraphicsDevice.CreateRootSignature(new VersionedRootSignatureDescription(rootSignatureDescription)));
        }
コード例 #3
0
        public RootSignature(GraphicsDevice device, RootSignatureDescription description)
        {
            GraphicsDevice = device;

            RootSignatureDescription1 nativeDescription = new RootSignatureDescription1((Vortice.Direct3D12.RootSignatureFlags)description.Flags);

            if (description.Parameters != null)
            {
                nativeDescription.Parameters = Unsafe.As <RootParameter1[]>(description.Parameters);
            }

            if (description.StaticSamplers != null)
            {
                nativeDescription.StaticSamplers = Unsafe.As <Vortice.Direct3D12.StaticSamplerDescription[]>(description.StaticSamplers);
            }

            NativeRootSignature = GraphicsDevice.NativeDevice.CreateRootSignature(new VersionedRootSignatureDescription(nativeDescription));
        }
コード例 #4
0
        internal void Sign1(GraphicsDevice graphicsDevice, int registerSpace = 0)
        {
            //static samplers
            StaticSamplerDescription[] samplerDescription = null;
            if (flags != RootSignatureFlags.LocalRootSignature)
            {
                samplerDescription    = new StaticSamplerDescription[4];
                samplerDescription[0] = new StaticSamplerDescription()
                {
                    AddressU           = TextureAddressMode.Clamp,
                    AddressV           = TextureAddressMode.Clamp,
                    AddressW           = TextureAddressMode.Clamp,
                    BorderColor        = StaticBorderColor.OpaqueBlack,
                    ComparisonFunction = ComparisonFunction.Never,
                    Filter             = Filter.MinMagMipLinear,
                    MipLODBias         = 0,
                    MaxAnisotropy      = 0,
                    MinLOD             = 0,
                    MaxLOD             = float.MaxValue,
                    ShaderVisibility   = ShaderVisibility.All,
                    RegisterSpace      = 0,
                    ShaderRegister     = 0,
                };
                samplerDescription[1]          = samplerDescription[0];
                samplerDescription[1].AddressU = TextureAddressMode.Wrap;
                samplerDescription[1].AddressV = TextureAddressMode.Wrap;
                samplerDescription[1].AddressW = TextureAddressMode.Wrap;
                samplerDescription[2]          = samplerDescription[0];
                samplerDescription[3]          = samplerDescription[0];

                samplerDescription[1].ShaderRegister     = 1;
                samplerDescription[2].ShaderRegister     = 2;
                samplerDescription[3].ShaderRegister     = 3;
                samplerDescription[1].MaxAnisotropy      = 16;
                samplerDescription[1].Filter             = Filter.Anisotropic;
                samplerDescription[2].ComparisonFunction = ComparisonFunction.Less;
                samplerDescription[2].Filter             = Filter.ComparisonMinMagMipLinear;
                samplerDescription[3].Filter             = Filter.MinMagMipPoint;
            }

            RootParameter1[] rootParameters = new RootParameter1[descs.Length];

            int cbvCount = 0;
            int srvCount = 0;
            int uavCount = 0;

            cbv.Clear();
            srv.Clear();
            uav.Clear();

            for (int i = 0; i < descs.Length; i++)
            {
                ResourceAccessType t = descs[i];
                switch (t)
                {
                case ResourceAccessType.CBV:
                    rootParameters[i] = new RootParameter1(RootParameterType.ConstantBufferView, new RootDescriptor1(cbvCount, registerSpace), ShaderVisibility.All);
                    cbv[cbvCount]     = i;
                    cbvCount++;
                    break;

                case ResourceAccessType.SRV:
                    rootParameters[i] = new RootParameter1(RootParameterType.ShaderResourceView, new RootDescriptor1(srvCount, registerSpace), ShaderVisibility.All);
                    srv[srvCount]     = i;
                    srvCount++;
                    break;

                case ResourceAccessType.UAV:
                    rootParameters[i] = new RootParameter1(RootParameterType.UnorderedAccessView, new RootDescriptor1(uavCount, registerSpace), ShaderVisibility.All);
                    uav[uavCount]     = i;
                    uavCount++;
                    break;

                case ResourceAccessType.CBVTable:
                    rootParameters[i] = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvCount, registerSpace)), ShaderVisibility.All);
                    cbv[cbvCount]     = i;
                    cbvCount++;
                    break;

                case ResourceAccessType.SRVTable:
                    rootParameters[i] = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ShaderResourceView, 1, srvCount, registerSpace)), ShaderVisibility.All);
                    srv[srvCount]     = i;
                    srvCount++;
                    break;

                case ResourceAccessType.UAVTable:
                    rootParameters[i] = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.UnorderedAccessView, 1, uavCount, registerSpace)), ShaderVisibility.All);
                    uav[uavCount]     = i;
                    uavCount++;
                    break;
                }
            }

            RootSignatureDescription1 rootSignatureDescription = new RootSignatureDescription1();

            rootSignatureDescription.StaticSamplers = samplerDescription;
            rootSignatureDescription.Flags          = flags;
            rootSignatureDescription.Parameters     = rootParameters;

            rootSignature?.Release();
            rootSignature = graphicsDevice.device.CreateRootSignature <ID3D12RootSignature>(0, rootSignatureDescription);
        }
コード例 #5
0
ファイル: GraphicsDevice.cs プロジェクト: sselecirPyM/RTUGame
        public void CreateRootSignature(RootSignature rootSignature, IList <RootSignatureParamP> types)
        {
            //static samplers
            StaticSamplerDescription[] samplerDescription = new StaticSamplerDescription[4];
            samplerDescription[0] = new StaticSamplerDescription(ShaderVisibility.All, 0, 0)
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Clamp,
                AddressW           = TextureAddressMode.Clamp,
                BorderColor        = StaticBorderColor.OpaqueBlack,
                ComparisonFunction = ComparisonFunction.Never,
                Filter             = Filter.MinMagMipLinear,
                MipLODBias         = 0,
                MaxAnisotropy      = 0,
                MinLOD             = 0,
                MaxLOD             = float.MaxValue,
                ShaderVisibility   = ShaderVisibility.All,
                RegisterSpace      = 0,
                ShaderRegister     = 0,
            };
            samplerDescription[1] = samplerDescription[0];
            samplerDescription[2] = samplerDescription[0];
            samplerDescription[3] = samplerDescription[0];

            samplerDescription[1].ShaderRegister     = 1;
            samplerDescription[2].ShaderRegister     = 2;
            samplerDescription[3].ShaderRegister     = 3;
            samplerDescription[1].MaxAnisotropy      = 16;
            samplerDescription[1].Filter             = Filter.Anisotropic;
            samplerDescription[2].ComparisonFunction = ComparisonFunction.Less;
            samplerDescription[2].Filter             = Filter.ComparisonMinMagMipLinear;
            samplerDescription[3].Filter             = Filter.MinMagMipPoint;

            RootParameter1[] rootParameters = new RootParameter1[types.Count];

            int cbvCount = 0;
            int srvCount = 0;
            int uavCount = 0;

            rootSignature.cbv.Clear();
            rootSignature.srv.Clear();
            rootSignature.uav.Clear();

            for (int i = 0; i < types.Count; i++)
            {
                RootSignatureParamP t = types[i];
                switch (t)
                {
                case RootSignatureParamP.CBV:
                    rootParameters[i]           = new RootParameter1(RootParameterType.ConstantBufferView, new RootDescriptor1(cbvCount, 0), ShaderVisibility.All);
                    rootSignature.cbv[cbvCount] = i;
                    cbvCount++;
                    break;

                case RootSignatureParamP.SRV:
                    rootParameters[i]           = new RootParameter1(RootParameterType.ShaderResourceView, new RootDescriptor1(srvCount, 0), ShaderVisibility.All);
                    rootSignature.srv[srvCount] = i;
                    srvCount++;
                    break;

                case RootSignatureParamP.UAV:
                    rootParameters[i]           = new RootParameter1(RootParameterType.UnorderedAccessView, new RootDescriptor1(uavCount, 0), ShaderVisibility.All);
                    rootSignature.uav[uavCount] = i;
                    uavCount++;
                    break;

                case RootSignatureParamP.CBVTable:
                    rootParameters[i]           = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, cbvCount)), ShaderVisibility.All);
                    rootSignature.cbv[cbvCount] = i;
                    cbvCount++;
                    break;

                case RootSignatureParamP.SRVTable:
                    rootParameters[i]           = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.ShaderResourceView, 1, srvCount)), ShaderVisibility.All);
                    rootSignature.srv[srvCount] = i;
                    srvCount++;
                    break;

                case RootSignatureParamP.UAVTable:
                    rootParameters[i]           = new RootParameter1(new RootDescriptorTable1(new DescriptorRange1(DescriptorRangeType.UnorderedAccessView, 1, uavCount)), ShaderVisibility.All);
                    rootSignature.uav[uavCount] = i;
                    uavCount++;
                    break;
                }
            }

            RootSignatureDescription1 rootSignatureDescription = new RootSignatureDescription1();

            rootSignatureDescription.StaticSamplers = samplerDescription;
            rootSignatureDescription.Flags          = RootSignatureFlags.AllowInputAssemblerInputLayout;
            rootSignatureDescription.Parameters     = rootParameters;

            rootSignature.rootSignature = device.CreateRootSignature <ID3D12RootSignature>(0, rootSignatureDescription);
        }
コード例 #6
0
 public VersionedRootSignatureDescription(RootSignatureDescription1 description)
 {
     Version         = RootSignatureVersion.Version11;
     Description_1_1 = description;
 }