From ac9d72a95ca9a60de8d39484a14aecf489d6d016 Mon Sep 17 00:00:00 2001
From: Wunk <wunkolo@gmail.com>
Date: Wed, 1 Nov 2023 13:30:54 -0700
Subject: [PATCH] vk_texture_runtime: Fix debug scope label lambda-capture
 (#7102)

`DebugScope` was capturing a `string_view` in a lambda which is only
valid during the scope of this ctor. When the lambda gets invoked at a
later time, it will read undefined garbage. The lambda needs to make a
deep copy of this `string_view` into a `string` so that it is valid by
the time the scheduler invokes this lambda.
---
 src/video_core/renderer_vulkan/vk_texture_runtime.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp
index 4dc222c1e..bff700969 100644
--- a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp
@@ -1562,7 +1562,7 @@ DebugScope::DebugScope(TextureRuntime& runtime, Common::Vec4f color, std::string
     if (!has_debug_tool) {
         return;
     }
-    scheduler.Record([color, label](vk::CommandBuffer cmdbuf) {
+    scheduler.Record([color, label = std::string(label)](vk::CommandBuffer cmdbuf) {
         const vk::DebugUtilsLabelEXT debug_label = {
             .pLabelName = label.data(),
             .color = std::array{color[0], color[1], color[2], color[3]},