Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ Release notes on GitHub are taken from the matching section here.
where the driver is slow to destroy the old swapchain. Nightcap now waits at most 100 ms for a destroy
and finishes slow ones in the background, so the first resize no longer freezes either. Quick resizes
and window rebuilds no longer wait for those background destroys.
- With Vulkan, Nightcap no longer lands on the slow software renderer (lavapipe) when it cannot pin a GPU
driver. If no hardware Vulkan device exists at all, it starts with the OpenGL backend instead of
showing a blank window; `VK_DRIVER_FILES` forces Vulkan.
- Older Intel GPUs (Haswell, Broadwell) get a Vulkan device when both ANV and hasvk are installed.
Nightcap also finds GPU drivers on NixOS and in Flatpak, accepts AMDVLK, and skips a GPU passed
through to a VM.
- On AMD and Intel, `DRI_PRIME` and Mesa's GPU choice on laptops with two GPUs work again, and
Intel-only Mesa settings are no longer applied to AMD.
- Pasting into a Roblox TextBox no longer stalls the game while the program that owns the clipboard is
slow to answer.
- On a busy Wayland compositor, or with a Sway or Hyprland window rule, Nightcap no longer quits when the
window takes longer than usual to appear.
- On FreeBSD, Roblox downloads no longer fail with "error adding trust anchors" in a Fedora userspace.
- On FreeBSD, sound plays through `/dev/dsp` without an `asound.conf`, once `alsa-plugins-oss` is installed
in the Linux userspace. An existing `~/.asoundrc` or `/etc/asound.conf` is still used.
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
endif()
target_link_libraries(mocktail_runtime PUBLIC Threads::Threads)
target_link_libraries(mocktail_runtime PRIVATE
Vulkan::Headers
OpenSSL::Crypto
CURL::libcurl
nlohmann_json::nlohmann_json
Expand Down
33 changes: 29 additions & 4 deletions include/runtime/graphics_launch_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,49 @@ struct HostGpu {
};

struct VulkanIcdSelection {
std::string manifest; // Empty when no GPU has a usable driver.
// Empty when no GPU has a usable driver. Intel pins ANV and hasvk together
// (colon-separated): each claims only its own GPU generations.
std::string manifest;
unsigned int vendor = 0;
std::vector<std::string> skipped; // Why each passed-over GPU was skipped.
};

// ICD manifest for the first GPU whose bound kernel driver has an installed
// Vulkan driver. NVIDIA and AMD cards are tried before Intel when
// `prefer_discrete` is set, and after it otherwise. A GPU with an unknown
// kernel driver is matched by vendor alone.
// kernel driver is matched by vendor alone; one bound to a non-graphics
// driver (vfio-pci, pci-stub) is skipped.
VulkanIcdSelection SelectHostVulkanIcd(
const std::vector<HostGpu>& gpus,
const std::vector<std::filesystem::path>& directories,
bool prefer_discrete);

std::vector<std::filesystem::path> VulkanIcdDirectories(
const char* xdg_data_home, const char* xdg_data_dirs, const char* home);

enum class HostVulkanDevices { kHardware, kSoftwareOnly, kNone, kUnknown };

// Enumerates host Vulkan devices in a short-lived child process, so a driver
// that crashes or hangs on instance teardown never touches this process.
// kUnknown when the probe could not run or timed out.
HostVulkanDevices ProbeHostVulkanDevices();

using HostVulkanProbe = HostVulkanDevices (*)();

// GPUs listed under /sys/class/drm.
std::vector<HostGpu> DetectHostGpus();

using HostGpuDetector = std::vector<HostGpu> (*)();

// Publishes the resolved graphics backend before the managed payload updater
// starts. OpenGL is a strict system EGL/GLES path; it never silently retries
// through ANGLE/Vulkan or accepts a window without a real graphics context.
bool ApplyGraphicsLaunchPolicy(const RuntimeConfig& config,
std::string* error = nullptr);
// When direct Vulkan has no pinned driver and `probe` finds no hardware
// device, `config` is switched to OpenGL.
bool ApplyGraphicsLaunchPolicy(RuntimeConfig* config,
std::string* error = nullptr,
HostVulkanProbe probe = ProbeHostVulkanDevices,
HostGpuDetector detect_gpus = DetectHostGpus);

} // namespace runtime
} // namespace mocktail
Expand Down
3 changes: 2 additions & 1 deletion include/runtime/roblox_text_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ class RobloxTextEditor final {
bool extend_selection);
RobloxTextEditResult SelectAllLocked();
RobloxTextEditResult CopySelectionLocked(bool cut);
RobloxTextEditResult PasteLocked();
RobloxTextEditResult PasteLocked(const Status& clipboard_status,
std::string* clipboard_text);
RobloxTextEditResult FinishLocked();
RobloxTextEditResult ReleaseLocked();
Status SyncLocked();
Expand Down
4 changes: 4 additions & 0 deletions include/runtime/runtime_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ class RuntimeConfig {
const std::string& graphics_backend_name() const {
return graphics_backend_name_;
}
void UseGraphicsBackend(std::string name) {
graphics_backend_ = ParseGraphicsBackend(name);
graphics_backend_name_ = std::move(name);
}
const WindowConfig& window() const { return window_; }
const std::string& theme_mode() const { return theme_mode_; }
bool theme_mode_valid() const {
Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
if (command_line.options.mode == mocktail::runtime::CommandMode::kRun &&
!mocktail::runtime::ApplyGraphicsLaunchPolicy(runtime_config.config,
!mocktail::runtime::ApplyGraphicsLaunchPolicy(&runtime_config.config,
&command_line_error)) {
std::cerr << "[FATAL] " << command_line_error << '\n';
return EXIT_FAILURE;
Expand Down
Loading