internal ExtensionRequiredAttribute(VkExtension ext)
 {
     Extension = ext;
 }
Example #2
0
 /// <summary>
 /// Checks if the given extension is enabled on this device.
 /// </summary>
 /// <param name="ext"></param>
 /// <returns></returns>
 public bool ExtensionEnabled(VkExtension ext)
 {
     return(_enabledExtensions.Contains(ext));
 }
 public static ExtensionDescriptionAttribute Extension(VkExtension id)
 {
     return(_defById[(int)id]);
 }
Example #4
0
        private void ReadExtension(XElement e)
        {
            string name = e.Attribute("name")?.Value;

            Debug.Assert(name != null);
            string numberStr = e.Attribute("number")?.Value;

            Debug.Assert(int.TryParse(numberStr, out int number));
            var requiresExtensions = e.Attribute("requires")?.Value?.Split(',');

            var extension = new VkExtension(name, e.Attribute("type")?.Value, e.Attribute("comment")?.Value, number,
                                            requiresExtensions ?? new string[0]);

            foreach (var req in e.Elements("require"))
            {
                foreach (var en in req.Elements("enum"))
                {
                    var cname = en.Attribute("name")?.Value;
                    Debug.Assert(cname != null);
                    var        extends        = en.Attribute("extends")?.Value;
                    var        offset         = en.Attribute("offset")?.Value;
                    var        dir            = en.Attribute("dir")?.Value ?? "+";
                    var        value          = en.Attribute("value")?.Value;
                    var        bitpos         = en.Attribute("bitpos")?.Value;
                    var        comment        = en.Attribute("comment")?.Value;
                    var        valueWasString = false;
                    VkConstant cstType;
                    if (bitpos == null && value == null)
                    {
                        if (offset != null)
                        {
                            Debug.Assert(dir == "+" || dir == "-");
                            value = (ExtBase + (ExtBlockSize * (number - 1)) + int.Parse(offset)).ToString();
                            if (dir == "-")
                            {
                                value = "-(" + value + ")";
                            }
                        }
                        else
                        {
                            cstType = _spec.Constants[cname];
                            extension.ProvidedConstants.Add(cstType);
                            continue;
                        }
                    }
                    if (value != null && value.StartsWith("\"") && value.EndsWith("\""))
                    {
                        value          = value.Substring(1, value.Length - 2);
                        valueWasString = true;
                    }
                    if (bitpos != null)
                    {
                        cstType = VkConstant.AsBitPosition(cname, comment, bitpos);
                    }
                    else
                    {
                        Debug.Assert(value != null);
                        cstType = VkConstant.AsValue(cname, comment, value);
                    }
                    if (extends != null)
                    {
                        var enumType = (VkEnum)_spec.TypeDefs[extends];
                        ((IList <VkConstant>)enumType.Values).Add(cstType);
                    }
                    else if (cstType.Name.EndsWith("_EXTENSION_NAME", StringComparison.OrdinalIgnoreCase))
                    {
                        extension.Name = value;
                        continue;
                    }
                    else if (cstType.Name.EndsWith("_SPEC_VERSION", StringComparison.OrdinalIgnoreCase))
                    {
                        extension.Version = long.Parse(value);
                        continue;
                    }
                    if (!valueWasString)
                    {
                        _spec.Add(cstType);
                        extension.ProvidedConstants.Add(cstType);
                    }
                }
                foreach (var en in req.Elements("type"))
                {
                    extension.ProvidedTypes.Add(_spec.TypeDefs[en.Attribute("name")?.Value]);
                }
                foreach (var en in req.Elements("command"))
                {
                    extension.ProvidedTypes.Add((VkCommand)_spec.TypeDefs[en.Attribute("name")?.Value]);
                }
            }
            _spec.Add(extension);
        }