<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 01/08/17 23:32, Jason Ekstrand
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOFGe95RVvbHqubJ1=9S9Gax92vcqwYxgPhUw8kg=7co2f9rig@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Tue, Aug 1, 2017 at 2:07 PM,
            Lionel Landwerlin <span dir="ltr"><<a
                href="mailto:lionel.g.landwerlin@intel.com"
                target="_blank" moz-do-not-send="true">lionel.g.landwerlin@intel.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5">On 01/08/17 19:54, Jason Ekstrand wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    The VkVersion class is probably overkill but it
                    makes it really easy to<br>
                    compare versions in a way that's safe without the
                    caller having to think<br>
                    about patch vs. no patch.<br>
                    ---<br>
                      src/intel/vulkan/anv_entrypoin<wbr>ts_gen.py |  4
                    +--<br>
                      src/intel/vulkan/anv_extension<wbr>s.py      | 43
                    ++++++++++++++++++++++++++++++<wbr>+++<br>
                      2 files changed, 44 insertions(+), 3 deletions(-)<br>
                    <br>
                    diff --git a/src/intel/vulkan/anv_entrypo<wbr>ints_gen.py
                    b/src/intel/vulkan/anv_entrypo<wbr>ints_gen.py<br>
                    index 9177a94..f5c527e 100644<br>
                    --- a/src/intel/vulkan/anv_entrypo<wbr>ints_gen.py<br>
                    +++ b/src/intel/vulkan/anv_entrypo<wbr>ints_gen.py<br>
                    @@ -32,8 +32,6 @@ from mako.template import Template<br>
                        from anv_extensions import *<br>
                      -MAX_API_VERSION = 1.0<br>
                    -<br>
                      # We generate a static hash table for entry point
                    lookup<br>
                      # (vkGetProcAddress). We use a linear congruential
                    generator for our hash<br>
                      # function and a power-of-two size table. The
                    prime numbers are determined<br>
                    @@ -262,7 +260,7 @@ def get_entrypoints(doc,
                    entrypoints_to_defines):<br>
                          enabled_commands = set()<br>
                          for feature in doc.findall('./feature'):<br>
                              assert feature.attrib['api'] == 'vulkan'<br>
                    -        if float(feature.attrib['number']<wbr>)
                    > MAX_API_VERSION:<br>
                    +        if VkVersion(feature.attrib['numb<wbr>er'])
                    > MAX_API_VERSION:<br>
                                  continue<br>
                                for command in
                    feature.findall('./require/com<wbr>mand'):<br>
                    diff --git a/src/intel/vulkan/anv_extensi<wbr>ons.py
                    b/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
                    index 0d243c6..7307cac 100644<br>
                    --- a/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
                    +++ b/src/intel/vulkan/anv_extensi<wbr>ons.py<br>
                    @@ -25,10 +25,14 @@ COPYRIGHT = """\<br>
                      """<br>
                        import argparse<br>
                    +import copy<br>
                    +import re<br>
                      import xml.etree.cElementTree as et<br>
                        from mako.template import Template<br>
                      +MAX_API_VERSION = '1.0.54'<br>
                    +<br>
                      class Extension:<br>
                          def __init__(self, name, ext_version, enable):<br>
                              <a href="http://self.name"
                      rel="noreferrer" target="_blank"
                      moz-do-not-send="true">self.name</a> = name<br>
                    @@ -64,6 +68,45 @@ EXTENSIONS = [<br>
                          Extension('VK_KHX_multiview',                 
                           1, True),<br>
                      ]<br>
                      +class VkVersion:<br>
                    +    def __init__(self, string):<br>
                    +        split = string.split('.')<br>
                    +        self.major = int(split[0])<br>
                    +        self.minor = int(split[1])<br>
                    +        if len(split) > 2:<br>
                    +            assert len(split) == 3<br>
                    +            self.patch = int(split[2])<br>
                    +        else:<br>
                    +            self.patch = None<br>
                    +<br>
                    +        # Sanity check.  The range bits are
                    required by the definition of the<br>
                    +        # VK_MAKE_VERSION macro<br>
                    +        assert self.major < 1024 and self.minor
                    < 1024<br>
                    +        assert self.patch is None or self.patch
                    < 4096<br>
                    +        assert(str(self) == string)<br>
                    +<br>
                    +    def __str__(self):<br>
                    +        ver_list = [str(self.major),
                    str(self.minor)]<br>
                    +        if self.patch is not None:<br>
                    +            ver_list.append(str(self.patch<wbr>))<br>
                    +        return '.'.join(ver_list)<br>
                    +<br>
                    +    def __int_ver(self):<br>
                    +        # This is just an expansion of VK_VERSION<br>
                    +        patch = self.patch if self.patch is not
                    None else 0<br>
                    +        return (self.major << 22) |
                    (self.minor << 12) | patch<br>
                    +<br>
                    +    def __cmp__(self, other):<br>
                    +        # If only one of them has a patch version,
                    "ignore" it by making<br>
                    +        # other's patch version match self.<br>
                    +        if (self.patch is None) != (other.patch is
                    None):<br>
                    +            other = copy.copy(other)<br>
                    +            other.patch = self.patch<br>
                    +<br>
                    +        return self.__int_ver().__cmp__(other<wbr>.__int_ver())<br>
                    +<br>
                    +MAX_API_VERSION = VkVersion(MAX_API_VERSION)<br>
                  </blockquote>
                  <br>
                </div>
              </div>
              Why not just MAX_API_VERSION = VkVersion('1.0.54') ?<br>
            </blockquote>
            <div><br>
            </div>
            <div>Because I wanted the obvious declaration
              MAX_API_VERSION to go as high up in the file as possible
              for readability.  VkVersion is an annoyingly complicated
              class and I didn't want it cluttering the top of the
              file.  The end result is this little bit of uglyness.  I'm
              not sure if it was worth it.<br>
              <br>
            </div>
            <div>--Jason<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Alright, I thought maybe I was missing something :<br>
    <br>
    Reviewed-by: Lionel Landwerlin <a class="moz-txt-link-rfc2396E" href="mailto:lionel.g.landwerlin@intel.com"><lionel.g.landwerlin@intel.com></a><br>
    <br>
    <blockquote type="cite"
cite="mid:CAOFGe95RVvbHqubJ1=9S9Gax92vcqwYxgPhUw8kg=7co2f9rig@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div class="HOEnZb">
                <div class="h5">
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    +<br>
                      def _init_exts_from_xml(xml):<br>
                          """ Walk the Vulkan XML and fill out extra
                    extension information. """<br>
                      <br>
                  </blockquote>
                  <br>
                  <br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
mesa-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>