From a6211ef1da130a7cc01bec7d23042edb19826012 Mon Sep 17 00:00:00 2001
From: Ludovico de Nittis <ludovico.denittis@collabora.com>
Date: Thu, 11 Feb 2021 11:10:50 +0100
Subject: [PATCH] graphics: Parse Vulkan layers from a report in the right
 order

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
---
 steam-runtime-tools/graphics.c        |  2 +-
 tests/json-report/partial-report.json | 20 ++++++++++++++++++++
 tests/system-info.c                   | 21 +++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c
index 619250109..0038e2c10 100644
--- a/steam-runtime-tools/graphics.c
+++ b/steam-runtime-tools/graphics.c
@@ -7111,7 +7111,7 @@ get_driver_loadables_from_json_report (JsonObject *json_obj,
         }
     }
 out:
-  return driver_info;
+  return g_list_reverse (driver_info);
 }
 
 /**
diff --git a/tests/json-report/partial-report.json b/tests/json-report/partial-report.json
index a76188cef..2cfd6d989 100644
--- a/tests/json-report/partial-report.json
+++ b/tests/json-report/partial-report.json
@@ -62,6 +62,26 @@
         "error" : "Something went wrong"
       }
     ],
+    "explicit_layers" : [
+      {
+        "json_path" : "/usr/share/vulkan/explicit_layer.d/VkLayer_MESA_overlay.json",
+        "name": "VK_LAYER_MESA_overlay",
+        "description": "Mesa Overlay layer",
+        "type": "GLOBAL",
+        "api_version" : "1.1.73",
+        "implementation_version": "1",
+        "library_path" : "libVkLayer_MESA_overlay.so"
+      },
+      {
+        "json_path" : "/usr/share/vulkan/explicit_layer.d/VkLayer_new.json",
+        "name": "VK_LAYER_MESA_overlay",
+        "description": "Mesa Overlay layer",
+        "type": "GLOBAL",
+        "api_version" : "1.1.73",
+        "implementation_version": "1",
+        "library_path" : "/usr/lib/libVkLayer_MESA_overlay.so"
+      }
+    ],
     "implicit_layers" : [
       {
         "json_path" : "/usr/share/vulkan/implicit_layer.d/MangoHud.json",
diff --git a/tests/system-info.c b/tests/system-info.c
index 8c99e03d6..9235c0de5 100644
--- a/tests/system-info.c
+++ b/tests/system-info.c
@@ -3094,6 +3094,27 @@ static const JsonTest json_test[] =
         .error_message = "Something went wrong",
       },
     },
+    .vulkan_explicit_layer =
+    {
+      {
+        .json_path = "/usr/share/vulkan/explicit_layer.d/VkLayer_MESA_overlay.json",
+        .name = "VK_LAYER_MESA_overlay",
+        .description = "Mesa Overlay layer",
+        .type = "GLOBAL",
+        .api_version = "1.1.73",
+        .implementation_version = "1",
+        .library_path = "libVkLayer_MESA_overlay.so",
+      },
+      {
+        .json_path = "/usr/share/vulkan/explicit_layer.d/VkLayer_new.json",
+        .name = "VK_LAYER_MESA_overlay",
+        .description = "Mesa Overlay layer",
+        .type = "GLOBAL",
+        .api_version = "1.1.73",
+        .implementation_version = "1",
+        .library_path = "/usr/lib/libVkLayer_MESA_overlay.so",
+      },
+    },
     .vulkan_implicit_layer =
     {
       {
-- 
GitLab