示例#1
0
文件: VFXData.cs 项目: Audaxxy/Blight
        public VFXAttributeMode GetAttributeMode(VFXAttribute attrib)
        {
            VFXAttributeMode mode = VFXAttributeMode.None;
            Dictionary <VFXContext, VFXAttributeMode> contexts;

            if (m_AttributesToContexts.TryGetValue(attrib, out contexts))
            {
                foreach (var context in contexts)
                {
                    mode |= context.Value;
                }
            }

            return(mode);
        }
示例#2
0
        private string GetByteAddressBufferMethodSuffix(VFXAttribute attrib)
        {
            int size = VFXExpression.TypeToSize(attrib.type);

            if (size == 1)
            {
                return(string.Empty);
            }
            else if (size <= 4)
            {
                return(size.ToString());
            }
            else
            {
                throw new ArgumentException(string.Format("Attribute {0} of type {1} cannot be handled in ByteAddressBuffer due to its size of {2}", attrib.name, attrib.type, size));
            }
        }
示例#3
0
文件: VFXData.cs 项目: Audaxxy/Blight
        public VFXAttributeMode GetAttributeMode(VFXAttribute attrib, VFXContext context)
        {
            Dictionary <VFXContext, VFXAttributeMode> contexts;

            if (m_AttributesToContexts.TryGetValue(attrib, out contexts))
            {
                foreach (var c in contexts)
                {
                    if (c.Key == context)
                    {
                        return(c.Value);
                    }
                }
            }

            return(VFXAttributeMode.None);
        }
示例#4
0
        public override string GetLoadAttributeCode(VFXAttribute attrib, VFXAttributeLocation location)
        {
            var attributeStore  = location == VFXAttributeLocation.Current ? m_layoutAttributeCurrent : m_layoutAttributeSource;
            var attributeBuffer = location == VFXAttributeLocation.Current ? "attributeBuffer" : "sourceAttributeBuffer";
            var index           = location == VFXAttributeLocation.Current ? "index" : "sourceIndex";

            if (location == VFXAttributeLocation.Current && !m_StoredCurrentAttributes.ContainsKey(attrib))
            {
                throw new ArgumentException(string.Format("Attribute {0} does not exist in data layout", attrib.name));
            }

            if (location == VFXAttributeLocation.Source && !m_ReadSourceAttributes.Any(a => a.name == attrib.name))
            {
                throw new ArgumentException(string.Format("Attribute {0} does not exist in data layout", attrib.name));
            }

            return(string.Format("{0}({3}.Load{1}({2}))", GetCastAttributePrefix(attrib), GetByteAddressBufferMethodSuffix(attrib), attributeStore.GetCodeOffset(attrib, index), attributeBuffer));
        }
        static private VFXShaderWriter GenerateComputeSourceIndex(VFXContext context)
        {
            var r = new VFXShaderWriter();
            var spawnCountAttribute = new VFXAttribute("spawnCount", VFXValueType.Float);

            if (!context.GetData().dependenciesIn.Any())
            {
                var spawnLinkCount = context.GetData().sourceCount;
                r.WriteLine("int sourceIndex = 0;");

                if (spawnLinkCount <= 1)
                {
                    r.WriteLine("/*//Loop with 1 iteration generate a wrong IL Assembly (and actually, useless code)");
                }

                r.WriteLine("uint currentSumSpawnCount = 0u;");
                r.WriteLineFormat("for (sourceIndex=0; sourceIndex<{0}; sourceIndex++)", spawnLinkCount);
                r.EnterScope();
                r.WriteLineFormat("currentSumSpawnCount += uint({0});", context.GetData().GetLoadAttributeCode(spawnCountAttribute, VFXAttributeLocation.Source));
                r.WriteLine("if (id < currentSumSpawnCount)");
                r.EnterScope();
                r.WriteLine("break;");
                r.ExitScope();
                r.ExitScope();

                if (spawnLinkCount <= 1)
                {
                    r.WriteLine("*/");
                }
            }
            else
            {
                /* context invalid or GPU event */
            }
            return(r);
        }
示例#6
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsSourceAttributeUsed(VFXAttribute attrib)
 {
     return((GetAttributeMode(attrib) & VFXAttributeMode.ReadSource) != 0);
 }
示例#7
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsCurrentAttributeUsed(VFXAttribute attrib, VFXContext context)
 {
     return((GetAttributeMode(attrib, context) & VFXAttributeMode.ReadWrite) != 0);
 }
