Ejemplo n.º 1
0
        /// <summary>
        /// Sets blittable values.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parameter"></param>
        /// <param name="values"></param>
        public void Set <T>(ValueParameter <T> parameter, int count, ref T firstValue) where T : struct
        {
            var data = GetValuePointer(parameter);

            // Align to float4
            var stride       = (Utilities.SizeOf <T>() + 15) / 16 * 16;
            var elementCount = parameter.Count;

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

            var value = Interop.Pin(ref firstValue);

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

                value = Interop.IncrementPinned(value);
            }
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets pointer to directly copy blittable values.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public unsafe IntPtr GetValuePointer <T>(ValueParameter <T> parameter) where T : struct
 {
     fixed(byte *dataValues = DataValues)
     return((IntPtr)dataValues + parameter.Offset);
 }