<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 6/3/19 9:46 AM, Alex Smith wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAD=bm1mU65ofpzhhA6CEe3PbqwtESPWtukJ8VFnv3R3i=0vtLg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">On Sun, 2 Jun 2019 at 11:59, Bas Nieuwenhuizen
          <<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank"
            moz-do-not-send="true">bas@basnieuwenhuizen.nl</a>>
          wrote:<br>
        </div>
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">On Sun, Jun 2, 2019 at
            12:32 PM Alex Smith <<a
              href="mailto:asmith@feralinteractive.com" target="_blank"
              moz-do-not-send="true">asmith@feralinteractive.com</a>>
            wrote:<br>
            ><br>
            > Put the uncached GTT type at a higher index than the
            visible VRAM type,<br>
            > rather than having GTT first.<br>
            ><br>
            > When we don't have dedicated VRAM, we don't have a
            non-visible VRAM<br>
            > type, and the property flags for GTT and visible VRAM
            are identical.<br>
            > According to the spec, for types with identical flags,
            we should give<br>
            > the one with better performance a lower index.<br>
            ><br>
            > Previously, apps which follow the spec guidance for
            choosing a memory<br>
            > type would have picked the GTT type in preference to
            visible VRAM (all<br>
            > Feral games will do this), and end up with lower
            performance.<br>
            ><br>
            > On a Ryzen 5 2500U laptop (Raven Ridge), this improves
            average FPS in<br>
            > the Rise of the Tomb Raider benchmark by up to ~30%.
            Tested a couple of<br>
            > other (Feral) games and saw similar improvement on
            those as well.<br>
            ><br>
            > Signed-off-by: Alex Smith <<a
              href="mailto:asmith@feralinteractive.com" target="_blank"
              moz-do-not-send="true">asmith@feralinteractive.com</a>><br>
            > ---<br>
            > I noticed that the memory types advertised on my Raven
            laptop looked a<br>
            > bit odd so played around with it and found this. I'm
            not sure if it is<br>
            > actually expected that the performance difference
            between visible VRAM<br>
            > and GTT is so large, seeing as it's not dedicated VRAM,
            but the results<br>
            > are clear (and consistent, tested multiple times).<br>
            <br>
            AFAIU it is still using different memory paths, with GTT
            using<br>
            different pagetables (those from the CPU I believe on APUs)
            and<br>
            possible CPU snooping.<br>
            <br>
            Main risk here seems applications pushing out driver
            internal stuff<br>
            (descriptor sets etc.) from "VRAM", posssibly hitting perf
            elsewhere.<br>
          </blockquote>
          <div><br>
          </div>
          <div>Driver internal allocations have higher BO priorities
            than all app allocations, wouldn't that help avoid that? I'm
            not sure how much effect the priorities actually have...</div>
        </div>
      </div>
    </blockquote>
    Priorities shouldn't matter much.<br>
    <blockquote type="cite"
cite="mid:CAD=bm1mU65ofpzhhA6CEe3PbqwtESPWtukJ8VFnv3R3i=0vtLg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            That said,<br>
            <br>
            Reviewed-by: Bas Nieuwenhuizen <<a
              href="mailto:bas@basnieuwenhuizen.nl" target="_blank"
              moz-do-not-send="true">bas@basnieuwenhuizen.nl</a>><br>
            <br>
            > ---<br>
            >  src/amd/vulkan/radv_device.c | 18 +++++++++++++++---<br>
            >  1 file changed, 15 insertions(+), 3 deletions(-)<br>
            ><br>
            > diff --git a/src/amd/vulkan/radv_device.c
            b/src/amd/vulkan/radv_device.c<br>
            > index 3cf050ed220..d36ee226ebd 100644<br>
            > --- a/src/amd/vulkan/radv_device.c<br>
            > +++ b/src/amd/vulkan/radv_device.c<br>
            > @@ -171,12 +171,11 @@
            radv_physical_device_init_mem_types(struct
            radv_physical_device *device)<br>
            >                         .heapIndex = vram_index,<br>
            >                 };<br>
            >         }<br>
            > -       if (gart_index >= 0) {<br>
            > +       if (gart_index >= 0 &&
            device->rad_info.has_dedicated_vram) {<br>
            >                 device->mem_type_indices[type_count]
            = RADV_MEM_TYPE_GTT_WRITE_COMBINE;<br>
            >               
             device->memory_properties.memoryTypes[type_count++] =
            (VkMemoryType) {<br>
            >                         .propertyFlags =
            VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |<br>
            > -                     
             VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |<br>
            > -                     
             (device->rad_info.has_dedicated_vram ? 0 :
            VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT),<br>
            > +                     
             VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,<br>
            >                         .heapIndex = gart_index,<br>
            >                 };<br>
            >         }<br>
            > @@ -189,6 +188,19 @@
            radv_physical_device_init_mem_types(struct
            radv_physical_device *device)<br>
            >                         .heapIndex =
            visible_vram_index,<br>
            >                 };<br>
            >         }<br>
            > +       if (gart_index >= 0 &&
            !device->rad_info.has_dedicated_vram) {<br>
            > +               /* Put GTT after visible VRAM for GPUs
            without dedicated VRAM<br>
            > +                * as they have identical property
            flags, and according to the<br>
            > +                * spec, for types with identical
            flags, the one with greater<br>
            > +                * performance must be given a lower
            index. */<br>
            > +               device->mem_type_indices[type_count]
            = RADV_MEM_TYPE_GTT_WRITE_COMBINE;<br>
            > +             
             device->memory_properties.memoryTypes[type_count++] =
            (VkMemoryType) {<br>
            > +                       .propertyFlags =
            VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |<br>
            > +                     
             VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |<br>
            > +                     
             VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,<br>
            > +                       .heapIndex = gart_index,<br>
            > +               };<br>
            > +       }<br>
            >         if (gart_index >= 0) {<br>
            >                 device->mem_type_indices[type_count]
            = RADV_MEM_TYPE_GTT_CACHED;<br>
            >               
             device->memory_properties.memoryTypes[type_count++] =
            (VkMemoryType) {<br>
            > --<br>
            > 2.21.0<br>
            ><br>
            > _______________________________________________<br>
            > mesa-dev mailing list<br>
            > <a href="mailto:mesa-dev@lists.freedesktop.org"
              target="_blank" moz-do-not-send="true">mesa-dev@lists.freedesktop.org</a><br>
            > <a
              href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev"
              rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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>
  </body>
</html>