public static IEnumerable <D3DXCONSTANT_DESC> GetConstantDesc(
            this ID3DXConstantTable contantTable,
            IntPtr constantHandle)
        {
            VerifyNonNullArgument(
                contantTable,
                "contantTable");

            uint count = 0;

            if (Succeeded(
                    contantTable.GetConstantDesc(
                        constantHandle,
                        null,
                        ref count)))
            {
                var array = new D3DXCONSTANT_DESC[count];
                if (Succeeded(
                        contantTable.GetConstantDesc(
                            constantHandle,
                            array,
                            ref count)))
                {
                    return(array.Take((int)count));
                }
            }
            return(Enumerable.Empty <D3DXCONSTANT_DESC>());
        }
        public static ConstantInfo ToConstantInfo(this D3DXCONSTANT_DESC desc)
        {
            var info = new ConstantInfo
            {
                Name          = desc.Name.ReadAsAnsiString(),
                RegisterSet   = desc.RegisterSet.ToRegisterSet(),
                RegisterIndex = (int)desc.RegisterIndex,
                RegisterCount = (int)desc.RegisterCount,
                Class         = desc.Class.ToParameterClass(),
                Type          = desc.Type.ToParameterType(),
                Rows          = (int)desc.Rows,
                Columns       = (int)desc.Columns,
                Elements      = (int)desc.Elements,
                StructMembers = (int)desc.StructMembers,
                Bytes         = (int)desc.Bytes,
            };

            if (desc.DefaultValue != IntPtr.Zero)
            {
                info.DefaultValue = new byte[desc.Bytes];
                Marshal.Copy(
                    desc.DefaultValue,
                    info.DefaultValue,
                    0,
                    (int)desc.Bytes);
            }

            return(info);
        }