Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0c295c2
Update Perfetto files to include changes made in PR #5348.
m--koma Apr 16, 2026
0de983b
Run clang-format on screenshot.cpp.
m--koma Apr 16, 2026
8a9b212
Write screenshots captured by layer into Perfetto file.
m--koma Apr 16, 2026
d9c2b5d
Fix Windows/MinGW build by linking Winsock for Perfetto.
m--koma Apr 16, 2026
269aa4c
Fix unresolved external symbol for TrackEventDataSource on Windows.
m--koma Apr 16, 2026
3c088f0
Refactor perfetto helpers to be per-layer for screenshots
m--koma Apr 16, 2026
13c89fb
Revert changes to perfetto_helpers to focus on screenshots
m--koma Apr 16, 2026
0be5093
Rename Perfetto category to VulkanScreenshots
m--koma Apr 16, 2026
f57d7c3
Refactor Vulkan screenshot layer: remove boilerplate, rename function…
m--koma Apr 17, 2026
3f0faa6
Mark screenshots as TrackEvent::TYPE_INSTANT.
m--koma Apr 17, 2026
500bf04
Refactor screenshot layer to support dual output (Perfetto + File) an…
m--koma Apr 17, 2026
95b1b45
Refactor screenshot writers, use C++20
m--koma Apr 17, 2026
c0182ee
Fix Windows CI linker error and apply code formatting
m--koma Apr 17, 2026
a462ab9
Early exit ScreenshotDataSource if the write setting is FILE.
m--koma Apr 17, 2026
29e00c5
s/globalScreenshotWriter/screenshotWriter
m--koma Apr 17, 2026
c6d4295
A few clean ups.
m--koma Apr 17, 2026
b34fe6c
Remove explicit screenshot:: namespace and update pause logic
m--koma Apr 17, 2026
8163eb0
Rename updateLayerSettings to controlPause
m--koma Apr 17, 2026
d6d8771
Add atomic store for pauseCapture, and remove isPerfetto() checks
m--koma Apr 17, 2026
461f2d0
Update canControlPause() logic; re-run clang.
m--koma Apr 17, 2026
726cecc
Move imports and ScreenshotQueueData to .cpp file
m--koma Apr 17, 2026
5768066
Reorder headers.
m--koma Apr 17, 2026
d847d98
Merge branch 'main' into perfetto_screenshot_clean
m--koma Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(Qt6_FOUND)
get_target_property(QT_TARGET_TYPE Qt6::Core TYPE)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
7 changes: 7 additions & 0 deletions layersvt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ if(BUILD_SCREENSHOT)
screenshot.cpp
screenshot_parsing.cpp
screenshot_parsing.h
perfetto/perfetto.cc
perfetto/screenshots_perfetto_helpers.cpp
vk_layer_table.cpp
vk_layer_table.h
screenshot_layer.md
Expand Down Expand Up @@ -202,12 +204,17 @@ foreach(layer ${TOOL_LAYERS})
target_link_Libraries(${layer} PRIVATE log android atomic)
endif()

if (WIN32)
Comment thread
m--koma marked this conversation as resolved.
target_link_Libraries(${layer} PRIVATE ws2_32)
endif()

target_include_directories(${layer} PRIVATE .)

if (MSVC)
target_link_options(${layer} PRIVATE /DEF:${CMAKE_CURRENT_SOURCE_DIR}/${layer}.def)
elseif(MINGW)
target_sources(${layer} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${layer}.def)
target_compile_definitions(${layer} PRIVATE uid_t=int)
endif()

if (APPLE)
Expand Down
957 changes: 170 additions & 787 deletions layersvt/perfetto/perfetto.cc

Large diffs are not rendered by default.

2,935 changes: 1,086 additions & 1,849 deletions layersvt/perfetto/perfetto.h

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions layersvt/perfetto/screenshots_perfetto_helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "screenshots_perfetto_helpers.h"
#include <atomic>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <list>

#ifdef ANDROID
#include <android/log.h>
#endif

#include "screenshot_writer.h"

Comment thread
m--koma marked this conversation as resolved.
namespace screenshot {
struct ScreenshotQueueData;
extern std::atomic_bool pauseCapture;
extern std::mutex globalLock;
extern std::condition_variable screenshotSavedCV;
extern std::list<std::shared_ptr<ScreenshotQueueData>> screenshotsData;
} // namespace screenshot

PERFETTO_DEFINE_CATEGORIES(perfetto::Category("VulkanScreenshots").SetDescription("Vulkan Layer Screenshots"));

PERFETTO_TRACK_EVENT_STATIC_STORAGE();

void InitializeScreenshotsPerfetto() {
std::atomic_store(&screenshot::pauseCapture, true);

perfetto::TracingInitArgs args;
// The backends determine where trace events are recorded.
// kSystemBackend connects to the system traced service (e.g. on Android).
args.backends = perfetto::kSystemBackend;

perfetto::Tracing::Initialize(args);
perfetto::TrackEvent::Register();

perfetto::DataSourceDescriptor dsd;
dsd.set_name("VulkanScreenshots");
ScreenshotDataSource::Register(dsd);
}
Comment thread
olehkuznetsov marked this conversation as resolved.

void ScreenshotDataSource::OnStart(const StartArgs&) {
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "screenshot", "ScreenshotDataSource::OnStart called");
#endif
std::atomic_store(&screenshot::pauseCapture, false);
}

void ScreenshotDataSource::OnStop(const StopArgs& args) {
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "screenshot", "ScreenshotDataSource::OnStop called");
#endif

std::atomic_store(&screenshot::pauseCapture, true);
Comment thread
m--koma marked this conversation as resolved.
auto async_stop_closure = args.HandleStopAsynchronously();

Comment thread
m--koma marked this conversation as resolved.
std::thread([stop_closure = std::move(async_stop_closure)]() {
{
std::unique_lock<std::mutex> lock(screenshot::globalLock);
screenshot::screenshotSavedCV.wait(lock, [] { return screenshot::screenshotsData.empty(); });
}

// Explicitly notify Perfetto that this data source is now ready to be destroyed.
stop_closure();
}).detach();
}
14 changes: 14 additions & 0 deletions layersvt/perfetto/screenshots_perfetto_helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H
#define LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H

#include "perfetto.h"

class ScreenshotDataSource : public perfetto::DataSource<ScreenshotDataSource> {
Comment thread
m--koma marked this conversation as resolved.
public:
void OnStart(const StartArgs&) override;
void OnStop(const StopArgs& args) override;
};

void InitializeScreenshotsPerfetto();

#endif // LAYERSVT_SCREENSHOTS_PERFETTO_HELPERS_H
Loading
Loading