Files
mandy/runtime/src/vulkan_present_splash.h
Moriz82 273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00

64 lines
3.0 KiB
C++

#pragma once
#include "vulkan_present.h"
namespace leonida {
inline bool VulkanPresenter::present_splash(ResourceId source, std::shared_ptr<void> owner) {
std::lock_guard lock(present_mutex_);
if (!deferred_.empty() || context_.holds().any_held()) return false;
{
std::shared_lock resources(context_.resource_mutex_);
const auto* binding = context_.resolve(source);
if (!binding || !binding->image) return false;
splash_binding_ = *binding;
}
if (!capture_) splash_capture_only_ = enable_capture();
const auto before = presented();
if (present(source, true) != VK_SUCCESS || presented() == before) return false;
const Frame& frame = frames_[(frame_index_ - 1) % frames_.size()];
if (vkWaitForFences_(context_.device(), 1, &frame.done, VK_TRUE, UINT64_MAX) != VK_SUCCESS ||
finish_pending_capture() != VK_SUCCESS) return false;
if (capture_ptr_) {
splash_source_ = source;
splash_owner_ = std::move(owner);
}
return true;
}
// A changed surface or colour format may not support readback. Keep the title able to present on it.
inline bool VulkanPresenter::recreate_for_present(bool vsync, bool srgb, bool hdr) {
if (recreate(vsync, srgb, hdr)) return true;
if (!splash_capture_only_) return false;
splash_owner_.reset();
splash_capture_only_ = false;
capture_ = false;
return recreate(vsync, srgb, hdr);
}
// Called only during the launch handoff, with the tracker and queue locked. Check the composed pixels so a
// transparent overlay or a clear with nonzero alpha cannot dismiss the splash. Later black frames are genuine.
inline VkResult VulkanPresenter::finish_startup_frame(Frame& frame, std::uint32_t image, bool& show_title) {
const VkDevice device = context_.device();
VkResult result = vkWaitForFences_(device, 1, &frame.done, VK_TRUE, UINT64_MAX);
if (result != VK_SUCCESS) return result;
const bool ten_bit = format_ == VK_FORMAT_A2B10G10R10_UNORM_PACK32 || format_ == VK_FORMAT_A2R10G10B10_UNORM_PACK32;
const std::uint32_t rgb = ten_bit ? 0x3fffffffu : 0xffffffu;
const auto* pixels = reinterpret_cast<const std::uint32_t*>(capture_ptr_);
const auto count = std::size_t(extent_.width) * extent_.height;
show_title = std::any_of(pixels, pixels + count, [rgb](auto pixel) { return (pixel & rgb) != 0; });
VkSubmitInfo ready{VK_STRUCTURE_TYPE_SUBMIT_INFO};
ready.signalSemaphoreCount = 1;
ready.pSignalSemaphores = &ready_[image];
if (show_title) return context_.vk.vkQueueSubmit(queue_, 1, &ready, VK_NULL_HANDLE);
// The acquire was consumed and the title commands finished. Overwrite the same image before presenting it.
record(frame.commands, splash_binding_, splash_source_, image, nullptr);
result = vkResetFences_(device, 1, &frame.done);
if (result != VK_SUCCESS) return result;
ready.commandBufferCount = 1;
ready.pCommandBuffers = &frame.commands;
return context_.vk.vkQueueSubmit(queue_, 1, &ready, frame.done);
}
} // namespace leonida