/// <summary>
 /// Initializes a new instance of the <see cref="RootSignatureDescription1"/> class.
 /// </summary>
 /// <param name="flags">The flags.</param>
 /// <param name="parameters">The parameters.</param>
 /// <param name="samplers">The samplers.</param>
 public RootSignatureDescription1(RootSignatureFlags flags, RootParameter1[] parameters = null, StaticSamplerDescription[] samplers = null)
 {
     Parameters = parameters;
     StaticSamplers = samplers;
     Flags = flags;
 }
        private unsafe void Deserialize(IntPtr pNativePtr)
        {
            if(pNativePtr == IntPtr.Zero)
            {
                return;
            }

            __Native* pNative = (__Native*)pNativePtr;

            if (pNative->ParameterCount > 0)
            {
                Parameters = new RootParameter1[pNative->ParameterCount];
                RootParameter1.__Native* rpn = (RootParameter1.__Native * ) pNative->ParametersPointer;
                for (int i = 0; i < Parameters.Length; ++i)
                {
                    Parameters[i] = new RootParameter1();
                    if (rpn[i].ParameterType == RootParameterType.DescriptorTable)
                    {
                        // Marshal descriptor table
                        DescriptorRange[] ranges = null;

                        int rangeCount = rpn[i].Union.DescriptorTable.DescriptorRangeCount;
                        if (rangeCount > 0)
                        {
                            ranges = new DescriptorRange[rangeCount];
                            Utilities.Read(rpn[i].Union.DescriptorTable.DescriptorRangesPointer, ranges, 0, ranges.Length);
                        }

                        Parameters[i] = new RootParameter1(rpn[i].ShaderVisibility, ranges);
                    }
                    else
                    {
                        // No need to marshal them when RootParameter don't contain DescriptorTable - simple copy as-is
                        Parameters[i] = new RootParameter1 {native = *rpn};
                    }
                }
            }
             
            if (pNative->StaticSamplerCount > 0)
            {
                StaticSamplers = new StaticSamplerDescription[pNative->StaticSamplerCount];
                Utilities.Read(pNative->StaticSamplerPointer, StaticSamplers, 0, StaticSamplers.Length);
            }
        }