From 2f57a35d2da89f98a5847da570365939957384b8 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Tue, 22 Apr 2025 16:57:57 +1000 Subject: [PATCH] video_core/vulkan: Fix callback variable shadowing in async shader compilation Resolves a variable shadowing issue in AsyncCompileShader where the callback lambda parameter was shadowing the outer callback variable. This was causing compilation warnings/errors in Android Studio. The fix: - Renames the outer callback variable to 'outer_callback' - Renames the inner lambda callback parameters to 'inner_callback' - Maintains consistent naming across all error handling paths This change improves code clarity and eliminates compiler warnings while maintaining the same functionality for async shader compilation. Signed-off-by: Zephyron --- .../renderer_vulkan/vk_shader_util.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_shader_util.cpp b/src/video_core/renderer_vulkan/vk_shader_util.cpp index c2d365411..cef1cc77f 100644 --- a/src/video_core/renderer_vulkan/vk_shader_util.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_util.cpp @@ -171,7 +171,7 @@ void AsyncCompileShader(const Device& device, const std::string& shader_path, } // Use actual threading for async compilation - std::thread([device_ptr = &device, shader_path, callback = std::move(callback)]() mutable { + std::thread([device_ptr = &device, shader_path, outer_callback = std::move(callback)]() mutable { auto startTime = std::chrono::high_resolution_clock::now(); try { @@ -215,25 +215,25 @@ void AsyncCompileShader(const Device& device, const std::string& shader_path, VkShaderModule raw_module = *shader; // Submit callback to main thread via command queue for thread safety - SubmitCommandToQueue([callback = std::move(callback), raw_module]() { - callback(raw_module); + SubmitCommandToQueue([inner_callback = std::move(outer_callback), raw_module]() { + inner_callback(raw_module); }); } else { LOG_ERROR(Render_Vulkan, "Shader validation failed: {}", shader_path); - SubmitCommandToQueue([callback = std::move(callback)]() { - callback(VK_NULL_HANDLE); + SubmitCommandToQueue([inner_callback = std::move(outer_callback)]() { + inner_callback(VK_NULL_HANDLE); }); } } else { LOG_ERROR(Render_Vulkan, "Failed to read shader file: {}", shader_path); - SubmitCommandToQueue([callback = std::move(callback)]() { - callback(VK_NULL_HANDLE); + SubmitCommandToQueue([inner_callback = std::move(outer_callback)]() { + inner_callback(VK_NULL_HANDLE); }); } } catch (const std::exception& e) { LOG_ERROR(Render_Vulkan, "Error compiling shader: {}", e.what()); - SubmitCommandToQueue([callback = std::move(callback)]() { - callback(VK_NULL_HANDLE); + SubmitCommandToQueue([inner_callback = std::move(outer_callback)]() { + inner_callback(VK_NULL_HANDLE); }); }