示例#1
0
        /// <summary>
        /// Sets blittable values.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parameter"></param>
        /// <param name="count"></param>
        /// <param name="firstValue"></param>
        public unsafe void Set <T>(ValueParameter <T> parameter, int count, ref T firstValue) where T : struct
        {
            // Align to float4
            var stride       = (Utilities.SizeOf <T>() + 15) / 16 * 16;
            var elementCount = parameter.Count;

            if (count > elementCount)
            {
                throw new IndexOutOfRangeException();
            }

            fixed(byte *dataValues = DataValues)
            {
                var dataPtr = (IntPtr)dataValues + parameter.Offset;

                var value = Interop.Pin(ref firstValue);

                for (int i = 0; i < count; ++i)
                {
                    Utilities.Write(dataPtr, ref value);
                    dataPtr += stride;

                    value = Interop.IncrementPinned(value);
                }
            }
        }
示例#2
0
 /// <summary>
 /// Gets a value.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public unsafe T Get <T>(ValueParameter <T> parameter) where T : struct
 {
     fixed(byte *dataValues = DataValues)
     return(Utilities.Read <T>((IntPtr)dataValues + parameter.Offset));
 }
示例#3
0
 /// <summary>
 /// Sets a blittable value.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <param name="value"></param>
 public unsafe void Set <T>(ValueParameter <T> parameter, ref T value) where T : struct
 {
     fixed(byte *dataValues = DataValues)
     Utilities.Write((IntPtr)dataValues + parameter.Offset, ref value);
 }