示例#8
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsCurrentAttributeUsed(VFXAttribute attrib)
 {
     return((GetAttributeMode(attrib) & VFXAttributeMode.ReadWrite) != 0);
 }
 public VFXAttributeInfo(VFXAttribute attrib, VFXAttributeMode mode)
 {
     this.attrib = attrib;
     this.mode   = mode;
 }
示例#10
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public abstract string GetLoadAttributeCode(VFXAttribute attrib, VFXAttributeLocation location);
示例#11
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsAttributeStored(VFXAttribute attrib)
 {
     return(m_StoredCurrentAttributes.ContainsKey(attrib));
 }
示例#12
0
 public override string GetStoreAttributeCode(VFXAttribute attrib, string value)
 {
     throw new NotImplementedException();
 }
示例#13
0
 public override string GetLoadAttributeCode(VFXAttribute attrib, VFXAttributeLocation location)
 {
     throw new NotImplementedException();
 }
        protected override VFXExpression[] BuildExpression(VFXExpression[] inputExpression)
        {
            var attribute = VFXAttribute.Find(this.attribute);

            if (attribute.variadic == VFXVariadic.True)
            {
                var attributes  = new VFXAttribute[] { VFXAttribute.Find(attribute.name + "X"), VFXAttribute.Find(attribute.name + "Y"), VFXAttribute.Find(attribute.name + "Z") };
                var expressions = attributes.Select(a => new VFXAttributeExpression(a, location)).ToArray();

                var componentStack = new Stack <VFXExpression>();
                int outputSize     = mask.Length;
                for (int iComponent = 0; iComponent < outputSize; iComponent++)
                {
                    char componentChar    = char.ToLower(mask[iComponent]);
                    int  currentComponent = Math.Min(componentChar - 'x', 2);
                    componentStack.Push(expressions[currentComponent]);
                }

                VFXExpression finalExpression = null;
                if (componentStack.Count == 1)
                {
                    finalExpression = componentStack.Pop();
                }
                else
                {
                    finalExpression = new VFXExpressionCombine(componentStack.Reverse().ToArray());
                }
                return(new[] { finalExpression });
            }
            else
            {
                var expression = new VFXAttributeExpression(attribute, location);
                return(new VFXExpression[] { expression });
            }
        }
 public VFXAttributeExpression(VFXAttribute attribute, VFXAttributeLocation location = VFXAttributeLocation.Current) : base(Flags.PerElement)
 {
     m_attribute         = attribute;
     m_attributeLocation = location;
 }
示例#16
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsSourceAttributeUsed(VFXAttribute attrib, VFXContext context)
 {
     return((GetAttributeMode(attrib, context) & VFXAttributeMode.ReadSource) != 0);
 }
示例#17
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsAttributeLocal(VFXAttribute attrib)
 {
     return(m_LocalCurrentAttributes.Contains(attrib));
 }
示例#18
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsCurrentAttributeWritten(VFXAttribute attrib)
 {
     return((GetAttributeMode(attrib) & VFXAttributeMode.Write) != 0);
 }
示例#19
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsCurrentAttributeWritten(VFXAttribute attrib, VFXContext context)
 {
     return((GetAttributeMode(attrib, context) & VFXAttributeMode.Write) != 0);
 }
示例#20
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsAttributeUsed(VFXAttribute attrib)
 {
     return(GetAttributeMode(attrib) != VFXAttributeMode.None);
 }
示例#21
0
文件: VFXData.cs 项目: Audaxxy/Blight
 protected bool HasImplicitInit(VFXAttribute attrib)
 {
     return(attrib.Equals(VFXAttribute.Seed) || attrib.Equals(VFXAttribute.ParticleId));
 }
示例#22
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public bool IsAttributeUsed(VFXAttribute attrib, VFXContext context)
 {
     return(GetAttributeMode(attrib, context) != VFXAttributeMode.None);
 }
示例#23
0
文件: VFXData.cs 项目: Audaxxy/Blight
 public abstract string GetStoreAttributeCode(VFXAttribute attrib, string value);
示例#24
0
 public VFXReadEventAttributeExpression(VFXAttribute attribute, UInt32 elementOffset) : base(Flags.PerSpawn | Flags.InvalidOnGPU)
 {
     m_attribute     = attribute;
     m_elementOffset = elementOffset;
 }