示例#1
0
        /// <summary>
        /// Gets blittable values.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public T[] GetValues <T>(ValueParameterKey <T> key) where T : struct
        {
            var parameter = GetAccessor(key);
            var data      = GetValuePointer(parameter);

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

            for (int i = 0; i < values.Length; ++i)
            {
                Utilities.Read(data, ref values[i]);
                data += stride;
            }

            return(values);
        }
示例#2
0
        public override void Serialize(ref ValueParameterKey <T> obj, ArchiveMode mode, SerializationStream stream)
        {
            if (mode == ArchiveMode.Serialize)
            {
                stream.Write(obj.Name);
                stream.Write(obj.Length);
            }
            else
            {
                var parameterName   = stream.ReadString();
                var parameterLength = stream.ReadInt32();
                obj = (ValueParameterKey <T>)ParameterKeys.FindByName(parameterName);

                // If parameter could not be found, create one matching this type.
                if (obj == null)
                {
                    var metadata = new ParameterKeyValueMetadata <T>();
                    obj = new ValueParameterKey <T>(parameterName, parameterLength, metadata);
                    ParameterKeys.Merge(obj, null, parameterName);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Gets a blittable value.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public T Get <T>(ValueParameterKey <T> parameter) where T : struct
 {
     return(Get(GetAccessor(parameter)));
 }
示例#4
0
 /// <summary>
 /// Sets blittable values.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <param name="values"></param>
 public void Set <T>(ValueParameterKey <T> parameter, int count, ref T firstValue) where T : struct
 {
     Set(GetAccessor(parameter, count), count, ref firstValue);
 }
示例#5
0
 /// <summary>
 /// Sets blittable values.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <param name="values"></param>
 public void Set <T>(ValueParameterKey <T> parameter, T[] values) where T : struct
 {
     Set(GetAccessor(parameter, values.Length), values.Length, ref values[0]);
 }
示例#6
0
 /// <summary>
 /// Sets a blittable value.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="parameter"></param>
 /// <param name="value"></param>
 public void Set <T>(ValueParameterKey <T> parameter, ref T value) where T : struct
 {
     Set(GetAccessor(parameter), ref value);
 }
示例#7
0
        /// <summary>
        /// Gets an accessor to get and set blittable values more quickly.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="parameterKey"></param>
        /// <returns></returns>
        public ValueParameter <T> GetAccessor <T>(ValueParameterKey <T> parameterKey, int elementCount = 1) where T : struct
        {
            var accessor = GetValueAccessorHelper(parameterKey, elementCount);

            return(new ValueParameter <T>(accessor.Offset, accessor.Count));
        }