### Post-Initialization Setup Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Performs setup after all components have been loaded. This is a crucial step for ensuring the backend is fully ready for operation. ```cpp pBackend->PostInit(); ``` -------------------------------- ### Example: wl_surface_interface Implementation Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example showing how to use WL_PROTO() to dispatch Wayland events to member functions. ```cpp static const struct wl_surface_interface Implementation = { .attach = WL_PROTO(MySurface, OnAttach), .commit = WL_PROTO(MySurface, OnCommit), }; ``` -------------------------------- ### Example: wl_compositor_interface Implementation Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example showing how to use WL_PROTO_DESTROY() for the destroy handler in a Wayland interface implementation. ```cpp static const struct wl_compositor_interface Implementation = { .destroy = WL_PROTO_DESTROY(), // Auto calls wl_resource_destroy }; ``` -------------------------------- ### CBaseBackendFb Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example usage of the CBaseBackendFb implementation, demonstrating its initialization and buffer management capabilities with reference counting. ```APIDOC ## CBaseBackendFb Usage Example ### Description Basic framebuffer implementation with reference counting. ### Example ```cpp auto fb = std::make_shared(); fb->SetBuffer(clientBuffer); fb->SetReleasePoint(releasePoint); // Use fb for presentation... // Auto-released when shared_ptr goes out of scope ``` ``` -------------------------------- ### PostInit() Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Performs post-initialization setup after all components have been loaded. Returns a boolean indicating success. ```APIDOC ## PostInit() ### Description Post-initialization setup after all components are loaded. ### Method ```cpp virtual bool PostInit() = 0; ``` ### Returns `bool` - True if post-initialization succeeded. ### Example ```cpp pBackend->PostInit(); ``` ``` -------------------------------- ### Example: Defining a Wayland Resource Class Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example of defining a Wayland resource class using WL_PROTO_DEFINE() and inheriting constructors. ```cpp class MySurface : public CWaylandResource { WL_PROTO_DEFINE(wl_surface, 4) // ... }; class MySurface : public CWaylandResource { WL_PROTO_DEFAULT_CONSTRUCTOR() // ... }; ``` -------------------------------- ### Get Available Display Modes Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves a list of available display modes for the connector. The example shows how to iterate through modes and print their resolution and refresh rate. ```cpp virtual std::span GetModes() const = 0; ``` ```cpp for (const auto &mode : connector->GetModes()) { printf("%ux%u@%uHz\n", mode.uWidth, mode.uHeight, mode.uRefresh); } ``` -------------------------------- ### Install Gamescope Source: https://github.com/valvesoftware/gamescope/blob/master/README.md Command to install Gamescope after building it, skipping subprojects. ```sh meson install -C build/ --skip-subprojects ``` -------------------------------- ### Define, Get, and Set ConVars Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Demonstrates how to declare integer, boolean, and string ConVars, retrieve their values, and modify them. Includes an example of a ConVar with a callback function that executes when its value changes. ```cpp // Define variables gamescope::ConVar g_nTargetFPS("target_fps", 60, "Target frame rate"); gamescope::ConVar g_bEnableVRR("enable_vrr", true, "Enable VRR"); gamescope::ConVar g_sBackend("backend", "drm", "Display backend"); // Get values int fps = g_nTargetFPS.Get(); if (g_bEnableVRR) { /* enable VRR */ } // Set values g_nTargetFPS = 144; g_sBackend.SetValue("sdl"); // With callback gamescope::ConVar cv_debug( "debug_mode", false, "Debug mode toggle", [](gamescope::ConVar &cv) { if (cv.Get()) { SetupDebugLogging(); } else { DisableDebugLogging(); } } ); ``` -------------------------------- ### Install Fedora Dependencies Source: https://github.com/valvesoftware/gamescope/wiki/Distribution-specific-instructions Installs essential development libraries and tools for Gamescope on Fedora using dnf. ```bash dnf install -y meson \ cmake \ libX11-devel \ libXdamage-devel \ libXcomposite-devel \ libXrender-devel \ libXext-devel \ libXxf86vm-devel \ libXtst-devel \ libXres-devel \ libdrm-devel \ mesa-vulkan-devel \ wayland-devel \ wayland-protocols-devel \ libxkbcommon-devel \ libcap-devel \ SDL2-devel \ mesa-libgbm-devel \ systemd-devel \ pixman-devel \ libinput-devel \ libseat-devel \ libxcb-devel \ xcb-util-wm-devel \ glslang \ pipewire-devel \ stb-devel ``` -------------------------------- ### SetPoint Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Shows how to update a timeline point to a new value. ```cpp point->SetPoint(43); ``` -------------------------------- ### SetReleasePoint Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example demonstrating how to set a release point for a framebuffer. The framebuffer will signal this point when the GPU has finished processing it. ```cpp auto releasePoint = std::make_shared(timeline, 100); framebuffer->SetReleasePoint(releasePoint); // Framebuffer signals point when GPU finishes with it ``` -------------------------------- ### Get Presentation Feedback Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves a feedback structure for tracking the status of queued and completed frame presents. The example shows how to get the feedback object and query the number of presents currently in flight. ```cpp virtual BackendPresentFeedback& PresentationFeedback() = 0; ``` ```cpp auto &feedback = connector->PresentationFeedback(); uint64_t inFlight = feedback.CurrentPresentsInFlight(); ``` -------------------------------- ### Setup NVIDIA Streamline SDK Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md Before building the Streamline sample, navigate to the third_party directory and run the setup_streamline.bat script, specifying the Visual Studio version. ```bash $ $> cd samples\third_party $> setup_streamline.bat vs2019 ``` -------------------------------- ### Initialize Gamescope Backend Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Get the current backend instance and initialize it. Call PostInit after successful initialization. Retrieve the active display connector. ```cpp #include "backend.h" // Get current backend gamescope::IBackend *pBackend = gamescope::IBackend::Get(); // Initialize if (!pBackend->Init()) { // Initialization failed } // Post-init pBackend->PostInit(); // Get active display gamescope::IBackendConnector *connector = pBackend->GetCurrentConnector(); ``` -------------------------------- ### Initialize the Backend Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md This snippet shows how to get the current backend instance, initialize it, and perform post-initialization steps to access the active display. ```APIDOC ## Initialize the Backend ### Description Initializes the Gamescope backend and retrieves the current display connector. ### Method C++ API calls ### Code Example ```cpp #include "backend.h" // Get current backend gamescope::IBackend *pBackend = gamescope::IBackend::Get(); // Initialize if (!pBackend->Init()) { // Initialization failed } // Post-init pBackend->PostInit(); // Get active display gamescope::IBackendConnector *connector = pBackend->GetCurrentConnector(); ``` ``` -------------------------------- ### GetPoint Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Demonstrates retrieving the current value of a timeline point. ```cpp uint64_t val = point->GetPoint(); ``` -------------------------------- ### Defer Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Example of using the defer helper to ensure a file descriptor is closed when exiting the scope. The cleanup function is called automatically. ```cpp { int fd = open(...); auto cleanup = defer([fd]() { close(fd); }); // ... use fd ... // cleanup called automatically at end of scope } ``` -------------------------------- ### Create CTimelinePoint Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Demonstrates how to create a new timeline and an acquire timeline point at a specific value. ```cpp auto timeline = gamescope::CTimeline::Create(); auto point = std::make_shared(timeline, 42); ``` -------------------------------- ### GetTimeline Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Shows how to get the parent timeline object from a timeline point. ```cpp auto timeline = point->GetTimeline(); ``` -------------------------------- ### CreateEventFd Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Shows how to create an eventfd for a timeline point and how to check for errors or pre-signalled states. Remember to close the eventfd when done. ```cpp auto [eventFd, alreadySignalled] = point->CreateEventFd(); if (eventFd >= 0) { // Can poll/wait on eventFd close(eventFd); } ``` -------------------------------- ### Initialize tonemap_info_t Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/color-api.md Example of initializing `tonemap_info_t` structures with specific black and white point nits values for source and target displays. ```cpp gamescope::tonemap_info_t source, target; source.flBlackPointNits = 0.0f; source.flWhitePointNits = 10000.0f; target.flBlackPointNits = 0.0f; target.flWhitePointNits = 500.0f; ``` -------------------------------- ### ShouldSignalOnDestruction Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Example demonstrating how to check if a point will signal on destruction, useful for identifying Release points. ```cpp if (point->ShouldSignalOnDestruction()) { // Release point: will signal timeline when destroyed } ``` -------------------------------- ### Run Game at Specific Resolution and Scale Output Source: https://github.com/valvesoftware/gamescope/blob/master/README.md Example of running a game at 1080p and scaling the output to a fullscreen 3440x1440 ultrawide window with pillarboxing. The %command% placeholder is typically used by game launchers like Steam. ```sh gamescope -w 1920 -h 1080 -W 3440 -H 1440 -b -- %command% ``` -------------------------------- ### DX11 NVScaler Dispatch Example Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md A basic example of dispatching the NVScaler compute shader in a DX11 application. It sets the necessary shader resources, unordered access views, samplers, constant buffers, and the compute shader itself before dispatching. ```cpp context->CSSetShaderResources(0, 1, input); // SRV context->CSSetShaderResource (1, 1, scalerSRV.GetAddressOf()); context->CSSetShaderResource (2, 1, usmSRV.GetAddressOf()); context->CSSetUnorderedAccessViews(0, 1, output, nullptr); context->CSSetSamplers(0, 1, linearClampSampler.GetAddressOf()); context->CSSetConstantBuffers(0, 1, csBuffer.GetAddressOf()); context->CSSetShader(NVScalerCS.Get(), nullptr, 0); context->Dispatch(UINT(std::ceil(outputWidth / float(blockWidth))), UINT(std::ceil(outputHeight / float(blockHeight))), 1); ``` -------------------------------- ### Example Usage of Ratio Class Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/types.md Demonstrates how to create and use the `Ratio` class to represent an aspect ratio. Shows instantiation with numerator and denominator, and accessing these values. ```cpp gamescope::Ratio aspect(16, 9); // 16:9 auto w = aspect.Num(); // 16 auto h = aspect.Denom(); // 9 ``` -------------------------------- ### Start Gamescope Tracing Source: https://github.com/valvesoftware/gamescope/wiki/Tracing This script configures and starts ftrace event recording for Gamescope. It checks and sets permissions for tracefs, then uses trace-cmd to record specific kernel events related to scheduling, AMD/Intel GPU operations, and DRM VBLANK events. Ensure you have sudo privileges to modify tracefs permissions if needed. ```shell #!/bin/sh -eu TRACEFS="/sys/kernel/tracing" if ! [ -w "$TRACEFS/trace_marker" ]; then echo "Allowing unprivileged users to write to $TRACEFS/trace_marker" sudo chmod 0755 "$TRACEFS" sudo chmod 0222 "$TRACEFS/trace_marker" echo "Now restart the traced process and run this script again" exit 1 fi trace-cmd record -i \ -e "sched:sched_switch" -e "sched:sched_process_exec" -e "sched:sched_process_fork" -e "sched:sched_process_exit" -e "amdgpu:amdgpu_vm_flush" -e "amdgpu:amdgpu_cs_ioctl" -e "amdgpu:amdgpu_sched_run_job" -e "*fence:*fence_signaled" -e "drm:drm_vblank_event" -e "drm:drm_vblank_event_queued" -e "i915:i915_flip_request" -e "i915:i915_flip_complete" -e "i915:intel_gpu_freq_change" -e "i915:i915_gem_request_add" -e "i915:i915_gem_request_submit" -e "i915:i915_gem_request_in" -e "i915:i915_gem_request_out" -e "i915:intel_engine_notify" -e "i915:i915_gem_request_wait_begin" -e "i915:i915_gem_request_wait_end" ``` -------------------------------- ### Run Gamescope with Steam Integration Source: https://github.com/valvesoftware/gamescope/wiki/Home Launch Gamescope with the -e flag to enable Steam integration, and then start Steam in tenfoot mode. ```bash gamescope -e -- steam -tenfoot -steamos ``` -------------------------------- ### Setting cv_backend_virtual_connector_strategy to PerAppId Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/configuration.md Example of setting the cv_backend_virtual_connector_strategy to enable per-application display separation. ```cpp // Enable per-app display separation cv_backend_virtual_connector_strategy = gamescope::VirtualConnectorStrategies::PerAppId; ``` -------------------------------- ### Setting cv_backend to DRM Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/configuration.md Example of setting the cv_backend console variable to use the DRM backend. ```cpp // Select DRM backend cv_backend = "drm"; ``` -------------------------------- ### CBaseBackendFb Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Example demonstrating the creation and usage of CBaseBackendFb. The framebuffer is automatically released when the shared_ptr goes out of scope. ```cpp auto fb = std::make_shared(); fb->SetBuffer(clientBuffer); fb->SetReleasePoint(releasePoint); // Use fb for presentation... // Auto-released when shared_ptr goes out of scope ``` -------------------------------- ### Basic Timeline Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Demonstrates the basic usage of the Gamescope CTimeline, including creating a timeline, setting up a release point that signals on destruction, and an acquire point that waits for the signal. ```cpp // Create timeline auto timeline = gamescope::CTimeline::Create(); // Create release point (signals on destruction) { auto releasePoint = std::make_shared( timeline, 100 ); // Do work... // Point automatically signals timeline at value 100 when destroyed } // Create acquire point (waits for signal) auto acquirePoint = std::make_shared( timeline, 100 ); bool done = acquirePoint->Wait(); ``` -------------------------------- ### Display Modes and Properties Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Demonstrates how to retrieve available display modes, check the screen type, and get the current display orientation. ```APIDOC ## Display Modes and Properties ### Description Retrieves information about display modes, screen type, and orientation. ### Method C++ API calls ### Code Example ```cpp // Get available display modes auto modes = connector->GetModes(); for (const auto &mode : modes) { printf("%u x %u @ %u Hz\n", mode.uWidth, mode.uHeight, mode.uRefresh); } // Get screen type gamescope::GamescopeScreenType type = connector->GetScreenType(); if (type == GAMESCOPE_SCREEN_TYPE_INTERNAL) { // Built-in display } // Get orientation gamescope::GamescopePanelOrientation orientation = connector->GetCurrentOrientation(); ``` ``` -------------------------------- ### Wait Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Demonstrates waiting for a timeline point to be signalled within a specified timeout. Returns true if signalled, false on timeout. ```cpp bool signalled = point->Wait(1000000000); // 1 second if (signalled) { // Point reached } ``` -------------------------------- ### NonCopyable Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Demonstrates how to use the NonCopyable base class to make a class non-copyable. Instances of MyClass cannot be copied. ```cpp class MyClass : public gamescope::NonCopyable { }; // MyClass instances cannot be copied ``` -------------------------------- ### Get Vulkan Instance Extensions Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves a list of Vulkan instance extensions required by the backend. These extensions are necessary for creating the Vulkan instance. ```cpp auto extensions = pBackend->GetInstanceExtensions(); for (const char *ext : extensions) { // Add to Vulkan instance creation info } ``` -------------------------------- ### Get Global Backend Instance Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the singleton instance of the backend. This is a static method and can be called without an existing backend object. ```cpp static IBackend *Get(); ``` ```cpp gamescope::IBackend *pBackend = gamescope::IBackend::Get(); ``` -------------------------------- ### Spawn a Child Process Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Use SpawnProcess to create a new child process. An optional callback can be provided to run setup code in the child before execution. A double fork can be used to detach the child from the parent. ```cpp char *argv[] = {"/usr/bin/steam", "--help", nullptr}; pid_t child = gamescope::Process::SpawnProcess(argv); ``` ```cpp char *argv[] = {"/usr/bin/steam", "--help", nullptr}; pid_t child2 = gamescope::Process::SpawnProcess( argv, []() { // This runs in child before exec setenv("DISPLAY", ":1", 1); } ); ``` -------------------------------- ### Get Present Image Layout Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the Vulkan image layout used for presentation. This is typically VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. ```cpp VkImageLayout ``` -------------------------------- ### Upscale Game Resolution with Integer Scaling Source: https://github.com/valvesoftware/gamescope/blob/master/README.md Example of using Gamescope to upscale a 720p game to 1440p using integer scaling. The %command% placeholder is typically used by game launchers like Steam to pass the game's executable and arguments. ```sh gamescope -h 720 -H 1440 -S integer -- %command% ``` -------------------------------- ### HDR Tone-Mapping Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/color-api.md Demonstrates the process of tone-mapping an HDR frame to SDR. It involves retrieving HDR information, setting up source and target nit values, initializing a tonemapper, and applying it to HDR nit values. ```cpp // Get HDR info from connector const auto &hdrInfo = connector->GetHDRInfo(); // Get display colorimetry displaycolorimetry_t dispColor; EOTF dispEOTF; gamescope::EOTF outputEncoding; connector->GetNativeColorimetry( true, // Query HDR10 &dispColor, &dispEOTF, nullptr, &outputEncoding ); // Set up tone-mapping gamescope::tonemap_info_t source, target; source.flBlackPointNits = 0.0f; source.flWhitePointNits = hdrInfo.uMaxContentLightLevel; target.flBlackPointNits = 0.1f; target.flWhitePointNits = 500.0f; gamescope::eetf_2390_t tonemapper; tonemapper.init(source, target); // Apply to HDR frame float hdr_nits = 8000.0f; float sdr_nits = tonemapper.apply(hdr_nits); float sdr_linear = srgb_to_linear(sdr_nits / 255.0f); ``` -------------------------------- ### Algorithm Utilities Usage Example Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Demonstrates the usage of the Algorithm::Contains function to check for the presence of an element within a std::vector. ```cpp std::vector vec = {1, 2, 3, 4, 5}; if (gamescope::Algorithm::Contains(vec, 3)) { // Found } ``` -------------------------------- ### Get Preferred Output Formats Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Queries the preferred DRM formats for the primary and overlay planes. Output is provided via pointers to uint32_t. ```cpp uint32_t primaryFmt, overlayFmt; pBackend->GetPreferredOutputFormat(&primaryFmt, &overlayFmt); ``` -------------------------------- ### Query HDR Capabilities and Status Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Query HDR capabilities and status of the connector. Use the example to check HDR support and retrieve HDR information. ```cpp virtual bool SupportsHDR() const = 0; virtual bool IsHDRActive() const = 0; virtual const BackendConnectorHDRInfo &GetHDRInfo() const = 0; ``` ```cpp if (connector->SupportsHDR()) { const auto &hdrInfo = connector->GetHDRInfo(); // hdrInfo.uMaxContentLightLevel // hdrInfo.eOutputEncodingEOTF } ``` -------------------------------- ### Build Gamescope from Source Source: https://github.com/valvesoftware/gamescope/blob/master/README.md Steps to clone the repository, initialize submodules, set up the build environment with Meson, compile the project with Ninja, and run Gamescope. ```sh git submodule update --init meson setup build/ ninja -C build/ build/src/gamescope -- ``` -------------------------------- ### Get Display Identification Strings Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves identification strings for the display, including its name, manufacturer, and model, typically sourced from EDID data. The example demonstrates printing the make and model of the display. ```cpp virtual const char *GetName() const = 0; virtual const char *GetMake() const = 0; virtual const char *GetModel() const = 0; ``` ```cpp printf("Display: %s by %s\n", connector->GetMake(), connector->GetModel()); ``` -------------------------------- ### Build DirectX Samples with CMake Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md Navigate to the samples directory, create a build directory, and run CMake to configure the build for DirectX11 and DirectX12 samples. ```bash $ $> cd samples $> mkdir build $> cd build $> cmake .. ``` -------------------------------- ### Init() Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Initializes the backend system. This method must be called before any other operations. It returns a boolean indicating success or failure. ```APIDOC ## Init() ### Description Initialize the backend. Called before any other operations. ### Method ```cpp virtual bool Init() = 0; ``` ### Parameters No parameters. ### Returns `bool` - True if initialization succeeded, false otherwise. ### Example ```cpp gamescope::IBackend *pBackend = gamescope::IBackend::Get(); if (!pBackend->Init()) { // Handle initialization failure } ``` ``` -------------------------------- ### Backend Interface Overview Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/README.md The IBackend interface provides abstract methods for initializing and managing the display system, including state management, buffer import, and format support. ```text IBackend (abstract interface) ├── Init() / PostInit() ├── DirtyState() / PollState() (state management) ├── GetCurrentConnector() (display access) ├── ImportDmabufToBackend() (buffer import) └── GetSupportedModifiers() (format support) ``` -------------------------------- ### Build NV12 Sample with CMake Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md Configure the build for the NV12 sample by adding the -DNIS_NV12_SAMPLE=ON option to the CMake command. ```bash $ $> cmake .. -DNIS_NV12_SAMPLE=ON ``` -------------------------------- ### Initialize Backend Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Initializes the backend system. This must be called before any other operations. Failure to initialize will prevent further backend usage. ```cpp gamescope::IBackend *pBackend = gamescope::IBackend::Get(); if (!pBackend->Init()) { // Handle initialization failure } ``` -------------------------------- ### Get Screen Type Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the type of the display (internal or external). ```cpp virtual GamescopeScreenType GetScreenType() const = 0; ``` -------------------------------- ### Get Connector ID Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the unique identifier for a display connector. ```cpp virtual uint64_t GetConnectorID() const = 0; ``` -------------------------------- ### Build Streamline Sample with CMake Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md After setting up the Streamline SDK, navigate back to the samples directory and run CMake with the -DNIS_SL_SAMPLE=ON option. Multiple options can be concatenated. ```bash $ $> cd samples $> cmake .. -DNIS_SL_SAMPLE=ON ``` -------------------------------- ### Get() - Value Access Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Retrieves the current value of the console variable. ```APIDOC ## Get() ### Description Retrieves the current value of the console variable. ### Signature ```cpp const T& Get() const; ``` ### Returns - **const T&** - Current value reference ### Example ```cpp int rate = cv_framerate.Get(); ``` ``` -------------------------------- ### Get Current Orientation Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the current rotation or orientation of the display panel. ```cpp virtual GamescopePanelOrientation GetCurrentOrientation() const = 0; ``` -------------------------------- ### GetPresentLayout() Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Gets the Vulkan image layout used for presentation, typically VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. ```APIDOC ## GetPresentLayout() ### Description Get the Vulkan image layout for presentation. ### Method ```cpp virtual VkImageLayout GetPresentLayout() const = 0; ``` ### Returns `VkImageLayout` - Layout (typically VK_IMAGE_LAYOUT_PRESENT_SRC_KHR). ``` -------------------------------- ### Manage Processes and Priorities Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Set up the process as a subreaper and raise the file descriptor limit. Spawn a child process, set its environment, and optionally set real-time priority. Wait for the child process to exit. ```cpp #include "Utils/Process.h" // Set up process gamescope::Process::BecomeSubreaper(); gamescope::Process::RaiseFdLimit(); // Spawn game process char *argv[] = {"/usr/bin/game", "--fullscreen", nullptr}; pid_t gamePid = gamescope::Process::SpawnProcess(argv, []() { setenv("DISPLAY", ":1", 1); }); // Set real-time priority if (gamescope::Process::HasCapSysNice()) { gamescope::Process::SetNice(-20); } if (gamescope::Process::SetRealtime()) { // Running with RT priority } // Wait for game auto exitStatus = gamescope::Process::WaitForChild(gamePid); ``` -------------------------------- ### Implement a ConCommand Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Shows how to define a new console command with a description and a callback function. The callback receives a span of string views representing arguments and iterates through available commands to display their names and descriptions. ```cpp gamescope::ConCommand cmd_help( "help", "Show available commands", [](std::span args) { auto &cmds = gamescope::ConCommand::GetCommands(); for (auto &[name, cmd] : cmds) { printf("%s: %s\n", std::string(name).c_str(), std::string(cmd->GetDescription()).c_str() ); } } ); ``` -------------------------------- ### Build Vulkan Sample with CMake Source: https://github.com/valvesoftware/gamescope/blob/master/src/shaders/NVIDIAImageScaling/README.md Configure the build for the Vulkan sample by adding the -DNIS_VK_SAMPLE=ON option to the CMake command. ```bash $ $> cmake .. -DNIS_VK_SAMPLE=ON ``` -------------------------------- ### Get ConCommand Name Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Retrieve the registered name of a ConCommand instance. This is useful for debugging or introspection. ```cpp std::cout << cmd.GetName() << std::endl; ``` -------------------------------- ### Create CBaseBackendConnector Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Instantiates a base connector. Use this when a virtual connector key is not needed. ```cpp auto connector = new CBaseBackendConnector(); // Automatically assigned unique connector ID ``` -------------------------------- ### Get Current Connector Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the currently active display connector. If no connector is active, nullptr is returned. ```cpp virtual IBackendConnector *GetCurrentConnector() = 0; ``` ```cpp auto pConnector = pBackend->GetCurrentConnector(); if (pConnector) { uint32_t width = pConnector->GetModes()[0].uWidth; } ``` -------------------------------- ### Get Gamescope Version Information Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Retrieves the version string or major/minor version components of the Gamescope application. ```cpp namespace gamescope { const char *GetVersionString(); int GetVersionMajor(); int GetVersionMinor(); } ``` -------------------------------- ### Present Frames and Check Status Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Import a DMA-buf into the backend to create a framebuffer and then present the frame. Monitor the presentation feedback for frames in flight. ```cpp // Import DMA-buf from client wlr_dmabuf_attributes dmabuf = /* ... */; auto pFramebuffer = pBackend->ImportDmabufToBackend(&dmabuf); // Present frame FrameInfo_t frameInfo = /* ... */; int result = connector->Present(&frameInfo, false); // Check presentation status auto &feedback = connector->PresentationFeedback(); uint64_t inFlight = feedback.CurrentPresentsInFlight(); ``` -------------------------------- ### Get ConVar Value Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Retrieves the current value of a console variable. Returns a const reference to the current value. ```cpp const T& Get() const; ``` ```cpp int rate = cv_framerate.Get(); ``` -------------------------------- ### ConCommand Constructor Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Creates a new console command with a specified name, description, implementation, and script registration option. ```APIDOC ## ConCommand Constructor ### Description Create a new console command. ### Parameters #### Path Parameters - **pszName** (string_view) - Required - Command name - **pszDescription** (string_view) - Required - Help text - **func** (ConCommandFunc) - Required - Command implementation - **bRegisterScript** (bool) - Optional - Default: true - Register in scripting ### Callback Signature ```cpp using ConCommandFunc = std::function)>; // args[0] = command name // args[1...] = parameters ``` ### Example ```cpp gamescope::ConCommand cmd_reload( "reload_shaders", "Reload shader programs", [](std::span args) { // args[0] = "reload_shaders" // args[1...] = any arguments std::cout << "Reloading shaders..." << std::endl; } ); ``` ``` -------------------------------- ### Create a ConCommand Instance Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Instantiate a ConCommand object to define a new console command. This involves providing a name, description, and a callback function. The command can optionally be registered for scripting. ```cpp gamescope::ConCommand cmd_reload( "reload_shaders", "Reload shader programs", [](std::span args) { // args[0] = "reload_shaders" // args[1...] = any arguments std::cout << "Reloading shaders..." << std::endl; } ); ``` -------------------------------- ### Get ConCommand Description Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Retrieve the help text associated with a ConCommand. This is typically displayed when a user requests help for the command. ```cpp std::cout << cmd.GetDescription() << std::endl; ``` -------------------------------- ### Accessing and Setting ConVars Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/configuration.md Demonstrates how to get and set values for Gamescope console variables using the ConVar template class. ```cpp // Get value gamescope::ConVar cv_example("name", defaultValue, "description"); T value = cv_example.Get(); // Set value cv_example.SetValue(newValue); cv_example = newValue; // Via operator= ``` -------------------------------- ### ConCommand::GetDescription Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Retrieves the help text associated with the console command. ```APIDOC ## ConCommand::GetDescription() ### Description Get help text. ### Returns `string_view` - Description string ### Example ```cpp std::cout << cmd.GetDescription() << std::endl; ``` ``` -------------------------------- ### TimelineCreateDesc_t Structure Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/types.md Initialization parameters for a timeline, specifically defining the starting point. Used when creating a new timeline instance. ```cpp struct TimelineCreateDesc_t { uint64_t ulStartingPoint = 0ul; }; ``` -------------------------------- ### Execute ConCommands at Runtime Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Demonstrates how to execute console commands and ConVar modifications programmatically using the `ConCommand::Exec` static method. This allows for dynamic changes to game settings or invocation of commands from code. ```cpp // From console or script ConCommand::Exec({"target_fps", "120"}); ConCommand::Exec({"enable_vrr", "false"}); ConCommand::Exec({"help"}); ``` -------------------------------- ### Create Method Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Creates and binds a new Wayland resource for a given client. It handles the creation of the resource and passes constructor arguments to the resource's type. ```cpp template static T *Create(wl_client *pClient, uint32_t uVersion, uint32_t uId, Args... args); ``` ```cpp auto pRes = CWaylandResource::Create( client, version, resourceId, WaylandResourceDesc_t{client, resource, version} ); ``` -------------------------------- ### Create Directory Recursively Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Creates a directory and any necessary parent directories. Use this when you need to ensure a directory path exists. ```cpp namespace gamescope::DirHelpers { bool CreateDirectoryRecursive(const std::string &path); std::vector ListDirectory(const std::string &path); bool FileExists(const std::string &path); } gamescope::DirHelpers::CreateDirectoryRecursive("/tmp/gamescope"); ``` -------------------------------- ### Execute Console Commands Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/configuration.md Shows how to execute console commands programmatically from C++ code or directly via the console interface. ```cpp // From code ConCommand::Exec({"command", "arg1", "arg2"}); ``` ```cpp // Via console gamescope_console.Exec("command arg1 arg2"); ``` -------------------------------- ### Get Current Process Name Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Use GetProcessName to retrieve the executable name of the current process. This can be useful for logging or identification purposes. ```cpp printf("Process: %s\n", gamescope::Process::GetProcessName()); ``` -------------------------------- ### Access All Registered Commands Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Get a reference to the global dictionary containing all registered ConCommands. This allows iterating through and inspecting all available commands. ```cpp auto &commands = gamescope::ConCommand::GetCommands(); for (auto &[name, cmd] : commands) { std::cout << name << ": " << cmd->GetDescription() << std::endl; } ``` -------------------------------- ### Get Syncobj Handle Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Retrieves the DRM syncobj handle for this timeline. This handle can be used in various DRM ioctl calls for synchronization. ```cpp uint32_t GetSyncobjHandle() const; ``` ```cpp uint32_t handle = timeline->GetSyncobjHandle(); // Use with DRM ioctl calls ``` -------------------------------- ### Initialize eetf_2390_t with PQ Values Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/color-api.md Initialize the tone-mapper directly using PQ-encoded values for source and target black and white points. Requires a `nits_to_pq` function for conversion. ```cpp tonemapper.init_pq( nits_to_pq(0.0f), // Source black nits_to_pq(10000.0f), // Source white nits_to_pq(0.1f), // Target black nits_to_pq(100.0f) // Target white ); ``` -------------------------------- ### Initialize Input Handling Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Initialize the Gamescope input server, which creates an EIS socket. Alternatively, initialize the libinput handler for input management. ```cpp #include "InputEmulation.h" // Initialize input server gamescope::GamescopeInputServer inputServer; if (!inputServer.Init("/run/user/1000/gamescope-eis")) { // EIS socket created } // Or use libinput #include "LibInputHandler.h" gamescope::CLibInputHandler libinput; if (libinput.Init()) { // libinput initialized } ``` -------------------------------- ### Get DRM Blob ID Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the underlying DRM blob ID if the blob is owned by DRM. Returns 0 if not owned by DRM. ```cpp uint32_t drm_id = blob->GetBlobValue(); ``` -------------------------------- ### Get Raw Blob Data Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the raw byte data from a BackendBlob. Use this to access the underlying data for operations like copying. ```cpp auto data = blob->GetData(); memcpy(destination, data.data(), data.size()); ``` -------------------------------- ### GetInstanceExtensions() Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves a list of Vulkan instance extensions required by this backend. ```APIDOC ## GetInstanceExtensions() ### Description Get Vulkan instance extensions required by this backend. ### Method ```cpp virtual std::span GetInstanceExtensions() const = 0; ``` ### Returns `std::span` - List of extension names. ### Example ```cpp auto extensions = pBackend->GetInstanceExtensions(); for (const char *ext : extensions) { // Add to Vulkan instance creation info } ``` ``` -------------------------------- ### Get Vulkan Device Extensions Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves Vulkan device extensions for a specific physical device. These extensions are needed for creating the Vulkan device. ```cpp auto devExtensions = pBackend->GetDeviceExtensions(physDevice); ``` -------------------------------- ### Get Syncobj File Descriptor Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Retrieves the DRM file descriptor associated with the CTimeline object. This is the file descriptor used for syncobj operations. ```cpp int32_t GetSyncobjFd() const; ``` ```cpp int fd = timeline->GetSyncobjFd(); ``` -------------------------------- ### Run Gamescope with Hardware Planes and 4K Resolution Source: https://github.com/valvesoftware/gamescope/wiki/Home Launch Gamescope from a VT with hardware planes enabled (-e), debugging information (-d), and forcing a 4K resolution (3840x2160). Steam is also launched in tenfoot mode. ```bash gamescope -e -d -w 3840 -h 2160 -- steam -tenfoot -steamos ``` -------------------------------- ### Set Backend Implementation by Type Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Sets the global backend to a specific implementation type using its default constructor. Returns true if the backend was set successfully. ```cpp template static bool Set(); ``` ```cpp if (!gamescope::IBackend::Set()) { // Failed to set DRM backend } ``` -------------------------------- ### Get Supported Modifiers for DRM Format Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves a list of supported DRM format modifiers for a given DRM format. The format is specified by a uint32_t code. ```cpp virtual std::span GetSupportedModifiers(uint32_t uDrmFormat) const = 0; ``` ```cpp auto modifiers = pBackend->GetSupportedModifiers(DRM_FORMAT_ARGB8888); if (!modifiers.empty()) { // Modifiers are supported for this format } ``` -------------------------------- ### Timeline Synchronization for Buffer Management Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Create a timeline for synchronization. Set up release and acquire points to manage buffer ownership and wait for rendering completion between GPU and client. ```cpp // Create timeline auto timeline = gamescope::CTimeline::Create(); // Create release point (buffer ownership) auto releasePoint = std::make_shared( timeline, 42 ); // Attach to framebuffer framebuffer->SetReleasePoint(releasePoint); // In GPU code: // - Signal timeline point when rendering done // - Client waits on acquire point for same timeline // Create acquire point for waiting auto acquirePoint = std::make_shared( timeline, 42 ); bool rendered = acquirePoint->Wait(1000000000); // 1 second timeout ``` -------------------------------- ### Query Display Modes and Screen Type Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Retrieve available display modes for a connector and check the screen type. Also, get the current display orientation. ```cpp // Get available display modes auto modes = connector->GetModes(); for (const auto &mode : modes) { printf("%u x %u @ %u Hz\n", mode.uWidth, mode.uHeight, mode.uRefresh); } // Get screen type gamescope::GamescopeScreenType type = connector->GetScreenType(); if (type == GAMESCOPE_SCREEN_TYPE_INTERNAL) { // Built-in display } // Get orientation gamescope::GamescopePanelOrientation orientation = connector->GetCurrentOrientation(); ``` -------------------------------- ### Manage Gamescope Configuration Variables Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Query console variables like the current backend. Change upscaling filters and scalers. Register callbacks for variable changes and execute commands. ```cpp #include "convar.h" // Query current backend std::string backend = cv_backend.Get(); // Change upscaling cv_upscaleFilter = gamescope::GamescopeUpscaleFilter::FSR; cv_upscaleScaler = gamescope::GamescopeUpscaleScaler::INTEGER; // With callback on change gamescope::ConVar cv_test_fps( "test_fps", 60, "Target FPS", [](gamescope::ConVar &cv) { printf("FPS changed to %d\n", cv.Get()); } ); // Set via command ConCommand::Exec({"test_fps", "144"}); ``` -------------------------------- ### Get Raw EDID Data Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the raw Extended Display Identification Data (EDID) for the display. This data contains detailed information about the display's capabilities. ```cpp virtual std::span GetRawEDID() const = 0; ``` -------------------------------- ### HDR Configuration Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/getting-started.md Shows how to check for HDR support, retrieve HDR information, and set up tone-mapping for HDR content. ```APIDOC ## HDR Configuration ### Description Configures High Dynamic Range (HDR) settings, including support checks and tone-mapping. ### Method C++ API calls ### Code Example ```cpp // Check HDR support if (connector->SupportsHDR()) { const auto &hdrInfo = connector->GetHDRInfo(); // Set up tone-mapping gamescope::tonemap_info_t source, target; source.flWhitePointNits = hdrInfo.uMaxContentLightLevel; target.flWhitePointNits = 500.0f; gamescope::eetf_2390_t tonemapper; tonemapper.init(source, target); // Apply to values float output = tonemapper.apply(8000.0f); } ``` ``` -------------------------------- ### Get Connector by Screen Type Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves the connector associated with a specific screen type, such as internal or external displays. Returns nullptr if no connector is found for the given type. ```cpp virtual IBackendConnector *GetConnector(GamescopeScreenType eScreenType) = 0; ``` ```cpp auto pExternal = pBackend->GetConnector(GAMESCOPE_SCREEN_TYPE_EXTERNAL); ``` -------------------------------- ### CWaylandResource Constructor Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/wayland-server-api.md Creates a Wayland resource instance bound to a specific client connection. It initializes the resource with client, resource pointer, and protocol version. ```cpp CWaylandResource(WaylandResourceDesc_t desc) : m_pClient{ desc.pClient } , m_pResource{ desc.pResource } , m_uVersion{ desc.uVersion } ``` ```cpp gamescope::WaylandServer::WaylandResourceDesc_t desc{ .pClient = client, .pResource = resource, .uVersion = 1 }; auto res = std::make_unique(desc); ``` -------------------------------- ### Get Global DRM Render FD Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Retrieves the file descriptor for the global DRM render device. This is useful for initializing synchronization objects or performing other DRM-related operations. ```cpp static int32_t GetDrmRenderFD(); ``` ```cpp int drmFd = gamescope::CTimeline::GetDrmRenderFD(); if (drmFd >= 0) { // DRM available } ``` -------------------------------- ### Create Temporary Directory Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/utilities-api.md Creates a temporary directory with a specified prefix. Useful for staging temporary files during runtime. ```cpp namespace gamescope::TempFiles { std::string CreateTempDirectory(const std::string &prefix); int CreateTempFile(const std::string &prefix); } std::string tempDir = gamescope::TempFiles::CreateTempDirectory("gs_"); ``` -------------------------------- ### Factory Method to Create CTimeline Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md A factory method for creating new CTimeline instances. It accepts an optional `TimelineCreateDesc_t` structure to configure the creation parameters, such as the starting point. ```cpp static std::shared_ptr Create( const TimelineCreateDesc_t &desc = {} ); ``` ```cpp gamescope::TimelineCreateDesc_t desc; desc.ulStartingPoint = 100; auto timeline = gamescope::CTimeline::Create(desc); ``` -------------------------------- ### Present Frame and Synchronize Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Presents a frame to the display and synchronizes with the vertical blanking interval. The `Present` method takes frame data and an asynchronous flag, while `FrameSync` returns the next vblank timing. ```cpp virtual int Present(const FrameInfo_t *pFrameInfo, bool bAsync) = 0; virtual VBlankScheduleTime FrameSync() = 0; ``` -------------------------------- ### Get Colorimetry Information Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/backend-api.md Retrieves colorimetry information for color space conversion. The function takes a boolean to specify HDR10 querying and outputs various colorimetry and EOTF parameters. ```cpp virtual void GetNativeColorimetry( bool bHDR10, displaycolorimetry_t *displayColorimetry, EOTF *displayEOTF, displaycolorimetry_t *outputEncodingColorimetry, EOTF *outputEncodingEOTF ) const = 0; ``` -------------------------------- ### ConVar Constructor Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/convar-api.md Creates a new console variable with optional default value, description, callback, and script registration settings. The callback can be run at startup. ```cpp template ConVar::ConVar( std::string_view pszName, T defaultValue = T{}, std::string_view pszDescription = "", ConVarCallbackFunc func = nullptr, bool bRunCallbackAtStartup = false, bool bRegisterScript = true ); ``` ```cpp gamescope::ConVar cv_framerate( "framerate", 60, "Target frame rate in FPS", [](gamescope::ConVar &cv) { std::cout << "Framerate: " << cv.Get() << std::endl; } ); ``` -------------------------------- ### Initialize eetf_2390_t with Display Brightness Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/color-api.md Initialize the ITU-R BT.2390 EETF tone-mapper using source and target display brightness in nits. Ensure `tonemap_info_t` objects are correctly populated before calling. ```cpp gamescope::eetf_2390_t tonemapper; gamescope::tonemap_info_t sourceHDR, targetSDR; sourceHDR.flBlackPointNits = 0.0f; sourceHDR.flWhitePointNits = 10000.0f; targetSDR.flBlackPointNits = 0.1f; targetSDR.flWhitePointNits = 100.0f; tonemapper.init(sourceHDR, targetSDR); ``` -------------------------------- ### Get Associated Vulkan Semaphore Source: https://github.com/valvesoftware/gamescope/blob/master/_autodocs/timeline-api.md Retrieves the Vulkan timeline semaphore associated with this CTimeline object. If no Vulkan semaphore exists, it attempts to create one. This semaphore can be used for Vulkan synchronization. ```cpp std::shared_ptr ToVkSemaphore(); ``` ```cpp auto vkSem = timeline->ToVkSemaphore(); if (vkSem) { // Use in Vulkan synchronization } ```