mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:48:37 +00:00
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>
89 lines
3.6 KiB
C++
89 lines
3.6 KiB
C++
// LEONIDA_STUB_PIPELINES (diagnostic): a pipeline whose translated shader is missing is created as a no-op stub
|
|
// instead of failing. Without the switch, a graphics PSO with no shader library is E_FAIL, as before; with it, the
|
|
// call succeeds and the PSO is never registered, so it binds as no pipeline at all (its draws and dispatches are
|
|
// no-ops, D3D-482). Synthetic only: no shader library, no game data, nothing reaches the GPU.
|
|
#include "../shims/d3d12_com.h"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
namespace {
|
|
|
|
int g_failed = 0;
|
|
#define CHECK(x) \
|
|
do { \
|
|
if (!(x)) { \
|
|
std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); \
|
|
++g_failed; \
|
|
} \
|
|
} while (0)
|
|
|
|
template <class T>
|
|
struct Ref {
|
|
T* p = nullptr;
|
|
~Ref() {
|
|
if (p) p->Release();
|
|
}
|
|
};
|
|
|
|
D3D12_GRAPHICS_PIPELINE_STATE_DESC graphics_desc() {
|
|
static const unsigned char kBytes[16] = {'D', 'X', 'B', 'C'}; // never parsed: the library lookup comes first
|
|
D3D12_GRAPHICS_PIPELINE_STATE_DESC desc{};
|
|
desc.VS = {kBytes, sizeof kBytes};
|
|
desc.SampleMask = UINT_MAX;
|
|
desc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
|
desc.NumRenderTargets = 1;
|
|
desc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
desc.SampleDesc.Count = 1;
|
|
return desc;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
// No shader library, whatever the environment says.
|
|
SetEnvironmentVariableW(L"LEONIDA_SHADERS", nullptr);
|
|
_putenv_s("LEONIDA_STUB_PIPELINES", "");
|
|
|
|
Ref<ID3D12Device> device;
|
|
if (FAILED(rt::d3d12::create_vulkan_device_standalone(IID_PPV_ARGS(&device.p))) || !device.p) {
|
|
std::printf("SKIP: no Vulkan device\n");
|
|
return 77;
|
|
}
|
|
const D3D12_GRAPHICS_PIPELINE_STATE_DESC desc = graphics_desc();
|
|
|
|
{ // Off: refused as before, and no object.
|
|
Ref<ID3D12PipelineState> pso;
|
|
const HRESULT hr = device.p->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso.p));
|
|
if (hr == E_NOTIMPL) { // a device without the GPU address arena or graphics entry points refuses earlier
|
|
std::printf("SKIP: the device cannot create graphics pipelines (E_NOTIMPL)\n");
|
|
return 77;
|
|
}
|
|
CHECK(hr == E_FAIL);
|
|
CHECK(!pso.p);
|
|
}
|
|
{ // "0" is off too.
|
|
_putenv_s("LEONIDA_STUB_PIPELINES", "0");
|
|
Ref<ID3D12PipelineState> pso;
|
|
CHECK(device.p->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso.p)) == E_FAIL && !pso.p);
|
|
}
|
|
{ // On: a stub that is no registered pipeline, so SetPipelineState binds none.
|
|
_putenv_s("LEONIDA_STUB_PIPELINES", "1");
|
|
Ref<ID3D12PipelineState> pso;
|
|
CHECK(device.p->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso.p)) == S_OK);
|
|
CHECK(pso.p != nullptr);
|
|
CHECK(rt::d3d12::graphics_pipeline_id(pso.p) == 0);
|
|
CHECK(rt::d3d12::compute_pipeline_id(pso.p) == 0);
|
|
}
|
|
{ // Real refusals are not stubbed: a bad description is still E_INVALIDARG.
|
|
D3D12_GRAPHICS_PIPELINE_STATE_DESC bad = desc;
|
|
bad.VS = {};
|
|
Ref<ID3D12PipelineState> pso;
|
|
CHECK(device.p->CreateGraphicsPipelineState(&bad, IID_PPV_ARGS(&pso.p)) == E_INVALIDARG && !pso.p);
|
|
}
|
|
_putenv_s("LEONIDA_STUB_PIPELINES", "");
|
|
|
|
std::printf("%s\n", g_failed ? "FAILED" : "PASS");
|
|
return g_failed ? 1 : 0;
|
|
}
|