diff --git a/.gitignore b/.gitignore index b736876..8e2b3be 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,9 @@ build-linux/ # ---- NVIDIA's DLSS SDK (scripts/ngx_sdk.py): NVIDIA's files, never committed ---- ngx-sdk/ +# ---- RenoDX's shaders compiled (scripts/renodx_shaders.py): worked from the game's own shaders, never committed ---- +renodx_spv.h + # Triforce Setup's build output (setup\build.ps1, setup\pack_tools.ps1) setup/out/ build1.done diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 959654a..8a96082 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ Open an [issue](https://github.com/ruckus7382sfgsgdf/CBeta0.2/issues) and includ Before you report: -- Try the [newest release](https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases) first. +- Try the [newest release](https://triforceproject.com) first. - Search the open issues; if yours is there, add your details to it. - For graphics or performance problems, test without ReShade, overlays, shader-cache tools and frame-generation injectors: they change what Triforce does. @@ -70,7 +70,7 @@ versions do not work, and the build reads your files where they are without chan free and takes around 40 minutes; a run uses about 10 GB of RAM. Build on an SSD if you can. The easy way to get every tool a build needs is **Triforce Setup** from the -[releases](https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases): it installs the tools (Python with its packages, +[releases](https://triforceproject.com): it installs the tools (Python with its packages, llvm-mingw, the Vulkan headers, FFmpeg, SDL2) into `%LOCALAPPDATA%\Programs\Triforce\tools`. To build from a clone instead: @@ -102,6 +102,21 @@ on your real install. The translated C and every build are local files; they are never committed. +### RenoDX HDR (optional) + +RenoDX's tone mapping and HDR output for OoT (`gpu/vk/vk_renodx.cpp`) are built in only with RenoDX's Zelda OoT shaders +(github.com/clshortfuse/renodx, MIT). They are worked from the game's own shaders, so neither they nor what is compiled +from them (`renodx_spv.h`) is ever committed, bundled or uploaded. `--renodx` (the builder's RenoDX HDR tick) runs +`scripts/renodx_shaders.py`, which fetches the sources at one pinned commit and the Slang compiler at one pinned +release, each file checked against its SHA-256, and compiles them on the PC into a `renodx` folder beside the work +folder (or `HOOKSHOT_RENODX=`). An `--update` of that game folder keeps it; `--no-renodx` drops it. In the game +it works with the Insert menu's HDR set to Native, where its rows appear. + +Each replacement is named by the CRC-32 of the module the renderer's own emitter makes for that shader (the table in +`scripts/renodx_shaders.py`). A change to the emitter changes those, and RenoDX then replaces nothing, with only its +coverage line in the log to say so: dump the modules again (`RX_VK_DUMP_ALL_SPV=`) and match them by what they +read. Never share a game folder built with it. + ## Testing The game-free checks need no game files: diff --git a/builder/HookshotBuilder/BuilderSettings.cs b/builder/HookshotBuilder/BuilderSettings.cs index 53804bd..0ad5255 100644 --- a/builder/HookshotBuilder/BuilderSettings.cs +++ b/builder/HookshotBuilder/BuilderSettings.cs @@ -9,6 +9,7 @@ sealed class BuilderSettings public string? Exefs { get; set; } public bool Dlss { get; set; } // (NVIDIA DLSS ticked: NVIDIA's license was accepted) public bool Fsr { get; set; } // (AMD FSR 4 ticked) + public bool Renodx { get; set; } // (RenoDX HDR ticked) public bool PrepareLater { get; set; } // ("Prepare shaders now" unticked) public static BuilderSettings? Load(string path) diff --git a/builder/HookshotBuilder/MainWindow.xaml b/builder/HookshotBuilder/MainWindow.xaml index 96fff7f..807d13d 100644 --- a/builder/HookshotBuilder/MainWindow.xaml +++ b/builder/HookshotBuilder/MainWindow.xaml @@ -189,6 +189,12 @@ Content="AMD FSR 4 (AMD's files are not included: see the readme)"/> + + + diff --git a/builder/HookshotBuilder/MainWindow.xaml.cs b/builder/HookshotBuilder/MainWindow.xaml.cs index f22beea..c86d6cb 100644 --- a/builder/HookshotBuilder/MainWindow.xaml.cs +++ b/builder/HookshotBuilder/MainWindow.xaml.cs @@ -264,6 +264,7 @@ public partial class MainWindow : Window if (!string.IsNullOrEmpty(s.Out)) OutPath.Text = s.Out; DlssTick.IsChecked = s.Dlss; FsrTick.IsChecked = s.Fsr; + RenodxTick.IsChecked = s.Renodx; if (s.Romfs != null && s.Exefs != null && Directory.Exists(s.Romfs) && File.Exists(System.IO.Path.Combine(s.Exefs, "main"))) { romfs = s.Romfs; @@ -287,6 +288,7 @@ public partial class MainWindow : Window { var s = new BuilderSettings { Out = OutPath.Text, Nup = romfs == null ? chosenNup : null, Romfs = romfs, Exefs = exefs, Dlss = DlssTick.IsChecked == true, Fsr = FsrTick.IsChecked == true, + Renodx = RenodxTick.IsChecked == true, PrepareLater = PrepareTick.IsChecked != true }; Directory.CreateDirectory(System.IO.Path.GetDirectoryName(SettingsPath)!); File.WriteAllText(SettingsPath, System.Text.Json.JsonSerializer.Serialize(s)); @@ -703,6 +705,7 @@ public partial class MainWindow : Window else return; args.AddRange(new[] { "--out", OutPath.Text, "--language", lang.Code }); if (FsrTick.IsChecked == true) args.Add("--fsr"); // (an --update of the folder keeps it: make_game.py's mark) + if (RenodxTick.IsChecked == true) args.Add("--renodx"); // (the same: its shaders are fetched and compiled by the build) prepareNow = PrepareTick.IsChecked == true; Run(tools, ShaderStep.Args(args, prepareNow), dlss: DlssTick.IsChecked == true); } diff --git a/builder/linux/linux_update.py b/builder/linux/linux_update.py index 10ee8f8..f122d54 100644 --- a/builder/linux/linux_update.py +++ b/builder/linux/linux_update.py @@ -23,11 +23,14 @@ import zipfile from part_links import SYSROOT_PART, is_absolute_link, relative_sysroot_link LIST_NAME = "triforce-linux.txt" -REPO = "ruckus7382sfgsgdf/CBeta0.2" # (Triforce's releases) -LATEST_LIST = "https://github.com/%s/releases/latest/download/%s" % (REPO, LIST_NAME) +# (11-13: Triforce's own home. Releases are in triforce/downloads on its Forgejo: the list is asked on the main domain, +# which passes /api/v1 on; a release's files are the Forgejo's own links. Up to v0.3.5: github.com/ruckus7382sfgsgdf/CBeta0.2) +HOME_API = "https://triforceproject.com/api/v1/repos/triforce/downloads" +DOWNLOADS = "https://git.triforceproject.com/triforce/downloads" +LATEST_LIST = "%s/releases/latest/download/%s" % (DOWNLOADS, LIST_NAME) # (Triforce: the newest release, pre-releases too, as the Windows side asks: /releases/latest skips pre-releases, and # every Triforce release so far is one. The answer is a list of one release) -LATEST_API = "https://api.github.com/repos/%s/releases?per_page=1" % REPO +LATEST_API = HOME_API + "/releases?limit=1" # (the game folder's names, nx2/make_game.py's; Hookshot's after them, for a folder that still has those) GAME_NAMES = ("triforce", "hookshot") VERSION_FILES = ("triforce_version.txt", "hookshot_version.txt") @@ -551,7 +554,7 @@ def fetch_manifest(get=None): body = body[0] if body else {} tag = body.get("tag_name") or "" if tag and all(ch.isalnum() or ch in "._-" for ch in tag): - url = "https://github.com/%s/releases/download/%s/%s" % (REPO, tag, LIST_NAME) + url = "%s/releases/download/%s/%s" % (DOWNLOADS, tag, LIST_NAME) return parse_list(get(url).decode("utf-8"), local=False) except Exception: pass diff --git a/docs/development.md b/docs/development.md index 77a79a8..5b73059 100644 --- a/docs/development.md +++ b/docs/development.md @@ -143,7 +143,9 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_SKIP_PROG=,...` | Leaves out the draws of these programs (default `53509044401d78d2`; `-` leaves out none) | | `RX_VK_PIPE_SKIP=0`, `1` or `2` | Default/`1`: wait for shader translation; a pending pipeline can be skipped only for attachment-only draws whose targets hold an earlier frame. `0`: wait for every pipeline too. `2`: restore the old skip for untranslated draws with persistent targets; this can omit writes before the shader is known. Translated memory-writing draws still wait | | `RX_VK_PRECOMPILE=0` or `1` | The shader preparation before the title off or on (on in builds made with `RX_RELEASE=1`, as the builders' are) | +| `RX_VK_TASK_MESH_FALLBACK=0` or `1` | Task + mesh draws through the compute fallback (1) or the driver's mesh shaders (0). By default the fallback is on for AMD's Navi 21 and Navi 22 on Windows (RX 6800, 6800 XT, 6900 XT, 6950 XT, 6700 XT), where the native path timed out the driver (issue 996) | | `RX_VK_NO_PROGRAM_CACHE` (set) | Neither reads nor writes `hookshot_programs.bin` and the pipeline notes | +| `RX_VK_FETCH_BOUNDS=0` or `1`, `RX_VK_NAN_BITS=0` or `1`, `RX_VK_GATHER_OFFSET=0` or `1` | The translation's vendor and driver workarounds (`gpu/vk/vk_vendor.h`) off or on for one run, whatever the GPU; the log's `vk: vendor fixes` line says which are on. By default: out-of-bounds texel fetches answered with 0 on every GPU but NVIDIA's; NaN tests on a value's bits on AMD's older Windows shader compiler (RX 5000 and RX 6000); gathers nudged by 1/512 of a texel on AMD's and Intel's drivers. They change the shaders' translation (one preparation of the shaders) | | `RX_VK_MIRROR=0`, `RX_VK_MIRROR_MB=` | No VRAM mirrors of the game's memory pools (on for discrete cards); their budget | | `RX_VK_VRAM_MB=` | The texture cache's budget (default 70% of what the driver allows, at most 6 GB) | | `RX_VK_COMPACT=1`, `RX_VK_COMPACT_PCT=<50..90>`, `RX_VK_COMPACT_MB=` | VRAM compaction (off by default): the textures that are not render targets in a pool of their own, moved out of sparsely used blocks a few a present so that the blocks go back to the driver, and the texture budget holding the driver's count at that share of what it allows (85); the free space that starts a run (512; 192 while the count is over 90%) | diff --git a/gpu/vk/dlss_actor.h b/gpu/vk/dlss_actor.h index d9a36d9..c664fa3 100644 --- a/gpu/vk/dlss_actor.h +++ b/gpu/vk/dlss_actor.h @@ -1,5 +1,6 @@ -// (hookshot) NVIDIA DLSS's actor motion (vk_dlss.cpp): what is worked out on the CPU for a skinned draw drawn again, kept -// apart so tests/test_dlss_actor.cpp checks it without a GPU. Header only, no Vulkan. +// (hookshot) The temporal upscaler's own motion (vk_temporal.cpp): what is worked out on the CPU for a draw drawn again, from +// its bones (actor_motion) or from the positions its vertex stage stored (capture_motion), kept apart so +// tests/test_dlss_actor.cpp checks it without a GPU. Header only, no Vulkan. #pragma once #include @@ -36,21 +37,119 @@ struct Push { uint32_t pos, sets; // (bytes in a vertex: the position; the joint and weight sets, 1 or 2) uint32_t joints[2], weights[2]; uint32_t formats; // (kHalfPosition, kByteJoints << set) - uint32_t tolerance; // (depth steps from the scene's within which a pixel is the draw's) + uint32_t tolerance; // (unused: dlss_actor.frag reads the cameras' buffer's word 66) }; static_assert(sizeof(Push) == 6 * 8 + 14 * 4 && sizeof(Push) <= 128, "dlss_actor.vert's push constants"); +/// A draw's pose in a pose buffer: its origin (12 bytes, at 0), the view it was drawn with (3 x 4 row major, at 16), its +/// projection (4 x 4, at 64), then its bones (at kPoseHead); Push::origins and bones point there +constexpr uint32_t kPoseHead = 128; + +/// Push::itype of a draw without indices (a plain vertex array): its vertex i is base_vertex + i +constexpr int kNoIndices = 3; + /// Where a draw's indices are for the shader: the address 4-aligned down, and its first index from there inline void index_start(uint64_t address, int itype, uint64_t* aligned, uint32_t* first) { *aligned = address & ~3ull; *first = (uint32_t)((address & 3) >> (itype < 0 ? 0 : itype > 2 ? 2 : itype)); } -/// Push::formats: the position is RGBA16F (else RGB32F); a set's joints are RGBA8UI (else RGBA16UI) -constexpr uint32_t kHalfPosition = 1, kByteJoints = 2; +/// Push::formats: the position is RGBA16F (else RGB32F); a set's joints are 8-bit (else 16-bit); how many joints and weights +/// a set has (kCountShift + 2 * set: 0 four, 1 one, 2 two: RGBA, R or RG formats); kRigid: no weights, set 0's one joint has +/// all of the vertex (a part that moves with one bone). Joints and weights are read byte by byte, at any offset +constexpr uint32_t kHalfPosition = 1, kByteJoints = 2, kCountShift = 4, kRigid = 1u << 8; +/// The count code of a set of n joints and weights (1, 2 or 4), for Push::formats; 3 (none) for any other n +inline uint32_t count_code(int n) { return n == 4 ? 0u : n == 1 ? 1u : n == 2 ? 2u : 3u; } +/// How many joints and weights a set has, from Push::formats +inline int set_count(uint32_t formats, int set) { + const uint32_t c = (formats >> (kCountShift + 2 * set)) & 3u; + return c == 0 ? 4 : c == 1 ? 1 : c == 2 ? 2 : 0; +} -/// The cameras' buffer, 36 words: this frame's camera (as drawn, jittered), the frame before's (its jitter taken off), this -/// frame's jitter in clip space, the render size -constexpr uint32_t kHeadWords = 36; +/// The cameras' buffer: this frame's camera (as drawn, jittered), the frame before's (its jitter taken off), this frame's +/// jitter in clip space, the render size (words 0 to 35); then this frame's view (3 x 4, row major) and projection (4 x 4), +/// apart, as the game's vertex shaders apply them (36 to 63); then its near and far planes (0: not a plain perspective +/// projection), for the fragment stage's test in distance (64, 65); the tolerance of that test in thousandths of the +/// distance, kMarkBit for RX_VK_DLSS_DEBUG=actors and kOwnBit with it for =characters (66); the frame before's jitter in clip space (68, 69), which +/// dlss_capture.vert takes off the positions stored then; this frame's clip space to the frame before's (72 to 87, as +/// shaders/dlss_prep.comp's reproject: the camera's motion), which the fragment stage's mark compares the draw's own with +constexpr uint32_t kHeadWords = 88; +constexpr uint32_t kToleranceWord = 66, kJitterBeforeWord = 68, kReprojectWord = 72, kMarkBit = 0x80000000u; +/// (with kMarkBit: the mark is not a motion but kOwnMark in x, which no motion is, and in y how far the draw's own motion +/// is from the camera's, in render pixels: shaders/dlss_prep.comp's flag 8 shows those pixels blue on grey) +constexpr uint32_t kOwnBit = 0x40000000u; +constexpr float kOwnMark = -30000.0f; + +/// shaders/dlss_capture.vert's push constants: a draw's slots this frame and the frame before (the address of the first, the +/// vertex index it is, how many) +struct CapturePush { + uint64_t now; + uint64_t before; + uint32_t first_now; + uint32_t first_before; + uint32_t count_now; + uint32_t count_before; + float jitter_now[2]; // (the jitter of the camera the draw was drawn with, in clip space: this frame's, the frame before's) + float jitter_before[2]; +}; +static_assert(sizeof(CapturePush) == 48, "dlss_capture.vert's push constants"); + +/// The jitter of the camera a draw was drawn with, from its projection (4 x 4 row major, the vertex stage's uniform buffer 3 +/// at 0x70): the offset in its third column, as the scene's (vk_temporal.cpp temporal_note_scene_draw). False when it is not +/// a perspective projection (its w row not 0, 0, -1, 0) or the offset is not a sub-pixel one: the scene's is used then +inline bool camera_jitter(const float proj[16], float out[2]) { + if (proj[12] != 0.0f || proj[13] != 0.0f || proj[14] != -1.0f || proj[15] != 0.0f) return false; + const float x = -proj[2], y = -proj[6]; + if (!(x > -0.05f && x < 0.05f && y > -0.05f && y < 0.05f)) return false; + out[0] = x, out[1] = y; + return true; +} + +/// The vertices an indexed draw's count indices name (itype 0, 1, 2: 8, 16, 32 bits): the least and the greatest. With +/// restart, the restart index (all ones) is none. False when there is none +inline bool index_range(const void* indices, int count, int itype, bool restart, uint32_t* lo, uint32_t* hi) { + if (count <= 0 || itype < 0 || itype > 2) return false; + const uint32_t size = 1u << itype; + const uint32_t cut = itype == 0 ? 0xffu : itype == 1 ? 0xffffu : 0xffffffffu; + uint32_t a = UINT32_MAX, b = 0; + bool any = false; + for (int i = 0; i < count; i++) { + uint32_t v = 0; + std::memcpy(&v, (const uint8_t*)indices + (size_t)i * size, size); + if (restart && v == cut) continue; + a = std::min(a, v), b = std::max(b, v), any = true; + } + if (any) *lo = a, *hi = b; + return any; +} + +/// A draw's slots for its stored positions: the vertex index of the first (as the vertex stage sees it, the base vertex in it) +/// and how many, at most max. Indexed (itype 0 to 2): base_vertex + lo to base_vertex + hi; without indices (kNoIndices): +/// base_vertex (the draw's first) and count on. False when there are none, or more than max +inline bool capture_span(int itype, int count, int base_vertex, uint32_t lo, uint32_t hi, uint32_t max, uint32_t* first, + uint32_t* n) { + if (count <= 0) return false; + uint64_t many; + if (itype == kNoIndices) *first = (uint32_t)base_vertex, many = (uint64_t)count; + else if (itype >= 0 && itype <= 2 && lo <= hi) *first = (uint32_t)base_vertex + lo, many = (uint64_t)hi - lo + 1; + else return false; + if (many > max) return false; + *n = (uint32_t)many; + return true; +} + +/// The slot of a vertex (its VertexIndex) in a span, as the vertex stages take it (unsigned, wrapping): false when outside +inline bool capture_slot(int32_t vertex_index, uint32_t first, uint32_t n, uint32_t* slot) { + const uint32_t s = (uint32_t)vertex_index - first; + if (s >= n) return false; + *slot = s; + return true; +} + +/// A clip position stored the frame before, its jitter taken off (dlss_capture.vert; dlss_math::unjitter on a camera) +inline void unjitter_position(float p[4], const float jitter[2]) { + p[0] -= jitter[0] * p[3]; + p[1] -= jitter[1] * p[3]; +} } // namespace dlss_actor diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp index a634acc..a629048 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp @@ -117,6 +117,15 @@ void EmitInst(EmitContext& ctx, IR::Inst* inst) { EmitInstOf(ctx, inst); } catch (const NotImplementedException& e) { throw NotImplementedException("{} ({})", e.what(), IR::NameOf(inst->GetOpcode())); + } catch (const std::runtime_error& e) { // (super build: sirit's null Id, named by the IR op that asked for it) + std::string args; + for (size_t i = 0; i < inst->NumArgs(); ++i) { + const IR::Value a{inst->Arg(i)}; + args += a.IsImmediate() ? " imm" : a.IsEmpty() ? " empty" : a.IsIdentity() ? " identity" + : (" " + std::string(IR::NameOf(a.InstRecursive()->GetOpcode())) + + (a.InstRecursive()->Definition().value == 0 ? "(undefined)" : "")); + } + throw LogicError("{} ({}; args:{})", e.what(), IR::NameOf(inst->GetOpcode()), args); } } diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h index e255817..3ef6601 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.h @@ -45,6 +45,13 @@ constexpr u32 MESH_FALLBACK_PAYLOAD_PUSH_OFFSET = MESH_FALLBACK_PUSH_OFFSET; constexpr u32 MESH_FALLBACK_RECORDS_PUSH_OFFSET = MESH_FALLBACK_PUSH_OFFSET + 8; constexpr u32 MESH_FALLBACK_INDIRECT_INPUT_PUSH_OFFSET = MESH_FALLBACK_PUSH_OFFSET + 16; constexpr u32 MESH_FALLBACK_PUSH_END = MESH_FALLBACK_PUSH_OFFSET + 24; +// (hookshot) a scene vertex stage's position capture (RuntimeInfo::capture_position), after them: the u64 address its slots +// start at (0: none), the vertex index of slot 0 (a u32, the slot taken from VertexIndex wrapping) and the slots there are +// (u32). A vertex stores its position (vec4, 16 bytes) at address + (VertexIndex - first) * 16 when that is below the count +constexpr u32 CAPTURE_PUSH_OFFSET = MESH_FALLBACK_PUSH_END; +constexpr u32 CAPTURE_FIRST_PUSH_OFFSET = CAPTURE_PUSH_OFFSET + 8; +constexpr u32 CAPTURE_COUNT_PUSH_OFFSET = CAPTURE_PUSH_OFFSET + 12; +constexpr u32 CAPTURE_PUSH_END = CAPTURE_PUSH_OFFSET + 16; // (hookshot) the fallback's mesh workgroups a draw can run: each a slot, a word of the payload buffer saying whether its task // started it; then each task workgroup's payload. It was 1024, a record block each, and Ocarina's floor grass (433 tasks of // 32 slots) lost 13 of 14 meshlets. At 16384, Hyrule Field's far trees (3cb76827/4f0c0b40: 721 tasks of 32) lost the tasks diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index e85f914..ae5d1fe 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -323,7 +323,16 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { } const Id pointer{ AttrPointer(ctx, generic.pointer_type, vertex, generic.id, ctx.Const(element))}; - const Id value{ctx.OpLoad(generic.component_type, pointer)}; + Id value{ctx.OpLoad(generic.component_type, pointer)}; + if (ctx.stage == Stage::Fragment && ctx.noperspective_as_smooth_inputs[index]) { + // Written times Position.w and interpolated perspective-correct: undo with 1/w. + // Only float inputs are marked, and DefineInputs forces FragCoord for them. + ASSERT(generic.load_op == InputGenericLoadOp::None && ValidId(ctx.input_position)); + const Id frag_w{ctx.OpLoad( + ctx.F32[1], + ctx.OpAccessChain(ctx.input_f32, ctx.input_position, ctx.Const(3u)))}; + value = ctx.OpFMul(ctx.F32[1], value, frag_w); + } return [&ctx, generic, value]() { switch (generic.load_op) { case InputGenericLoadOp::Bitcast: @@ -502,7 +511,7 @@ void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, Id value) { const Id pointer{ctx.OpAccessChain(ctx.output_f32, ctx.frag_color.at(index), component_id)}; if (frag_nan_guard) { // (amd-fix, mma_layout.h) NaN -> 0, the rest clamped to +-1e30 const Id clamped{ctx.OpNMin(ctx.F32[1], ctx.OpNMax(ctx.F32[1], value, ctx.Const(-1e30f)), ctx.Const(1e30f))}; - value = ctx.OpSelect(ctx.F32[1], ctx.OpIsNan(ctx.U1, value), ctx.Const(0.0f), clamped); + value = ctx.OpSelect(ctx.F32[1], IsNan(ctx, value, 32), ctx.Const(0.0f), clamped); } ctx.OpStore(pointer, value); } else if (type == AttributeType::UnsignedInt) { diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_convert.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_convert.cpp index 9fa84cc..5258f03 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_convert.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_convert.cpp @@ -155,7 +155,7 @@ Id EmitConvertF16F32(EmitContext& ctx, Id value) { return ctx.OpFConvert(ctx.F16[1], value); #else const auto result = ctx.OpFConvert(ctx.F16[1], value); - const auto isOverflowing = ctx.OpIsNan(ctx.U1, result); + const auto isOverflowing = IsNan(ctx, result, 16); // (hookshot: mma_layout.h nan_bits) return ctx.OpSelect(ctx.F16[1], isOverflowing, ctx.Constant(ctx.F16[1], 0), result); #endif } diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp index 9ce375c..5d04e2e 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" +#include "shader_recompiler/backend/spirv/mma_layout.h" #include "shader_recompiler/backend/spirv/spirv_emit_context.h" #include "shader_recompiler/frontend/ir/modifiers.h" @@ -381,16 +382,40 @@ Id EmitFPUnordGreaterThanEqual64(EmitContext& ctx, Id lhs, Id rhs) { return FPUnordCompare(&EmitContext::OpFUnordGreaterThanEqual, ctx, lhs, rhs); } +// (hookshot) isnan of a scalar float of that many bits. With nan_bits (mma_layout.h: AMD's older Windows shader compiler) it is +// a test of the value's bits, a NaN being an exponent of all ones and a mantissa that is not 0, which no float-mode setting of the +// compiler can fold away; else OpIsNan, as before +Id IsNan(EmitContext& ctx, Id value, u32 bits) { + if (!nan_bits) { + return ctx.OpIsNan(ctx.U1, value); + } + if (bits == 64) { + const Id words{ctx.OpBitcast(ctx.U32[2], value)}; + const Id high{ctx.OpBitwiseAnd(ctx.U32[1], ctx.OpCompositeExtract(ctx.U32[1], words, 1U), + ctx.Const(0x7fffffffu))}; + const Id low{ctx.OpCompositeExtract(ctx.U32[1], words, 0U)}; + const Id infinity{ctx.Const(0x7ff00000u)}; + return ctx.OpLogicalOr(ctx.U1, ctx.OpUGreaterThan(ctx.U1, high, infinity), + ctx.OpLogicalAnd(ctx.U1, ctx.OpIEqual(ctx.U1, high, infinity), + ctx.OpINotEqual(ctx.U1, low, ctx.u32_zero_value))); + } + if (bits == 16) { + value = ctx.OpFConvert(ctx.F32[1], value); // (exact: a NaN stays a NaN, and nothing else becomes one) + } + const Id magnitude{ctx.OpBitwiseAnd(ctx.U32[1], ctx.OpBitcast(ctx.U32[1], value), ctx.Const(0x7fffffffu))}; + return ctx.OpUGreaterThan(ctx.U1, magnitude, ctx.Const(0x7f800000u)); +} + Id EmitFPIsNan16(EmitContext& ctx, Id value) { - return ctx.OpIsNan(ctx.U1, value); + return IsNan(ctx, value, 16); } Id EmitFPIsNan32(EmitContext& ctx, Id value) { - return ctx.OpIsNan(ctx.U1, value); + return IsNan(ctx, value, 32); } Id EmitFPIsNan64(EmitContext& ctx, Id value) { - return ctx.OpIsNan(ctx.U1, value); + return IsNan(ctx, value, 64); } } // namespace Shader::Backend::SPIRV diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_image.cpp index bdac534..2bbc4b6 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_image.cpp @@ -9,6 +9,7 @@ #include "common/settings.h" #include "shader_recompiler/backend/spirv/emit_spirv.h" #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" +#include "shader_recompiler/backend/spirv/mma_layout.h" #include "shader_recompiler/backend/spirv/spirv_emit_context.h" #include "shader_recompiler/frontend/ir/modifiers.h" @@ -445,9 +446,10 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, case TextureType::Color2DRect: return calculate_coords(2); case TextureType::ColorArray2D: - case TextureType::ColorCube: return calculate_coords(3); default: + // (hookshot) a cube's coordinates are a direction: no texel to nudge by, and its size query has two components, not + // three (the cube case here made invalid SPIR-V: OpImageQuerySizeLod's result of three components on a cube) return coords; } } @@ -488,6 +490,64 @@ void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, I } coords = ctx.OpIAdd(result_type, coords, offset); } +// (hookshot, mma_layout.h fetch_bounds) Whether a texel fetch of image at coords (with its level, or its sample, when it has one) +// is inside the image, as U1; coords, lod and sample are made ones that are (a coordinate out of range 0, a level or sample past +// the last 0), so that the fetch itself never leaves the image, and the caller answers zero for it. NVIDIA's GPUs answer an +// out-of-bounds fetch with zero (measured on an RTX 3090 with robustness off: every texture type, past each edge, past the last +// level and the last sample; the alpha of a format without one is 1 there, as in range, and 0 here: the translation does not +// know the format). Vulkan leaves such a fetch undefined without robustImageAccess, and on AMD the ground fog's depth reads at +// points projected off screen took the other branch: a pale box at the screen's edges (found by Ocarina of Lain's author on +// an RX 9070). Id{}: a type left as it was: a texel buffer while robustBufferAccess2 is on (on by default: the Robust buffers +// row), which answers its out-of-bounds reads with zero already (fetch_bounds_buffers), and the cube types, which no fetch reads +Id FetchInBounds(EmitContext& ctx, const IR::TextureInstInfo& info, Id image, Id& coords, Id& lod, Id& sample) { + u32 dims{}; + switch (info.type) { + case TextureType::Buffer: + if (!fetch_bounds_buffers) { + return Id{}; + } + dims = 1; + break; + case TextureType::Color1D: + dims = 1; + break; + case TextureType::ColorArray1D: + case TextureType::Color2D: + case TextureType::Color2DRect: + dims = 2; + break; + case TextureType::ColorArray2D: + case TextureType::Color3D: + dims = 3; + break; + default: + return Id{}; + } + const Id size_type{ctx.U32[dims]}; + Id level_ok{}; + Id size{}; + if (Sirit::ValidId(lod)) { + const Id levels{ctx.OpImageQueryLevels(ctx.U32[1], image)}; + level_ok = ctx.OpULessThan(ctx.U1, lod, levels); + lod = ctx.OpSelect(ctx.U32[1], level_ok, lod, ctx.u32_zero_value); + size = ctx.OpImageQuerySizeLod(size_type, image, lod); + } else { + size = ctx.OpImageQuerySize(size_type, image); // (a texel buffer, or a multisampled image) + } + // (unsigned: a negative coordinate is past the end too) + const Id inside{ctx.OpULessThan(dims == 1 ? ctx.U1 : ctx.TypeVector(ctx.U1, dims), coords, size)}; + coords = ctx.OpSelect(size_type, inside, coords, ctx.ConstantNull(size_type)); + Id in_bounds{dims == 1 ? inside : ctx.OpAll(ctx.U1, inside)}; + if (Sirit::ValidId(level_ok)) { + in_bounds = ctx.OpLogicalAnd(ctx.U1, in_bounds, level_ok); + } + if (Sirit::ValidId(sample)) { + const Id sample_ok{ctx.OpULessThan(ctx.U1, sample, ctx.OpImageQuerySamples(ctx.U32[1], image))}; + sample = ctx.OpSelect(ctx.U32[1], sample_ok, sample, ctx.u32_zero_value); + in_bounds = ctx.OpLogicalAnd(ctx.U1, in_bounds, sample_ok); + } + return in_bounds; +} } // Anonymous namespace Id EmitBindlessImageSampleImplicitLod(EmitContext&) { @@ -724,6 +784,17 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c // This image is multisampled, lod must be implicit lod = Id{}; } + if (fetch_bounds) { // (hookshot: FetchInBounds) + const Id image{TextureImage(ctx, info, index)}; + const Id in_bounds{FetchInBounds(ctx, info, image, coords, lod, ms)}; + const ImageOperands operands(lod, ms); + Id color{Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, + result_type, image, coords, operands.MaskOptional(), operands.Span())}; + if (Sirit::ValidId(in_bounds)) { + color = ctx.OpSelect(result_type, in_bounds, color, ctx.ConstantNull(result_type)); + } + return is_integer ? ctx.OpBitcast(ctx.F32[4], color) : color; + } const ImageOperands operands(lod, ms); const Id color{Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, result_type, TextureImage(ctx, info, index), coords, diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_instructions.h index d6262e2..b716c23 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -644,4 +644,7 @@ Id EmitDPdyFine(EmitContext& ctx, Id op_a); Id EmitDPdxCoarse(EmitContext& ctx, Id op_a); Id EmitDPdyCoarse(EmitContext& ctx, Id op_a); +// (hookshot) Helpers the emitters share, not IR instructions +Id IsNan(EmitContext& ctx, Id value, u32 bits); // (OpIsNan, or a test of the bits: mma_layout.h nan_bits) + } // namespace Shader::Backend::SPIRV diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_special.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_special.cpp index 2b36c1f..daa83de 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_special.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_special.cpp @@ -4,6 +4,9 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include + #include "shader_recompiler/backend/spirv/emit_spirv.h" #include "shader_recompiler/backend/spirv/emit_spirv_instructions.h" #include "shader_recompiler/backend/spirv/spirv_emit_context.h" @@ -20,6 +23,74 @@ void ConvertDepthMode(EmitContext& ctx) { ctx.OpStore(ctx.output_position, vector); } +/// Output variable and the unscaled value it held before ScaleNoPerspectiveOutputs. +using ScaledOutputs = std::vector>; + +/// Write screen-linear generic outputs times Position.w (see RuntimeInfo::noperspective_outputs). +/// Returns the unscaled values so a geometry shader can restore them after EmitVertex. +ScaledOutputs ScaleNoPerspectiveOutputs(EmitContext& ctx) { + ScaledOutputs saved; + if (ctx.runtime_info.noperspective_outputs.none() || !Sirit::ValidId(ctx.output_position)) { + return saved; + } + const Id position{ctx.OpLoad(ctx.F32[4], ctx.output_position)}; + const Id w{ctx.OpCompositeExtract(ctx.F32[1], position, 3u)}; + for (size_t index = 0; index < ctx.output_generics.size(); ++index) { + if (!ctx.runtime_info.noperspective_outputs.test(index)) { + continue; + } + Id last{}; + for (const GenericElementInfo& element : ctx.output_generics[index]) { + if (!Sirit::ValidId(element.id) || element.id.value == last.value || + element.num_components == 0) { + continue; + } + last = element.id; + const Id type{ctx.F32[element.num_components]}; + const Id value{ctx.OpLoad(type, element.id)}; + const Id scaled{element.num_components == 1 ? ctx.OpFMul(type, value, w) + : ctx.OpVectorTimesScalar(type, value, w)}; + ctx.OpStore(element.id, scaled); + saved.emplace_back(element.id, value); + } + } + return saved; +} + +/// A geometry shader keeps its outputs between EmitVertex calls: restore the unscaled values. +void RestoreNoPerspectiveOutputs(EmitContext& ctx, const ScaledOutputs& saved) { + for (const auto& [id, value] : saved) { + ctx.OpStore(id, value); + } +} + +/// (hookshot) RuntimeInfo::capture_position: the position as the stage leaves it, stored at the pushed address's slot for +/// this vertex (CAPTURE_PUSH_OFFSET), when the address is not 0 and the slot below the pushed count. What is drawn is not +/// changed: the store is the stage's last act, and reads only what it wrote +void CapturePosition(EmitContext& ctx) { + const auto push = [&](Id type, u32 member) { + const Id pointer{ctx.TypePointer(spv::StorageClass::PushConstant, type)}; + return ctx.OpLoad(type, ctx.OpAccessChain(pointer, ctx.rescaling_push_constants, ctx.Const(member))); + }; + const Id address{push(ctx.U64, ctx.capture_address_member_index)}; + const Id first{push(ctx.U32[1], ctx.capture_first_member_index)}; + const Id count{push(ctx.U32[1], ctx.capture_count_member_index)}; + const Id slot{ctx.OpISub(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.capture_vertex_index), first)}; + const Id zero{ctx.Constant(ctx.U64, u64{0})}; + const Id wanted{ctx.OpLogicalAnd(ctx.U1, ctx.OpINotEqual(ctx.U1, address, zero), ctx.OpULessThan(ctx.U1, slot, count))}; + const Id store_label{ctx.OpLabel()}; + const Id end_label{ctx.OpLabel()}; + ctx.OpSelectionMerge(end_label, spv::SelectionControlMask::MaskNone); + ctx.OpBranchConditional(wanted, store_label, end_label); + ctx.AddLabel(store_label); + const Id offset{ctx.OpIMul(ctx.U64, ctx.OpUConvert(ctx.U64, slot), ctx.Constant(ctx.U64, u64{16}))}; + const Id at{ctx.OpIAdd(ctx.U64, address, offset)}; + const Id position{ctx.OpLoad(ctx.F32[4], ctx.output_position)}; + ctx.OpStore(ctx.OpConvertUToPtr(ctx.capture_pointer, at), position, spv::MemoryAccessMask::Aligned, 16U); + ctx.OpBranch(end_label); + ctx.AddLabel(end_label); +} + void SetFixedPipelinePointSize(EmitContext& ctx) { if (ctx.runtime_info.fixed_state_point_size) { const float point_size{*ctx.runtime_info.fixed_state_point_size}; @@ -151,6 +222,12 @@ void EmitEpilogue(EmitContext& ctx) { !ctx.profile.support_native_ndc) { ConvertDepthMode(ctx); } + if (ctx.stage == Stage::VertexB || ctx.stage == Stage::TessellationEval) { + ScaleNoPerspectiveOutputs(ctx); + } + if (ctx.stage == Stage::VertexB && ctx.wants_capture) { // (after the depth's conversion: the position as drawn) + CapturePosition(ctx); + } if (ctx.stage == Stage::Fragment) { AlphaTest(ctx); } @@ -160,6 +237,7 @@ void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { if (ctx.runtime_info.convert_depth_mode && !ctx.profile.support_native_ndc) { ConvertDepthMode(ctx); } + const ScaledOutputs scaled{ScaleNoPerspectiveOutputs(ctx)}; if (!ctx.profile.support_geometry_streams) { throw NotImplementedException("Geometry streams"); } else if (stream.IsImmediate()) { @@ -170,6 +248,7 @@ void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { } // Restore fixed pipeline point size after emitting the vertex SetFixedPipelinePointSize(ctx); + RestoreNoPerspectiveOutputs(ctx, scaled); } void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) { diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/mma_layout.h b/gpu/vk/eden/shader_recompiler/backend/spirv/mma_layout.h index 7d47b11..7af771c 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/mma_layout.h +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/mma_layout.h @@ -25,5 +25,15 @@ inline bool frag_nan_guard = false; // the colour pass is then rejected in spots: holes showing the bright sky, blown up by bloom (the glowing flowers). // On for every card but NVIDIA (vk_coopmat.cpp); RX_VK_NO_INVARIANT=1 off. From NX2navi patch 0007. inline bool position_invariant = false; +// (hookshot) An out-of-bounds texel fetch answers zero, as NVIDIA's GPUs answer it (measured on an RTX 3090), rather than +// whatever the host's does (EmitImageFetch). Vulkan leaves it undefined without robustImageAccess; on AMD the ground fog's +// off-screen depth reads drew a pale box at the screen's edges. Every card but NVIDIA (gpu/vk/vk_vendor.h); RX_VK_FETCH_BOUNDS +inline bool fetch_bounds = false; +// (hookshot) and texel buffers' fetches too: only when robustBufferAccess2 is off (the Debug tab's Robust buffers Off, RX_VK_ROBUST=0, +// or a driver without it), which otherwise answers their out-of-bounds reads with zero already (vk_coopmat.cpp) +inline bool fetch_bounds_buffers = false; +// (hookshot) isnan tested on the value's bits (IsNan in emit_spirv_floating_point.cpp), not OpIsNan, for AMD's older Windows +// shader compiler (RX 5000 and RX 6000: gpu/vk/vk_vendor.h); RX_VK_NAN_BITS=0 or 1 +inline bool nan_bits = false; } // namespace Shader::Backend::SPIRV diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 1de1160..d9daec6 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -524,6 +524,12 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf if (runtime_info.mesh_fallback || runtime_info.mesh_fallback_vertex) { wants_mesh_fallback = true; // (before any DefineRescalingInputPushConstant, which is made once) } + // (hookshot) a scene vertex stage's position capture: its members go in the one push block, so decided before it is made. + // Not with the render area's block (a second push block; full-screen passes, never the scene's geometry) + if (runtime_info.capture_position && stage == Stage::VertexB && !runtime_info.mesh_fallback_vertex && + profile.unified_descriptor_binding && profile.support_int64 && !program.info.uses_render_area) { + wants_capture = true; + } DefineCommonTypes(program.info); DefineCommonConstants(); DefineInterfaces(program); @@ -576,6 +582,21 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf mesh_info = program.mesh; DefineRescalingInputPushConstant(); } + if (wants_capture) { // (the store itself: EmitEpilogue, emit_spirv_special.cpp) + if (!Sirit::ValidId(U64)) { + AddCapability(spv::Capability::Int64); + U64 = Name(TypeInt(64, false), "u64"); + } + AddCapability(spv::Capability::PhysicalStorageBufferAddresses); + AddExtension("SPV_KHR_physical_storage_buffer"); + SetMemoryModel(spv::AddressingModel::PhysicalStorageBuffer64, spv::MemoryModel::GLSL450); + // (Vulkan's VertexIndex, base vertex included: the redraw draws the same indices with the same base) + capture_vertex_index = Sirit::ValidId(vertex_index) + ? vertex_index + : DefineInput(*this, U32[1], true, spv::BuiltIn::VertexIndex); + capture_pointer = TypePointer(spv::StorageClass::PhysicalStorageBuffer, F32[4]); + program.info.captures_position = true; + } DefineMesh(program); DefineLocalMemory(program); DefineSharedMemory(program); @@ -592,6 +613,13 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf DefineGlobalMemoryFunctions(program.info); DefineRescalingInput(program.info); DefineRenderArea(program.info); + // (the capture's push block, when nothing above made it. Not made before them: the block is made once, with the members + // wanted by then, and DefineGlobalMemoryFunctions asks for the page table's (wants_guest_pages) only as it runs. Made + // earlier, the block had no such member, the stage read the table's address from member 0, and the GPU was lost at the + // first frame in play) + if (wants_capture) { + DefineRescalingInputPushConstant(); + } } EmitContext::~EmitContext() = default; @@ -1603,6 +1631,14 @@ void EmitContext::DefineRescalingInputPushConstant() { mesh_fallback_indirect_input_member_index = member_index++; } } + if (wants_capture) { + members.push_back(U64); + capture_address_member_index = member_index++; + members.push_back(U32[1]); + capture_first_member_index = member_index++; + members.push_back(U32[1]); + capture_count_member_index = member_index++; + } const Id push_constant_struct{TypeStruct(std::span(members.data(), members.size()))}; Decorate(push_constant_struct, spv::Decoration::Block); Name(push_constant_struct, "ResolutionInfo"); @@ -1641,6 +1677,14 @@ void EmitContext::DefineRescalingInputPushConstant() { MESH_FALLBACK_INDIRECT_INPUT_PUSH_OFFSET); } } + if (wants_capture) { + MemberDecorate(push_constant_struct, capture_address_member_index, spv::Decoration::Offset, CAPTURE_PUSH_OFFSET); + MemberDecorate(push_constant_struct, capture_first_member_index, spv::Decoration::Offset, CAPTURE_FIRST_PUSH_OFFSET); + MemberDecorate(push_constant_struct, capture_count_member_index, spv::Decoration::Offset, CAPTURE_COUNT_PUSH_OFFSET); + MemberName(push_constant_struct, capture_address_member_index, "capture_address"); + MemberName(push_constant_struct, capture_first_member_index, "capture_first"); + MemberName(push_constant_struct, capture_count_member_index, "capture_count"); + } const Id pointer_type{TypePointer(spv::StorageClass::PushConstant, push_constant_struct)}; rescaling_push_constants = AddGlobalVariable(pointer_type, spv::StorageClass::PushConstant); Name(rescaling_push_constants, "rescaling_push_constants"); @@ -2017,6 +2061,12 @@ void EmitContext::DefineImages(const Info& info, u32& binding, u32& scaling_inde void EmitContext::DefineInputs(const IR::Program& program) { const Info& info{program.info}; const VaryingState loads{info.loads.mask | info.passthrough.mask}; + const bool noperspective_as_smooth{ + stage == Stage::Fragment && runtime_info.scaled_noperspective_inputs && + std::ranges::any_of(info.interpolation, + [](Interpolation mode) { + return mode == Interpolation::NoPerspective; + })}; if (info.uses_workgroup_id) { workgroup_id = DefineInput(*this, U32[3], false, spv::BuiltIn::WorkgroupId); @@ -2084,7 +2134,8 @@ void EmitContext::DefineInputs(const IR::Program& program) { layer = DefineInput(*this, U32[1], false, spv::BuiltIn::Layer); Decorate(layer, spv::Decoration::Flat); } - if (loads.AnyComponent(IR::Attribute::PositionX)) { + if (loads.AnyComponent(IR::Attribute::PositionX) || + info.passthrough.AnyComponent(IR::Attribute::PositionX) || noperspective_as_smooth) { const bool is_fragment{stage == Stage::Fragment}; if (!is_fragment && profile.has_broken_spirv_position_input) { need_input_position_indirect = true; @@ -2189,7 +2240,12 @@ void EmitContext::DefineInputs(const IR::Program& program) { case Interpolation::Smooth: break; case Interpolation::NoPerspective: - Decorate(id, spv::Decoration::NoPerspective); + // The previous stage may write it times Position.w (noperspective_outputs). + if (!runtime_info.scaled_noperspective_inputs) { + Decorate(id, spv::Decoration::NoPerspective); + } else { + noperspective_as_smooth_inputs[index] = true; + } break; case Interpolation::Flat: Decorate(id, spv::Decoration::Flat); diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.h b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.h index f491c9e..e7f5915 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.h @@ -369,6 +369,8 @@ public: bool need_input_position_indirect{}; Id input_position{}; std::array input_generics{}; + /// Screen-linear fragment inputs read through perspective interpolation, times FragCoord.w. + std::array noperspective_as_smooth_inputs{}; Id output_point_size{}; Id output_position{}; @@ -429,6 +431,13 @@ public: u32 mesh_fallback_payload_member_index{}; u32 mesh_fallback_records_member_index{}; u32 mesh_fallback_indirect_input_member_index{}; + /// (hookshot) RuntimeInfo::capture_position: the push block's capture members, the vertex index and a vec4 pointer type + bool wants_capture{}; + u32 capture_address_member_index{}; + u32 capture_first_member_index{}; + u32 capture_count_member_index{}; + Id capture_vertex_index{}; + Id capture_pointer{}; /// A pointer to the u32 at a PhysicalStorageBuffer device address Id MeshFallbackWord(Id address); diff --git a/gpu/vk/eden/shader_recompiler/ir_opt/passes.h b/gpu/vk/eden/shader_recompiler/ir_opt/passes.h index d763614..e3f77d1 100644 --- a/gpu/vk/eden/shader_recompiler/ir_opt/passes.h +++ b/gpu/vk/eden/shader_recompiler/ir_opt/passes.h @@ -6,6 +6,7 @@ #pragma once +#include #include "shader_recompiler/environment.h" #include "shader_recompiler/frontend/ir/program.h" @@ -31,6 +32,11 @@ void SsaRewritePass(IR::Program& program); void PositionPass(Environment& env, IR::Program& program); void BlitConstantsPass(Environment& env, IR::Program& program); void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo& host_info); +/// (hookshot) The texture handles of the last translation on this thread that no handle program could follow (they take +/// the first constant buffer word on their path): how many, and the operations the programs stopped at. Resets them. +u32 TakeHandleFallbacks(std::string& stopped_at); +/// (Triforce) The texture handles of the last translation on this thread that were given a handle table. Resets them. +u32 TakeHandleTables(); void LayerPass(IR::Program& program, const HostTranslateInfo& host_info); void VendorWorkaroundPass(IR::Program& program); void VerificationPass(const IR::Program& program); diff --git a/gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp b/gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp index 52202d1..c1bcad0 100644 --- a/gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp +++ b/gpu/vk/eden/shader_recompiler/ir_opt/texture_pass.cpp @@ -5,6 +5,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include // (EDEN_IR_PRE below. The players' compiler has libc++, which does not bring it in by itself) +#include +#include #include #include #include @@ -248,10 +251,16 @@ bool IsStorageImageOpcode(IR::Opcode opcode) { u32 DynamicSampledTextureArrayCount(const TextureInstVector& to_replace) { u32 count{}; + // (hookshot) the samples of one handle table share one descriptor: counted once (the water's 69 shadow samples of + // one table cut its share of the budget to 14 elements) + std::unordered_set tables; for (const TextureInst& inst : to_replace) { const auto flags{inst.inst->Flags()}; if (inst.cbuf.count > 1 && !IsStorageImageOpcode(IndexedInstruction(*inst.inst)) && flags.type != TextureType::Buffer) { + if (inst.cbuf.handle_program != ~0U && !tables.insert(inst.cbuf.handle_program).second) { + continue; + } ++count; } } @@ -451,6 +460,13 @@ bool IsUndefined(IR::Opcode opcode) { thread_local std::unordered_map g_handle_slots; thread_local u32 g_handle_slot_count{}; thread_local int g_handle_depth{}; +// (hookshot) A handle table read in a loop (a light's shadow map, the light's index from a per-pixel list): the +// element index, built as HandleOp::Index wherever the handle reads it +thread_local const IR::Inst* g_index_operand{}; +// (hookshot) The handles no handle program followed in this translation, and where they stopped (TakeHandleFallbacks) +thread_local u32 g_fallbacks{}; +thread_local u32 g_tables{}; // (Triforce: the handles given a table in this translation, TakeHandleTables) +thread_local std::string g_fallback_ops; bool BuildHandleNode(const IR::Value& value, std::vector& code, int& budget, const IR::Block* block); @@ -524,6 +540,10 @@ bool BuildHandleNode(const IR::Value& value, std::vector& code, int& budget return true; } const IR::Inst* const inst{value.InstRecursive()}; + if (inst == g_index_operand) { + emit(Op::Index); + return true; + } const auto build = [&](size_t arg) { return BuildHandleProgram(inst->Arg(arg), code, budget, block); }; const auto binary = [&](Op op) { if (!build(0) || !build(1)) return false; @@ -587,7 +607,8 @@ bool BuildHandleNode(const IR::Value& value, std::vector& code, int& budget case IR::Opcode::GetCbufU32: case IR::Opcode::LoadStorage32: return load_word(inst, 0); - case IR::Opcode::CompositeExtractU32x2: { + case IR::Opcode::CompositeExtractU32x2: + case IR::Opcode::CompositeExtractU32x4: { const IR::Value element{inst->Arg(1)}; if (!element.IsImmediate() || inst->Arg(0).IsImmediate()) return false; return load_word(inst->Arg(0).InstRecursive(), element.U32() * 4); @@ -930,10 +951,140 @@ std::optional TryGetConstBuffer(const IR::Inst* inst, Environme }; } +IR::Value SkipIdentity(IR::Value v) { + for (int i = 0; i < 16 && !v.IsImmediate() && v.InstRecursive()->GetOpcode() == IR::Opcode::Identity; ++i) { + v = v.InstRecursive()->Arg(0); + } + return v; +} + +// The value a 16-bit half extract reads (BitFieldUExtract x, 0, 16: the low half of an XMAD pair's index), else itself +IR::Value IndexThroughLowHalf(IR::Value v) { + v = SkipIdentity(v); + if (v.IsImmediate()) return v; + const IR::Inst* const i{v.InstRecursive()}; + if (i->GetOpcode() == IR::Opcode::BitFieldUExtract) { + const IR::Value offset{SkipIdentity(i->Arg(1))}; + const IR::Value count{SkipIdentity(i->Arg(2))}; + if (offset.IsImmediate() && count.IsImmediate() && offset.U32() == 0 && count.U32() == 16) { + return SkipIdentity(i->Arg(0)); + } + } + return v; +} + +// (hookshot) The handle is a word of a storage buffer record whose address adds index * stride, a table of records: +// Ocarina of Time's water and wet floors read each light's shadow map handle from the light's record, for the lights +// of the pixel's cluster. The index (in *index) when the handle is read so: a multiply by a stride of 4..4096 bytes (or +// an XMAD pair's halves of one) or a shift by 2..12, in the sums that make the record's address. +bool FindHandleTableIndex(const IR::Value& handle, IR::Value& index) { + const IR::Value v{SkipIdentity(handle)}; + if (v.IsImmediate()) return false; + const IR::Inst* load{v.InstRecursive()}; + if (load->GetOpcode() == IR::Opcode::CompositeExtractU32x2 || + load->GetOpcode() == IR::Opcode::CompositeExtractU32x4) { + const IR::Value src{SkipIdentity(load->Arg(0))}; + if (src.IsImmediate()) return false; + load = src.InstRecursive(); + } + switch (load->GetOpcode()) { + case IR::Opcode::LoadStorage32: + case IR::Opcode::LoadStorage64: + case IR::Opcode::LoadStorage128: + break; + default: + return false; + } + // Through the sums that make the record's address only + std::vector work{load->Arg(1)}; + for (int steps = 0; !work.empty() && steps < 64; ++steps) { + const IR::Value cur{SkipIdentity(work.back())}; + work.pop_back(); + if (cur.IsImmediate()) continue; + const IR::Inst* const i{cur.InstRecursive()}; + switch (i->GetOpcode()) { + case IR::Opcode::IAdd32: + case IR::Opcode::ISub32: + work.push_back(i->Arg(0)); + work.push_back(i->Arg(1)); + break; + case IR::Opcode::IMul32: + for (size_t a = 0; a < 2; ++a) { + const IR::Value k{SkipIdentity(i->Arg(a))}; + const IR::Value x{IndexThroughLowHalf(i->Arg(1 - a))}; + if (k.IsImmediate() && k.U32() >= 4 && k.U32() <= 4096 && !x.IsImmediate()) { + index = x; + return true; + } + } + break; + case IR::Opcode::ShiftLeftLogical32: { + const IR::Value k{SkipIdentity(i->Arg(1))}; + const IR::Value x{SkipIdentity(i->Arg(0))}; + if (k.IsImmediate() && k.U32() >= 2 && k.U32() <= 12 && !x.IsImmediate()) { + index = x; + return true; + } + break; + } + default: + break; + } + } + return false; +} + +// (Triforce, 11-13) The handle behind the merges of a register. Ocarina of Time's wet floors and water filter each +// projector's shadow map in one of several ways, picked by a jump table; the 9- and the 16-sample filters come after the +// others, and their handle is a Phi of the record's handle word (the one value, on every path that leads to them) and of +// an earlier filter's RESULT, which the same register held on a path that does not lead to them. The search for the +// handle's constant buffer word went into that result's sample, down to its coordinates, and took the first constant it +// met there for the handle: a float, 0.001, no texture. Every one of those 25 samples then read the stand-in texture, +// "in shadow", and the projector's whole cluster tiles lost their local lights: the dark squares on wet floors (upstream +// issue 2509; its pull request 3047 gives the handle's table to the 44 samples that read the record directly, and +// these 25 stayed as they were). A texture sample's result is never a handle: such inputs are left out, and when what is +// left is one and the same value, that value is the handle. Anything else is returned as it is. +// EDEN_HANDLE_PHI=0: as before +IR::Value ResolveHandlePhi(const IR::Value& handle) { + static const char* const off_env{std::getenv("EDEN_HANDLE_PHI")}; + if (off_env && off_env[0] == '0') return handle; + const IR::Value start{SkipIdentity(handle)}; + if (start.IsImmediate() || start.InstRecursive()->GetOpcode() != IR::Opcode::Phi) return handle; + std::vector work{start}; + std::unordered_set seen; + const IR::Inst* found{}; + IR::Value found_value; + for (int steps = 0; !work.empty(); ++steps) { + if (steps > 512) return handle; + const IR::Value cur{SkipIdentity(work.back())}; + work.pop_back(); + if (cur.IsImmediate()) return handle; // (a constant on a path: not this case) + const IR::Inst* const i{cur.InstRecursive()}; + if (i->GetOpcode() == IR::Opcode::Phi) { + if (seen.insert(i).second) { + for (size_t a = 0; a < i->NumArgs(); ++a) work.push_back(i->Arg(a)); + } + continue; + } + // (a sample's result, or its bits) + const IR::Inst* source{i}; + if (source->GetOpcode() == IR::Opcode::BitCastU32F32) { + const IR::Value bits{SkipIdentity(source->Arg(0))}; + if (!bits.IsImmediate()) source = bits.InstRecursive(); + } + if (IsTextureInstruction(*source)) continue; + if (found && found != i) return handle; // (two different values: a real choice, left to the search) + found = i; + found_value = cur; + } + return found ? found_value : handle; +} + TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst, const HostTranslateInfo& host_info) { ConstBufferAddr addr; if (IsBindless(inst)) { - const std::optional track_addr{TrackCached(inst.Arg(0), env, host_info, block)}; + const IR::Value handle{ResolveHandlePhi(inst.Arg(0))}; + const std::optional track_addr{TrackCached(handle, env, host_info, block)}; if (track_addr) { addr = *track_addr; @@ -942,10 +1093,61 @@ TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst, const H std::vector code; int budget = 4096; g_handle_failure = IR::Opcode::Void; - if (!g_handle_programs || !BuildHandleProgram(inst.Arg(0), code, budget, block)) { + if (!g_handle_programs || !BuildHandleProgram(handle, code, budget, block)) { + // (hookshot) A table read in a loop: one texture for each element, picked in the shader by the + // element's index (RX_VK_HANDLE_TABLE=0: the search below, one texture for all of them) + static const char* const table_env = std::getenv("RX_VK_HANDLE_TABLE"); + static const bool table_on = !(table_env && table_env[0] == '0'); + static const u32 table_count = [] { + const char* const c = std::getenv("RX_VK_HANDLE_TABLE_COUNT"); + const long n = c ? std::strtol(c, nullptr, 0) : 64; + return static_cast(std::clamp(n, 2, 256)); + }(); + IR::Value index_value; + if (table_on && g_handle_programs && FindHandleTableIndex(handle, index_value)) { + code.clear(); + budget = 4096; + g_index_operand = index_value.InstRecursive(); + const bool built = BuildHandleProgram(handle, code, budget, block); + g_index_operand = nullptr; + if (built) { + ++g_tables; + auto& programs{*g_handle_programs}; + auto it{std::ranges::find(programs, code)}; + if (it == programs.end()) { + programs.push_back(std::move(code)); + it = programs.end() - 1; + } + // The element's index as a descriptor offset (the array reads it back: offset >> 3) + IR::IREmitter ir{*block, IR::Block::InstructionList::s_iterator_to(inst)}; + const IR::U32 offset{ir.ShiftLeftLogical(IR::U32{index_value}, ir.Imm32(DESCRIPTOR_SIZE_SHIFT))}; + return TextureInst{ + .cbuf = ConstBufferAddr{ + .index = 0, + .offset = 0, + .shift_left = 0, + .secondary_index = 0, + .secondary_offset = 0, + .secondary_shift_left = 0, + .dynamic_offset = offset, + .count = table_count, + .has_secondary = false, + .handle_program = static_cast(it - programs.begin()), + }, + .inst = &inst, + .block = block, + }; + } + code.clear(); + budget = 4096; + } + ++g_fallbacks; + if (g_fallback_ops.size() < 200) { + g_fallback_ops += fmt::format("{}{}", g_fallback_ops.empty() ? "" : ", ", g_handle_failure); + } // Not computable for a whole draw (a handle that changes in a loop): keep the // earlier search through loads, which at least gives the shader a texture. - const std::optional legacy{IR::BreadthFirstSearch(inst.Arg(0), + const std::optional legacy{IR::BreadthFirstSearch(handle, [&env, &host_info, block](const IR::Inst* candidate) { return TryGetConstBuffer(candidate, env, host_info, block); }, [&](IR::Value operand) { return ResolveConditionalPhi(operand, block); })}; @@ -1167,7 +1369,39 @@ void PatchTexelFetch(IR::Block& block, IR::Inst& inst, TexturePixelFormat pixel_ } } // Anonymous namespace +u32 TakeHandleTables() { + const u32 n = g_tables; + g_tables = 0; + return n; +} + +u32 TakeHandleFallbacks(std::string& stopped_at) { + const u32 n = g_fallbacks; + stopped_at = std::move(g_fallback_ops); + g_fallbacks = 0; + g_fallback_ops.clear(); + return n; +} + void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo& host_info) { + // (lab, 11-13) EDEN_IR_PRE=: the programs with n depth-compare samples whose handle is still to be found are + // written out as they come INTO this pass (ir_pre__.txt beside the game): where a sample's handle comes + // from can only be read there, this pass replaces it. An EDEN_ name: the shaders are translated again for it + if (static const char* const pre = std::getenv("EDEN_IR_PRE"); pre) { + size_t n = 0; + for (IR::Block* const b : program.blocks) + for (IR::Inst& i : b->Instructions()) n += i.GetOpcode() == IR::Opcode::BindlessImageSampleDrefImplicitLod; + static std::atomic written{0}; // (at least n of them; the first twelve programs) + if (n && n >= static_cast(std::atoi(pre)) && written++ < 12) { + char name[64]; + std::snprintf(name, sizeof name, "ir_pre_%zu_%zu.txt", n, program.blocks.size()); + if (FILE* const f = std::fopen(name, "w")) { + const std::string text{IR::DumpProgram(program)}; + std::fwrite(text.data(), 1, text.size(), f); + std::fclose(f); + } + } + } // reset per-pass caches env.cbuf_word_cache.clear(); env.handle_cache.clear(); diff --git a/gpu/vk/eden/shader_recompiler/runtime_info.h b/gpu/vk/eden/shader_recompiler/runtime_info.h index c5f97b0..ba01322 100644 --- a/gpu/vk/eden/shader_recompiler/runtime_info.h +++ b/gpu/vk/eden/shader_recompiler/runtime_info.h @@ -88,6 +88,12 @@ struct RuntimeInfo { VaryingState previous_stage_stores; /// Fragment stage after a mesh program: generic inputs it writes per primitive. std::bitset<32> per_primitive_generics{}; + /// Last pre-rasterization stage: generic outputs the fragment stage reads screen-linear. + /// They are written times Position.w and the fragment stage reads them perspective-correct + /// times FragCoord.w, so clipping a primitive close to the camera interpolates them right. + std::bitset<32> noperspective_outputs{}; + /// Fragment stage: the previous stage writes noperspective_outputs (not a mesh program). + bool scaled_noperspective_inputs{}; /// Fragment stage after a mesh program that draws points: generic inputs the hardware's point sprite /// replaces with the coordinate within the point (s, t, 0, 1), as NVN's do with the generics the mesh /// program leaves unwritten. @@ -111,6 +117,10 @@ struct RuntimeInfo { u32 mesh_fallback_task_threads{}; /// (hookshot) the fallback's record slots: mesh workgroups past this one write nothing u32 mesh_fallback_capacity{}; + /// (hookshot) a vertex stage that also stores its final position (clip space, after convert_depth_mode) at a pushed + /// device address, one vec4 a vertex: the temporal upscaler's motion of what the game moves in its shaders + /// (vk_temporal.cpp). A zero address stores nothing (Info::captures_position says it was emitted) + bool capture_position{}; TessPrimitive tess_primitive{}; TessSpacing tess_spacing{}; diff --git a/gpu/vk/eden/shader_recompiler/shader_info.h b/gpu/vk/eden/shader_recompiler/shader_info.h index 5fef0ad..74ae3d4 100644 --- a/gpu/vk/eden/shader_recompiler/shader_info.h +++ b/gpu/vk/eden/shader_recompiler/shader_info.h @@ -363,6 +363,7 @@ struct Info { bool uses_rescaling_uniform{}; bool uses_cbuf_indirect{}; bool uses_render_area{}; + bool captures_position{}; ///< (hookshot) RuntimeInfo::capture_position, emitted: CAPTURE_PUSH_OFFSET is read IR::Type used_constant_buffer_types{}; IR::Type used_storage_buffer_types{}; @@ -420,13 +421,14 @@ enum class HandleOp : u32 { Select, ///< condition, true value, false value Tee, ///< slot: keeps the top value in the slot (shared subexpressions) Load, ///< slot: the value kept there + Index, ///< (hookshot) the array element being evaluated (a handle table read in a loop: one texture an element) }; /// Runs a handle program; read_cbuf(index, offset) and read_storage(binding, offset) return the /// words it reads. Returns nothing for a malformed program. template std::optional EvaluateHandleProgram(std::span code, ReadCbuf&& read_cbuf, - ReadStorage&& read_storage) { + ReadStorage&& read_storage, u32 element = 0) { std::array stack{}; std::array slots{}; size_t size = 0; @@ -461,6 +463,10 @@ std::optional EvaluateHandleProgram(std::span code, ReadCbuf&& r push(op == HandleOp::Neg ? 0U - a : op == HandleOp::Not ? ~a : (a == 0 ? 1U : 0U)); continue; } + if (op == HandleOp::Index) { + push(element); + continue; + } if (op == HandleOp::Tee) { const u32 slot = operand(); if (slot < slots.size() && size > 0) slots[slot] = stack[size - 1]; diff --git a/gpu/vk/oot_cheat_items.h b/gpu/vk/oot_cheat_items.h index b791175..8d0fe58 100644 --- a/gpu/vk/oot_cheat_items.h +++ b/gpu/vk/oot_cheat_items.h @@ -37,10 +37,9 @@ OOT_ITEM("Hookshot", "Item_Hookshot", 0) \ OOT_ITEM("Longshot", "Item_Longshot", 0) \ OOT_ITEM("Boomerang", "Item_Boomerang", 0) \ - OOT_ITEM("Lens of Truth", "Item_GlassTruth", 0) \ + OOT_ITEM("Lens of Truth", "Armor_GlassTruth", 0) \ OOT_ITEM("Magic Beans", "Item_MagicBean", 1) \ OOT_ITEM("Megaton Hammer", "Item_Hammer", 0) \ - OOT_ITEM("Empty Bottle", "Item_Bottle", 1) \ OOT_SECTION("Masks") \ OOT_ITEM("Keaton Mask", "Armor_Child_Mask_Keaton", 0) \ OOT_ITEM("Skull Mask", "Armor_Child_Mask_Skull", 0) \ @@ -51,7 +50,7 @@ OOT_ITEM("Gerudo Mask", "Armor_Child_Mask_Gerudo", 0) \ OOT_ITEM("Mask of Truth", "Armor_Child_Mask_Truth", 0) \ OOT_SECTION("Upgrades") \ - OOT_ITEM("Goron's Bracelet", "Item_Gauntlet_Goron", 0) \ + OOT_ITEM("Goron's Bracelet", "Armor_Child_Gauntlet_Goron", 0) \ OOT_ITEM("Silver Gauntlets", "Armor_Adult_Gauntlet_Silver", 0) \ OOT_ITEM("Golden Gauntlets", "Armor_Adult_Gauntlet_Gold", 0) \ OOT_ITEM("Silver Scale", "Item_Scale_Silver", 0) \ diff --git a/gpu/vk/shaders/dlss_actor.frag b/gpu/vk/shaders/dlss_actor.frag index bb64abb..5e4a917 100644 --- a/gpu/vk/shaders/dlss_actor.frag +++ b/gpu/vk/shaders/dlss_actor.frag @@ -1,38 +1,62 @@ #version 450 -#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require -// (hookshot) NVIDIA DLSS's actor motion (dlss_actor.vert): where the draw is what the scene shows (its depth within -// pc.tolerance steps of the scene's), the motion from where it is now (the pixel, the jitter taken off) to where it was, in -// render pixels as shaders/dlss_prep.comp makes them +// (hookshot) The temporal upscaler's own motion of a draw drawn again (dlss_actor.vert from its bones, dlss_capture.vert from +// the positions its own vertex stage stored): where the draw is what the scene shows (its distance within the tolerance of +// the scene's), the motion from where it is now (the pixel, the jitter taken off) to where it was, in render pixels as +// shaders/dlss_prep.comp makes them. The tolerance is the cameras' buffer's word 66 (dlss_actor.h kHeadWords), not a push +// constant: the two vertex stages push their own layout(std430, binding = 0) readonly buffer Data { uint w[]; } data; layout(binding = 1) uniform sampler2D scene_depth; -layout(push_constant) uniform P { - uint64_t vertices; // (the vertex stream's address) - uint64_t indices; // (the index buffer's address, 4-aligned down; first: the draw's first index in it) - uint64_t origins[2]; // (the draw's origin, xyz: this frame's and the frame before's) - uint64_t bones[2]; // (its palettes: this frame's, the frame before's) - uint nbones; - uint stride; // (in words) - uint count; // (vertices in the stream: an index past them draws nothing) - uint first; - uint itype; // (0: 8-bit, 1: 16-bit, 2: 32-bit indices) - int base_vertex; - uint pos, sets; // (byte offsets in a vertex, the joint and weight sets: 1 or 2) - uint joints[2], weights[2]; - uint formats; // (1: the position RGBA16F, else RGB32F; 2 << set: that set's joints RGBA8UI, else RGBA16UI) - uint tolerance; // (the fragment stage's) -} pc; layout(location = 0) in vec4 before; +layout(location = 1) flat in vec2 jitter; // (this frame's, of the camera the draw was drawn with) layout(location = 0) out vec2 motion; void main() { const uint scene = floatBitsToUint(texelFetch(scene_depth, ivec2(gl_FragCoord.xy), 0).r); const uint here = floatBitsToUint(gl_FragCoord.z); - if (max(scene, here) - min(scene, here) > pc.tolerance || before.w <= 1e-6) discard; + // (the tolerance's top bit, RX_VK_DLSS_DEBUG=actors: the pixels the draw gives its own motion to marked green, the rest + // left as they are. Its fragments that are not the scene's are discarded as in play: marked red, the back of a character + // and what it hides were drawn over the front's green, and most of a character near the camera showed red) + const uint word = data.w[66]; + const bool mark = (word & 0x80000000u) != 0u; + const uint tolerance = word & 0x3fffffffu; + // (in distance from the camera: within tolerance thousandths of the scene's. The game's depth is OpenGL's, -1 to 1 as 0 to 1) + const float n = uintBitsToFloat(data.w[64]), f = uintBitsToFloat(data.w[65]); + bool off; + if (n > 0.0 && f > n) { + // (n f / (n + (1 - d)(f - n)): the same as 2nf / ((f + n) - (2d - 1)(f - n)), without its cancellation near d = 1 and + // with a far plane of 1e9 (an infinite one)) + const float zs = n * f / (n + (1.0 - uintBitsToFloat(scene)) * (f - n)); + const float zh = n * f / (n + (1.0 - gl_FragCoord.z) * (f - n)); + off = abs(zh - zs) > zs * float(tolerance) * 0.001; + } else { + off = max(scene, here) - min(scene, here) > 64u; // (no plain perspective: depth buffer steps) + } + if (off || before.w <= 1e-6) discard; const vec2 size = vec2(uintBitsToFloat(data.w[34]), uintBitsToFloat(data.w[35])); - const vec2 jitter = vec2(uintBitsToFloat(data.w[32]), uintBitsToFloat(data.w[33])); - const vec2 now = vec2(gl_FragCoord.x / size.x * 2.0 - 1.0, 1.0 - gl_FragCoord.y / size.y * 2.0) - jitter; + const vec2 here_clip = vec2(gl_FragCoord.x / size.x * 2.0 - 1.0, 1.0 - gl_FragCoord.y / size.y * 2.0); + const vec2 now = here_clip - jitter; const vec2 then = before.xy / before.w; const vec2 px = vec2(then.x - now.x, now.y - then.y) * 0.5 * size; if (!all(lessThan(abs(px), vec2(16384.0)))) discard; + if (mark) { + // (only where the draw's own motion is not the camera's, by a quarter of a pixel: with every draw of the scene drawn + // again from its stored positions, all of it was marked. The camera's as shaders/dlss_prep.comp makes it, from this + // depth and the scene's jitter. The mark is the one colour: shown as how far apart they are, it could not be told from + // the camera's motion, which the pixels left unmarked show) + mat4 reproject; // (row major in the buffer, as dlss_math::reprojection writes it: read by columns, it was its transpose, + // and all that the camera moved was shown as apart) + for (int c = 0; c < 4; c++) + for (int r = 0; r < 4; r++) reproject[c][r] = uintBitsToFloat(data.w[72 + r * 4 + c]); + const vec4 camera = reproject * vec4(here_clip, gl_FragCoord.z * 2.0 - 1.0, 1.0); + if (camera.w <= 1e-6) discard; + const vec2 was = camera.xy / camera.w; + const vec2 scene_now = here_clip - vec2(uintBitsToFloat(data.w[32]), uintBitsToFloat(data.w[33])); + const vec2 camera_px = vec2(was.x - scene_now.x, scene_now.y - was.y) * 0.5 * size; + if (all(lessThan(abs(px - camera_px), vec2(0.25)))) discard; + // (bit 30 with it, RX_VK_DLSS_DEBUG=characters: no motion but dlss_actor.h kOwnMark, and how far apart the two are, + // which shaders/dlss_prep.comp's flag 8 shows blue on grey) + motion = (word & 0x40000000u) != 0u ? vec2(-30000.0, length(px - camera_px)) : vec2(0.0, 64.0); + return; + } motion = px; } diff --git a/gpu/vk/shaders/dlss_actor.vert b/gpu/vk/shaders/dlss_actor.vert index 1e899de..0ef2e47 100644 --- a/gpu/vk/shaders/dlss_actor.vert +++ b/gpu/vk/shaders/dlss_actor.vert @@ -19,14 +19,15 @@ layout(push_constant) uniform P { uint stride; // (in words) uint count; // (vertices in the stream: an index past them draws nothing) uint first; - uint itype; // (0: 8-bit, 1: 16-bit, 2: 32-bit indices) + uint itype; // (0: 8-bit, 1: 16-bit, 2: 32-bit indices; 3: none, vertex i is base_vertex + i) int base_vertex; uint pos, sets; // (byte offsets in a vertex, the joint and weight sets: 1 or 2) uint joints[2], weights[2]; - uint formats; // (1: the position RGBA16F, else RGB32F; 2 << set: that set's joints RGBA8UI, else RGBA16UI) + uint formats; // (dlss_actor.h: 1 the position RGBA16F; 2 << set that set's joints 8-bit; its count at 4 + 2 * set; 256 rigid) uint tolerance; // (the fragment stage's) } pc; layout(location = 0) out vec4 before; +layout(location = 1) flat out vec2 jitter; // (this frame's, of the camera the draw was drawn with: the scene's here) float f(uint i) { return uintBitsToFloat(data.w[i]); } vec4 f4(uint i) { return vec4(f(i), f(i + 1), f(i + 2), f(i + 3)); } @@ -34,20 +35,23 @@ mat4 camera(uint at) { // (row major in the buffer) return transpose(mat4(f4(at), f4(at + 4), f4(at + 8), f4(at + 12))); } vec4 row(Words m, uint i) { return uintBitsToFloat(uvec4(m.w[i], m.w[i + 1u], m.w[i + 2u], m.w[i + 3u])); } -void skin(Words palette, uvec4 j, vec4 wt, vec4 p, inout vec3 acc) { - for (int k = 0; k < 4; k++) { - if (wt[k] <= 0.0 || j[k] >= pc.nbones) continue; - const uint b = j[k] * 12u; - acc += wt[k] * vec3(dot(row(palette, b), p), dot(row(palette, b + 4u), p), dot(row(palette, b + 8u), p)); - } +vec3 skinned(Words palette, uint j, vec4 p) { + const uint b = j * 12u; + return vec3(dot(row(palette, b), p), dot(row(palette, b + 4u), p), dot(row(palette, b + 8u), p)); +} +uint byte_at(Words v, uint o) { return (v.w[o >> 2] >> ((o & 3u) * 8u)) & 0xffu; } +uint set_count(uint s) { // (dlss_actor.h set_count) + const uint c = (pc.formats >> (4u + 2u * s)) & 3u; + return c == 0u ? 4u : c == 1u ? 1u : c == 2u ? 2u : 0u; } void main() { + jitter = vec2(f(32u), f(33u)); const uint at = pc.first + uint(gl_VertexIndex); - Words ib = Words(pc.indices); uint index; - if (pc.itype == 2u) index = ib.w[at]; - else if (pc.itype == 1u) index = (ib.w[at >> 1] >> ((at & 1u) * 16u)) & 0xffffu; - else index = (ib.w[at >> 2] >> ((at & 3u) * 8u)) & 0xffu; + if (pc.itype == 3u) index = at; // (a plain vertex array) + else if (pc.itype == 2u) index = Words(pc.indices).w[at]; + else if (pc.itype == 1u) index = (Words(pc.indices).w[at >> 1] >> ((at & 1u) * 16u)) & 0xffffu; + else index = (Words(pc.indices).w[at >> 2] >> ((at & 3u) * 8u)) & 0xffu; const int vi = pc.base_vertex + int(index); if (vi < 0 || uint(vi) >= pc.count) { // (outside the stream: nothing, its triangle dropped) gl_Position = vec4(0.0, 0.0, 0.0, -1.0); @@ -60,17 +64,33 @@ void main() { : vec4(uintBitsToFloat(vb.w[q]), uintBitsToFloat(vb.w[q + 1u]), uintBitsToFloat(vb.w[q + 2u]), 1.0); vec3 now = vec3(0.0), then = vec3(0.0); + // (each set: 1, 2 or 4 joints, 8- or 16-bit, and as many 8-bit weights, read byte by byte; rigid: one joint, all of it) for (uint s = 0u; s < pc.sets; s++) { - const uint a = vb.w[pc.joints[s] / 4u]; - const uvec4 j = (pc.formats & (2u << s)) != 0u ? (uvec4(a, a >> 8, a >> 16, a >> 24) & 0xffu) - : uvec4(a & 0xffffu, a >> 16, vb.w[pc.joints[s] / 4u + 1u] & 0xffffu, - vb.w[pc.joints[s] / 4u + 1u] >> 16); - const vec4 wt = unpackUnorm4x8(vb.w[pc.weights[s] / 4u]); - skin(Words(pc.bones[0]), j, wt, p, now); - skin(Words(pc.bones[1]), j, wt, p, then); + const bool bytes = (pc.formats & (2u << s)) != 0u; + const uint n = set_count(s); + for (uint k = 0u; k < n; k++) { + const uint jo = pc.joints[s] + (bytes ? k : 2u * k); + const uint j = bytes ? byte_at(vb, jo) : byte_at(vb, jo) | (byte_at(vb, jo + 1u) << 8); + const float wt = (pc.formats & 256u) != 0u ? 1.0 : float(byte_at(vb, pc.weights[s] + k)) / 255.0; + if (wt <= 0.0 || j >= pc.nbones) continue; + now += wt * skinned(Words(pc.bones[0]), j, p); + then += wt * skinned(Words(pc.bones[1]), j, p); + } } const vec3 o0 = row(Words(pc.origins[0]), 0u).xyz, o1 = row(Words(pc.origins[1]), 0u).xyz; - const vec4 clip = camera(0u) * vec4(now + o0, 1.0); + // (this frame's position as the game's shaders make it: the origin and the skinned offset through the view apart, never + // added in the world's large numbers, then the projection. Through the one view-projection, the depth was off by more than + // the fragment stage's tolerance, and most of a character was left with the camera's motion) + // (the view and projection the draw itself was drawn with, in its pose: dlss_actor.h kPoseHead) + Words posed = Words(pc.origins[0]); + precise vec3 eye; + for (uint r = 0u; r < 3u; r++) { + const vec4 v = row(posed, 4u + 4u * r); + precise float at = dot(v.xyz, o0) + v.w; + eye[r] = at + dot(v.xyz, now); + } + precise vec4 clip; + for (uint r = 0u; r < 4u; r++) clip[r] = dot(row(posed, 16u + 4u * r), vec4(eye, 1.0)); before = camera(16u) * vec4(then + o1, 1.0); // (the game's clip space: y up, depth -1 to 1; Vulkan's: y down, depth 0 to 1) gl_Position = vec4(clip.x, -clip.y, (clip.z + clip.w) * 0.5, clip.w); diff --git a/gpu/vk/shaders/dlss_actor_frag_spv.h b/gpu/vk/shaders/dlss_actor_frag_spv.h index 0715d9d..fa1b2c2 100644 --- a/gpu/vk/shaders/dlss_actor_frag_spv.h +++ b/gpu/vk/shaders/dlss_actor_frag_spv.h @@ -1,137 +1,230 @@ // 1116.6.0 #pragma once const uint32_t DLSS_ACTOR_FRAG_SPV[] = { - 0x07230203,0x00010600,0x0008000b,0x00000099,0x00000000,0x00020011,0x00000001,0x00020011, - 0x0000000b,0x00020011,0x00001503,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e, - 0x00000000,0x0003000e,0x00000000,0x00000001,0x000b000f,0x00000004,0x00000004,0x6e69616d, - 0x00000000,0x0000000d,0x00000011,0x00000033,0x0000003c,0x0000004a,0x00000097,0x00030010, - 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000d0004,0x455f4c47,0x735f5458, - 0x65646168,0x78655f72,0x63696c70,0x615f7469,0x68746972,0x6974656d,0x79745f63,0x5f736570, - 0x36746e69,0x00000034,0x00040005,0x00000004,0x6e69616d,0x00000000,0x00040005,0x00000008, - 0x6e656373,0x00000065,0x00050005,0x0000000d,0x6e656373,0x65645f65,0x00687470,0x00060005, - 0x00000011,0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00040005,0x0000001e,0x65726568, - 0x00000000,0x00030005,0x00000031,0x00000050,0x00060006,0x00000031,0x00000000,0x74726576, - 0x73656369,0x00000000,0x00050006,0x00000031,0x00000001,0x69646e69,0x00736563,0x00050006, - 0x00000031,0x00000002,0x6769726f,0x00736e69,0x00050006,0x00000031,0x00000003,0x656e6f62, - 0x00000073,0x00050006,0x00000031,0x00000004,0x6e6f626e,0x00007365,0x00050006,0x00000031, - 0x00000005,0x69727473,0x00006564,0x00050006,0x00000031,0x00000006,0x6e756f63,0x00000074, - 0x00050006,0x00000031,0x00000007,0x73726966,0x00000074,0x00050006,0x00000031,0x00000008, - 0x70797469,0x00000065,0x00060006,0x00000031,0x00000009,0x65736162,0x7265765f,0x00786574, - 0x00040006,0x00000031,0x0000000a,0x00736f70,0x00050006,0x00000031,0x0000000b,0x73746573, - 0x00000000,0x00050006,0x00000031,0x0000000c,0x6e696f6a,0x00007374,0x00050006,0x00000031, - 0x0000000d,0x67696577,0x00737468,0x00050006,0x00000031,0x0000000e,0x6d726f66,0x00737461, - 0x00060006,0x00000031,0x0000000f,0x656c6f74,0x636e6172,0x00000065,0x00030005,0x00000033, - 0x00006370,0x00040005,0x0000003c,0x6f666562,0x00006572,0x00040005,0x00000046,0x657a6973, - 0x00000000,0x00040005,0x00000048,0x61746144,0x00000000,0x00040006,0x00000048,0x00000000, - 0x00000077,0x00040005,0x0000004a,0x61746164,0x00000000,0x00040005,0x00000055,0x7474696a, - 0x00007265,0x00030005,0x0000005f,0x00776f6e,0x00040005,0x00000075,0x6e656874,0x00000000, - 0x00030005,0x0000007c,0x00007870,0x00040005,0x00000097,0x69746f6d,0x00006e6f,0x00040047, - 0x0000000d,0x00000021,0x00000001,0x00040047,0x0000000d,0x00000022,0x00000000,0x00040047, - 0x00000011,0x0000000b,0x0000000f,0x00040047,0x0000002d,0x00000006,0x00000008,0x00040047, - 0x0000002e,0x00000006,0x00000008,0x00040047,0x0000002f,0x00000006,0x00000004,0x00040047, - 0x00000030,0x00000006,0x00000004,0x00030047,0x00000031,0x00000002,0x00050048,0x00000031, - 0x00000000,0x00000023,0x00000000,0x00050048,0x00000031,0x00000001,0x00000023,0x00000008, - 0x00050048,0x00000031,0x00000002,0x00000023,0x00000010,0x00050048,0x00000031,0x00000003, - 0x00000023,0x00000020,0x00050048,0x00000031,0x00000004,0x00000023,0x00000030,0x00050048, - 0x00000031,0x00000005,0x00000023,0x00000034,0x00050048,0x00000031,0x00000006,0x00000023, - 0x00000038,0x00050048,0x00000031,0x00000007,0x00000023,0x0000003c,0x00050048,0x00000031, - 0x00000008,0x00000023,0x00000040,0x00050048,0x00000031,0x00000009,0x00000023,0x00000044, - 0x00050048,0x00000031,0x0000000a,0x00000023,0x00000048,0x00050048,0x00000031,0x0000000b, - 0x00000023,0x0000004c,0x00050048,0x00000031,0x0000000c,0x00000023,0x00000050,0x00050048, - 0x00000031,0x0000000d,0x00000023,0x00000058,0x00050048,0x00000031,0x0000000e,0x00000023, - 0x00000060,0x00050048,0x00000031,0x0000000f,0x00000023,0x00000064,0x00040047,0x0000003c, - 0x0000001e,0x00000000,0x00040047,0x00000047,0x00000006,0x00000004,0x00030047,0x00000048, - 0x00000002,0x00040048,0x00000048,0x00000000,0x00000018,0x00050048,0x00000048,0x00000000, - 0x00000023,0x00000000,0x00030047,0x0000004a,0x00000018,0x00040047,0x0000004a,0x00000021, - 0x00000000,0x00040047,0x0000004a,0x00000022,0x00000000,0x00040047,0x00000097,0x0000001e, - 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006, - 0x00000020,0x00000000,0x00040020,0x00000007,0x00000007,0x00000006,0x00030016,0x00000009, - 0x00000020,0x00090019,0x0000000a,0x00000009,0x00000001,0x00000000,0x00000000,0x00000000, - 0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a,0x00040020,0x0000000c,0x00000000, - 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000,0x00040017,0x0000000f,0x00000009, - 0x00000004,0x00040020,0x00000010,0x00000001,0x0000000f,0x0004003b,0x00000010,0x00000011, - 0x00000001,0x00040017,0x00000012,0x00000009,0x00000002,0x00040015,0x00000015,0x00000020, - 0x00000001,0x00040017,0x00000016,0x00000015,0x00000002,0x0004002b,0x00000015,0x00000018, - 0x00000000,0x0004002b,0x00000006,0x0000001b,0x00000000,0x0004002b,0x00000006,0x0000001f, - 0x00000002,0x00040020,0x00000020,0x00000001,0x00000009,0x00020014,0x00000024,0x00040015, - 0x0000002c,0x00000040,0x00000000,0x0004001c,0x0000002d,0x0000002c,0x0000001f,0x0004001c, - 0x0000002e,0x0000002c,0x0000001f,0x0004001c,0x0000002f,0x00000006,0x0000001f,0x0004001c, - 0x00000030,0x00000006,0x0000001f,0x0012001e,0x00000031,0x0000002c,0x0000002c,0x0000002d, - 0x0000002e,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000015,0x00000006, - 0x00000006,0x0000002f,0x00000030,0x00000006,0x00000006,0x00040020,0x00000032,0x00000009, - 0x00000031,0x0004003b,0x00000032,0x00000033,0x00000009,0x0004002b,0x00000015,0x00000034, - 0x0000000f,0x00040020,0x00000035,0x00000009,0x00000006,0x0004003b,0x00000010,0x0000003c, - 0x00000001,0x0004002b,0x00000006,0x0000003d,0x00000003,0x0004002b,0x00000009,0x00000040, - 0x358637bd,0x00040020,0x00000045,0x00000007,0x00000012,0x0003001d,0x00000047,0x00000006, - 0x0003001e,0x00000048,0x00000047,0x00040020,0x00000049,0x0000000c,0x00000048,0x0004003b, - 0x00000049,0x0000004a,0x0000000c,0x0004002b,0x00000015,0x0000004b,0x00000022,0x00040020, - 0x0000004c,0x0000000c,0x00000006,0x0004002b,0x00000015,0x00000050,0x00000023,0x0004002b, - 0x00000015,0x00000056,0x00000020,0x0004002b,0x00000015,0x0000005a,0x00000021,0x00040020, - 0x00000062,0x00000007,0x00000009,0x0004002b,0x00000009,0x00000066,0x40000000,0x0004002b, - 0x00000009,0x00000068,0x3f800000,0x0004002b,0x00000006,0x0000006a,0x00000001,0x0004002b, - 0x00000009,0x00000088,0x3f000000,0x0004002b,0x00000009,0x0000008e,0x46800000,0x0005002c, - 0x00000012,0x0000008f,0x0000008e,0x0000008e,0x00040017,0x00000090,0x00000024,0x00000002, - 0x00040020,0x00000096,0x00000003,0x00000012,0x0004003b,0x00000096,0x00000097,0x00000003, - 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, - 0x00000007,0x00000008,0x00000007,0x0004003b,0x00000007,0x0000001e,0x00000007,0x0004003b, - 0x00000045,0x00000046,0x00000007,0x0004003b,0x00000045,0x00000055,0x00000007,0x0004003b, - 0x00000045,0x0000005f,0x00000007,0x0004003b,0x00000045,0x00000075,0x00000007,0x0004003b, - 0x00000045,0x0000007c,0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d, - 0x0000000f,0x00000013,0x00000011,0x0007004f,0x00000012,0x00000014,0x00000013,0x00000013, - 0x00000000,0x00000001,0x0004006e,0x00000016,0x00000017,0x00000014,0x00040064,0x0000000a, - 0x00000019,0x0000000e,0x0007005f,0x0000000f,0x0000001a,0x00000019,0x00000017,0x00000002, - 0x00000018,0x00050051,0x00000009,0x0000001c,0x0000001a,0x00000000,0x0004007c,0x00000006, - 0x0000001d,0x0000001c,0x0003003e,0x00000008,0x0000001d,0x00050041,0x00000020,0x00000021, - 0x00000011,0x0000001f,0x0004003d,0x00000009,0x00000022,0x00000021,0x0004007c,0x00000006, - 0x00000023,0x00000022,0x0003003e,0x0000001e,0x00000023,0x0004003d,0x00000006,0x00000025, - 0x00000008,0x0004003d,0x00000006,0x00000026,0x0000001e,0x0007000c,0x00000006,0x00000027, - 0x00000001,0x00000029,0x00000025,0x00000026,0x0004003d,0x00000006,0x00000028,0x00000008, - 0x0004003d,0x00000006,0x00000029,0x0000001e,0x0007000c,0x00000006,0x0000002a,0x00000001, - 0x00000026,0x00000028,0x00000029,0x00050082,0x00000006,0x0000002b,0x00000027,0x0000002a, - 0x00050041,0x00000035,0x00000036,0x00000033,0x00000034,0x0004003d,0x00000006,0x00000037, - 0x00000036,0x000500ac,0x00000024,0x00000038,0x0000002b,0x00000037,0x000400a8,0x00000024, - 0x00000039,0x00000038,0x000300f7,0x0000003b,0x00000000,0x000400fa,0x00000039,0x0000003a, - 0x0000003b,0x000200f8,0x0000003a,0x00050041,0x00000020,0x0000003e,0x0000003c,0x0000003d, - 0x0004003d,0x00000009,0x0000003f,0x0000003e,0x000500bc,0x00000024,0x00000041,0x0000003f, - 0x00000040,0x000200f9,0x0000003b,0x000200f8,0x0000003b,0x000700f5,0x00000024,0x00000042, - 0x00000038,0x00000005,0x00000041,0x0000003a,0x000300f7,0x00000044,0x00000000,0x000400fa, - 0x00000042,0x00000043,0x00000044,0x000200f8,0x00000043,0x00011504,0x000200f9,0x00000044, - 0x000200f8,0x00000044,0x00060041,0x0000004c,0x0000004d,0x0000004a,0x00000018,0x0000004b, - 0x0004003d,0x00000006,0x0000004e,0x0000004d,0x0004007c,0x00000009,0x0000004f,0x0000004e, - 0x00060041,0x0000004c,0x00000051,0x0000004a,0x00000018,0x00000050,0x0004003d,0x00000006, - 0x00000052,0x00000051,0x0004007c,0x00000009,0x00000053,0x00000052,0x00050050,0x00000012, - 0x00000054,0x0000004f,0x00000053,0x0003003e,0x00000046,0x00000054,0x00060041,0x0000004c, - 0x00000057,0x0000004a,0x00000018,0x00000056,0x0004003d,0x00000006,0x00000058,0x00000057, - 0x0004007c,0x00000009,0x00000059,0x00000058,0x00060041,0x0000004c,0x0000005b,0x0000004a, - 0x00000018,0x0000005a,0x0004003d,0x00000006,0x0000005c,0x0000005b,0x0004007c,0x00000009, - 0x0000005d,0x0000005c,0x00050050,0x00000012,0x0000005e,0x00000059,0x0000005d,0x0003003e, - 0x00000055,0x0000005e,0x00050041,0x00000020,0x00000060,0x00000011,0x0000001b,0x0004003d, - 0x00000009,0x00000061,0x00000060,0x00050041,0x00000062,0x00000063,0x00000046,0x0000001b, - 0x0004003d,0x00000009,0x00000064,0x00000063,0x00050088,0x00000009,0x00000065,0x00000061, - 0x00000064,0x00050085,0x00000009,0x00000067,0x00000065,0x00000066,0x00050083,0x00000009, - 0x00000069,0x00000067,0x00000068,0x00050041,0x00000020,0x0000006b,0x00000011,0x0000006a, - 0x0004003d,0x00000009,0x0000006c,0x0000006b,0x00050041,0x00000062,0x0000006d,0x00000046, - 0x0000006a,0x0004003d,0x00000009,0x0000006e,0x0000006d,0x00050088,0x00000009,0x0000006f, - 0x0000006c,0x0000006e,0x00050085,0x00000009,0x00000070,0x0000006f,0x00000066,0x00050083, - 0x00000009,0x00000071,0x00000068,0x00000070,0x00050050,0x00000012,0x00000072,0x00000069, - 0x00000071,0x0004003d,0x00000012,0x00000073,0x00000055,0x00050083,0x00000012,0x00000074, - 0x00000072,0x00000073,0x0003003e,0x0000005f,0x00000074,0x0004003d,0x0000000f,0x00000076, - 0x0000003c,0x0007004f,0x00000012,0x00000077,0x00000076,0x00000076,0x00000000,0x00000001, - 0x00050041,0x00000020,0x00000078,0x0000003c,0x0000003d,0x0004003d,0x00000009,0x00000079, - 0x00000078,0x00050050,0x00000012,0x0000007a,0x00000079,0x00000079,0x00050088,0x00000012, - 0x0000007b,0x00000077,0x0000007a,0x0003003e,0x00000075,0x0000007b,0x00050041,0x00000062, - 0x0000007d,0x00000075,0x0000001b,0x0004003d,0x00000009,0x0000007e,0x0000007d,0x00050041, - 0x00000062,0x0000007f,0x0000005f,0x0000001b,0x0004003d,0x00000009,0x00000080,0x0000007f, - 0x00050083,0x00000009,0x00000081,0x0000007e,0x00000080,0x00050041,0x00000062,0x00000082, - 0x0000005f,0x0000006a,0x0004003d,0x00000009,0x00000083,0x00000082,0x00050041,0x00000062, - 0x00000084,0x00000075,0x0000006a,0x0004003d,0x00000009,0x00000085,0x00000084,0x00050083, - 0x00000009,0x00000086,0x00000083,0x00000085,0x00050050,0x00000012,0x00000087,0x00000081, - 0x00000086,0x0005008e,0x00000012,0x00000089,0x00000087,0x00000088,0x0004003d,0x00000012, - 0x0000008a,0x00000046,0x00050085,0x00000012,0x0000008b,0x00000089,0x0000008a,0x0003003e, - 0x0000007c,0x0000008b,0x0004003d,0x00000012,0x0000008c,0x0000007c,0x0006000c,0x00000012, - 0x0000008d,0x00000001,0x00000004,0x0000008c,0x000500b8,0x00000090,0x00000091,0x0000008d, - 0x0000008f,0x0004009b,0x00000024,0x00000092,0x00000091,0x000400a8,0x00000024,0x00000093, - 0x00000092,0x000300f7,0x00000095,0x00000000,0x000400fa,0x00000093,0x00000094,0x00000095, - 0x000200f8,0x00000094,0x00011504,0x000200f9,0x00000095,0x000200f8,0x00000095,0x0004003d, - 0x00000012,0x00000098,0x0000007c,0x0003003e,0x00000097,0x00000098,0x000100fd,0x00010038 + 0x07230203,0x00010600,0x0008000b,0x0000014b,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00001503,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x000b000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d, + 0x00000011,0x00000028,0x00000083,0x000000ac,0x00000137,0x00030010,0x00000004,0x00000007, + 0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000,0x00040005, + 0x00000008,0x6e656373,0x00000065,0x00050005,0x0000000d,0x6e656373,0x65645f65,0x00687470, + 0x00060005,0x00000011,0x465f6c67,0x43676172,0x64726f6f,0x00000000,0x00040005,0x0000001e, + 0x65726568,0x00000000,0x00040005,0x00000024,0x64726f77,0x00000000,0x00040005,0x00000026, + 0x61746144,0x00000000,0x00040006,0x00000026,0x00000000,0x00000077,0x00040005,0x00000028, + 0x61746164,0x00000000,0x00040005,0x0000002f,0x6b72616d,0x00000000,0x00050005,0x00000034, + 0x656c6f74,0x636e6172,0x00000065,0x00030005,0x00000039,0x0000006e,0x00030005,0x0000003e, + 0x00000066,0x00030005,0x0000004c,0x0000737a,0x00030005,0x0000005b,0x0000687a,0x00030005, + 0x00000069,0x0066666f,0x00040005,0x00000083,0x6f666562,0x00006572,0x00040005,0x0000008d, + 0x657a6973,0x00000000,0x00050005,0x00000097,0x65726568,0x696c635f,0x00000070,0x00030005, + 0x000000a9,0x00776f6e,0x00040005,0x000000ac,0x7474696a,0x00007265,0x00040005,0x000000af, + 0x6e656874,0x00000000,0x00030005,0x000000b6,0x00007870,0x00030005,0x000000d4,0x00000063, + 0x00030005,0x000000dd,0x00000072,0x00050005,0x000000e7,0x72706572,0x63656a6f,0x00000074, + 0x00040005,0x000000fa,0x656d6163,0x00006172,0x00030005,0x0000010a,0x00736177,0x00050005, + 0x00000111,0x6e656373,0x6f6e5f65,0x00000077,0x00050005,0x0000011d,0x656d6163,0x705f6172, + 0x00000078,0x00040005,0x00000137,0x69746f6d,0x00006e6f,0x00040047,0x0000000d,0x00000021, + 0x00000001,0x00040047,0x0000000d,0x00000022,0x00000000,0x00040047,0x00000011,0x0000000b, + 0x0000000f,0x00040047,0x00000025,0x00000006,0x00000004,0x00030047,0x00000026,0x00000002, + 0x00040048,0x00000026,0x00000000,0x00000018,0x00050048,0x00000026,0x00000000,0x00000023, + 0x00000000,0x00030047,0x00000028,0x00000018,0x00040047,0x00000028,0x00000021,0x00000000, + 0x00040047,0x00000028,0x00000022,0x00000000,0x00040047,0x00000083,0x0000001e,0x00000000, + 0x00030047,0x000000ac,0x0000000e,0x00040047,0x000000ac,0x0000001e,0x00000001,0x00040047, + 0x00000137,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, + 0x00040015,0x00000006,0x00000020,0x00000000,0x00040020,0x00000007,0x00000007,0x00000006, + 0x00030016,0x00000009,0x00000020,0x00090019,0x0000000a,0x00000009,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a,0x00040020, + 0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000,0x00040017, + 0x0000000f,0x00000009,0x00000004,0x00040020,0x00000010,0x00000001,0x0000000f,0x0004003b, + 0x00000010,0x00000011,0x00000001,0x00040017,0x00000012,0x00000009,0x00000002,0x00040015, + 0x00000015,0x00000020,0x00000001,0x00040017,0x00000016,0x00000015,0x00000002,0x0004002b, + 0x00000015,0x00000018,0x00000000,0x0004002b,0x00000006,0x0000001b,0x00000000,0x0004002b, + 0x00000006,0x0000001f,0x00000002,0x00040020,0x00000020,0x00000001,0x00000009,0x0003001d, + 0x00000025,0x00000006,0x0003001e,0x00000026,0x00000025,0x00040020,0x00000027,0x0000000c, + 0x00000026,0x0004003b,0x00000027,0x00000028,0x0000000c,0x0004002b,0x00000015,0x00000029, + 0x00000042,0x00040020,0x0000002a,0x0000000c,0x00000006,0x00020014,0x0000002d,0x00040020, + 0x0000002e,0x00000007,0x0000002d,0x0004002b,0x00000006,0x00000031,0x80000000,0x0004002b, + 0x00000006,0x00000036,0x3fffffff,0x00040020,0x00000038,0x00000007,0x00000009,0x0004002b, + 0x00000015,0x0000003a,0x00000040,0x0004002b,0x00000015,0x0000003f,0x00000041,0x0004002b, + 0x00000009,0x00000044,0x00000000,0x0004002b,0x00000009,0x00000051,0x3f800000,0x0004002b, + 0x00000009,0x00000072,0x3a83126f,0x0004002b,0x00000006,0x0000007d,0x00000040,0x0004003b, + 0x00000010,0x00000083,0x00000001,0x0004002b,0x00000006,0x00000084,0x00000003,0x0004002b, + 0x00000009,0x00000087,0x358637bd,0x00040020,0x0000008c,0x00000007,0x00000012,0x0004002b, + 0x00000015,0x0000008e,0x00000022,0x0004002b,0x00000015,0x00000092,0x00000023,0x0004002b, + 0x00000009,0x0000009d,0x40000000,0x0004002b,0x00000006,0x000000a0,0x00000001,0x00040020, + 0x000000ab,0x00000001,0x00000012,0x0004003b,0x000000ab,0x000000ac,0x00000001,0x0004002b, + 0x00000009,0x000000c2,0x3f000000,0x0004002b,0x00000009,0x000000c8,0x46800000,0x0005002c, + 0x00000012,0x000000c9,0x000000c8,0x000000c8,0x00040017,0x000000ca,0x0000002d,0x00000002, + 0x00040020,0x000000d3,0x00000007,0x00000015,0x0004002b,0x00000015,0x000000db,0x00000004, + 0x00040018,0x000000e5,0x0000000f,0x00000004,0x00040020,0x000000e6,0x00000007,0x000000e5, + 0x0004002b,0x00000015,0x000000ea,0x00000048,0x0004002b,0x00000015,0x000000f5,0x00000001, + 0x00040020,0x000000f9,0x00000007,0x0000000f,0x0004002b,0x00000015,0x00000113,0x00000020, + 0x0004002b,0x00000015,0x00000117,0x00000021,0x0004002b,0x00000009,0x00000130,0x3e800000, + 0x0005002c,0x00000012,0x00000131,0x00000130,0x00000130,0x00040020,0x00000136,0x00000003, + 0x00000012,0x0004003b,0x00000136,0x00000137,0x00000003,0x0004002b,0x00000006,0x00000139, + 0x40000000,0x0004002b,0x00000009,0x0000013f,0xc6ea6000,0x0004002b,0x00000009,0x00000146, + 0x42800000,0x0005002c,0x00000012,0x00000147,0x00000044,0x00000146,0x00050036,0x00000002, + 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000007,0x00000008, + 0x00000007,0x0004003b,0x00000007,0x0000001e,0x00000007,0x0004003b,0x00000007,0x00000024, + 0x00000007,0x0004003b,0x0000002e,0x0000002f,0x00000007,0x0004003b,0x00000007,0x00000034, + 0x00000007,0x0004003b,0x00000038,0x00000039,0x00000007,0x0004003b,0x00000038,0x0000003e, + 0x00000007,0x0004003b,0x00000038,0x0000004c,0x00000007,0x0004003b,0x00000038,0x0000005b, + 0x00000007,0x0004003b,0x0000002e,0x00000069,0x00000007,0x0004003b,0x0000008c,0x0000008d, + 0x00000007,0x0004003b,0x0000008c,0x00000097,0x00000007,0x0004003b,0x0000008c,0x000000a9, + 0x00000007,0x0004003b,0x0000008c,0x000000af,0x00000007,0x0004003b,0x0000008c,0x000000b6, + 0x00000007,0x0004003b,0x000000d3,0x000000d4,0x00000007,0x0004003b,0x000000d3,0x000000dd, + 0x00000007,0x0004003b,0x000000e6,0x000000e7,0x00000007,0x0004003b,0x000000f9,0x000000fa, + 0x00000007,0x0004003b,0x0000008c,0x0000010a,0x00000007,0x0004003b,0x0000008c,0x00000111, + 0x00000007,0x0004003b,0x0000008c,0x0000011d,0x00000007,0x0004003b,0x0000008c,0x0000013c, + 0x00000007,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d,0x0000000f,0x00000013, + 0x00000011,0x0007004f,0x00000012,0x00000014,0x00000013,0x00000013,0x00000000,0x00000001, + 0x0004006e,0x00000016,0x00000017,0x00000014,0x00040064,0x0000000a,0x00000019,0x0000000e, + 0x0007005f,0x0000000f,0x0000001a,0x00000019,0x00000017,0x00000002,0x00000018,0x00050051, + 0x00000009,0x0000001c,0x0000001a,0x00000000,0x0004007c,0x00000006,0x0000001d,0x0000001c, + 0x0003003e,0x00000008,0x0000001d,0x00050041,0x00000020,0x00000021,0x00000011,0x0000001f, + 0x0004003d,0x00000009,0x00000022,0x00000021,0x0004007c,0x00000006,0x00000023,0x00000022, + 0x0003003e,0x0000001e,0x00000023,0x00060041,0x0000002a,0x0000002b,0x00000028,0x00000018, + 0x00000029,0x0004003d,0x00000006,0x0000002c,0x0000002b,0x0003003e,0x00000024,0x0000002c, + 0x0004003d,0x00000006,0x00000030,0x00000024,0x000500c7,0x00000006,0x00000032,0x00000030, + 0x00000031,0x000500ab,0x0000002d,0x00000033,0x00000032,0x0000001b,0x0003003e,0x0000002f, + 0x00000033,0x0004003d,0x00000006,0x00000035,0x00000024,0x000500c7,0x00000006,0x00000037, + 0x00000035,0x00000036,0x0003003e,0x00000034,0x00000037,0x00060041,0x0000002a,0x0000003b, + 0x00000028,0x00000018,0x0000003a,0x0004003d,0x00000006,0x0000003c,0x0000003b,0x0004007c, + 0x00000009,0x0000003d,0x0000003c,0x0003003e,0x00000039,0x0000003d,0x00060041,0x0000002a, + 0x00000040,0x00000028,0x00000018,0x0000003f,0x0004003d,0x00000006,0x00000041,0x00000040, + 0x0004007c,0x00000009,0x00000042,0x00000041,0x0003003e,0x0000003e,0x00000042,0x0004003d, + 0x00000009,0x00000043,0x00000039,0x000500ba,0x0000002d,0x00000045,0x00000043,0x00000044, + 0x0004003d,0x00000009,0x00000046,0x0000003e,0x0004003d,0x00000009,0x00000047,0x00000039, + 0x000500ba,0x0000002d,0x00000048,0x00000046,0x00000047,0x000500a7,0x0000002d,0x00000049, + 0x00000045,0x00000048,0x000300f7,0x0000004b,0x00000000,0x000400fa,0x00000049,0x0000004a, + 0x00000075,0x000200f8,0x0000004a,0x0004003d,0x00000009,0x0000004d,0x00000039,0x0004003d, + 0x00000009,0x0000004e,0x0000003e,0x00050085,0x00000009,0x0000004f,0x0000004d,0x0000004e, + 0x0004003d,0x00000009,0x00000050,0x00000039,0x0004003d,0x00000006,0x00000052,0x00000008, + 0x0004007c,0x00000009,0x00000053,0x00000052,0x00050083,0x00000009,0x00000054,0x00000051, + 0x00000053,0x0004003d,0x00000009,0x00000055,0x0000003e,0x0004003d,0x00000009,0x00000056, + 0x00000039,0x00050083,0x00000009,0x00000057,0x00000055,0x00000056,0x00050085,0x00000009, + 0x00000058,0x00000054,0x00000057,0x00050081,0x00000009,0x00000059,0x00000050,0x00000058, + 0x00050088,0x00000009,0x0000005a,0x0000004f,0x00000059,0x0003003e,0x0000004c,0x0000005a, + 0x0004003d,0x00000009,0x0000005c,0x00000039,0x0004003d,0x00000009,0x0000005d,0x0000003e, + 0x00050085,0x00000009,0x0000005e,0x0000005c,0x0000005d,0x0004003d,0x00000009,0x0000005f, + 0x00000039,0x00050041,0x00000020,0x00000060,0x00000011,0x0000001f,0x0004003d,0x00000009, + 0x00000061,0x00000060,0x00050083,0x00000009,0x00000062,0x00000051,0x00000061,0x0004003d, + 0x00000009,0x00000063,0x0000003e,0x0004003d,0x00000009,0x00000064,0x00000039,0x00050083, + 0x00000009,0x00000065,0x00000063,0x00000064,0x00050085,0x00000009,0x00000066,0x00000062, + 0x00000065,0x00050081,0x00000009,0x00000067,0x0000005f,0x00000066,0x00050088,0x00000009, + 0x00000068,0x0000005e,0x00000067,0x0003003e,0x0000005b,0x00000068,0x0004003d,0x00000009, + 0x0000006a,0x0000005b,0x0004003d,0x00000009,0x0000006b,0x0000004c,0x00050083,0x00000009, + 0x0000006c,0x0000006a,0x0000006b,0x0006000c,0x00000009,0x0000006d,0x00000001,0x00000004, + 0x0000006c,0x0004003d,0x00000009,0x0000006e,0x0000004c,0x0004003d,0x00000006,0x0000006f, + 0x00000034,0x00040070,0x00000009,0x00000070,0x0000006f,0x00050085,0x00000009,0x00000071, + 0x0000006e,0x00000070,0x00050085,0x00000009,0x00000073,0x00000071,0x00000072,0x000500ba, + 0x0000002d,0x00000074,0x0000006d,0x00000073,0x0003003e,0x00000069,0x00000074,0x000200f9, + 0x0000004b,0x000200f8,0x00000075,0x0004003d,0x00000006,0x00000076,0x00000008,0x0004003d, + 0x00000006,0x00000077,0x0000001e,0x0007000c,0x00000006,0x00000078,0x00000001,0x00000029, + 0x00000076,0x00000077,0x0004003d,0x00000006,0x00000079,0x00000008,0x0004003d,0x00000006, + 0x0000007a,0x0000001e,0x0007000c,0x00000006,0x0000007b,0x00000001,0x00000026,0x00000079, + 0x0000007a,0x00050082,0x00000006,0x0000007c,0x00000078,0x0000007b,0x000500ac,0x0000002d, + 0x0000007e,0x0000007c,0x0000007d,0x0003003e,0x00000069,0x0000007e,0x000200f9,0x0000004b, + 0x000200f8,0x0000004b,0x0004003d,0x0000002d,0x0000007f,0x00000069,0x000400a8,0x0000002d, + 0x00000080,0x0000007f,0x000300f7,0x00000082,0x00000000,0x000400fa,0x00000080,0x00000081, + 0x00000082,0x000200f8,0x00000081,0x00050041,0x00000020,0x00000085,0x00000083,0x00000084, + 0x0004003d,0x00000009,0x00000086,0x00000085,0x000500bc,0x0000002d,0x00000088,0x00000086, + 0x00000087,0x000200f9,0x00000082,0x000200f8,0x00000082,0x000700f5,0x0000002d,0x00000089, + 0x0000007f,0x0000004b,0x00000088,0x00000081,0x000300f7,0x0000008b,0x00000000,0x000400fa, + 0x00000089,0x0000008a,0x0000008b,0x000200f8,0x0000008a,0x00011504,0x000200f9,0x0000008b, + 0x000200f8,0x0000008b,0x00060041,0x0000002a,0x0000008f,0x00000028,0x00000018,0x0000008e, + 0x0004003d,0x00000006,0x00000090,0x0000008f,0x0004007c,0x00000009,0x00000091,0x00000090, + 0x00060041,0x0000002a,0x00000093,0x00000028,0x00000018,0x00000092,0x0004003d,0x00000006, + 0x00000094,0x00000093,0x0004007c,0x00000009,0x00000095,0x00000094,0x00050050,0x00000012, + 0x00000096,0x00000091,0x00000095,0x0003003e,0x0000008d,0x00000096,0x00050041,0x00000020, + 0x00000098,0x00000011,0x0000001b,0x0004003d,0x00000009,0x00000099,0x00000098,0x00050041, + 0x00000038,0x0000009a,0x0000008d,0x0000001b,0x0004003d,0x00000009,0x0000009b,0x0000009a, + 0x00050088,0x00000009,0x0000009c,0x00000099,0x0000009b,0x00050085,0x00000009,0x0000009e, + 0x0000009c,0x0000009d,0x00050083,0x00000009,0x0000009f,0x0000009e,0x00000051,0x00050041, + 0x00000020,0x000000a1,0x00000011,0x000000a0,0x0004003d,0x00000009,0x000000a2,0x000000a1, + 0x00050041,0x00000038,0x000000a3,0x0000008d,0x000000a0,0x0004003d,0x00000009,0x000000a4, + 0x000000a3,0x00050088,0x00000009,0x000000a5,0x000000a2,0x000000a4,0x00050085,0x00000009, + 0x000000a6,0x000000a5,0x0000009d,0x00050083,0x00000009,0x000000a7,0x00000051,0x000000a6, + 0x00050050,0x00000012,0x000000a8,0x0000009f,0x000000a7,0x0003003e,0x00000097,0x000000a8, + 0x0004003d,0x00000012,0x000000aa,0x00000097,0x0004003d,0x00000012,0x000000ad,0x000000ac, + 0x00050083,0x00000012,0x000000ae,0x000000aa,0x000000ad,0x0003003e,0x000000a9,0x000000ae, + 0x0004003d,0x0000000f,0x000000b0,0x00000083,0x0007004f,0x00000012,0x000000b1,0x000000b0, + 0x000000b0,0x00000000,0x00000001,0x00050041,0x00000020,0x000000b2,0x00000083,0x00000084, + 0x0004003d,0x00000009,0x000000b3,0x000000b2,0x00050050,0x00000012,0x000000b4,0x000000b3, + 0x000000b3,0x00050088,0x00000012,0x000000b5,0x000000b1,0x000000b4,0x0003003e,0x000000af, + 0x000000b5,0x00050041,0x00000038,0x000000b7,0x000000af,0x0000001b,0x0004003d,0x00000009, + 0x000000b8,0x000000b7,0x00050041,0x00000038,0x000000b9,0x000000a9,0x0000001b,0x0004003d, + 0x00000009,0x000000ba,0x000000b9,0x00050083,0x00000009,0x000000bb,0x000000b8,0x000000ba, + 0x00050041,0x00000038,0x000000bc,0x000000a9,0x000000a0,0x0004003d,0x00000009,0x000000bd, + 0x000000bc,0x00050041,0x00000038,0x000000be,0x000000af,0x000000a0,0x0004003d,0x00000009, + 0x000000bf,0x000000be,0x00050083,0x00000009,0x000000c0,0x000000bd,0x000000bf,0x00050050, + 0x00000012,0x000000c1,0x000000bb,0x000000c0,0x0005008e,0x00000012,0x000000c3,0x000000c1, + 0x000000c2,0x0004003d,0x00000012,0x000000c4,0x0000008d,0x00050085,0x00000012,0x000000c5, + 0x000000c3,0x000000c4,0x0003003e,0x000000b6,0x000000c5,0x0004003d,0x00000012,0x000000c6, + 0x000000b6,0x0006000c,0x00000012,0x000000c7,0x00000001,0x00000004,0x000000c6,0x000500b8, + 0x000000ca,0x000000cb,0x000000c7,0x000000c9,0x0004009b,0x0000002d,0x000000cc,0x000000cb, + 0x000400a8,0x0000002d,0x000000cd,0x000000cc,0x000300f7,0x000000cf,0x00000000,0x000400fa, + 0x000000cd,0x000000ce,0x000000cf,0x000200f8,0x000000ce,0x00011504,0x000200f9,0x000000cf, + 0x000200f8,0x000000cf,0x0004003d,0x0000002d,0x000000d0,0x0000002f,0x000300f7,0x000000d2, + 0x00000000,0x000400fa,0x000000d0,0x000000d1,0x000000d2,0x000200f8,0x000000d1,0x0003003e, + 0x000000d4,0x00000018,0x000200f9,0x000000d5,0x000200f8,0x000000d5,0x000400f6,0x000000d7, + 0x000000d8,0x00000000,0x000200f9,0x000000d9,0x000200f8,0x000000d9,0x0004003d,0x00000015, + 0x000000da,0x000000d4,0x000500b1,0x0000002d,0x000000dc,0x000000da,0x000000db,0x000400fa, + 0x000000dc,0x000000d6,0x000000d7,0x000200f8,0x000000d6,0x0003003e,0x000000dd,0x00000018, + 0x000200f9,0x000000de,0x000200f8,0x000000de,0x000400f6,0x000000e0,0x000000e1,0x00000000, + 0x000200f9,0x000000e2,0x000200f8,0x000000e2,0x0004003d,0x00000015,0x000000e3,0x000000dd, + 0x000500b1,0x0000002d,0x000000e4,0x000000e3,0x000000db,0x000400fa,0x000000e4,0x000000df, + 0x000000e0,0x000200f8,0x000000df,0x0004003d,0x00000015,0x000000e8,0x000000d4,0x0004003d, + 0x00000015,0x000000e9,0x000000dd,0x0004003d,0x00000015,0x000000eb,0x000000dd,0x00050084, + 0x00000015,0x000000ec,0x000000eb,0x000000db,0x00050080,0x00000015,0x000000ed,0x000000ea, + 0x000000ec,0x0004003d,0x00000015,0x000000ee,0x000000d4,0x00050080,0x00000015,0x000000ef, + 0x000000ed,0x000000ee,0x00060041,0x0000002a,0x000000f0,0x00000028,0x00000018,0x000000ef, + 0x0004003d,0x00000006,0x000000f1,0x000000f0,0x0004007c,0x00000009,0x000000f2,0x000000f1, + 0x00060041,0x00000038,0x000000f3,0x000000e7,0x000000e8,0x000000e9,0x0003003e,0x000000f3, + 0x000000f2,0x000200f9,0x000000e1,0x000200f8,0x000000e1,0x0004003d,0x00000015,0x000000f4, + 0x000000dd,0x00050080,0x00000015,0x000000f6,0x000000f4,0x000000f5,0x0003003e,0x000000dd, + 0x000000f6,0x000200f9,0x000000de,0x000200f8,0x000000e0,0x000200f9,0x000000d8,0x000200f8, + 0x000000d8,0x0004003d,0x00000015,0x000000f7,0x000000d4,0x00050080,0x00000015,0x000000f8, + 0x000000f7,0x000000f5,0x0003003e,0x000000d4,0x000000f8,0x000200f9,0x000000d5,0x000200f8, + 0x000000d7,0x0004003d,0x000000e5,0x000000fb,0x000000e7,0x0004003d,0x00000012,0x000000fc, + 0x00000097,0x00050041,0x00000020,0x000000fd,0x00000011,0x0000001f,0x0004003d,0x00000009, + 0x000000fe,0x000000fd,0x00050085,0x00000009,0x000000ff,0x000000fe,0x0000009d,0x00050083, + 0x00000009,0x00000100,0x000000ff,0x00000051,0x00050051,0x00000009,0x00000101,0x000000fc, + 0x00000000,0x00050051,0x00000009,0x00000102,0x000000fc,0x00000001,0x00070050,0x0000000f, + 0x00000103,0x00000101,0x00000102,0x00000100,0x00000051,0x00050091,0x0000000f,0x00000104, + 0x000000fb,0x00000103,0x0003003e,0x000000fa,0x00000104,0x00050041,0x00000038,0x00000105, + 0x000000fa,0x00000084,0x0004003d,0x00000009,0x00000106,0x00000105,0x000500bc,0x0000002d, + 0x00000107,0x00000106,0x00000087,0x000300f7,0x00000109,0x00000000,0x000400fa,0x00000107, + 0x00000108,0x00000109,0x000200f8,0x00000108,0x00011504,0x000200f9,0x00000109,0x000200f8, + 0x00000109,0x0004003d,0x0000000f,0x0000010b,0x000000fa,0x0007004f,0x00000012,0x0000010c, + 0x0000010b,0x0000010b,0x00000000,0x00000001,0x00050041,0x00000038,0x0000010d,0x000000fa, + 0x00000084,0x0004003d,0x00000009,0x0000010e,0x0000010d,0x00050050,0x00000012,0x0000010f, + 0x0000010e,0x0000010e,0x00050088,0x00000012,0x00000110,0x0000010c,0x0000010f,0x0003003e, + 0x0000010a,0x00000110,0x0004003d,0x00000012,0x00000112,0x00000097,0x00060041,0x0000002a, + 0x00000114,0x00000028,0x00000018,0x00000113,0x0004003d,0x00000006,0x00000115,0x00000114, + 0x0004007c,0x00000009,0x00000116,0x00000115,0x00060041,0x0000002a,0x00000118,0x00000028, + 0x00000018,0x00000117,0x0004003d,0x00000006,0x00000119,0x00000118,0x0004007c,0x00000009, + 0x0000011a,0x00000119,0x00050050,0x00000012,0x0000011b,0x00000116,0x0000011a,0x00050083, + 0x00000012,0x0000011c,0x00000112,0x0000011b,0x0003003e,0x00000111,0x0000011c,0x00050041, + 0x00000038,0x0000011e,0x0000010a,0x0000001b,0x0004003d,0x00000009,0x0000011f,0x0000011e, + 0x00050041,0x00000038,0x00000120,0x00000111,0x0000001b,0x0004003d,0x00000009,0x00000121, + 0x00000120,0x00050083,0x00000009,0x00000122,0x0000011f,0x00000121,0x00050041,0x00000038, + 0x00000123,0x00000111,0x000000a0,0x0004003d,0x00000009,0x00000124,0x00000123,0x00050041, + 0x00000038,0x00000125,0x0000010a,0x000000a0,0x0004003d,0x00000009,0x00000126,0x00000125, + 0x00050083,0x00000009,0x00000127,0x00000124,0x00000126,0x00050050,0x00000012,0x00000128, + 0x00000122,0x00000127,0x0005008e,0x00000012,0x00000129,0x00000128,0x000000c2,0x0004003d, + 0x00000012,0x0000012a,0x0000008d,0x00050085,0x00000012,0x0000012b,0x00000129,0x0000012a, + 0x0003003e,0x0000011d,0x0000012b,0x0004003d,0x00000012,0x0000012c,0x000000b6,0x0004003d, + 0x00000012,0x0000012d,0x0000011d,0x00050083,0x00000012,0x0000012e,0x0000012c,0x0000012d, + 0x0006000c,0x00000012,0x0000012f,0x00000001,0x00000004,0x0000012e,0x000500b8,0x000000ca, + 0x00000132,0x0000012f,0x00000131,0x0004009b,0x0000002d,0x00000133,0x00000132,0x000300f7, + 0x00000135,0x00000000,0x000400fa,0x00000133,0x00000134,0x00000135,0x000200f8,0x00000134, + 0x00011504,0x000200f9,0x00000135,0x000200f8,0x00000135,0x0004003d,0x00000006,0x00000138, + 0x00000024,0x000500c7,0x00000006,0x0000013a,0x00000138,0x00000139,0x000500ab,0x0000002d, + 0x0000013b,0x0000013a,0x0000001b,0x000300f7,0x0000013e,0x00000000,0x000400fa,0x0000013b, + 0x0000013d,0x00000145,0x000200f8,0x0000013d,0x0004003d,0x00000012,0x00000140,0x000000b6, + 0x0004003d,0x00000012,0x00000141,0x0000011d,0x00050083,0x00000012,0x00000142,0x00000140, + 0x00000141,0x0006000c,0x00000009,0x00000143,0x00000001,0x00000042,0x00000142,0x00050050, + 0x00000012,0x00000144,0x0000013f,0x00000143,0x0003003e,0x0000013c,0x00000144,0x000200f9, + 0x0000013e,0x000200f8,0x00000145,0x0003003e,0x0000013c,0x00000147,0x000200f9,0x0000013e, + 0x000200f8,0x0000013e,0x0004003d,0x00000012,0x00000148,0x0000013c,0x0003003e,0x00000137, + 0x00000148,0x000100fd,0x000200f8,0x000000d2,0x0004003d,0x00000012,0x0000014a,0x000000b6, + 0x0003003e,0x00000137,0x0000014a,0x000100fd,0x00010038 }; diff --git a/gpu/vk/shaders/dlss_actor_vert_spv.h b/gpu/vk/shaders/dlss_actor_vert_spv.h index 7faba95..0c06ab4 100644 --- a/gpu/vk/shaders/dlss_actor_vert_spv.h +++ b/gpu/vk/shaders/dlss_actor_vert_spv.h @@ -1,421 +1,519 @@ // 1116.6.0 #pragma once const uint32_t DLSS_ACTOR_VERT_SPV[] = { - 0x07230203,0x00010600,0x0008000b,0x0000021e,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010600,0x0008000b,0x00000292,0x00000000,0x00020011,0x00000001,0x00020011, 0x0000000b,0x00020011,0x000014e3,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e, - 0x00000000,0x0003000e,0x000014e4,0x00000001,0x000a000f,0x00000000,0x00000004,0x6e69616d, - 0x00000000,0x00000030,0x000000b0,0x000000e4,0x00000130,0x00000135,0x00030003,0x00000002, - 0x000001c2,0x00070004,0x455f4c47,0x625f5458,0x65666675,0x65725f72,0x65726566,0x0065636e, - 0x000d0004,0x455f4c47,0x735f5458,0x65646168,0x78655f72,0x63696c70,0x615f7469,0x68746972, - 0x6974656d,0x79745f63,0x5f736570,0x36746e69,0x00000034,0x00040005,0x00000004,0x6e69616d, - 0x00000000,0x00040005,0x0000000b,0x31752866,0x0000003b,0x00030005,0x0000000a,0x00000069, - 0x00040005,0x00000010,0x75283466,0x00003b31,0x00030005,0x0000000f,0x00000069,0x00050005, - 0x00000015,0x656d6163,0x75286172,0x00003b31,0x00030005,0x00000014,0x00007461,0x00040005, - 0x00000019,0x64726f57,0x00000073,0x00040006,0x00000019,0x00000000,0x00000077,0x00050005, - 0x0000001e,0x28776f72,0x31753b31,0x0000003b,0x00030005,0x0000001c,0x0000006d,0x00030005, - 0x0000001d,0x00000069,0x00080005,0x0000002b,0x6e696b73,0x763b3128,0x763b3475,0x763b3466, - 0x763b3466,0x003b3366,0x00040005,0x00000026,0x656c6170,0x00657474,0x00030005,0x00000027, - 0x0000006a,0x00030005,0x00000028,0x00007477,0x00030005,0x00000029,0x00000070,0x00030005, - 0x0000002a,0x00636361,0x00040005,0x0000002e,0x61746144,0x00000000,0x00040006,0x0000002e, - 0x00000000,0x00000077,0x00040005,0x00000030,0x61746164,0x00000000,0x00040005,0x0000003a, - 0x61726170,0x0000006d,0x00040005,0x00000040,0x61726170,0x0000006d,0x00040005,0x00000045, - 0x61726170,0x0000006d,0x00040005,0x0000004a,0x61726170,0x0000006d,0x00040005,0x0000004f, - 0x61726170,0x0000006d,0x00040005,0x00000055,0x61726170,0x0000006d,0x00040005,0x0000005a, - 0x61726170,0x0000006d,0x00040005,0x0000005f,0x61726170,0x0000006d,0x00030005,0x00000094, - 0x0000006b,0x00030005,0x000000ae,0x00000050,0x00060006,0x000000ae,0x00000000,0x74726576, - 0x73656369,0x00000000,0x00050006,0x000000ae,0x00000001,0x69646e69,0x00736563,0x00050006, - 0x000000ae,0x00000002,0x6769726f,0x00736e69,0x00050006,0x000000ae,0x00000003,0x656e6f62, - 0x00000073,0x00050006,0x000000ae,0x00000004,0x6e6f626e,0x00007365,0x00050006,0x000000ae, - 0x00000005,0x69727473,0x00006564,0x00050006,0x000000ae,0x00000006,0x6e756f63,0x00000074, - 0x00050006,0x000000ae,0x00000007,0x73726966,0x00000074,0x00050006,0x000000ae,0x00000008, - 0x70797469,0x00000065,0x00060006,0x000000ae,0x00000009,0x65736162,0x7265765f,0x00786574, - 0x00040006,0x000000ae,0x0000000a,0x00736f70,0x00050006,0x000000ae,0x0000000b,0x73746573, - 0x00000000,0x00050006,0x000000ae,0x0000000c,0x6e696f6a,0x00007374,0x00050006,0x000000ae, - 0x0000000d,0x67696577,0x00737468,0x00050006,0x000000ae,0x0000000e,0x6d726f66,0x00737461, - 0x00060006,0x000000ae,0x0000000f,0x656c6f74,0x636e6172,0x00000065,0x00030005,0x000000b0, - 0x00006370,0x00030005,0x000000b9,0x00000062,0x00040005,0x000000c1,0x61726170,0x0000006d, - 0x00040005,0x000000c3,0x61726170,0x0000006d,0x00040005,0x000000ca,0x61726170,0x0000006d, - 0x00040005,0x000000cc,0x61726170,0x0000006d,0x00040005,0x000000d2,0x61726170,0x0000006d, - 0x00040005,0x000000d4,0x61726170,0x0000006d,0x00030005,0x000000df,0x00007461,0x00060005, - 0x000000e4,0x565f6c67,0x65747265,0x646e4978,0x00007865,0x00030005,0x000000e8,0x00006269, - 0x00040005,0x000000f3,0x65646e69,0x00000078,0x00030005,0x00000117,0x00006976,0x00060005, - 0x0000012e,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x0000012e,0x00000000, - 0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x0000012e,0x00000001,0x505f6c67,0x746e696f, - 0x657a6953,0x00000000,0x00070006,0x0000012e,0x00000002,0x435f6c67,0x4470696c,0x61747369, - 0x0065636e,0x00070006,0x0000012e,0x00000003,0x435f6c67,0x446c6c75,0x61747369,0x0065636e, - 0x00030005,0x00000130,0x00000000,0x00040005,0x00000135,0x6f666562,0x00006572,0x00030005, - 0x00000138,0x00006276,0x00030005,0x00000147,0x00000071,0x00030005,0x0000014c,0x00000070, - 0x00030005,0x0000017a,0x00776f6e,0x00040005,0x0000017c,0x6e656874,0x00000000,0x00030005, - 0x0000017d,0x00000073,0x00030005,0x00000188,0x00000061,0x00030005,0x00000191,0x0000006a, - 0x00030005,0x000001c0,0x00007477,0x00040005,0x000001ce,0x61726170,0x0000006d,0x00040005, - 0x000001cf,0x61726170,0x0000006d,0x00040005,0x000001d1,0x61726170,0x0000006d,0x00040005, - 0x000001d3,0x61726170,0x0000006d,0x00040005,0x000001d5,0x61726170,0x0000006d,0x00040005, - 0x000001dc,0x61726170,0x0000006d,0x00040005,0x000001dd,0x61726170,0x0000006d,0x00040005, - 0x000001df,0x61726170,0x0000006d,0x00040005,0x000001e1,0x61726170,0x0000006d,0x00040005, - 0x000001e3,0x61726170,0x0000006d,0x00030005,0x000001e9,0x0000306f,0x00040005,0x000001ed, - 0x61726170,0x0000006d,0x00040005,0x000001ee,0x61726170,0x0000006d,0x00030005,0x000001f1, - 0x0000316f,0x00040005,0x000001f5,0x61726170,0x0000006d,0x00040005,0x000001f6,0x61726170, - 0x0000006d,0x00040005,0x000001f9,0x70696c63,0x00000000,0x00040005,0x000001fa,0x61726170, - 0x0000006d,0x00040005,0x00000204,0x61726170,0x0000006d,0x00040047,0x00000018,0x00000006, - 0x00000004,0x00030047,0x00000019,0x00000002,0x00040048,0x00000019,0x00000000,0x00000018, - 0x00050048,0x00000019,0x00000000,0x00000023,0x00000000,0x00030047,0x0000001c,0x000014ec, - 0x00030047,0x00000026,0x000014ec,0x00040047,0x0000002d,0x00000006,0x00000004,0x00030047, - 0x0000002e,0x00000002,0x00040048,0x0000002e,0x00000000,0x00000018,0x00050048,0x0000002e, - 0x00000000,0x00000023,0x00000000,0x00030047,0x00000030,0x00000018,0x00040047,0x00000030, - 0x00000021,0x00000000,0x00040047,0x00000030,0x00000022,0x00000000,0x00040047,0x000000aa, - 0x00000006,0x00000008,0x00040047,0x000000ab,0x00000006,0x00000008,0x00040047,0x000000ac, - 0x00000006,0x00000004,0x00040047,0x000000ad,0x00000006,0x00000004,0x00030047,0x000000ae, - 0x00000002,0x00050048,0x000000ae,0x00000000,0x00000023,0x00000000,0x00050048,0x000000ae, - 0x00000001,0x00000023,0x00000008,0x00050048,0x000000ae,0x00000002,0x00000023,0x00000010, - 0x00050048,0x000000ae,0x00000003,0x00000023,0x00000020,0x00050048,0x000000ae,0x00000004, - 0x00000023,0x00000030,0x00050048,0x000000ae,0x00000005,0x00000023,0x00000034,0x00050048, - 0x000000ae,0x00000006,0x00000023,0x00000038,0x00050048,0x000000ae,0x00000007,0x00000023, - 0x0000003c,0x00050048,0x000000ae,0x00000008,0x00000023,0x00000040,0x00050048,0x000000ae, - 0x00000009,0x00000023,0x00000044,0x00050048,0x000000ae,0x0000000a,0x00000023,0x00000048, - 0x00050048,0x000000ae,0x0000000b,0x00000023,0x0000004c,0x00050048,0x000000ae,0x0000000c, - 0x00000023,0x00000050,0x00050048,0x000000ae,0x0000000d,0x00000023,0x00000058,0x00050048, - 0x000000ae,0x0000000e,0x00000023,0x00000060,0x00050048,0x000000ae,0x0000000f,0x00000023, - 0x00000064,0x00030047,0x000000c1,0x000014ec,0x00030047,0x000000ca,0x000014ec,0x00030047, - 0x000000d2,0x000014ec,0x00040047,0x000000e4,0x0000000b,0x0000002a,0x00030047,0x000000e8, - 0x000014ec,0x00030047,0x0000012e,0x00000002,0x00050048,0x0000012e,0x00000000,0x0000000b, - 0x00000000,0x00050048,0x0000012e,0x00000001,0x0000000b,0x00000001,0x00050048,0x0000012e, - 0x00000002,0x0000000b,0x00000003,0x00050048,0x0000012e,0x00000003,0x0000000b,0x00000004, - 0x00040047,0x00000135,0x0000001e,0x00000000,0x00030047,0x00000138,0x000014ec,0x00030047, - 0x000001ce,0x000014ec,0x00030047,0x000001dc,0x000014ec,0x00030047,0x000001ed,0x000014ec, - 0x00030047,0x000001f5,0x000014ec,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, - 0x00040015,0x00000006,0x00000020,0x00000000,0x00040020,0x00000007,0x00000007,0x00000006, - 0x00030016,0x00000008,0x00000020,0x00040021,0x00000009,0x00000008,0x00000007,0x00040017, - 0x0000000d,0x00000008,0x00000004,0x00040021,0x0000000e,0x0000000d,0x00000007,0x00040018, - 0x00000012,0x0000000d,0x00000004,0x00040021,0x00000013,0x00000012,0x00000007,0x00030027, - 0x00000017,0x000014e5,0x0003001d,0x00000018,0x00000006,0x0003001e,0x00000019,0x00000018, - 0x00040020,0x00000017,0x000014e5,0x00000019,0x00040020,0x0000001a,0x00000007,0x00000017, - 0x00050021,0x0000001b,0x0000000d,0x0000001a,0x00000007,0x00040017,0x00000020,0x00000006, - 0x00000004,0x00040020,0x00000021,0x00000007,0x00000020,0x00040020,0x00000022,0x00000007, - 0x0000000d,0x00040017,0x00000023,0x00000008,0x00000003,0x00040020,0x00000024,0x00000007, - 0x00000023,0x00080021,0x00000025,0x00000002,0x0000001a,0x00000021,0x00000022,0x00000022, - 0x00000024,0x0003001d,0x0000002d,0x00000006,0x0003001e,0x0000002e,0x0000002d,0x00040020, - 0x0000002f,0x0000000c,0x0000002e,0x0004003b,0x0000002f,0x00000030,0x0000000c,0x00040015, - 0x00000031,0x00000020,0x00000001,0x0004002b,0x00000031,0x00000032,0x00000000,0x00040020, - 0x00000034,0x0000000c,0x00000006,0x0004002b,0x00000006,0x0000003e,0x00000001,0x0004002b, - 0x00000006,0x00000043,0x00000002,0x0004002b,0x00000006,0x00000048,0x00000003,0x0004002b, - 0x00000006,0x00000053,0x00000004,0x0004002b,0x00000006,0x00000058,0x00000008,0x0004002b, - 0x00000006,0x0000005d,0x0000000c,0x0004002b,0x00000008,0x00000061,0x3f800000,0x0004002b, - 0x00000008,0x00000062,0x00000000,0x00040020,0x0000007d,0x000014e5,0x00000006,0x00040020, - 0x00000093,0x00000007,0x00000031,0x0004002b,0x00000031,0x0000009b,0x00000004,0x00020014, - 0x0000009c,0x00040020,0x0000009f,0x00000007,0x00000008,0x00040015,0x000000a9,0x00000040, - 0x00000000,0x0004001c,0x000000aa,0x000000a9,0x00000043,0x0004001c,0x000000ab,0x000000a9, - 0x00000043,0x0004001c,0x000000ac,0x00000006,0x00000043,0x0004001c,0x000000ad,0x00000006, - 0x00000043,0x0012001e,0x000000ae,0x000000a9,0x000000a9,0x000000aa,0x000000ab,0x00000006, - 0x00000006,0x00000006,0x00000006,0x00000006,0x00000031,0x00000006,0x00000006,0x000000ac, - 0x000000ad,0x00000006,0x00000006,0x00040020,0x000000af,0x00000009,0x000000ae,0x0004003b, - 0x000000af,0x000000b0,0x00000009,0x00040020,0x000000b1,0x00000009,0x00000006,0x0004002b, - 0x00000031,0x000000dd,0x00000001,0x0004002b,0x00000031,0x000000e0,0x00000007,0x00040020, - 0x000000e3,0x00000001,0x00000031,0x0004003b,0x000000e3,0x000000e4,0x00000001,0x00040020, - 0x000000e9,0x00000009,0x000000a9,0x0004002b,0x00000031,0x000000ed,0x00000008,0x0004002b, - 0x00000006,0x00000105,0x00000010,0x0004002b,0x00000006,0x00000108,0x0000ffff,0x0004002b, - 0x00000031,0x0000010d,0x00000002,0x0004002b,0x00000006,0x00000115,0x000000ff,0x0004002b, - 0x00000031,0x00000118,0x00000009,0x00040020,0x00000119,0x00000009,0x00000031,0x0004002b, - 0x00000031,0x00000126,0x00000006,0x0004001c,0x0000012d,0x00000008,0x0000003e,0x0006001e, - 0x0000012e,0x0000000d,0x00000008,0x0000012d,0x0000012d,0x00040020,0x0000012f,0x00000003, - 0x0000012e,0x0004003b,0x0000012f,0x00000130,0x00000003,0x0004002b,0x00000008,0x00000131, - 0xbf800000,0x0007002c,0x0000000d,0x00000132,0x00000062,0x00000062,0x00000062,0x00000131, - 0x00040020,0x00000133,0x00000003,0x0000000d,0x0004003b,0x00000133,0x00000135,0x00000003, - 0x0007002c,0x0000000d,0x00000136,0x00000062,0x00000062,0x00000062,0x00000062,0x0004002b, - 0x00000031,0x0000013e,0x00000005,0x0005002b,0x000000a9,0x00000143,0x00000004,0x00000000, - 0x0004002b,0x00000031,0x00000148,0x0000000a,0x0004002b,0x00000031,0x0000014d,0x0000000e, - 0x0004002b,0x00000006,0x00000151,0x00000000,0x00040017,0x0000015a,0x00000008,0x00000002, - 0x0006002c,0x00000023,0x0000017b,0x00000062,0x00000062,0x00000062,0x0004002b,0x00000031, - 0x00000184,0x0000000b,0x0004002b,0x00000031,0x0000018a,0x0000000c,0x0004002b,0x00000031, - 0x0000019f,0x00000010,0x0004002b,0x00000031,0x000001a2,0x00000018,0x0004002b,0x00000031, - 0x000001c2,0x0000000d,0x0004002b,0x00000031,0x000001ca,0x00000003,0x0004002b,0x00000008, - 0x00000218,0x3f000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, - 0x00000005,0x0004003b,0x00000007,0x000000df,0x00000007,0x0004003b,0x0000001a,0x000000e8, - 0x00000007,0x0004003b,0x00000007,0x000000f3,0x00000007,0x0004003b,0x00000093,0x00000117, - 0x00000007,0x0004003b,0x0000001a,0x00000138,0x00000007,0x0004003b,0x00000007,0x00000147, - 0x00000007,0x0004003b,0x00000022,0x0000014c,0x00000007,0x0004003b,0x00000022,0x00000153, - 0x00000007,0x0004003b,0x00000024,0x0000017a,0x00000007,0x0004003b,0x00000024,0x0000017c, - 0x00000007,0x0004003b,0x00000007,0x0000017d,0x00000007,0x0004003b,0x00000007,0x00000188, - 0x00000007,0x0004003b,0x00000021,0x00000191,0x00000007,0x0004003b,0x00000021,0x00000198, - 0x00000007,0x0004003b,0x00000022,0x000001c0,0x00000007,0x0004003b,0x0000001a,0x000001ce, - 0x00000007,0x0004003b,0x00000021,0x000001cf,0x00000007,0x0004003b,0x00000022,0x000001d1, - 0x00000007,0x0004003b,0x00000022,0x000001d3,0x00000007,0x0004003b,0x00000024,0x000001d5, - 0x00000007,0x0004003b,0x0000001a,0x000001dc,0x00000007,0x0004003b,0x00000021,0x000001dd, - 0x00000007,0x0004003b,0x00000022,0x000001df,0x00000007,0x0004003b,0x00000022,0x000001e1, - 0x00000007,0x0004003b,0x00000024,0x000001e3,0x00000007,0x0004003b,0x00000024,0x000001e9, - 0x00000007,0x0004003b,0x0000001a,0x000001ed,0x00000007,0x0004003b,0x00000007,0x000001ee, - 0x00000007,0x0004003b,0x00000024,0x000001f1,0x00000007,0x0004003b,0x0000001a,0x000001f5, - 0x00000007,0x0004003b,0x00000007,0x000001f6,0x00000007,0x0004003b,0x00000022,0x000001f9, - 0x00000007,0x0004003b,0x00000007,0x000001fa,0x00000007,0x0004003b,0x00000007,0x00000204, - 0x00000007,0x00050041,0x000000b1,0x000000e1,0x000000b0,0x000000e0,0x0004003d,0x00000006, - 0x000000e2,0x000000e1,0x0004003d,0x00000031,0x000000e5,0x000000e4,0x0004007c,0x00000006, - 0x000000e6,0x000000e5,0x00050080,0x00000006,0x000000e7,0x000000e2,0x000000e6,0x0003003e, - 0x000000df,0x000000e7,0x00050041,0x000000e9,0x000000ea,0x000000b0,0x000000dd,0x0004003d, - 0x000000a9,0x000000eb,0x000000ea,0x00040078,0x00000017,0x000000ec,0x000000eb,0x0003003e, - 0x000000e8,0x000000ec,0x00050041,0x000000b1,0x000000ee,0x000000b0,0x000000ed,0x0004003d, - 0x00000006,0x000000ef,0x000000ee,0x000500aa,0x0000009c,0x000000f0,0x000000ef,0x00000043, - 0x000300f7,0x000000f2,0x00000000,0x000400fa,0x000000f0,0x000000f1,0x000000f8,0x000200f8, - 0x000000f1,0x0004003d,0x00000017,0x000000f4,0x000000e8,0x0004003d,0x00000006,0x000000f5, - 0x000000df,0x00060041,0x0000007d,0x000000f6,0x000000f4,0x00000032,0x000000f5,0x0006003d, - 0x00000006,0x000000f7,0x000000f6,0x00000002,0x00000004,0x0003003e,0x000000f3,0x000000f7, - 0x000200f9,0x000000f2,0x000200f8,0x000000f8,0x00050041,0x000000b1,0x000000f9,0x000000b0, - 0x000000ed,0x0004003d,0x00000006,0x000000fa,0x000000f9,0x000500aa,0x0000009c,0x000000fb, - 0x000000fa,0x0000003e,0x000300f7,0x000000fd,0x00000000,0x000400fa,0x000000fb,0x000000fc, - 0x0000010a,0x000200f8,0x000000fc,0x0004003d,0x00000017,0x000000fe,0x000000e8,0x0004003d, - 0x00000006,0x000000ff,0x000000df,0x000500c2,0x00000006,0x00000100,0x000000ff,0x000000dd, - 0x00060041,0x0000007d,0x00000101,0x000000fe,0x00000032,0x00000100,0x0006003d,0x00000006, - 0x00000102,0x00000101,0x00000002,0x00000004,0x0004003d,0x00000006,0x00000103,0x000000df, - 0x000500c7,0x00000006,0x00000104,0x00000103,0x0000003e,0x00050084,0x00000006,0x00000106, - 0x00000104,0x00000105,0x000500c2,0x00000006,0x00000107,0x00000102,0x00000106,0x000500c7, - 0x00000006,0x00000109,0x00000107,0x00000108,0x0003003e,0x000000f3,0x00000109,0x000200f9, - 0x000000fd,0x000200f8,0x0000010a,0x0004003d,0x00000017,0x0000010b,0x000000e8,0x0004003d, - 0x00000006,0x0000010c,0x000000df,0x000500c2,0x00000006,0x0000010e,0x0000010c,0x0000010d, - 0x00060041,0x0000007d,0x0000010f,0x0000010b,0x00000032,0x0000010e,0x0006003d,0x00000006, - 0x00000110,0x0000010f,0x00000002,0x00000004,0x0004003d,0x00000006,0x00000111,0x000000df, - 0x000500c7,0x00000006,0x00000112,0x00000111,0x00000048,0x00050084,0x00000006,0x00000113, - 0x00000112,0x00000058,0x000500c2,0x00000006,0x00000114,0x00000110,0x00000113,0x000500c7, - 0x00000006,0x00000116,0x00000114,0x00000115,0x0003003e,0x000000f3,0x00000116,0x000200f9, - 0x000000fd,0x000200f8,0x000000fd,0x000200f9,0x000000f2,0x000200f8,0x000000f2,0x00050041, - 0x00000119,0x0000011a,0x000000b0,0x00000118,0x0004003d,0x00000031,0x0000011b,0x0000011a, - 0x0004003d,0x00000006,0x0000011c,0x000000f3,0x0004007c,0x00000031,0x0000011d,0x0000011c, - 0x00050080,0x00000031,0x0000011e,0x0000011b,0x0000011d,0x0003003e,0x00000117,0x0000011e, - 0x0004003d,0x00000031,0x0000011f,0x00000117,0x000500b1,0x0000009c,0x00000120,0x0000011f, - 0x00000032,0x000400a8,0x0000009c,0x00000121,0x00000120,0x000300f7,0x00000123,0x00000000, - 0x000400fa,0x00000121,0x00000122,0x00000123,0x000200f8,0x00000122,0x0004003d,0x00000031, - 0x00000124,0x00000117,0x0004007c,0x00000006,0x00000125,0x00000124,0x00050041,0x000000b1, - 0x00000127,0x000000b0,0x00000126,0x0004003d,0x00000006,0x00000128,0x00000127,0x000500ae, - 0x0000009c,0x00000129,0x00000125,0x00000128,0x000200f9,0x00000123,0x000200f8,0x00000123, - 0x000700f5,0x0000009c,0x0000012a,0x00000120,0x000000f2,0x00000129,0x00000122,0x000300f7, - 0x0000012c,0x00000000,0x000400fa,0x0000012a,0x0000012b,0x0000012c,0x000200f8,0x0000012b, - 0x00050041,0x00000133,0x00000134,0x00000130,0x00000032,0x0003003e,0x00000134,0x00000132, - 0x0003003e,0x00000135,0x00000136,0x000100fd,0x000200f8,0x0000012c,0x00050041,0x000000e9, - 0x00000139,0x000000b0,0x00000032,0x0004003d,0x000000a9,0x0000013a,0x00000139,0x0004003d, - 0x00000031,0x0000013b,0x00000117,0x0004007c,0x00000006,0x0000013c,0x0000013b,0x00040071, - 0x000000a9,0x0000013d,0x0000013c,0x00050041,0x000000b1,0x0000013f,0x000000b0,0x0000013e, - 0x0004003d,0x00000006,0x00000140,0x0000013f,0x00040071,0x000000a9,0x00000141,0x00000140, - 0x00050084,0x000000a9,0x00000142,0x0000013d,0x00000141,0x00050084,0x000000a9,0x00000144, - 0x00000142,0x00000143,0x00050080,0x000000a9,0x00000145,0x0000013a,0x00000144,0x00040078, - 0x00000017,0x00000146,0x00000145,0x0003003e,0x00000138,0x00000146,0x00050041,0x000000b1, - 0x00000149,0x000000b0,0x00000148,0x0004003d,0x00000006,0x0000014a,0x00000149,0x00050086, - 0x00000006,0x0000014b,0x0000014a,0x00000053,0x0003003e,0x00000147,0x0000014b,0x00050041, - 0x000000b1,0x0000014e,0x000000b0,0x0000014d,0x0004003d,0x00000006,0x0000014f,0x0000014e, - 0x000500c7,0x00000006,0x00000150,0x0000014f,0x0000003e,0x000500ab,0x0000009c,0x00000152, - 0x00000150,0x00000151,0x000300f7,0x00000155,0x00000000,0x000400fa,0x00000152,0x00000154, - 0x00000166,0x000200f8,0x00000154,0x0004003d,0x00000017,0x00000156,0x00000138,0x0004003d, - 0x00000006,0x00000157,0x00000147,0x00060041,0x0000007d,0x00000158,0x00000156,0x00000032, - 0x00000157,0x0006003d,0x00000006,0x00000159,0x00000158,0x00000002,0x00000004,0x0006000c, - 0x0000015a,0x0000015b,0x00000001,0x0000003e,0x00000159,0x0004003d,0x00000017,0x0000015c, - 0x00000138,0x0004003d,0x00000006,0x0000015d,0x00000147,0x00050080,0x00000006,0x0000015e, - 0x0000015d,0x0000003e,0x00060041,0x0000007d,0x0000015f,0x0000015c,0x00000032,0x0000015e, - 0x0006003d,0x00000006,0x00000160,0x0000015f,0x00000002,0x00000004,0x0006000c,0x0000015a, - 0x00000161,0x00000001,0x0000003e,0x00000160,0x00050051,0x00000008,0x00000162,0x00000161, - 0x00000000,0x00050051,0x00000008,0x00000163,0x0000015b,0x00000000,0x00050051,0x00000008, - 0x00000164,0x0000015b,0x00000001,0x00070050,0x0000000d,0x00000165,0x00000163,0x00000164, - 0x00000162,0x00000061,0x0003003e,0x00000153,0x00000165,0x000200f9,0x00000155,0x000200f8, - 0x00000166,0x0004003d,0x00000017,0x00000167,0x00000138,0x0004003d,0x00000006,0x00000168, - 0x00000147,0x00060041,0x0000007d,0x00000169,0x00000167,0x00000032,0x00000168,0x0006003d, - 0x00000006,0x0000016a,0x00000169,0x00000002,0x00000004,0x0004007c,0x00000008,0x0000016b, - 0x0000016a,0x0004003d,0x00000017,0x0000016c,0x00000138,0x0004003d,0x00000006,0x0000016d, - 0x00000147,0x00050080,0x00000006,0x0000016e,0x0000016d,0x0000003e,0x00060041,0x0000007d, - 0x0000016f,0x0000016c,0x00000032,0x0000016e,0x0006003d,0x00000006,0x00000170,0x0000016f, - 0x00000002,0x00000004,0x0004007c,0x00000008,0x00000171,0x00000170,0x0004003d,0x00000017, - 0x00000172,0x00000138,0x0004003d,0x00000006,0x00000173,0x00000147,0x00050080,0x00000006, - 0x00000174,0x00000173,0x00000043,0x00060041,0x0000007d,0x00000175,0x00000172,0x00000032, - 0x00000174,0x0006003d,0x00000006,0x00000176,0x00000175,0x00000002,0x00000004,0x0004007c, - 0x00000008,0x00000177,0x00000176,0x00070050,0x0000000d,0x00000178,0x0000016b,0x00000171, - 0x00000177,0x00000061,0x0003003e,0x00000153,0x00000178,0x000200f9,0x00000155,0x000200f8, - 0x00000155,0x0004003d,0x0000000d,0x00000179,0x00000153,0x0003003e,0x0000014c,0x00000179, - 0x0003003e,0x0000017a,0x0000017b,0x0003003e,0x0000017c,0x0000017b,0x0003003e,0x0000017d, - 0x00000151,0x000200f9,0x0000017e,0x000200f8,0x0000017e,0x000400f6,0x00000180,0x00000181, - 0x00000000,0x000200f9,0x00000182,0x000200f8,0x00000182,0x0004003d,0x00000006,0x00000183, - 0x0000017d,0x00050041,0x000000b1,0x00000185,0x000000b0,0x00000184,0x0004003d,0x00000006, - 0x00000186,0x00000185,0x000500b0,0x0000009c,0x00000187,0x00000183,0x00000186,0x000400fa, - 0x00000187,0x0000017f,0x00000180,0x000200f8,0x0000017f,0x0004003d,0x00000017,0x00000189, - 0x00000138,0x0004003d,0x00000006,0x0000018b,0x0000017d,0x00060041,0x000000b1,0x0000018c, - 0x000000b0,0x0000018a,0x0000018b,0x0004003d,0x00000006,0x0000018d,0x0000018c,0x00050086, - 0x00000006,0x0000018e,0x0000018d,0x00000053,0x00060041,0x0000007d,0x0000018f,0x00000189, - 0x00000032,0x0000018e,0x0006003d,0x00000006,0x00000190,0x0000018f,0x00000002,0x00000004, - 0x0003003e,0x00000188,0x00000190,0x00050041,0x000000b1,0x00000192,0x000000b0,0x0000014d, - 0x0004003d,0x00000006,0x00000193,0x00000192,0x0004003d,0x00000006,0x00000194,0x0000017d, - 0x000500c4,0x00000006,0x00000195,0x00000043,0x00000194,0x000500c7,0x00000006,0x00000196, - 0x00000193,0x00000195,0x000500ab,0x0000009c,0x00000197,0x00000196,0x00000151,0x000300f7, - 0x0000019a,0x00000000,0x000400fa,0x00000197,0x00000199,0x000001a7,0x000200f8,0x00000199, - 0x0004003d,0x00000006,0x0000019b,0x00000188,0x0004003d,0x00000006,0x0000019c,0x00000188, - 0x000500c2,0x00000006,0x0000019d,0x0000019c,0x000000ed,0x0004003d,0x00000006,0x0000019e, - 0x00000188,0x000500c2,0x00000006,0x000001a0,0x0000019e,0x0000019f,0x0004003d,0x00000006, - 0x000001a1,0x00000188,0x000500c2,0x00000006,0x000001a3,0x000001a1,0x000001a2,0x00070050, - 0x00000020,0x000001a4,0x0000019b,0x0000019d,0x000001a0,0x000001a3,0x00070050,0x00000020, - 0x000001a5,0x00000115,0x00000115,0x00000115,0x00000115,0x000500c7,0x00000020,0x000001a6, - 0x000001a4,0x000001a5,0x0003003e,0x00000198,0x000001a6,0x000200f9,0x0000019a,0x000200f8, - 0x000001a7,0x0004003d,0x00000006,0x000001a8,0x00000188,0x000500c7,0x00000006,0x000001a9, - 0x000001a8,0x00000108,0x0004003d,0x00000006,0x000001aa,0x00000188,0x000500c2,0x00000006, - 0x000001ab,0x000001aa,0x0000019f,0x0004003d,0x00000017,0x000001ac,0x00000138,0x0004003d, - 0x00000006,0x000001ad,0x0000017d,0x00060041,0x000000b1,0x000001ae,0x000000b0,0x0000018a, - 0x000001ad,0x0004003d,0x00000006,0x000001af,0x000001ae,0x00050086,0x00000006,0x000001b0, - 0x000001af,0x00000053,0x00050080,0x00000006,0x000001b1,0x000001b0,0x0000003e,0x00060041, - 0x0000007d,0x000001b2,0x000001ac,0x00000032,0x000001b1,0x0006003d,0x00000006,0x000001b3, - 0x000001b2,0x00000002,0x00000004,0x000500c7,0x00000006,0x000001b4,0x000001b3,0x00000108, - 0x0004003d,0x00000017,0x000001b5,0x00000138,0x0004003d,0x00000006,0x000001b6,0x0000017d, - 0x00060041,0x000000b1,0x000001b7,0x000000b0,0x0000018a,0x000001b6,0x0004003d,0x00000006, - 0x000001b8,0x000001b7,0x00050086,0x00000006,0x000001b9,0x000001b8,0x00000053,0x00050080, - 0x00000006,0x000001ba,0x000001b9,0x0000003e,0x00060041,0x0000007d,0x000001bb,0x000001b5, - 0x00000032,0x000001ba,0x0006003d,0x00000006,0x000001bc,0x000001bb,0x00000002,0x00000004, - 0x000500c2,0x00000006,0x000001bd,0x000001bc,0x0000019f,0x00070050,0x00000020,0x000001be, - 0x000001a9,0x000001ab,0x000001b4,0x000001bd,0x0003003e,0x00000198,0x000001be,0x000200f9, - 0x0000019a,0x000200f8,0x0000019a,0x0004003d,0x00000020,0x000001bf,0x00000198,0x0003003e, - 0x00000191,0x000001bf,0x0004003d,0x00000017,0x000001c1,0x00000138,0x0004003d,0x00000006, - 0x000001c3,0x0000017d,0x00060041,0x000000b1,0x000001c4,0x000000b0,0x000001c2,0x000001c3, - 0x0004003d,0x00000006,0x000001c5,0x000001c4,0x00050086,0x00000006,0x000001c6,0x000001c5, - 0x00000053,0x00060041,0x0000007d,0x000001c7,0x000001c1,0x00000032,0x000001c6,0x0006003d, - 0x00000006,0x000001c8,0x000001c7,0x00000002,0x00000004,0x0006000c,0x0000000d,0x000001c9, - 0x00000001,0x00000040,0x000001c8,0x0003003e,0x000001c0,0x000001c9,0x00060041,0x000000e9, - 0x000001cb,0x000000b0,0x000001ca,0x00000032,0x0004003d,0x000000a9,0x000001cc,0x000001cb, - 0x00040078,0x00000017,0x000001cd,0x000001cc,0x0003003e,0x000001ce,0x000001cd,0x0004003d, - 0x00000020,0x000001d0,0x00000191,0x0003003e,0x000001cf,0x000001d0,0x0004003d,0x0000000d, - 0x000001d2,0x000001c0,0x0003003e,0x000001d1,0x000001d2,0x0004003d,0x0000000d,0x000001d4, - 0x0000014c,0x0003003e,0x000001d3,0x000001d4,0x0004003d,0x00000023,0x000001d6,0x0000017a, - 0x0003003e,0x000001d5,0x000001d6,0x00090039,0x00000002,0x000001d7,0x0000002b,0x000001ce, - 0x000001cf,0x000001d1,0x000001d3,0x000001d5,0x0004003d,0x00000023,0x000001d8,0x000001d5, - 0x0003003e,0x0000017a,0x000001d8,0x00060041,0x000000e9,0x000001d9,0x000000b0,0x000001ca, - 0x000000dd,0x0004003d,0x000000a9,0x000001da,0x000001d9,0x00040078,0x00000017,0x000001db, - 0x000001da,0x0003003e,0x000001dc,0x000001db,0x0004003d,0x00000020,0x000001de,0x00000191, - 0x0003003e,0x000001dd,0x000001de,0x0004003d,0x0000000d,0x000001e0,0x000001c0,0x0003003e, - 0x000001df,0x000001e0,0x0004003d,0x0000000d,0x000001e2,0x0000014c,0x0003003e,0x000001e1, - 0x000001e2,0x0004003d,0x00000023,0x000001e4,0x0000017c,0x0003003e,0x000001e3,0x000001e4, - 0x00090039,0x00000002,0x000001e5,0x0000002b,0x000001dc,0x000001dd,0x000001df,0x000001e1, - 0x000001e3,0x0004003d,0x00000023,0x000001e6,0x000001e3,0x0003003e,0x0000017c,0x000001e6, - 0x000200f9,0x00000181,0x000200f8,0x00000181,0x0004003d,0x00000006,0x000001e7,0x0000017d, - 0x00050080,0x00000006,0x000001e8,0x000001e7,0x000000dd,0x0003003e,0x0000017d,0x000001e8, - 0x000200f9,0x0000017e,0x000200f8,0x00000180,0x00060041,0x000000e9,0x000001ea,0x000000b0, - 0x0000010d,0x00000032,0x0004003d,0x000000a9,0x000001eb,0x000001ea,0x00040078,0x00000017, - 0x000001ec,0x000001eb,0x0003003e,0x000001ed,0x000001ec,0x0003003e,0x000001ee,0x00000151, - 0x00060039,0x0000000d,0x000001ef,0x0000001e,0x000001ed,0x000001ee,0x0008004f,0x00000023, - 0x000001f0,0x000001ef,0x000001ef,0x00000000,0x00000001,0x00000002,0x0003003e,0x000001e9, - 0x000001f0,0x00060041,0x000000e9,0x000001f2,0x000000b0,0x0000010d,0x000000dd,0x0004003d, - 0x000000a9,0x000001f3,0x000001f2,0x00040078,0x00000017,0x000001f4,0x000001f3,0x0003003e, - 0x000001f5,0x000001f4,0x0003003e,0x000001f6,0x00000151,0x00060039,0x0000000d,0x000001f7, - 0x0000001e,0x000001f5,0x000001f6,0x0008004f,0x00000023,0x000001f8,0x000001f7,0x000001f7, - 0x00000000,0x00000001,0x00000002,0x0003003e,0x000001f1,0x000001f8,0x0003003e,0x000001fa, - 0x00000151,0x00050039,0x00000012,0x000001fb,0x00000015,0x000001fa,0x0004003d,0x00000023, - 0x000001fc,0x0000017a,0x0004003d,0x00000023,0x000001fd,0x000001e9,0x00050081,0x00000023, - 0x000001fe,0x000001fc,0x000001fd,0x00050051,0x00000008,0x000001ff,0x000001fe,0x00000000, - 0x00050051,0x00000008,0x00000200,0x000001fe,0x00000001,0x00050051,0x00000008,0x00000201, - 0x000001fe,0x00000002,0x00070050,0x0000000d,0x00000202,0x000001ff,0x00000200,0x00000201, - 0x00000061,0x00050091,0x0000000d,0x00000203,0x000001fb,0x00000202,0x0003003e,0x000001f9, - 0x00000203,0x0003003e,0x00000204,0x00000105,0x00050039,0x00000012,0x00000205,0x00000015, - 0x00000204,0x0004003d,0x00000023,0x00000206,0x0000017c,0x0004003d,0x00000023,0x00000207, - 0x000001f1,0x00050081,0x00000023,0x00000208,0x00000206,0x00000207,0x00050051,0x00000008, - 0x00000209,0x00000208,0x00000000,0x00050051,0x00000008,0x0000020a,0x00000208,0x00000001, - 0x00050051,0x00000008,0x0000020b,0x00000208,0x00000002,0x00070050,0x0000000d,0x0000020c, - 0x00000209,0x0000020a,0x0000020b,0x00000061,0x00050091,0x0000000d,0x0000020d,0x00000205, - 0x0000020c,0x0003003e,0x00000135,0x0000020d,0x00050041,0x0000009f,0x0000020e,0x000001f9, - 0x00000151,0x0004003d,0x00000008,0x0000020f,0x0000020e,0x00050041,0x0000009f,0x00000210, - 0x000001f9,0x0000003e,0x0004003d,0x00000008,0x00000211,0x00000210,0x0004007f,0x00000008, - 0x00000212,0x00000211,0x00050041,0x0000009f,0x00000213,0x000001f9,0x00000043,0x0004003d, - 0x00000008,0x00000214,0x00000213,0x00050041,0x0000009f,0x00000215,0x000001f9,0x00000048, - 0x0004003d,0x00000008,0x00000216,0x00000215,0x00050081,0x00000008,0x00000217,0x00000214, - 0x00000216,0x00050085,0x00000008,0x00000219,0x00000217,0x00000218,0x00050041,0x0000009f, - 0x0000021a,0x000001f9,0x00000048,0x0004003d,0x00000008,0x0000021b,0x0000021a,0x00070050, - 0x0000000d,0x0000021c,0x0000020f,0x00000212,0x00000219,0x0000021b,0x00050041,0x00000133, - 0x0000021d,0x00000130,0x00000032,0x0003003e,0x0000021d,0x0000021c,0x000100fd,0x00010038, - 0x00050036,0x00000008,0x0000000b,0x00000000,0x00000009,0x00030037,0x00000007,0x0000000a, - 0x000200f8,0x0000000c,0x0004003d,0x00000006,0x00000033,0x0000000a,0x00060041,0x00000034, - 0x00000035,0x00000030,0x00000032,0x00000033,0x0004003d,0x00000006,0x00000036,0x00000035, - 0x0004007c,0x00000008,0x00000037,0x00000036,0x000200fe,0x00000037,0x00010038,0x00050036, - 0x0000000d,0x00000010,0x00000000,0x0000000e,0x00030037,0x00000007,0x0000000f,0x000200f8, - 0x00000011,0x0004003b,0x00000007,0x0000003a,0x00000007,0x0004003b,0x00000007,0x00000040, - 0x00000007,0x0004003b,0x00000007,0x00000045,0x00000007,0x0004003b,0x00000007,0x0000004a, - 0x00000007,0x0004003d,0x00000006,0x0000003b,0x0000000f,0x0003003e,0x0000003a,0x0000003b, - 0x00050039,0x00000008,0x0000003c,0x0000000b,0x0000003a,0x0004003d,0x00000006,0x0000003d, - 0x0000000f,0x00050080,0x00000006,0x0000003f,0x0000003d,0x0000003e,0x0003003e,0x00000040, - 0x0000003f,0x00050039,0x00000008,0x00000041,0x0000000b,0x00000040,0x0004003d,0x00000006, - 0x00000042,0x0000000f,0x00050080,0x00000006,0x00000044,0x00000042,0x00000043,0x0003003e, - 0x00000045,0x00000044,0x00050039,0x00000008,0x00000046,0x0000000b,0x00000045,0x0004003d, - 0x00000006,0x00000047,0x0000000f,0x00050080,0x00000006,0x00000049,0x00000047,0x00000048, - 0x0003003e,0x0000004a,0x00000049,0x00050039,0x00000008,0x0000004b,0x0000000b,0x0000004a, - 0x00070050,0x0000000d,0x0000004c,0x0000003c,0x00000041,0x00000046,0x0000004b,0x000200fe, - 0x0000004c,0x00010038,0x00050036,0x00000012,0x00000015,0x00000000,0x00000013,0x00030037, - 0x00000007,0x00000014,0x000200f8,0x00000016,0x0004003b,0x00000007,0x0000004f,0x00000007, - 0x0004003b,0x00000007,0x00000055,0x00000007,0x0004003b,0x00000007,0x0000005a,0x00000007, - 0x0004003b,0x00000007,0x0000005f,0x00000007,0x0004003d,0x00000006,0x00000050,0x00000014, - 0x0003003e,0x0000004f,0x00000050,0x00050039,0x0000000d,0x00000051,0x00000010,0x0000004f, - 0x0004003d,0x00000006,0x00000052,0x00000014,0x00050080,0x00000006,0x00000054,0x00000052, - 0x00000053,0x0003003e,0x00000055,0x00000054,0x00050039,0x0000000d,0x00000056,0x00000010, - 0x00000055,0x0004003d,0x00000006,0x00000057,0x00000014,0x00050080,0x00000006,0x00000059, - 0x00000057,0x00000058,0x0003003e,0x0000005a,0x00000059,0x00050039,0x0000000d,0x0000005b, - 0x00000010,0x0000005a,0x0004003d,0x00000006,0x0000005c,0x00000014,0x00050080,0x00000006, - 0x0000005e,0x0000005c,0x0000005d,0x0003003e,0x0000005f,0x0000005e,0x00050039,0x0000000d, - 0x00000060,0x00000010,0x0000005f,0x00050051,0x00000008,0x00000063,0x00000051,0x00000000, - 0x00050051,0x00000008,0x00000064,0x00000051,0x00000001,0x00050051,0x00000008,0x00000065, - 0x00000051,0x00000002,0x00050051,0x00000008,0x00000066,0x00000051,0x00000003,0x00050051, - 0x00000008,0x00000067,0x00000056,0x00000000,0x00050051,0x00000008,0x00000068,0x00000056, - 0x00000001,0x00050051,0x00000008,0x00000069,0x00000056,0x00000002,0x00050051,0x00000008, - 0x0000006a,0x00000056,0x00000003,0x00050051,0x00000008,0x0000006b,0x0000005b,0x00000000, - 0x00050051,0x00000008,0x0000006c,0x0000005b,0x00000001,0x00050051,0x00000008,0x0000006d, - 0x0000005b,0x00000002,0x00050051,0x00000008,0x0000006e,0x0000005b,0x00000003,0x00050051, - 0x00000008,0x0000006f,0x00000060,0x00000000,0x00050051,0x00000008,0x00000070,0x00000060, - 0x00000001,0x00050051,0x00000008,0x00000071,0x00000060,0x00000002,0x00050051,0x00000008, - 0x00000072,0x00000060,0x00000003,0x00070050,0x0000000d,0x00000073,0x00000063,0x00000064, - 0x00000065,0x00000066,0x00070050,0x0000000d,0x00000074,0x00000067,0x00000068,0x00000069, - 0x0000006a,0x00070050,0x0000000d,0x00000075,0x0000006b,0x0000006c,0x0000006d,0x0000006e, - 0x00070050,0x0000000d,0x00000076,0x0000006f,0x00000070,0x00000071,0x00000072,0x00070050, - 0x00000012,0x00000077,0x00000073,0x00000074,0x00000075,0x00000076,0x00040054,0x00000012, - 0x00000078,0x00000077,0x000200fe,0x00000078,0x00010038,0x00050036,0x0000000d,0x0000001e, - 0x00000000,0x0000001b,0x00030037,0x0000001a,0x0000001c,0x00030037,0x00000007,0x0000001d, - 0x000200f8,0x0000001f,0x0004003d,0x00000017,0x0000007b,0x0000001c,0x0004003d,0x00000006, - 0x0000007c,0x0000001d,0x00060041,0x0000007d,0x0000007e,0x0000007b,0x00000032,0x0000007c, - 0x0006003d,0x00000006,0x0000007f,0x0000007e,0x00000002,0x00000004,0x0004003d,0x00000017, - 0x00000080,0x0000001c,0x0004003d,0x00000006,0x00000081,0x0000001d,0x00050080,0x00000006, - 0x00000082,0x00000081,0x0000003e,0x00060041,0x0000007d,0x00000083,0x00000080,0x00000032, - 0x00000082,0x0006003d,0x00000006,0x00000084,0x00000083,0x00000002,0x00000004,0x0004003d, - 0x00000017,0x00000085,0x0000001c,0x0004003d,0x00000006,0x00000086,0x0000001d,0x00050080, - 0x00000006,0x00000087,0x00000086,0x00000043,0x00060041,0x0000007d,0x00000088,0x00000085, - 0x00000032,0x00000087,0x0006003d,0x00000006,0x00000089,0x00000088,0x00000002,0x00000004, - 0x0004003d,0x00000017,0x0000008a,0x0000001c,0x0004003d,0x00000006,0x0000008b,0x0000001d, - 0x00050080,0x00000006,0x0000008c,0x0000008b,0x00000048,0x00060041,0x0000007d,0x0000008d, - 0x0000008a,0x00000032,0x0000008c,0x0006003d,0x00000006,0x0000008e,0x0000008d,0x00000002, - 0x00000004,0x00070050,0x00000020,0x0000008f,0x0000007f,0x00000084,0x00000089,0x0000008e, - 0x0004007c,0x0000000d,0x00000090,0x0000008f,0x000200fe,0x00000090,0x00010038,0x00050036, - 0x00000002,0x0000002b,0x00000000,0x00000025,0x00030037,0x0000001a,0x00000026,0x00030037, - 0x00000021,0x00000027,0x00030037,0x00000022,0x00000028,0x00030037,0x00000022,0x00000029, - 0x00030037,0x00000024,0x0000002a,0x000200f8,0x0000002c,0x0004003b,0x00000093,0x00000094, - 0x00000007,0x0004003b,0x00000007,0x000000b9,0x00000007,0x0004003b,0x0000001a,0x000000c1, - 0x00000007,0x0004003b,0x00000007,0x000000c3,0x00000007,0x0004003b,0x0000001a,0x000000ca, - 0x00000007,0x0004003b,0x00000007,0x000000cc,0x00000007,0x0004003b,0x0000001a,0x000000d2, - 0x00000007,0x0004003b,0x00000007,0x000000d4,0x00000007,0x0003003e,0x00000094,0x00000032, - 0x000200f9,0x00000095,0x000200f8,0x00000095,0x000400f6,0x00000097,0x00000098,0x00000000, - 0x000200f9,0x00000099,0x000200f8,0x00000099,0x0004003d,0x00000031,0x0000009a,0x00000094, - 0x000500b1,0x0000009c,0x0000009d,0x0000009a,0x0000009b,0x000400fa,0x0000009d,0x00000096, - 0x00000097,0x000200f8,0x00000096,0x0004003d,0x00000031,0x0000009e,0x00000094,0x00050041, - 0x0000009f,0x000000a0,0x00000028,0x0000009e,0x0004003d,0x00000008,0x000000a1,0x000000a0, - 0x000500bc,0x0000009c,0x000000a2,0x000000a1,0x00000062,0x000400a8,0x0000009c,0x000000a3, - 0x000000a2,0x000300f7,0x000000a5,0x00000000,0x000400fa,0x000000a3,0x000000a4,0x000000a5, - 0x000200f8,0x000000a4,0x0004003d,0x00000031,0x000000a6,0x00000094,0x00050041,0x00000007, - 0x000000a7,0x00000027,0x000000a6,0x0004003d,0x00000006,0x000000a8,0x000000a7,0x00050041, - 0x000000b1,0x000000b2,0x000000b0,0x0000009b,0x0004003d,0x00000006,0x000000b3,0x000000b2, - 0x000500ae,0x0000009c,0x000000b4,0x000000a8,0x000000b3,0x000200f9,0x000000a5,0x000200f8, - 0x000000a5,0x000700f5,0x0000009c,0x000000b5,0x000000a2,0x00000096,0x000000b4,0x000000a4, - 0x000300f7,0x000000b7,0x00000000,0x000400fa,0x000000b5,0x000000b6,0x000000b7,0x000200f8, - 0x000000b6,0x000200f9,0x00000098,0x000200f8,0x000000b7,0x0004003d,0x00000031,0x000000ba, - 0x00000094,0x00050041,0x00000007,0x000000bb,0x00000027,0x000000ba,0x0004003d,0x00000006, - 0x000000bc,0x000000bb,0x00050084,0x00000006,0x000000bd,0x000000bc,0x0000005d,0x0003003e, - 0x000000b9,0x000000bd,0x0004003d,0x00000031,0x000000be,0x00000094,0x00050041,0x0000009f, - 0x000000bf,0x00000028,0x000000be,0x0004003d,0x00000008,0x000000c0,0x000000bf,0x0004003d, - 0x00000017,0x000000c2,0x00000026,0x0003003e,0x000000c1,0x000000c2,0x0004003d,0x00000006, - 0x000000c4,0x000000b9,0x0003003e,0x000000c3,0x000000c4,0x00060039,0x0000000d,0x000000c5, - 0x0000001e,0x000000c1,0x000000c3,0x0004003d,0x0000000d,0x000000c6,0x00000029,0x00050094, - 0x00000008,0x000000c7,0x000000c5,0x000000c6,0x0004003d,0x00000006,0x000000c8,0x000000b9, - 0x00050080,0x00000006,0x000000c9,0x000000c8,0x00000053,0x0004003d,0x00000017,0x000000cb, - 0x00000026,0x0003003e,0x000000ca,0x000000cb,0x0003003e,0x000000cc,0x000000c9,0x00060039, - 0x0000000d,0x000000cd,0x0000001e,0x000000ca,0x000000cc,0x0004003d,0x0000000d,0x000000ce, - 0x00000029,0x00050094,0x00000008,0x000000cf,0x000000cd,0x000000ce,0x0004003d,0x00000006, - 0x000000d0,0x000000b9,0x00050080,0x00000006,0x000000d1,0x000000d0,0x00000058,0x0004003d, - 0x00000017,0x000000d3,0x00000026,0x0003003e,0x000000d2,0x000000d3,0x0003003e,0x000000d4, - 0x000000d1,0x00060039,0x0000000d,0x000000d5,0x0000001e,0x000000d2,0x000000d4,0x0004003d, - 0x0000000d,0x000000d6,0x00000029,0x00050094,0x00000008,0x000000d7,0x000000d5,0x000000d6, - 0x00060050,0x00000023,0x000000d8,0x000000c7,0x000000cf,0x000000d7,0x0005008e,0x00000023, - 0x000000d9,0x000000d8,0x000000c0,0x0004003d,0x00000023,0x000000da,0x0000002a,0x00050081, - 0x00000023,0x000000db,0x000000da,0x000000d9,0x0003003e,0x0000002a,0x000000db,0x000200f9, - 0x00000098,0x000200f8,0x00000098,0x0004003d,0x00000031,0x000000dc,0x00000094,0x00050080, - 0x00000031,0x000000de,0x000000dc,0x000000dd,0x0003003e,0x00000094,0x000000de,0x000200f9, - 0x00000095,0x000200f8,0x00000097,0x000100fd,0x00010038 + 0x00000000,0x0003000e,0x000014e4,0x00000001,0x000b000f,0x00000000,0x00000004,0x6e69616d, + 0x00000000,0x00000034,0x000000cb,0x000000ec,0x000000f9,0x0000014e,0x00000153,0x00030003, + 0x00000002,0x000001c2,0x00070004,0x455f4c47,0x625f5458,0x65666675,0x65725f72,0x65726566, + 0x0065636e,0x000d0004,0x455f4c47,0x735f5458,0x65646168,0x78655f72,0x63696c70,0x615f7469, + 0x68746972,0x6974656d,0x79745f63,0x5f736570,0x36746e69,0x00000034,0x00040005,0x00000004, + 0x6e69616d,0x00000000,0x00040005,0x0000000b,0x31752866,0x0000003b,0x00030005,0x0000000a, + 0x00000069,0x00040005,0x00000010,0x75283466,0x00003b31,0x00030005,0x0000000f,0x00000069, + 0x00050005,0x00000015,0x656d6163,0x75286172,0x00003b31,0x00030005,0x00000014,0x00007461, + 0x00040005,0x00000019,0x64726f57,0x00000073,0x00040006,0x00000019,0x00000000,0x00000077, + 0x00050005,0x0000001e,0x28776f72,0x31753b31,0x0000003b,0x00030005,0x0000001c,0x0000006d, + 0x00030005,0x0000001d,0x00000069,0x00070005,0x00000026,0x6e696b73,0x2864656e,0x31753b31, + 0x3466763b,0x0000003b,0x00040005,0x00000023,0x656c6170,0x00657474,0x00030005,0x00000024, + 0x0000006a,0x00030005,0x00000025,0x00000070,0x00060005,0x0000002b,0x65747962,0x2874615f, + 0x31753b31,0x0000003b,0x00030005,0x00000029,0x00000076,0x00030005,0x0000002a,0x0000006f, + 0x00060005,0x0000002f,0x5f746573,0x6e756f63,0x31752874,0x0000003b,0x00030005,0x0000002e, + 0x00000073,0x00040005,0x00000032,0x61746144,0x00000000,0x00040006,0x00000032,0x00000000, + 0x00000077,0x00040005,0x00000034,0x61746164,0x00000000,0x00040005,0x0000003e,0x61726170, + 0x0000006d,0x00040005,0x00000044,0x61726170,0x0000006d,0x00040005,0x00000049,0x61726170, + 0x0000006d,0x00040005,0x0000004e,0x61726170,0x0000006d,0x00040005,0x00000053,0x61726170, + 0x0000006d,0x00040005,0x00000059,0x61726170,0x0000006d,0x00040005,0x0000005e,0x61726170, + 0x0000006d,0x00040005,0x00000063,0x61726170,0x0000006d,0x00030005,0x00000098,0x00000062, + 0x00040005,0x0000009b,0x61726170,0x0000006d,0x00040005,0x0000009d,0x61726170,0x0000006d, + 0x00040005,0x000000a4,0x61726170,0x0000006d,0x00040005,0x000000a6,0x61726170,0x0000006d, + 0x00040005,0x000000ac,0x61726170,0x0000006d,0x00040005,0x000000ae,0x61726170,0x0000006d, + 0x00030005,0x000000c3,0x00000063,0x00030005,0x000000c9,0x00000050,0x00060006,0x000000c9, + 0x00000000,0x74726576,0x73656369,0x00000000,0x00050006,0x000000c9,0x00000001,0x69646e69, + 0x00736563,0x00050006,0x000000c9,0x00000002,0x6769726f,0x00736e69,0x00050006,0x000000c9, + 0x00000003,0x656e6f62,0x00000073,0x00050006,0x000000c9,0x00000004,0x6e6f626e,0x00007365, + 0x00050006,0x000000c9,0x00000005,0x69727473,0x00006564,0x00050006,0x000000c9,0x00000006, + 0x6e756f63,0x00000074,0x00050006,0x000000c9,0x00000007,0x73726966,0x00000074,0x00050006, + 0x000000c9,0x00000008,0x70797469,0x00000065,0x00060006,0x000000c9,0x00000009,0x65736162, + 0x7265765f,0x00786574,0x00040006,0x000000c9,0x0000000a,0x00736f70,0x00050006,0x000000c9, + 0x0000000b,0x73746573,0x00000000,0x00050006,0x000000c9,0x0000000c,0x6e696f6a,0x00007374, + 0x00050006,0x000000c9,0x0000000d,0x67696577,0x00737468,0x00050006,0x000000c9,0x0000000e, + 0x6d726f66,0x00737461,0x00060006,0x000000c9,0x0000000f,0x656c6f74,0x636e6172,0x00000065, + 0x00030005,0x000000cb,0x00006370,0x00040005,0x000000ec,0x7474696a,0x00007265,0x00040005, + 0x000000ee,0x61726170,0x0000006d,0x00040005,0x000000f1,0x61726170,0x0000006d,0x00030005, + 0x000000f4,0x00007461,0x00060005,0x000000f9,0x565f6c67,0x65747265,0x646e4978,0x00007865, + 0x00040005,0x00000103,0x65646e69,0x00000078,0x00030005,0x00000135,0x00006976,0x00060005, + 0x0000014c,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x0000014c,0x00000000, + 0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x0000014c,0x00000001,0x505f6c67,0x746e696f, + 0x657a6953,0x00000000,0x00070006,0x0000014c,0x00000002,0x435f6c67,0x4470696c,0x61747369, + 0x0065636e,0x00070006,0x0000014c,0x00000003,0x435f6c67,0x446c6c75,0x61747369,0x0065636e, + 0x00030005,0x0000014e,0x00000000,0x00040005,0x00000153,0x6f666562,0x00006572,0x00030005, + 0x00000156,0x00006276,0x00030005,0x00000165,0x00000071,0x00030005,0x0000016a,0x00000070, + 0x00030005,0x00000196,0x00776f6e,0x00040005,0x00000198,0x6e656874,0x00000000,0x00030005, + 0x00000199,0x00000073,0x00040005,0x000001a5,0x65747962,0x00000073,0x00030005,0x000001ac, + 0x0000006e,0x00040005,0x000001ad,0x61726170,0x0000006d,0x00030005,0x000001b0,0x0000006b, + 0x00030005,0x000001b9,0x00006f6a,0x00030005,0x000001c8,0x0000006a,0x00040005,0x000001cd, + 0x61726170,0x0000006d,0x00040005,0x000001cf,0x61726170,0x0000006d,0x00040005,0x000001d3, + 0x61726170,0x0000006d,0x00040005,0x000001d5,0x61726170,0x0000006d,0x00040005,0x000001da, + 0x61726170,0x0000006d,0x00040005,0x000001dc,0x61726170,0x0000006d,0x00030005,0x000001e2, + 0x00007477,0x00040005,0x000001f2,0x61726170,0x0000006d,0x00040005,0x000001f4,0x61726170, + 0x0000006d,0x00040005,0x0000020d,0x61726170,0x0000006d,0x00040005,0x0000020e,0x61726170, + 0x0000006d,0x00040005,0x00000210,0x61726170,0x0000006d,0x00040005,0x0000021a,0x61726170, + 0x0000006d,0x00040005,0x0000021b,0x61726170,0x0000006d,0x00040005,0x0000021d,0x61726170, + 0x0000006d,0x00030005,0x00000227,0x0000306f,0x00040005,0x0000022b,0x61726170,0x0000006d, + 0x00040005,0x0000022c,0x61726170,0x0000006d,0x00030005,0x0000022f,0x0000316f,0x00040005, + 0x00000233,0x61726170,0x0000006d,0x00040005,0x00000234,0x61726170,0x0000006d,0x00040005, + 0x00000237,0x65736f70,0x00000064,0x00030005,0x0000023b,0x00000072,0x00030005,0x00000243, + 0x00000076,0x00040005,0x00000247,0x61726170,0x0000006d,0x00040005,0x00000249,0x61726170, + 0x0000006d,0x00030005,0x0000024b,0x00007461,0x00030005,0x00000253,0x00657965,0x00030005, + 0x0000025e,0x00000072,0x00040005,0x00000266,0x70696c63,0x00000000,0x00040005,0x0000026b, + 0x61726170,0x0000006d,0x00040005,0x0000026d,0x61726170,0x0000006d,0x00040005,0x00000278, + 0x61726170,0x0000006d,0x00040047,0x00000018,0x00000006,0x00000004,0x00030047,0x00000019, + 0x00000002,0x00040048,0x00000019,0x00000000,0x00000018,0x00050048,0x00000019,0x00000000, + 0x00000023,0x00000000,0x00030047,0x0000001c,0x000014ec,0x00030047,0x00000023,0x000014ec, + 0x00030047,0x00000029,0x000014ec,0x00040047,0x00000031,0x00000006,0x00000004,0x00030047, + 0x00000032,0x00000002,0x00040048,0x00000032,0x00000000,0x00000018,0x00050048,0x00000032, + 0x00000000,0x00000023,0x00000000,0x00030047,0x00000034,0x00000018,0x00040047,0x00000034, + 0x00000021,0x00000000,0x00040047,0x00000034,0x00000022,0x00000000,0x00030047,0x0000009b, + 0x000014ec,0x00030047,0x000000a4,0x000014ec,0x00030047,0x000000ac,0x000014ec,0x00040047, + 0x000000c5,0x00000006,0x00000008,0x00040047,0x000000c6,0x00000006,0x00000008,0x00040047, + 0x000000c7,0x00000006,0x00000004,0x00040047,0x000000c8,0x00000006,0x00000004,0x00030047, + 0x000000c9,0x00000002,0x00050048,0x000000c9,0x00000000,0x00000023,0x00000000,0x00050048, + 0x000000c9,0x00000001,0x00000023,0x00000008,0x00050048,0x000000c9,0x00000002,0x00000023, + 0x00000010,0x00050048,0x000000c9,0x00000003,0x00000023,0x00000020,0x00050048,0x000000c9, + 0x00000004,0x00000023,0x00000030,0x00050048,0x000000c9,0x00000005,0x00000023,0x00000034, + 0x00050048,0x000000c9,0x00000006,0x00000023,0x00000038,0x00050048,0x000000c9,0x00000007, + 0x00000023,0x0000003c,0x00050048,0x000000c9,0x00000008,0x00000023,0x00000040,0x00050048, + 0x000000c9,0x00000009,0x00000023,0x00000044,0x00050048,0x000000c9,0x0000000a,0x00000023, + 0x00000048,0x00050048,0x000000c9,0x0000000b,0x00000023,0x0000004c,0x00050048,0x000000c9, + 0x0000000c,0x00000023,0x00000050,0x00050048,0x000000c9,0x0000000d,0x00000023,0x00000058, + 0x00050048,0x000000c9,0x0000000e,0x00000023,0x00000060,0x00050048,0x000000c9,0x0000000f, + 0x00000023,0x00000064,0x00030047,0x000000ec,0x0000000e,0x00040047,0x000000ec,0x0000001e, + 0x00000001,0x00040047,0x000000f9,0x0000000b,0x0000002a,0x00030047,0x000000fc,0x0000002a, + 0x00030047,0x00000123,0x0000002a,0x00030047,0x00000131,0x0000002a,0x00030047,0x0000014c, + 0x00000002,0x00050048,0x0000014c,0x00000000,0x0000000b,0x00000000,0x00050048,0x0000014c, + 0x00000001,0x0000000b,0x00000001,0x00050048,0x0000014c,0x00000002,0x0000000b,0x00000003, + 0x00050048,0x0000014c,0x00000003,0x0000000b,0x00000004,0x00040047,0x00000153,0x0000001e, + 0x00000000,0x00030047,0x00000156,0x000014ec,0x00030047,0x00000160,0x0000002a,0x00030047, + 0x00000162,0x0000002a,0x00030047,0x00000163,0x0000002a,0x00030047,0x000001c5,0x0000002a, + 0x00030047,0x000001c7,0x0000002a,0x00030047,0x000001cd,0x000014ec,0x00030047,0x000001d3, + 0x000014ec,0x00030047,0x000001d9,0x0000002a,0x00030047,0x000001da,0x000014ec,0x00030047, + 0x000001f1,0x0000002a,0x00030047,0x000001f2,0x000014ec,0x00030047,0x000001f8,0x0000002a, + 0x00030047,0x0000020d,0x000014ec,0x00030047,0x00000213,0x0000002a,0x00030047,0x00000215, + 0x0000002a,0x00030047,0x0000021a,0x000014ec,0x00030047,0x00000224,0x0000002a,0x00030047, + 0x00000226,0x0000002a,0x00030047,0x0000022b,0x000014ec,0x00030047,0x00000233,0x000014ec, + 0x00030047,0x00000237,0x000014ec,0x00030047,0x00000245,0x0000002a,0x00030047,0x00000246, + 0x0000002a,0x00030047,0x00000247,0x000014ec,0x00030047,0x0000024f,0x0000002a,0x00030047, + 0x00000252,0x0000002a,0x00030047,0x00000259,0x0000002a,0x00030047,0x0000025a,0x0000002a, + 0x00030047,0x0000025d,0x0000002a,0x00030047,0x00000269,0x0000002a,0x00030047,0x0000026a, + 0x0000002a,0x00030047,0x0000026b,0x000014ec,0x00030047,0x00000274,0x0000002a,0x00030047, + 0x00000277,0x0000002a,0x00030047,0x00000286,0x0000002a,0x00020013,0x00000002,0x00030021, + 0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000000,0x00040020,0x00000007, + 0x00000007,0x00000006,0x00030016,0x00000008,0x00000020,0x00040021,0x00000009,0x00000008, + 0x00000007,0x00040017,0x0000000d,0x00000008,0x00000004,0x00040021,0x0000000e,0x0000000d, + 0x00000007,0x00040018,0x00000012,0x0000000d,0x00000004,0x00040021,0x00000013,0x00000012, + 0x00000007,0x00030027,0x00000017,0x000014e5,0x0003001d,0x00000018,0x00000006,0x0003001e, + 0x00000019,0x00000018,0x00040020,0x00000017,0x000014e5,0x00000019,0x00040020,0x0000001a, + 0x00000007,0x00000017,0x00050021,0x0000001b,0x0000000d,0x0000001a,0x00000007,0x00040020, + 0x00000020,0x00000007,0x0000000d,0x00040017,0x00000021,0x00000008,0x00000003,0x00060021, + 0x00000022,0x00000021,0x0000001a,0x00000007,0x00000020,0x00050021,0x00000028,0x00000006, + 0x0000001a,0x00000007,0x00040021,0x0000002d,0x00000006,0x00000007,0x0003001d,0x00000031, + 0x00000006,0x0003001e,0x00000032,0x00000031,0x00040020,0x00000033,0x0000000c,0x00000032, + 0x0004003b,0x00000033,0x00000034,0x0000000c,0x00040015,0x00000035,0x00000020,0x00000001, + 0x0004002b,0x00000035,0x00000036,0x00000000,0x00040020,0x00000038,0x0000000c,0x00000006, + 0x0004002b,0x00000006,0x00000042,0x00000001,0x0004002b,0x00000006,0x00000047,0x00000002, + 0x0004002b,0x00000006,0x0000004c,0x00000003,0x0004002b,0x00000006,0x00000057,0x00000004, + 0x0004002b,0x00000006,0x0000005c,0x00000008,0x0004002b,0x00000006,0x00000061,0x0000000c, + 0x0004002b,0x00000008,0x00000065,0x3f800000,0x0004002b,0x00000008,0x00000066,0x00000000, + 0x00040020,0x00000081,0x000014e5,0x00000006,0x00040017,0x00000093,0x00000006,0x00000004, + 0x0004002b,0x00000035,0x000000b7,0x00000002,0x0004002b,0x00000006,0x000000bf,0x000000ff, + 0x00040015,0x000000c4,0x00000040,0x00000000,0x0004001c,0x000000c5,0x000000c4,0x00000047, + 0x0004001c,0x000000c6,0x000000c4,0x00000047,0x0004001c,0x000000c7,0x00000006,0x00000047, + 0x0004001c,0x000000c8,0x00000006,0x00000047,0x0012001e,0x000000c9,0x000000c4,0x000000c4, + 0x000000c5,0x000000c6,0x00000006,0x00000006,0x00000006,0x00000006,0x00000006,0x00000035, + 0x00000006,0x00000006,0x000000c7,0x000000c8,0x00000006,0x00000006,0x00040020,0x000000ca, + 0x00000009,0x000000c9,0x0004003b,0x000000ca,0x000000cb,0x00000009,0x0004002b,0x00000035, + 0x000000cc,0x0000000e,0x00040020,0x000000cd,0x00000009,0x00000006,0x0004002b,0x00000006, + 0x000000d6,0x00000000,0x00020014,0x000000d7,0x00040017,0x000000ea,0x00000008,0x00000002, + 0x00040020,0x000000eb,0x00000003,0x000000ea,0x0004003b,0x000000eb,0x000000ec,0x00000003, + 0x0004002b,0x00000006,0x000000ed,0x00000020,0x0004002b,0x00000006,0x000000f0,0x00000021, + 0x0004002b,0x00000035,0x000000f5,0x00000007,0x00040020,0x000000f8,0x00000001,0x00000035, + 0x0004003b,0x000000f8,0x000000f9,0x00000001,0x0004002b,0x00000035,0x000000fd,0x00000008, + 0x0004002b,0x00000035,0x0000010b,0x00000001,0x00040020,0x0000010c,0x00000009,0x000000c4, + 0x0004002b,0x00000006,0x00000122,0x00000010,0x0004002b,0x00000006,0x00000125,0x0000ffff, + 0x00040020,0x00000134,0x00000007,0x00000035,0x0004002b,0x00000035,0x00000136,0x00000009, + 0x00040020,0x00000137,0x00000009,0x00000035,0x0004002b,0x00000035,0x00000144,0x00000006, + 0x0004001c,0x0000014b,0x00000008,0x00000042,0x0006001e,0x0000014c,0x0000000d,0x00000008, + 0x0000014b,0x0000014b,0x00040020,0x0000014d,0x00000003,0x0000014c,0x0004003b,0x0000014d, + 0x0000014e,0x00000003,0x0004002b,0x00000008,0x0000014f,0xbf800000,0x0007002c,0x0000000d, + 0x00000150,0x00000066,0x00000066,0x00000066,0x0000014f,0x00040020,0x00000151,0x00000003, + 0x0000000d,0x0004003b,0x00000151,0x00000153,0x00000003,0x0007002c,0x0000000d,0x00000154, + 0x00000066,0x00000066,0x00000066,0x00000066,0x0004002b,0x00000035,0x0000015c,0x00000005, + 0x0005002b,0x000000c4,0x00000161,0x00000004,0x00000000,0x0004002b,0x00000035,0x00000166, + 0x0000000a,0x00040020,0x00000195,0x00000007,0x00000021,0x0006002c,0x00000021,0x00000197, + 0x00000066,0x00000066,0x00000066,0x0004002b,0x00000035,0x000001a0,0x0000000b,0x00040020, + 0x000001a4,0x00000007,0x000000d7,0x0004002b,0x00000035,0x000001ba,0x0000000c,0x00040020, + 0x000001e1,0x00000007,0x00000008,0x0004002b,0x00000006,0x000001e5,0x00000100,0x0004002b, + 0x00000035,0x000001ec,0x0000000d,0x0004002b,0x00000008,0x000001f7,0x437f0000,0x0004002b, + 0x00000035,0x00000200,0x00000004,0x0004002b,0x00000035,0x00000209,0x00000003,0x0004002b, + 0x00000008,0x0000028c,0x3f000000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003, + 0x000200f8,0x00000005,0x0004003b,0x00000007,0x000000ee,0x00000007,0x0004003b,0x00000007, + 0x000000f1,0x00000007,0x0004003b,0x00000007,0x000000f4,0x00000007,0x0004003b,0x00000007, + 0x00000103,0x00000007,0x0004003b,0x00000134,0x00000135,0x00000007,0x0004003b,0x0000001a, + 0x00000156,0x00000007,0x0004003b,0x00000007,0x00000165,0x00000007,0x0004003b,0x00000020, + 0x0000016a,0x00000007,0x0004003b,0x00000020,0x0000016f,0x00000007,0x0004003b,0x00000195, + 0x00000196,0x00000007,0x0004003b,0x00000195,0x00000198,0x00000007,0x0004003b,0x00000007, + 0x00000199,0x00000007,0x0004003b,0x000001a4,0x000001a5,0x00000007,0x0004003b,0x00000007, + 0x000001ac,0x00000007,0x0004003b,0x00000007,0x000001ad,0x00000007,0x0004003b,0x00000007, + 0x000001b0,0x00000007,0x0004003b,0x00000007,0x000001b9,0x00000007,0x0004003b,0x00000007, + 0x000001bf,0x00000007,0x0004003b,0x00000007,0x000001c8,0x00000007,0x0004003b,0x00000007, + 0x000001ca,0x00000007,0x0004003b,0x0000001a,0x000001cd,0x00000007,0x0004003b,0x00000007, + 0x000001cf,0x00000007,0x0004003b,0x0000001a,0x000001d3,0x00000007,0x0004003b,0x00000007, + 0x000001d5,0x00000007,0x0004003b,0x0000001a,0x000001da,0x00000007,0x0004003b,0x00000007, + 0x000001dc,0x00000007,0x0004003b,0x000001e1,0x000001e2,0x00000007,0x0004003b,0x000001e1, + 0x000001e8,0x00000007,0x0004003b,0x0000001a,0x000001f2,0x00000007,0x0004003b,0x00000007, + 0x000001f4,0x00000007,0x0004003b,0x0000001a,0x0000020d,0x00000007,0x0004003b,0x00000007, + 0x0000020e,0x00000007,0x0004003b,0x00000020,0x00000210,0x00000007,0x0004003b,0x0000001a, + 0x0000021a,0x00000007,0x0004003b,0x00000007,0x0000021b,0x00000007,0x0004003b,0x00000020, + 0x0000021d,0x00000007,0x0004003b,0x00000195,0x00000227,0x00000007,0x0004003b,0x0000001a, + 0x0000022b,0x00000007,0x0004003b,0x00000007,0x0000022c,0x00000007,0x0004003b,0x00000195, + 0x0000022f,0x00000007,0x0004003b,0x0000001a,0x00000233,0x00000007,0x0004003b,0x00000007, + 0x00000234,0x00000007,0x0004003b,0x0000001a,0x00000237,0x00000007,0x0004003b,0x00000007, + 0x0000023b,0x00000007,0x0004003b,0x00000020,0x00000243,0x00000007,0x0004003b,0x0000001a, + 0x00000247,0x00000007,0x0004003b,0x00000007,0x00000249,0x00000007,0x0004003b,0x000001e1, + 0x0000024b,0x00000007,0x0004003b,0x00000195,0x00000253,0x00000007,0x0004003b,0x00000007, + 0x0000025e,0x00000007,0x0004003b,0x00000020,0x00000266,0x00000007,0x0004003b,0x0000001a, + 0x0000026b,0x00000007,0x0004003b,0x00000007,0x0000026d,0x00000007,0x0004003b,0x00000007, + 0x00000278,0x00000007,0x0003003e,0x000000ee,0x000000ed,0x00050039,0x00000008,0x000000ef, + 0x0000000b,0x000000ee,0x0003003e,0x000000f1,0x000000f0,0x00050039,0x00000008,0x000000f2, + 0x0000000b,0x000000f1,0x00050050,0x000000ea,0x000000f3,0x000000ef,0x000000f2,0x0003003e, + 0x000000ec,0x000000f3,0x00050041,0x000000cd,0x000000f6,0x000000cb,0x000000f5,0x0004003d, + 0x00000006,0x000000f7,0x000000f6,0x0004003d,0x00000035,0x000000fa,0x000000f9,0x0004007c, + 0x00000006,0x000000fb,0x000000fa,0x00050080,0x00000006,0x000000fc,0x000000f7,0x000000fb, + 0x0003003e,0x000000f4,0x000000fc,0x00050041,0x000000cd,0x000000fe,0x000000cb,0x000000fd, + 0x0004003d,0x00000006,0x000000ff,0x000000fe,0x000500aa,0x000000d7,0x00000100,0x000000ff, + 0x0000004c,0x000300f7,0x00000102,0x00000000,0x000400fa,0x00000100,0x00000101,0x00000105, + 0x000200f8,0x00000101,0x0004003d,0x00000006,0x00000104,0x000000f4,0x0003003e,0x00000103, + 0x00000104,0x000200f9,0x00000102,0x000200f8,0x00000105,0x00050041,0x000000cd,0x00000106, + 0x000000cb,0x000000fd,0x0004003d,0x00000006,0x00000107,0x00000106,0x000500aa,0x000000d7, + 0x00000108,0x00000107,0x00000047,0x000300f7,0x0000010a,0x00000000,0x000400fa,0x00000108, + 0x00000109,0x00000113,0x000200f8,0x00000109,0x00050041,0x0000010c,0x0000010d,0x000000cb, + 0x0000010b,0x0004003d,0x000000c4,0x0000010e,0x0000010d,0x00040078,0x00000017,0x0000010f, + 0x0000010e,0x0004003d,0x00000006,0x00000110,0x000000f4,0x00060041,0x00000081,0x00000111, + 0x0000010f,0x00000036,0x00000110,0x0006003d,0x00000006,0x00000112,0x00000111,0x00000002, + 0x00000004,0x0003003e,0x00000103,0x00000112,0x000200f9,0x0000010a,0x000200f8,0x00000113, + 0x00050041,0x000000cd,0x00000114,0x000000cb,0x000000fd,0x0004003d,0x00000006,0x00000115, + 0x00000114,0x000500aa,0x000000d7,0x00000116,0x00000115,0x00000042,0x000300f7,0x00000118, + 0x00000000,0x000400fa,0x00000116,0x00000117,0x00000127,0x000200f8,0x00000117,0x00050041, + 0x0000010c,0x00000119,0x000000cb,0x0000010b,0x0004003d,0x000000c4,0x0000011a,0x00000119, + 0x00040078,0x00000017,0x0000011b,0x0000011a,0x0004003d,0x00000006,0x0000011c,0x000000f4, + 0x000500c2,0x00000006,0x0000011d,0x0000011c,0x0000010b,0x00060041,0x00000081,0x0000011e, + 0x0000011b,0x00000036,0x0000011d,0x0006003d,0x00000006,0x0000011f,0x0000011e,0x00000002, + 0x00000004,0x0004003d,0x00000006,0x00000120,0x000000f4,0x000500c7,0x00000006,0x00000121, + 0x00000120,0x00000042,0x00050084,0x00000006,0x00000123,0x00000121,0x00000122,0x000500c2, + 0x00000006,0x00000124,0x0000011f,0x00000123,0x000500c7,0x00000006,0x00000126,0x00000124, + 0x00000125,0x0003003e,0x00000103,0x00000126,0x000200f9,0x00000118,0x000200f8,0x00000127, + 0x00050041,0x0000010c,0x00000128,0x000000cb,0x0000010b,0x0004003d,0x000000c4,0x00000129, + 0x00000128,0x00040078,0x00000017,0x0000012a,0x00000129,0x0004003d,0x00000006,0x0000012b, + 0x000000f4,0x000500c2,0x00000006,0x0000012c,0x0000012b,0x000000b7,0x00060041,0x00000081, + 0x0000012d,0x0000012a,0x00000036,0x0000012c,0x0006003d,0x00000006,0x0000012e,0x0000012d, + 0x00000002,0x00000004,0x0004003d,0x00000006,0x0000012f,0x000000f4,0x000500c7,0x00000006, + 0x00000130,0x0000012f,0x0000004c,0x00050084,0x00000006,0x00000131,0x00000130,0x0000005c, + 0x000500c2,0x00000006,0x00000132,0x0000012e,0x00000131,0x000500c7,0x00000006,0x00000133, + 0x00000132,0x000000bf,0x0003003e,0x00000103,0x00000133,0x000200f9,0x00000118,0x000200f8, + 0x00000118,0x000200f9,0x0000010a,0x000200f8,0x0000010a,0x000200f9,0x00000102,0x000200f8, + 0x00000102,0x00050041,0x00000137,0x00000138,0x000000cb,0x00000136,0x0004003d,0x00000035, + 0x00000139,0x00000138,0x0004003d,0x00000006,0x0000013a,0x00000103,0x0004007c,0x00000035, + 0x0000013b,0x0000013a,0x00050080,0x00000035,0x0000013c,0x00000139,0x0000013b,0x0003003e, + 0x00000135,0x0000013c,0x0004003d,0x00000035,0x0000013d,0x00000135,0x000500b1,0x000000d7, + 0x0000013e,0x0000013d,0x00000036,0x000400a8,0x000000d7,0x0000013f,0x0000013e,0x000300f7, + 0x00000141,0x00000000,0x000400fa,0x0000013f,0x00000140,0x00000141,0x000200f8,0x00000140, + 0x0004003d,0x00000035,0x00000142,0x00000135,0x0004007c,0x00000006,0x00000143,0x00000142, + 0x00050041,0x000000cd,0x00000145,0x000000cb,0x00000144,0x0004003d,0x00000006,0x00000146, + 0x00000145,0x000500ae,0x000000d7,0x00000147,0x00000143,0x00000146,0x000200f9,0x00000141, + 0x000200f8,0x00000141,0x000700f5,0x000000d7,0x00000148,0x0000013e,0x00000102,0x00000147, + 0x00000140,0x000300f7,0x0000014a,0x00000000,0x000400fa,0x00000148,0x00000149,0x0000014a, + 0x000200f8,0x00000149,0x00050041,0x00000151,0x00000152,0x0000014e,0x00000036,0x0003003e, + 0x00000152,0x00000150,0x0003003e,0x00000153,0x00000154,0x000100fd,0x000200f8,0x0000014a, + 0x00050041,0x0000010c,0x00000157,0x000000cb,0x00000036,0x0004003d,0x000000c4,0x00000158, + 0x00000157,0x0004003d,0x00000035,0x00000159,0x00000135,0x0004007c,0x00000006,0x0000015a, + 0x00000159,0x00040071,0x000000c4,0x0000015b,0x0000015a,0x00050041,0x000000cd,0x0000015d, + 0x000000cb,0x0000015c,0x0004003d,0x00000006,0x0000015e,0x0000015d,0x00040071,0x000000c4, + 0x0000015f,0x0000015e,0x00050084,0x000000c4,0x00000160,0x0000015b,0x0000015f,0x00050084, + 0x000000c4,0x00000162,0x00000160,0x00000161,0x00050080,0x000000c4,0x00000163,0x00000158, + 0x00000162,0x00040078,0x00000017,0x00000164,0x00000163,0x0003003e,0x00000156,0x00000164, + 0x00050041,0x000000cd,0x00000167,0x000000cb,0x00000166,0x0004003d,0x00000006,0x00000168, + 0x00000167,0x00050086,0x00000006,0x00000169,0x00000168,0x00000057,0x0003003e,0x00000165, + 0x00000169,0x00050041,0x000000cd,0x0000016b,0x000000cb,0x000000cc,0x0004003d,0x00000006, + 0x0000016c,0x0000016b,0x000500c7,0x00000006,0x0000016d,0x0000016c,0x00000042,0x000500ab, + 0x000000d7,0x0000016e,0x0000016d,0x000000d6,0x000300f7,0x00000171,0x00000000,0x000400fa, + 0x0000016e,0x00000170,0x00000181,0x000200f8,0x00000170,0x0004003d,0x00000017,0x00000172, + 0x00000156,0x0004003d,0x00000006,0x00000173,0x00000165,0x00060041,0x00000081,0x00000174, + 0x00000172,0x00000036,0x00000173,0x0006003d,0x00000006,0x00000175,0x00000174,0x00000002, + 0x00000004,0x0006000c,0x000000ea,0x00000176,0x00000001,0x0000003e,0x00000175,0x0004003d, + 0x00000017,0x00000177,0x00000156,0x0004003d,0x00000006,0x00000178,0x00000165,0x00050080, + 0x00000006,0x00000179,0x00000178,0x00000042,0x00060041,0x00000081,0x0000017a,0x00000177, + 0x00000036,0x00000179,0x0006003d,0x00000006,0x0000017b,0x0000017a,0x00000002,0x00000004, + 0x0006000c,0x000000ea,0x0000017c,0x00000001,0x0000003e,0x0000017b,0x00050051,0x00000008, + 0x0000017d,0x0000017c,0x00000000,0x00050051,0x00000008,0x0000017e,0x00000176,0x00000000, + 0x00050051,0x00000008,0x0000017f,0x00000176,0x00000001,0x00070050,0x0000000d,0x00000180, + 0x0000017e,0x0000017f,0x0000017d,0x00000065,0x0003003e,0x0000016f,0x00000180,0x000200f9, + 0x00000171,0x000200f8,0x00000181,0x0004003d,0x00000017,0x00000182,0x00000156,0x0004003d, + 0x00000006,0x00000183,0x00000165,0x00060041,0x00000081,0x00000184,0x00000182,0x00000036, + 0x00000183,0x0006003d,0x00000006,0x00000185,0x00000184,0x00000002,0x00000004,0x0004007c, + 0x00000008,0x00000186,0x00000185,0x0004003d,0x00000017,0x00000187,0x00000156,0x0004003d, + 0x00000006,0x00000188,0x00000165,0x00050080,0x00000006,0x00000189,0x00000188,0x00000042, + 0x00060041,0x00000081,0x0000018a,0x00000187,0x00000036,0x00000189,0x0006003d,0x00000006, + 0x0000018b,0x0000018a,0x00000002,0x00000004,0x0004007c,0x00000008,0x0000018c,0x0000018b, + 0x0004003d,0x00000017,0x0000018d,0x00000156,0x0004003d,0x00000006,0x0000018e,0x00000165, + 0x00050080,0x00000006,0x0000018f,0x0000018e,0x00000047,0x00060041,0x00000081,0x00000190, + 0x0000018d,0x00000036,0x0000018f,0x0006003d,0x00000006,0x00000191,0x00000190,0x00000002, + 0x00000004,0x0004007c,0x00000008,0x00000192,0x00000191,0x00070050,0x0000000d,0x00000193, + 0x00000186,0x0000018c,0x00000192,0x00000065,0x0003003e,0x0000016f,0x00000193,0x000200f9, + 0x00000171,0x000200f8,0x00000171,0x0004003d,0x0000000d,0x00000194,0x0000016f,0x0003003e, + 0x0000016a,0x00000194,0x0003003e,0x00000196,0x00000197,0x0003003e,0x00000198,0x00000197, + 0x0003003e,0x00000199,0x000000d6,0x000200f9,0x0000019a,0x000200f8,0x0000019a,0x000400f6, + 0x0000019c,0x0000019d,0x00000000,0x000200f9,0x0000019e,0x000200f8,0x0000019e,0x0004003d, + 0x00000006,0x0000019f,0x00000199,0x00050041,0x000000cd,0x000001a1,0x000000cb,0x000001a0, + 0x0004003d,0x00000006,0x000001a2,0x000001a1,0x000500b0,0x000000d7,0x000001a3,0x0000019f, + 0x000001a2,0x000400fa,0x000001a3,0x0000019b,0x0000019c,0x000200f8,0x0000019b,0x00050041, + 0x000000cd,0x000001a6,0x000000cb,0x000000cc,0x0004003d,0x00000006,0x000001a7,0x000001a6, + 0x0004003d,0x00000006,0x000001a8,0x00000199,0x000500c4,0x00000006,0x000001a9,0x00000047, + 0x000001a8,0x000500c7,0x00000006,0x000001aa,0x000001a7,0x000001a9,0x000500ab,0x000000d7, + 0x000001ab,0x000001aa,0x000000d6,0x0003003e,0x000001a5,0x000001ab,0x0004003d,0x00000006, + 0x000001ae,0x00000199,0x0003003e,0x000001ad,0x000001ae,0x00050039,0x00000006,0x000001af, + 0x0000002f,0x000001ad,0x0003003e,0x000001ac,0x000001af,0x0003003e,0x000001b0,0x000000d6, + 0x000200f9,0x000001b1,0x000200f8,0x000001b1,0x000400f6,0x000001b3,0x000001b4,0x00000000, + 0x000200f9,0x000001b5,0x000200f8,0x000001b5,0x0004003d,0x00000006,0x000001b6,0x000001b0, + 0x0004003d,0x00000006,0x000001b7,0x000001ac,0x000500b0,0x000000d7,0x000001b8,0x000001b6, + 0x000001b7,0x000400fa,0x000001b8,0x000001b2,0x000001b3,0x000200f8,0x000001b2,0x0004003d, + 0x00000006,0x000001bb,0x00000199,0x00060041,0x000000cd,0x000001bc,0x000000cb,0x000001ba, + 0x000001bb,0x0004003d,0x00000006,0x000001bd,0x000001bc,0x0004003d,0x000000d7,0x000001be, + 0x000001a5,0x000300f7,0x000001c1,0x00000000,0x000400fa,0x000001be,0x000001c0,0x000001c3, + 0x000200f8,0x000001c0,0x0004003d,0x00000006,0x000001c2,0x000001b0,0x0003003e,0x000001bf, + 0x000001c2,0x000200f9,0x000001c1,0x000200f8,0x000001c3,0x0004003d,0x00000006,0x000001c4, + 0x000001b0,0x00050084,0x00000006,0x000001c5,0x00000047,0x000001c4,0x0003003e,0x000001bf, + 0x000001c5,0x000200f9,0x000001c1,0x000200f8,0x000001c1,0x0004003d,0x00000006,0x000001c6, + 0x000001bf,0x00050080,0x00000006,0x000001c7,0x000001bd,0x000001c6,0x0003003e,0x000001b9, + 0x000001c7,0x0004003d,0x000000d7,0x000001c9,0x000001a5,0x000300f7,0x000001cc,0x00000000, + 0x000400fa,0x000001c9,0x000001cb,0x000001d2,0x000200f8,0x000001cb,0x0004003d,0x00000017, + 0x000001ce,0x00000156,0x0003003e,0x000001cd,0x000001ce,0x0004003d,0x00000006,0x000001d0, + 0x000001b9,0x0003003e,0x000001cf,0x000001d0,0x00060039,0x00000006,0x000001d1,0x0000002b, + 0x000001cd,0x000001cf,0x0003003e,0x000001ca,0x000001d1,0x000200f9,0x000001cc,0x000200f8, + 0x000001d2,0x0004003d,0x00000017,0x000001d4,0x00000156,0x0003003e,0x000001d3,0x000001d4, + 0x0004003d,0x00000006,0x000001d6,0x000001b9,0x0003003e,0x000001d5,0x000001d6,0x00060039, + 0x00000006,0x000001d7,0x0000002b,0x000001d3,0x000001d5,0x0004003d,0x00000006,0x000001d8, + 0x000001b9,0x00050080,0x00000006,0x000001d9,0x000001d8,0x00000042,0x0004003d,0x00000017, + 0x000001db,0x00000156,0x0003003e,0x000001da,0x000001db,0x0003003e,0x000001dc,0x000001d9, + 0x00060039,0x00000006,0x000001dd,0x0000002b,0x000001da,0x000001dc,0x000500c4,0x00000006, + 0x000001de,0x000001dd,0x000000fd,0x000500c5,0x00000006,0x000001df,0x000001d7,0x000001de, + 0x0003003e,0x000001ca,0x000001df,0x000200f9,0x000001cc,0x000200f8,0x000001cc,0x0004003d, + 0x00000006,0x000001e0,0x000001ca,0x0003003e,0x000001c8,0x000001e0,0x00050041,0x000000cd, + 0x000001e3,0x000000cb,0x000000cc,0x0004003d,0x00000006,0x000001e4,0x000001e3,0x000500c7, + 0x00000006,0x000001e6,0x000001e4,0x000001e5,0x000500ab,0x000000d7,0x000001e7,0x000001e6, + 0x000000d6,0x000300f7,0x000001ea,0x00000000,0x000400fa,0x000001e7,0x000001e9,0x000001eb, + 0x000200f8,0x000001e9,0x0003003e,0x000001e8,0x00000065,0x000200f9,0x000001ea,0x000200f8, + 0x000001eb,0x0004003d,0x00000006,0x000001ed,0x00000199,0x00060041,0x000000cd,0x000001ee, + 0x000000cb,0x000001ec,0x000001ed,0x0004003d,0x00000006,0x000001ef,0x000001ee,0x0004003d, + 0x00000006,0x000001f0,0x000001b0,0x00050080,0x00000006,0x000001f1,0x000001ef,0x000001f0, + 0x0004003d,0x00000017,0x000001f3,0x00000156,0x0003003e,0x000001f2,0x000001f3,0x0003003e, + 0x000001f4,0x000001f1,0x00060039,0x00000006,0x000001f5,0x0000002b,0x000001f2,0x000001f4, + 0x00040070,0x00000008,0x000001f6,0x000001f5,0x00050088,0x00000008,0x000001f8,0x000001f6, + 0x000001f7,0x0003003e,0x000001e8,0x000001f8,0x000200f9,0x000001ea,0x000200f8,0x000001ea, + 0x0004003d,0x00000008,0x000001f9,0x000001e8,0x0003003e,0x000001e2,0x000001f9,0x0004003d, + 0x00000008,0x000001fa,0x000001e2,0x000500bc,0x000000d7,0x000001fb,0x000001fa,0x00000066, + 0x000400a8,0x000000d7,0x000001fc,0x000001fb,0x000300f7,0x000001fe,0x00000000,0x000400fa, + 0x000001fc,0x000001fd,0x000001fe,0x000200f8,0x000001fd,0x0004003d,0x00000006,0x000001ff, + 0x000001c8,0x00050041,0x000000cd,0x00000201,0x000000cb,0x00000200,0x0004003d,0x00000006, + 0x00000202,0x00000201,0x000500ae,0x000000d7,0x00000203,0x000001ff,0x00000202,0x000200f9, + 0x000001fe,0x000200f8,0x000001fe,0x000700f5,0x000000d7,0x00000204,0x000001fb,0x000001ea, + 0x00000203,0x000001fd,0x000300f7,0x00000206,0x00000000,0x000400fa,0x00000204,0x00000205, + 0x00000206,0x000200f8,0x00000205,0x000200f9,0x000001b4,0x000200f8,0x00000206,0x0004003d, + 0x00000008,0x00000208,0x000001e2,0x00060041,0x0000010c,0x0000020a,0x000000cb,0x00000209, + 0x00000036,0x0004003d,0x000000c4,0x0000020b,0x0000020a,0x00040078,0x00000017,0x0000020c, + 0x0000020b,0x0003003e,0x0000020d,0x0000020c,0x0004003d,0x00000006,0x0000020f,0x000001c8, + 0x0003003e,0x0000020e,0x0000020f,0x0004003d,0x0000000d,0x00000211,0x0000016a,0x0003003e, + 0x00000210,0x00000211,0x00070039,0x00000021,0x00000212,0x00000026,0x0000020d,0x0000020e, + 0x00000210,0x0005008e,0x00000021,0x00000213,0x00000212,0x00000208,0x0004003d,0x00000021, + 0x00000214,0x00000196,0x00050081,0x00000021,0x00000215,0x00000214,0x00000213,0x0003003e, + 0x00000196,0x00000215,0x0004003d,0x00000008,0x00000216,0x000001e2,0x00060041,0x0000010c, + 0x00000217,0x000000cb,0x00000209,0x0000010b,0x0004003d,0x000000c4,0x00000218,0x00000217, + 0x00040078,0x00000017,0x00000219,0x00000218,0x0003003e,0x0000021a,0x00000219,0x0004003d, + 0x00000006,0x0000021c,0x000001c8,0x0003003e,0x0000021b,0x0000021c,0x0004003d,0x0000000d, + 0x0000021e,0x0000016a,0x0003003e,0x0000021d,0x0000021e,0x00070039,0x00000021,0x0000021f, + 0x00000026,0x0000021a,0x0000021b,0x0000021d,0x0005008e,0x00000021,0x00000220,0x0000021f, + 0x00000216,0x0004003d,0x00000021,0x00000221,0x00000198,0x00050081,0x00000021,0x00000222, + 0x00000221,0x00000220,0x0003003e,0x00000198,0x00000222,0x000200f9,0x000001b4,0x000200f8, + 0x000001b4,0x0004003d,0x00000006,0x00000223,0x000001b0,0x00050080,0x00000006,0x00000224, + 0x00000223,0x0000010b,0x0003003e,0x000001b0,0x00000224,0x000200f9,0x000001b1,0x000200f8, + 0x000001b3,0x000200f9,0x0000019d,0x000200f8,0x0000019d,0x0004003d,0x00000006,0x00000225, + 0x00000199,0x00050080,0x00000006,0x00000226,0x00000225,0x0000010b,0x0003003e,0x00000199, + 0x00000226,0x000200f9,0x0000019a,0x000200f8,0x0000019c,0x00060041,0x0000010c,0x00000228, + 0x000000cb,0x000000b7,0x00000036,0x0004003d,0x000000c4,0x00000229,0x00000228,0x00040078, + 0x00000017,0x0000022a,0x00000229,0x0003003e,0x0000022b,0x0000022a,0x0003003e,0x0000022c, + 0x000000d6,0x00060039,0x0000000d,0x0000022d,0x0000001e,0x0000022b,0x0000022c,0x0008004f, + 0x00000021,0x0000022e,0x0000022d,0x0000022d,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000227,0x0000022e,0x00060041,0x0000010c,0x00000230,0x000000cb,0x000000b7,0x0000010b, + 0x0004003d,0x000000c4,0x00000231,0x00000230,0x00040078,0x00000017,0x00000232,0x00000231, + 0x0003003e,0x00000233,0x00000232,0x0003003e,0x00000234,0x000000d6,0x00060039,0x0000000d, + 0x00000235,0x0000001e,0x00000233,0x00000234,0x0008004f,0x00000021,0x00000236,0x00000235, + 0x00000235,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000022f,0x00000236,0x00060041, + 0x0000010c,0x00000238,0x000000cb,0x000000b7,0x00000036,0x0004003d,0x000000c4,0x00000239, + 0x00000238,0x00040078,0x00000017,0x0000023a,0x00000239,0x0003003e,0x00000237,0x0000023a, + 0x0003003e,0x0000023b,0x000000d6,0x000200f9,0x0000023c,0x000200f8,0x0000023c,0x000400f6, + 0x0000023e,0x0000023f,0x00000000,0x000200f9,0x00000240,0x000200f8,0x00000240,0x0004003d, + 0x00000006,0x00000241,0x0000023b,0x000500b0,0x000000d7,0x00000242,0x00000241,0x0000004c, + 0x000400fa,0x00000242,0x0000023d,0x0000023e,0x000200f8,0x0000023d,0x0004003d,0x00000006, + 0x00000244,0x0000023b,0x00050084,0x00000006,0x00000245,0x00000057,0x00000244,0x00050080, + 0x00000006,0x00000246,0x00000057,0x00000245,0x0004003d,0x00000017,0x00000248,0x00000237, + 0x0003003e,0x00000247,0x00000248,0x0003003e,0x00000249,0x00000246,0x00060039,0x0000000d, + 0x0000024a,0x0000001e,0x00000247,0x00000249,0x0003003e,0x00000243,0x0000024a,0x0004003d, + 0x0000000d,0x0000024c,0x00000243,0x0008004f,0x00000021,0x0000024d,0x0000024c,0x0000024c, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000021,0x0000024e,0x00000227,0x00050094, + 0x00000008,0x0000024f,0x0000024d,0x0000024e,0x00050041,0x000001e1,0x00000250,0x00000243, + 0x0000004c,0x0004003d,0x00000008,0x00000251,0x00000250,0x00050081,0x00000008,0x00000252, + 0x0000024f,0x00000251,0x0003003e,0x0000024b,0x00000252,0x0004003d,0x00000006,0x00000254, + 0x0000023b,0x0004003d,0x00000008,0x00000255,0x0000024b,0x0004003d,0x0000000d,0x00000256, + 0x00000243,0x0008004f,0x00000021,0x00000257,0x00000256,0x00000256,0x00000000,0x00000001, + 0x00000002,0x0004003d,0x00000021,0x00000258,0x00000196,0x00050094,0x00000008,0x00000259, + 0x00000257,0x00000258,0x00050081,0x00000008,0x0000025a,0x00000255,0x00000259,0x00050041, + 0x000001e1,0x0000025b,0x00000253,0x00000254,0x0003003e,0x0000025b,0x0000025a,0x000200f9, + 0x0000023f,0x000200f8,0x0000023f,0x0004003d,0x00000006,0x0000025c,0x0000023b,0x00050080, + 0x00000006,0x0000025d,0x0000025c,0x0000010b,0x0003003e,0x0000023b,0x0000025d,0x000200f9, + 0x0000023c,0x000200f8,0x0000023e,0x0003003e,0x0000025e,0x000000d6,0x000200f9,0x0000025f, + 0x000200f8,0x0000025f,0x000400f6,0x00000261,0x00000262,0x00000000,0x000200f9,0x00000263, + 0x000200f8,0x00000263,0x0004003d,0x00000006,0x00000264,0x0000025e,0x000500b0,0x000000d7, + 0x00000265,0x00000264,0x00000057,0x000400fa,0x00000265,0x00000260,0x00000261,0x000200f8, + 0x00000260,0x0004003d,0x00000006,0x00000267,0x0000025e,0x0004003d,0x00000006,0x00000268, + 0x0000025e,0x00050084,0x00000006,0x00000269,0x00000057,0x00000268,0x00050080,0x00000006, + 0x0000026a,0x00000122,0x00000269,0x0004003d,0x00000017,0x0000026c,0x00000237,0x0003003e, + 0x0000026b,0x0000026c,0x0003003e,0x0000026d,0x0000026a,0x00060039,0x0000000d,0x0000026e, + 0x0000001e,0x0000026b,0x0000026d,0x0004003d,0x00000021,0x0000026f,0x00000253,0x00050051, + 0x00000008,0x00000270,0x0000026f,0x00000000,0x00050051,0x00000008,0x00000271,0x0000026f, + 0x00000001,0x00050051,0x00000008,0x00000272,0x0000026f,0x00000002,0x00070050,0x0000000d, + 0x00000273,0x00000270,0x00000271,0x00000272,0x00000065,0x00050094,0x00000008,0x00000274, + 0x0000026e,0x00000273,0x00050041,0x000001e1,0x00000275,0x00000266,0x00000267,0x0003003e, + 0x00000275,0x00000274,0x000200f9,0x00000262,0x000200f8,0x00000262,0x0004003d,0x00000006, + 0x00000276,0x0000025e,0x00050080,0x00000006,0x00000277,0x00000276,0x0000010b,0x0003003e, + 0x0000025e,0x00000277,0x000200f9,0x0000025f,0x000200f8,0x00000261,0x0003003e,0x00000278, + 0x00000122,0x00050039,0x00000012,0x00000279,0x00000015,0x00000278,0x0004003d,0x00000021, + 0x0000027a,0x00000198,0x0004003d,0x00000021,0x0000027b,0x0000022f,0x00050081,0x00000021, + 0x0000027c,0x0000027a,0x0000027b,0x00050051,0x00000008,0x0000027d,0x0000027c,0x00000000, + 0x00050051,0x00000008,0x0000027e,0x0000027c,0x00000001,0x00050051,0x00000008,0x0000027f, + 0x0000027c,0x00000002,0x00070050,0x0000000d,0x00000280,0x0000027d,0x0000027e,0x0000027f, + 0x00000065,0x00050091,0x0000000d,0x00000281,0x00000279,0x00000280,0x0003003e,0x00000153, + 0x00000281,0x00050041,0x000001e1,0x00000282,0x00000266,0x000000d6,0x0004003d,0x00000008, + 0x00000283,0x00000282,0x00050041,0x000001e1,0x00000284,0x00000266,0x00000042,0x0004003d, + 0x00000008,0x00000285,0x00000284,0x0004007f,0x00000008,0x00000286,0x00000285,0x00050041, + 0x000001e1,0x00000287,0x00000266,0x00000047,0x0004003d,0x00000008,0x00000288,0x00000287, + 0x00050041,0x000001e1,0x00000289,0x00000266,0x0000004c,0x0004003d,0x00000008,0x0000028a, + 0x00000289,0x00050081,0x00000008,0x0000028b,0x00000288,0x0000028a,0x00050085,0x00000008, + 0x0000028d,0x0000028b,0x0000028c,0x00050041,0x000001e1,0x0000028e,0x00000266,0x0000004c, + 0x0004003d,0x00000008,0x0000028f,0x0000028e,0x00070050,0x0000000d,0x00000290,0x00000283, + 0x00000286,0x0000028d,0x0000028f,0x00050041,0x00000151,0x00000291,0x0000014e,0x00000036, + 0x0003003e,0x00000291,0x00000290,0x000100fd,0x00010038,0x00050036,0x00000008,0x0000000b, + 0x00000000,0x00000009,0x00030037,0x00000007,0x0000000a,0x000200f8,0x0000000c,0x0004003d, + 0x00000006,0x00000037,0x0000000a,0x00060041,0x00000038,0x00000039,0x00000034,0x00000036, + 0x00000037,0x0004003d,0x00000006,0x0000003a,0x00000039,0x0004007c,0x00000008,0x0000003b, + 0x0000003a,0x000200fe,0x0000003b,0x00010038,0x00050036,0x0000000d,0x00000010,0x00000000, + 0x0000000e,0x00030037,0x00000007,0x0000000f,0x000200f8,0x00000011,0x0004003b,0x00000007, + 0x0000003e,0x00000007,0x0004003b,0x00000007,0x00000044,0x00000007,0x0004003b,0x00000007, + 0x00000049,0x00000007,0x0004003b,0x00000007,0x0000004e,0x00000007,0x0004003d,0x00000006, + 0x0000003f,0x0000000f,0x0003003e,0x0000003e,0x0000003f,0x00050039,0x00000008,0x00000040, + 0x0000000b,0x0000003e,0x0004003d,0x00000006,0x00000041,0x0000000f,0x00050080,0x00000006, + 0x00000043,0x00000041,0x00000042,0x0003003e,0x00000044,0x00000043,0x00050039,0x00000008, + 0x00000045,0x0000000b,0x00000044,0x0004003d,0x00000006,0x00000046,0x0000000f,0x00050080, + 0x00000006,0x00000048,0x00000046,0x00000047,0x0003003e,0x00000049,0x00000048,0x00050039, + 0x00000008,0x0000004a,0x0000000b,0x00000049,0x0004003d,0x00000006,0x0000004b,0x0000000f, + 0x00050080,0x00000006,0x0000004d,0x0000004b,0x0000004c,0x0003003e,0x0000004e,0x0000004d, + 0x00050039,0x00000008,0x0000004f,0x0000000b,0x0000004e,0x00070050,0x0000000d,0x00000050, + 0x00000040,0x00000045,0x0000004a,0x0000004f,0x000200fe,0x00000050,0x00010038,0x00050036, + 0x00000012,0x00000015,0x00000000,0x00000013,0x00030037,0x00000007,0x00000014,0x000200f8, + 0x00000016,0x0004003b,0x00000007,0x00000053,0x00000007,0x0004003b,0x00000007,0x00000059, + 0x00000007,0x0004003b,0x00000007,0x0000005e,0x00000007,0x0004003b,0x00000007,0x00000063, + 0x00000007,0x0004003d,0x00000006,0x00000054,0x00000014,0x0003003e,0x00000053,0x00000054, + 0x00050039,0x0000000d,0x00000055,0x00000010,0x00000053,0x0004003d,0x00000006,0x00000056, + 0x00000014,0x00050080,0x00000006,0x00000058,0x00000056,0x00000057,0x0003003e,0x00000059, + 0x00000058,0x00050039,0x0000000d,0x0000005a,0x00000010,0x00000059,0x0004003d,0x00000006, + 0x0000005b,0x00000014,0x00050080,0x00000006,0x0000005d,0x0000005b,0x0000005c,0x0003003e, + 0x0000005e,0x0000005d,0x00050039,0x0000000d,0x0000005f,0x00000010,0x0000005e,0x0004003d, + 0x00000006,0x00000060,0x00000014,0x00050080,0x00000006,0x00000062,0x00000060,0x00000061, + 0x0003003e,0x00000063,0x00000062,0x00050039,0x0000000d,0x00000064,0x00000010,0x00000063, + 0x00050051,0x00000008,0x00000067,0x00000055,0x00000000,0x00050051,0x00000008,0x00000068, + 0x00000055,0x00000001,0x00050051,0x00000008,0x00000069,0x00000055,0x00000002,0x00050051, + 0x00000008,0x0000006a,0x00000055,0x00000003,0x00050051,0x00000008,0x0000006b,0x0000005a, + 0x00000000,0x00050051,0x00000008,0x0000006c,0x0000005a,0x00000001,0x00050051,0x00000008, + 0x0000006d,0x0000005a,0x00000002,0x00050051,0x00000008,0x0000006e,0x0000005a,0x00000003, + 0x00050051,0x00000008,0x0000006f,0x0000005f,0x00000000,0x00050051,0x00000008,0x00000070, + 0x0000005f,0x00000001,0x00050051,0x00000008,0x00000071,0x0000005f,0x00000002,0x00050051, + 0x00000008,0x00000072,0x0000005f,0x00000003,0x00050051,0x00000008,0x00000073,0x00000064, + 0x00000000,0x00050051,0x00000008,0x00000074,0x00000064,0x00000001,0x00050051,0x00000008, + 0x00000075,0x00000064,0x00000002,0x00050051,0x00000008,0x00000076,0x00000064,0x00000003, + 0x00070050,0x0000000d,0x00000077,0x00000067,0x00000068,0x00000069,0x0000006a,0x00070050, + 0x0000000d,0x00000078,0x0000006b,0x0000006c,0x0000006d,0x0000006e,0x00070050,0x0000000d, + 0x00000079,0x0000006f,0x00000070,0x00000071,0x00000072,0x00070050,0x0000000d,0x0000007a, + 0x00000073,0x00000074,0x00000075,0x00000076,0x00070050,0x00000012,0x0000007b,0x00000077, + 0x00000078,0x00000079,0x0000007a,0x00040054,0x00000012,0x0000007c,0x0000007b,0x000200fe, + 0x0000007c,0x00010038,0x00050036,0x0000000d,0x0000001e,0x00000000,0x0000001b,0x00030037, + 0x0000001a,0x0000001c,0x00030037,0x00000007,0x0000001d,0x000200f8,0x0000001f,0x0004003d, + 0x00000017,0x0000007f,0x0000001c,0x0004003d,0x00000006,0x00000080,0x0000001d,0x00060041, + 0x00000081,0x00000082,0x0000007f,0x00000036,0x00000080,0x0006003d,0x00000006,0x00000083, + 0x00000082,0x00000002,0x00000004,0x0004003d,0x00000017,0x00000084,0x0000001c,0x0004003d, + 0x00000006,0x00000085,0x0000001d,0x00050080,0x00000006,0x00000086,0x00000085,0x00000042, + 0x00060041,0x00000081,0x00000087,0x00000084,0x00000036,0x00000086,0x0006003d,0x00000006, + 0x00000088,0x00000087,0x00000002,0x00000004,0x0004003d,0x00000017,0x00000089,0x0000001c, + 0x0004003d,0x00000006,0x0000008a,0x0000001d,0x00050080,0x00000006,0x0000008b,0x0000008a, + 0x00000047,0x00060041,0x00000081,0x0000008c,0x00000089,0x00000036,0x0000008b,0x0006003d, + 0x00000006,0x0000008d,0x0000008c,0x00000002,0x00000004,0x0004003d,0x00000017,0x0000008e, + 0x0000001c,0x0004003d,0x00000006,0x0000008f,0x0000001d,0x00050080,0x00000006,0x00000090, + 0x0000008f,0x0000004c,0x00060041,0x00000081,0x00000091,0x0000008e,0x00000036,0x00000090, + 0x0006003d,0x00000006,0x00000092,0x00000091,0x00000002,0x00000004,0x00070050,0x00000093, + 0x00000094,0x00000083,0x00000088,0x0000008d,0x00000092,0x0004007c,0x0000000d,0x00000095, + 0x00000094,0x000200fe,0x00000095,0x00010038,0x00050036,0x00000021,0x00000026,0x00000000, + 0x00000022,0x00030037,0x0000001a,0x00000023,0x00030037,0x00000007,0x00000024,0x00030037, + 0x00000020,0x00000025,0x000200f8,0x00000027,0x0004003b,0x00000007,0x00000098,0x00000007, + 0x0004003b,0x0000001a,0x0000009b,0x00000007,0x0004003b,0x00000007,0x0000009d,0x00000007, + 0x0004003b,0x0000001a,0x000000a4,0x00000007,0x0004003b,0x00000007,0x000000a6,0x00000007, + 0x0004003b,0x0000001a,0x000000ac,0x00000007,0x0004003b,0x00000007,0x000000ae,0x00000007, + 0x0004003d,0x00000006,0x00000099,0x00000024,0x00050084,0x00000006,0x0000009a,0x00000099, + 0x00000061,0x0003003e,0x00000098,0x0000009a,0x0004003d,0x00000017,0x0000009c,0x00000023, + 0x0003003e,0x0000009b,0x0000009c,0x0004003d,0x00000006,0x0000009e,0x00000098,0x0003003e, + 0x0000009d,0x0000009e,0x00060039,0x0000000d,0x0000009f,0x0000001e,0x0000009b,0x0000009d, + 0x0004003d,0x0000000d,0x000000a0,0x00000025,0x00050094,0x00000008,0x000000a1,0x0000009f, + 0x000000a0,0x0004003d,0x00000006,0x000000a2,0x00000098,0x00050080,0x00000006,0x000000a3, + 0x000000a2,0x00000057,0x0004003d,0x00000017,0x000000a5,0x00000023,0x0003003e,0x000000a4, + 0x000000a5,0x0003003e,0x000000a6,0x000000a3,0x00060039,0x0000000d,0x000000a7,0x0000001e, + 0x000000a4,0x000000a6,0x0004003d,0x0000000d,0x000000a8,0x00000025,0x00050094,0x00000008, + 0x000000a9,0x000000a7,0x000000a8,0x0004003d,0x00000006,0x000000aa,0x00000098,0x00050080, + 0x00000006,0x000000ab,0x000000aa,0x0000005c,0x0004003d,0x00000017,0x000000ad,0x00000023, + 0x0003003e,0x000000ac,0x000000ad,0x0003003e,0x000000ae,0x000000ab,0x00060039,0x0000000d, + 0x000000af,0x0000001e,0x000000ac,0x000000ae,0x0004003d,0x0000000d,0x000000b0,0x00000025, + 0x00050094,0x00000008,0x000000b1,0x000000af,0x000000b0,0x00060050,0x00000021,0x000000b2, + 0x000000a1,0x000000a9,0x000000b1,0x000200fe,0x000000b2,0x00010038,0x00050036,0x00000006, + 0x0000002b,0x00000000,0x00000028,0x00030037,0x0000001a,0x00000029,0x00030037,0x00000007, + 0x0000002a,0x000200f8,0x0000002c,0x0004003d,0x00000017,0x000000b5,0x00000029,0x0004003d, + 0x00000006,0x000000b6,0x0000002a,0x000500c2,0x00000006,0x000000b8,0x000000b6,0x000000b7, + 0x00060041,0x00000081,0x000000b9,0x000000b5,0x00000036,0x000000b8,0x0006003d,0x00000006, + 0x000000ba,0x000000b9,0x00000002,0x00000004,0x0004003d,0x00000006,0x000000bb,0x0000002a, + 0x000500c7,0x00000006,0x000000bc,0x000000bb,0x0000004c,0x00050084,0x00000006,0x000000bd, + 0x000000bc,0x0000005c,0x000500c2,0x00000006,0x000000be,0x000000ba,0x000000bd,0x000500c7, + 0x00000006,0x000000c0,0x000000be,0x000000bf,0x000200fe,0x000000c0,0x00010038,0x00050036, + 0x00000006,0x0000002f,0x00000000,0x0000002d,0x00030037,0x00000007,0x0000002e,0x000200f8, + 0x00000030,0x0004003b,0x00000007,0x000000c3,0x00000007,0x0004003b,0x00000007,0x000000d9, + 0x00000007,0x0004003b,0x00000007,0x000000df,0x00000007,0x00050041,0x000000cd,0x000000ce, + 0x000000cb,0x000000cc,0x0004003d,0x00000006,0x000000cf,0x000000ce,0x0004003d,0x00000006, + 0x000000d0,0x0000002e,0x00050084,0x00000006,0x000000d1,0x00000047,0x000000d0,0x00050080, + 0x00000006,0x000000d2,0x00000057,0x000000d1,0x000500c2,0x00000006,0x000000d3,0x000000cf, + 0x000000d2,0x000500c7,0x00000006,0x000000d4,0x000000d3,0x0000004c,0x0003003e,0x000000c3, + 0x000000d4,0x0004003d,0x00000006,0x000000d5,0x000000c3,0x000500aa,0x000000d7,0x000000d8, + 0x000000d5,0x000000d6,0x000300f7,0x000000db,0x00000000,0x000400fa,0x000000d8,0x000000da, + 0x000000dc,0x000200f8,0x000000da,0x0003003e,0x000000d9,0x00000057,0x000200f9,0x000000db, + 0x000200f8,0x000000dc,0x0004003d,0x00000006,0x000000dd,0x000000c3,0x000500aa,0x000000d7, + 0x000000de,0x000000dd,0x00000042,0x000300f7,0x000000e1,0x00000000,0x000400fa,0x000000de, + 0x000000e0,0x000000e2,0x000200f8,0x000000e0,0x0003003e,0x000000df,0x00000042,0x000200f9, + 0x000000e1,0x000200f8,0x000000e2,0x0004003d,0x00000006,0x000000e3,0x000000c3,0x000500aa, + 0x000000d7,0x000000e4,0x000000e3,0x00000047,0x000600a9,0x00000006,0x000000e5,0x000000e4, + 0x00000047,0x000000d6,0x0003003e,0x000000df,0x000000e5,0x000200f9,0x000000e1,0x000200f8, + 0x000000e1,0x0004003d,0x00000006,0x000000e6,0x000000df,0x0003003e,0x000000d9,0x000000e6, + 0x000200f9,0x000000db,0x000200f8,0x000000db,0x0004003d,0x00000006,0x000000e7,0x000000d9, + 0x000200fe,0x000000e7,0x00010038 }; diff --git a/gpu/vk/shaders/dlss_capture.vert b/gpu/vk/shaders/dlss_capture.vert new file mode 100644 index 0000000..1e7c014 --- /dev/null +++ b/gpu/vk/shaders/dlss_capture.vert @@ -0,0 +1,42 @@ +#version 450 +#extension GL_EXT_buffer_reference : require +#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require +// (hookshot) The temporal upscaler's motion of what moves by itself (vk_temporal.cpp capture_motion): a draw of the scene drawn +// again from the positions the game's own vertex stage stored as it drew it (the shader recompiler's capture_position: +// clip space as drawn, y up, depth 0 to 1, a vec4 a vertex at its slot), this frame's and the frame before's, so that each +// pixel it covers gets its own motion: bones, waves along normals, morphs, a moving object, whatever the game's shader did. +// It is drawn with the same indices, base vertex and topology as the game drew it, so VertexIndex names the same vertex as it +// did then. The jitters are the draw's own, of the camera it was drawn with each frame (pushed: a draw whose camera has no +// jitter, where the scene's has, was given motion off by the two frames' jitters): the frame before's is taken off here, +// this frame's by the fragment stage. +// dlss_actor.frag tests the depth and writes the motion. +layout(std430, binding = 0) readonly buffer Data { uint w[]; } data; +layout(buffer_reference, std430, buffer_reference_align = 16) readonly buffer Positions { vec4 p[]; }; +layout(push_constant) uniform P { + uint64_t now; // (this frame's slots: the address of the first) + uint64_t before; // (the frame before's) + uint first_now; // (the vertex index each one's first slot is) + uint first_before; + uint count_now; // (the slots each one has) + uint count_before; + vec2 jitter_now; // (the draw's camera's jitter in clip space, each frame) + vec2 jitter_before; +} pc; +layout(location = 0) out vec4 before; +layout(location = 1) flat out vec2 jitter; + +void main() { + jitter = pc.jitter_now; + const uint i = uint(gl_VertexIndex) - pc.first_now, j = uint(gl_VertexIndex) - pc.first_before; + if (i >= pc.count_now || j >= pc.count_before) { // (outside what was stored: nothing, its triangle dropped) + gl_Position = vec4(0.0, 0.0, 0.0, -1.0); + before = vec4(0.0); + return; + } + const vec4 now = Positions(pc.now).p[i]; + const vec4 then = Positions(pc.before).p[j]; + // (the jitter is the projection's: clip x + jitter x * w. dlss_math::unjitter's, on the position) + before = vec4(then.xy - pc.jitter_before * then.w, then.zw); + // (the game's clip space: y up; Vulkan's: y down. The depth was made 0 to 1 before it was stored) + gl_Position = vec4(now.x, -now.y, now.z, now.w); +} diff --git a/gpu/vk/shaders/dlss_capture_vert_spv.h b/gpu/vk/shaders/dlss_capture_vert_spv.h new file mode 100644 index 0000000..6d4c61c --- /dev/null +++ b/gpu/vk/shaders/dlss_capture_vert_spv.h @@ -0,0 +1,117 @@ + // 1116.6.0 + #pragma once +const uint32_t DLSS_CAPTURE_VERT_SPV[] = { + 0x07230203,0x00010600,0x0008000b,0x0000007e,0x00000000,0x00020011,0x00000001,0x00020011, + 0x0000000b,0x00020011,0x000014e3,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e, + 0x00000000,0x0003000e,0x000014e4,0x00000001,0x000b000f,0x00000000,0x00000004,0x6e69616d, + 0x00000000,0x00000009,0x0000000e,0x00000017,0x0000003c,0x00000043,0x0000007d,0x00030003, + 0x00000002,0x000001c2,0x00070004,0x455f4c47,0x625f5458,0x65666675,0x65725f72,0x65726566, + 0x0065636e,0x000d0004,0x455f4c47,0x735f5458,0x65646168,0x78655f72,0x63696c70,0x615f7469, + 0x68746972,0x6974656d,0x79745f63,0x5f736570,0x36746e69,0x00000034,0x00040005,0x00000004, + 0x6e69616d,0x00000000,0x00040005,0x00000009,0x7474696a,0x00007265,0x00030005,0x0000000c, + 0x00000050,0x00040006,0x0000000c,0x00000000,0x00776f6e,0x00050006,0x0000000c,0x00000001, + 0x6f666562,0x00006572,0x00060006,0x0000000c,0x00000002,0x73726966,0x6f6e5f74,0x00000077, + 0x00070006,0x0000000c,0x00000003,0x73726966,0x65625f74,0x65726f66,0x00000000,0x00060006, + 0x0000000c,0x00000004,0x6e756f63,0x6f6e5f74,0x00000077,0x00070006,0x0000000c,0x00000005, + 0x6e756f63,0x65625f74,0x65726f66,0x00000000,0x00060006,0x0000000c,0x00000006,0x7474696a, + 0x6e5f7265,0x0000776f,0x00070006,0x0000000c,0x00000007,0x7474696a,0x625f7265,0x726f6665, + 0x00000065,0x00030005,0x0000000e,0x00006370,0x00030005,0x00000015,0x00000069,0x00060005, + 0x00000017,0x565f6c67,0x65747265,0x646e4978,0x00007865,0x00030005,0x0000001f,0x0000006a, + 0x00060005,0x0000003a,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x0000003a, + 0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x0000003a,0x00000001,0x505f6c67, + 0x746e696f,0x657a6953,0x00000000,0x00070006,0x0000003a,0x00000002,0x435f6c67,0x4470696c, + 0x61747369,0x0065636e,0x00070006,0x0000003a,0x00000003,0x435f6c67,0x446c6c75,0x61747369, + 0x0065636e,0x00030005,0x0000003c,0x00000000,0x00040005,0x00000043,0x6f666562,0x00006572, + 0x00030005,0x00000047,0x00776f6e,0x00050005,0x0000004d,0x69736f50,0x6e6f6974,0x00000073, + 0x00040006,0x0000004d,0x00000000,0x00000070,0x00040005,0x00000053,0x6e656874,0x00000000, + 0x00040005,0x0000007b,0x61746144,0x00000000,0x00040006,0x0000007b,0x00000000,0x00000077, + 0x00040005,0x0000007d,0x61746164,0x00000000,0x00030047,0x00000009,0x0000000e,0x00040047, + 0x00000009,0x0000001e,0x00000001,0x00030047,0x0000000c,0x00000002,0x00050048,0x0000000c, + 0x00000000,0x00000023,0x00000000,0x00050048,0x0000000c,0x00000001,0x00000023,0x00000008, + 0x00050048,0x0000000c,0x00000002,0x00000023,0x00000010,0x00050048,0x0000000c,0x00000003, + 0x00000023,0x00000014,0x00050048,0x0000000c,0x00000004,0x00000023,0x00000018,0x00050048, + 0x0000000c,0x00000005,0x00000023,0x0000001c,0x00050048,0x0000000c,0x00000006,0x00000023, + 0x00000020,0x00050048,0x0000000c,0x00000007,0x00000023,0x00000028,0x00040047,0x00000017, + 0x0000000b,0x0000002a,0x00030047,0x0000003a,0x00000002,0x00050048,0x0000003a,0x00000000, + 0x0000000b,0x00000000,0x00050048,0x0000003a,0x00000001,0x0000000b,0x00000001,0x00050048, + 0x0000003a,0x00000002,0x0000000b,0x00000003,0x00050048,0x0000003a,0x00000003,0x0000000b, + 0x00000004,0x00040047,0x00000043,0x0000001e,0x00000000,0x00040047,0x0000004c,0x00000006, + 0x00000010,0x00030047,0x0000004d,0x00000002,0x00040048,0x0000004d,0x00000000,0x00000018, + 0x00050048,0x0000004d,0x00000000,0x00000023,0x00000000,0x00040047,0x0000007a,0x00000006, + 0x00000004,0x00030047,0x0000007b,0x00000002,0x00040048,0x0000007b,0x00000000,0x00000018, + 0x00050048,0x0000007b,0x00000000,0x00000023,0x00000000,0x00030047,0x0000007d,0x00000018, + 0x00040047,0x0000007d,0x00000021,0x00000000,0x00040047,0x0000007d,0x00000022,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000003,0x00000007, + 0x0004003b,0x00000008,0x00000009,0x00000003,0x00040015,0x0000000a,0x00000040,0x00000000, + 0x00040015,0x0000000b,0x00000020,0x00000000,0x000a001e,0x0000000c,0x0000000a,0x0000000a, + 0x0000000b,0x0000000b,0x0000000b,0x0000000b,0x00000007,0x00000007,0x00040020,0x0000000d, + 0x00000009,0x0000000c,0x0004003b,0x0000000d,0x0000000e,0x00000009,0x00040015,0x0000000f, + 0x00000020,0x00000001,0x0004002b,0x0000000f,0x00000010,0x00000006,0x00040020,0x00000011, + 0x00000009,0x00000007,0x00040020,0x00000014,0x00000007,0x0000000b,0x00040020,0x00000016, + 0x00000001,0x0000000f,0x0004003b,0x00000016,0x00000017,0x00000001,0x0004002b,0x0000000f, + 0x0000001a,0x00000002,0x00040020,0x0000001b,0x00000009,0x0000000b,0x0004002b,0x0000000f, + 0x00000022,0x00000003,0x00020014,0x00000026,0x0004002b,0x0000000f,0x00000028,0x00000004, + 0x0004002b,0x0000000f,0x00000030,0x00000005,0x00040017,0x00000037,0x00000006,0x00000004, + 0x0004002b,0x0000000b,0x00000038,0x00000001,0x0004001c,0x00000039,0x00000006,0x00000038, + 0x0006001e,0x0000003a,0x00000037,0x00000006,0x00000039,0x00000039,0x00040020,0x0000003b, + 0x00000003,0x0000003a,0x0004003b,0x0000003b,0x0000003c,0x00000003,0x0004002b,0x0000000f, + 0x0000003d,0x00000000,0x0004002b,0x00000006,0x0000003e,0x00000000,0x0004002b,0x00000006, + 0x0000003f,0xbf800000,0x0007002c,0x00000037,0x00000040,0x0000003e,0x0000003e,0x0000003e, + 0x0000003f,0x00040020,0x00000041,0x00000003,0x00000037,0x0004003b,0x00000041,0x00000043, + 0x00000003,0x0007002c,0x00000037,0x00000044,0x0000003e,0x0000003e,0x0000003e,0x0000003e, + 0x00040020,0x00000046,0x00000007,0x00000037,0x00040020,0x00000048,0x00000009,0x0000000a, + 0x00030027,0x0000004b,0x000014e5,0x0003001d,0x0000004c,0x00000037,0x0003001e,0x0000004d, + 0x0000004c,0x00040020,0x0000004b,0x000014e5,0x0000004d,0x00040020,0x00000050,0x000014e5, + 0x00000037,0x0004002b,0x0000000f,0x00000054,0x00000001,0x0004002b,0x0000000f,0x0000005d, + 0x00000007,0x0004002b,0x0000000b,0x00000060,0x00000003,0x00040020,0x00000061,0x00000007, + 0x00000006,0x0004002b,0x0000000b,0x0000006d,0x00000000,0x0004002b,0x0000000b,0x00000073, + 0x00000002,0x0003001d,0x0000007a,0x0000000b,0x0003001e,0x0000007b,0x0000007a,0x00040020, + 0x0000007c,0x0000000c,0x0000007b,0x0004003b,0x0000007c,0x0000007d,0x0000000c,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000014, + 0x00000015,0x00000007,0x0004003b,0x00000014,0x0000001f,0x00000007,0x0004003b,0x00000046, + 0x00000047,0x00000007,0x0004003b,0x00000046,0x00000053,0x00000007,0x00050041,0x00000011, + 0x00000012,0x0000000e,0x00000010,0x0004003d,0x00000007,0x00000013,0x00000012,0x0003003e, + 0x00000009,0x00000013,0x0004003d,0x0000000f,0x00000018,0x00000017,0x0004007c,0x0000000b, + 0x00000019,0x00000018,0x00050041,0x0000001b,0x0000001c,0x0000000e,0x0000001a,0x0004003d, + 0x0000000b,0x0000001d,0x0000001c,0x00050082,0x0000000b,0x0000001e,0x00000019,0x0000001d, + 0x0003003e,0x00000015,0x0000001e,0x0004003d,0x0000000f,0x00000020,0x00000017,0x0004007c, + 0x0000000b,0x00000021,0x00000020,0x00050041,0x0000001b,0x00000023,0x0000000e,0x00000022, + 0x0004003d,0x0000000b,0x00000024,0x00000023,0x00050082,0x0000000b,0x00000025,0x00000021, + 0x00000024,0x0003003e,0x0000001f,0x00000025,0x0004003d,0x0000000b,0x00000027,0x00000015, + 0x00050041,0x0000001b,0x00000029,0x0000000e,0x00000028,0x0004003d,0x0000000b,0x0000002a, + 0x00000029,0x000500ae,0x00000026,0x0000002b,0x00000027,0x0000002a,0x000400a8,0x00000026, + 0x0000002c,0x0000002b,0x000300f7,0x0000002e,0x00000000,0x000400fa,0x0000002c,0x0000002d, + 0x0000002e,0x000200f8,0x0000002d,0x0004003d,0x0000000b,0x0000002f,0x0000001f,0x00050041, + 0x0000001b,0x00000031,0x0000000e,0x00000030,0x0004003d,0x0000000b,0x00000032,0x00000031, + 0x000500ae,0x00000026,0x00000033,0x0000002f,0x00000032,0x000200f9,0x0000002e,0x000200f8, + 0x0000002e,0x000700f5,0x00000026,0x00000034,0x0000002b,0x00000005,0x00000033,0x0000002d, + 0x000300f7,0x00000036,0x00000000,0x000400fa,0x00000034,0x00000035,0x00000036,0x000200f8, + 0x00000035,0x00050041,0x00000041,0x00000042,0x0000003c,0x0000003d,0x0003003e,0x00000042, + 0x00000040,0x0003003e,0x00000043,0x00000044,0x000100fd,0x000200f8,0x00000036,0x00050041, + 0x00000048,0x00000049,0x0000000e,0x0000003d,0x0004003d,0x0000000a,0x0000004a,0x00000049, + 0x00040078,0x0000004b,0x0000004e,0x0000004a,0x0004003d,0x0000000b,0x0000004f,0x00000015, + 0x00060041,0x00000050,0x00000051,0x0000004e,0x0000003d,0x0000004f,0x0006003d,0x00000037, + 0x00000052,0x00000051,0x00000002,0x00000010,0x0003003e,0x00000047,0x00000052,0x00050041, + 0x00000048,0x00000055,0x0000000e,0x00000054,0x0004003d,0x0000000a,0x00000056,0x00000055, + 0x00040078,0x0000004b,0x00000057,0x00000056,0x0004003d,0x0000000b,0x00000058,0x0000001f, + 0x00060041,0x00000050,0x00000059,0x00000057,0x0000003d,0x00000058,0x0006003d,0x00000037, + 0x0000005a,0x00000059,0x00000002,0x00000010,0x0003003e,0x00000053,0x0000005a,0x0004003d, + 0x00000037,0x0000005b,0x00000053,0x0007004f,0x00000007,0x0000005c,0x0000005b,0x0000005b, + 0x00000000,0x00000001,0x00050041,0x00000011,0x0000005e,0x0000000e,0x0000005d,0x0004003d, + 0x00000007,0x0000005f,0x0000005e,0x00050041,0x00000061,0x00000062,0x00000053,0x00000060, + 0x0004003d,0x00000006,0x00000063,0x00000062,0x0005008e,0x00000007,0x00000064,0x0000005f, + 0x00000063,0x00050083,0x00000007,0x00000065,0x0000005c,0x00000064,0x0004003d,0x00000037, + 0x00000066,0x00000053,0x0007004f,0x00000007,0x00000067,0x00000066,0x00000066,0x00000002, + 0x00000003,0x00050051,0x00000006,0x00000068,0x00000065,0x00000000,0x00050051,0x00000006, + 0x00000069,0x00000065,0x00000001,0x00050051,0x00000006,0x0000006a,0x00000067,0x00000000, + 0x00050051,0x00000006,0x0000006b,0x00000067,0x00000001,0x00070050,0x00000037,0x0000006c, + 0x00000068,0x00000069,0x0000006a,0x0000006b,0x0003003e,0x00000043,0x0000006c,0x00050041, + 0x00000061,0x0000006e,0x00000047,0x0000006d,0x0004003d,0x00000006,0x0000006f,0x0000006e, + 0x00050041,0x00000061,0x00000070,0x00000047,0x00000038,0x0004003d,0x00000006,0x00000071, + 0x00000070,0x0004007f,0x00000006,0x00000072,0x00000071,0x00050041,0x00000061,0x00000074, + 0x00000047,0x00000073,0x0004003d,0x00000006,0x00000075,0x00000074,0x00050041,0x00000061, + 0x00000076,0x00000047,0x00000060,0x0004003d,0x00000006,0x00000077,0x00000076,0x00070050, + 0x00000037,0x00000078,0x0000006f,0x00000072,0x00000075,0x00000077,0x00050041,0x00000041, + 0x00000079,0x0000003c,0x0000003d,0x0003003e,0x00000079,0x00000078,0x000100fd,0x00010038 +}; diff --git a/gpu/vk/shaders/dlss_merge.comp b/gpu/vk/shaders/dlss_merge.comp new file mode 100644 index 0000000..bcadfcd --- /dev/null +++ b/gpu/vk/shaders/dlss_merge.comp @@ -0,0 +1,21 @@ +#version 450 +// (local) The temporal upscaler before OoT's bloom and tone mapping, when it scaled up (vk_temporal.cpp temporal_pre_merged): +// what the game drew into the scene's colour target after the engine drew there (the lens flare's sprites, after the bloom's +// passes), carried into the engine's picture. The engine's picture went back into the scene scaled down, and the same +// into `base`, a copy in the scene's own format; the scene now less that copy is what was drawn since, at the scene's size: +// added to the engine's picture at the output's size, which the game's tone mapping then draws from. Nothing drawn since: +// the two are the same texel for texel, and the picture is the engine's as it is. +layout(local_size_x = 8, local_size_y = 8) in; +layout(binding = 0) uniform sampler2D scene; // (the scene's colour target now; linear filter) +layout(binding = 1) uniform sampler2D base; // (as the engine's pass left it; linear filter) +layout(binding = 2) uniform sampler2D picture; // (the engine's, at the output's size) +layout(binding = 3, rgba16f) uniform writeonly image2D dst; +layout(push_constant) uniform P { ivec2 size; } pc; +void main() { + const ivec2 g = ivec2(gl_GlobalInvocationID.xy); + if (any(greaterThanEqual(g, pc.size))) return; + const vec2 uv = (vec2(g) + 0.5) / vec2(pc.size); + const vec3 since = textureLod(scene, uv, 0.0).rgb - textureLod(base, uv, 0.0).rgb; + const vec3 c = texelFetch(picture, g, 0).rgb + since; + imageStore(dst, g, vec4(min(max(c, vec3(0.0)), vec3(64000.0)), 1.0)); +} diff --git a/gpu/vk/shaders/dlss_merge_comp_spv.h b/gpu/vk/shaders/dlss_merge_comp_spv.h new file mode 100644 index 0000000..156960e --- /dev/null +++ b/gpu/vk/shaders/dlss_merge_comp_spv.h @@ -0,0 +1,75 @@ + // 1116.6.0 + #pragma once +const uint32_t DLSS_MERGE_COMP_SPV[] = { + 0x07230203,0x00010600,0x0008000b,0x0000005d,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x000b000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00000015,0x00000034, + 0x0000003b,0x00000042,0x0000004c,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008, + 0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000, + 0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d,0x475f6c67,0x61626f6c,0x766e496c, + 0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000013,0x00000050,0x00050006,0x00000013, + 0x00000000,0x657a6973,0x00000000,0x00030005,0x00000015,0x00006370,0x00030005,0x00000024, + 0x00007675,0x00040005,0x00000030,0x636e6973,0x00000065,0x00040005,0x00000034,0x6e656373, + 0x00000065,0x00040005,0x0000003b,0x65736162,0x00000000,0x00030005,0x00000041,0x00000063, + 0x00040005,0x00000042,0x74636970,0x00657275,0x00030005,0x0000004c,0x00747364,0x00040047, + 0x0000000d,0x0000000b,0x0000001c,0x00030047,0x00000013,0x00000002,0x00050048,0x00000013, + 0x00000000,0x00000023,0x00000000,0x00040047,0x00000034,0x00000021,0x00000000,0x00040047, + 0x00000034,0x00000022,0x00000000,0x00040047,0x0000003b,0x00000021,0x00000001,0x00040047, + 0x0000003b,0x00000022,0x00000000,0x00040047,0x00000042,0x00000021,0x00000002,0x00040047, + 0x00000042,0x00000022,0x00000000,0x00030047,0x0000004c,0x00000019,0x00040047,0x0000004c, + 0x00000021,0x00000003,0x00040047,0x0000004c,0x00000022,0x00000000,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017, + 0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040015, + 0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a,0x00000003,0x00040020, + 0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040017, + 0x0000000e,0x0000000a,0x00000002,0x0003001e,0x00000013,0x00000007,0x00040020,0x00000014, + 0x00000009,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000009,0x0004002b,0x00000006, + 0x00000016,0x00000000,0x00040020,0x00000017,0x00000009,0x00000007,0x00020014,0x0000001a, + 0x00040017,0x0000001b,0x0000001a,0x00000002,0x00030016,0x00000021,0x00000020,0x00040017, + 0x00000022,0x00000021,0x00000002,0x00040020,0x00000023,0x00000007,0x00000022,0x0004002b, + 0x00000021,0x00000027,0x3f000000,0x00040017,0x0000002e,0x00000021,0x00000003,0x00040020, + 0x0000002f,0x00000007,0x0000002e,0x00090019,0x00000031,0x00000021,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000032,0x00000031,0x00040020, + 0x00000033,0x00000000,0x00000032,0x0004003b,0x00000033,0x00000034,0x00000000,0x0004002b, + 0x00000021,0x00000037,0x00000000,0x00040017,0x00000038,0x00000021,0x00000004,0x0004003b, + 0x00000033,0x0000003b,0x00000000,0x0004003b,0x00000033,0x00000042,0x00000000,0x00090019, + 0x0000004a,0x00000021,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000002, + 0x00040020,0x0000004b,0x00000000,0x0000004a,0x0004003b,0x0000004b,0x0000004c,0x00000000, + 0x0006002c,0x0000002e,0x00000050,0x00000037,0x00000037,0x00000037,0x0004002b,0x00000021, + 0x00000052,0x477a0000,0x0006002c,0x0000002e,0x00000053,0x00000052,0x00000052,0x00000052, + 0x0004002b,0x00000021,0x00000055,0x3f800000,0x0004002b,0x0000000a,0x0000005a,0x00000008, + 0x0004002b,0x0000000a,0x0000005b,0x00000001,0x0006002c,0x0000000b,0x0000005c,0x0000005a, + 0x0000005a,0x0000005b,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000023,0x00000024, + 0x00000007,0x0004003b,0x0000002f,0x00000030,0x00000007,0x0004003b,0x0000002f,0x00000041, + 0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010, + 0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010, + 0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041, + 0x00000017,0x00000018,0x00000015,0x00000016,0x0004003d,0x00000007,0x00000019,0x00000018, + 0x000500af,0x0000001b,0x0000001c,0x00000012,0x00000019,0x0004009a,0x0000001a,0x0000001d, + 0x0000001c,0x000300f7,0x0000001f,0x00000000,0x000400fa,0x0000001d,0x0000001e,0x0000001f, + 0x000200f8,0x0000001e,0x000100fd,0x000200f8,0x0000001f,0x0004003d,0x00000007,0x00000025, + 0x00000009,0x0004006f,0x00000022,0x00000026,0x00000025,0x00050050,0x00000022,0x00000028, + 0x00000027,0x00000027,0x00050081,0x00000022,0x00000029,0x00000026,0x00000028,0x00050041, + 0x00000017,0x0000002a,0x00000015,0x00000016,0x0004003d,0x00000007,0x0000002b,0x0000002a, + 0x0004006f,0x00000022,0x0000002c,0x0000002b,0x00050088,0x00000022,0x0000002d,0x00000029, + 0x0000002c,0x0003003e,0x00000024,0x0000002d,0x0004003d,0x00000032,0x00000035,0x00000034, + 0x0004003d,0x00000022,0x00000036,0x00000024,0x00070058,0x00000038,0x00000039,0x00000035, + 0x00000036,0x00000002,0x00000037,0x0008004f,0x0000002e,0x0000003a,0x00000039,0x00000039, + 0x00000000,0x00000001,0x00000002,0x0004003d,0x00000032,0x0000003c,0x0000003b,0x0004003d, + 0x00000022,0x0000003d,0x00000024,0x00070058,0x00000038,0x0000003e,0x0000003c,0x0000003d, + 0x00000002,0x00000037,0x0008004f,0x0000002e,0x0000003f,0x0000003e,0x0000003e,0x00000000, + 0x00000001,0x00000002,0x00050083,0x0000002e,0x00000040,0x0000003a,0x0000003f,0x0003003e, + 0x00000030,0x00000040,0x0004003d,0x00000032,0x00000043,0x00000042,0x0004003d,0x00000007, + 0x00000044,0x00000009,0x00040064,0x00000031,0x00000045,0x00000043,0x0007005f,0x00000038, + 0x00000046,0x00000045,0x00000044,0x00000002,0x00000016,0x0008004f,0x0000002e,0x00000047, + 0x00000046,0x00000046,0x00000000,0x00000001,0x00000002,0x0004003d,0x0000002e,0x00000048, + 0x00000030,0x00050081,0x0000002e,0x00000049,0x00000047,0x00000048,0x0003003e,0x00000041, + 0x00000049,0x0004003d,0x0000004a,0x0000004d,0x0000004c,0x0004003d,0x00000007,0x0000004e, + 0x00000009,0x0004003d,0x0000002e,0x0000004f,0x00000041,0x0007000c,0x0000002e,0x00000051, + 0x00000001,0x00000028,0x0000004f,0x00000050,0x0007000c,0x0000002e,0x00000054,0x00000001, + 0x00000025,0x00000051,0x00000053,0x00050051,0x00000021,0x00000056,0x00000054,0x00000000, + 0x00050051,0x00000021,0x00000057,0x00000054,0x00000001,0x00050051,0x00000021,0x00000058, + 0x00000054,0x00000002,0x00070050,0x00000038,0x00000059,0x00000056,0x00000057,0x00000058, + 0x00000055,0x00040063,0x0000004d,0x0000004e,0x00000059,0x000100fd,0x00010038 +}; diff --git a/gpu/vk/shaders/dlss_out.comp b/gpu/vk/shaders/dlss_out.comp index 30114cf..b024458 100644 --- a/gpu/vk/shaders/dlss_out.comp +++ b/gpu/vk/shaders/dlss_out.comp @@ -4,14 +4,29 @@ // output's with the sampler's linear filter. layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D src; +// (local, RenoDX port) -DHDR (dlss_out_hdr_comp_spv.h), for an RGBA16F scene: DLSS's picture is linear already (dlss_prep's +// HDR colour), written as it is into the RGBA16F output. +#ifdef HDR +layout(binding = 1, rgba16f) uniform writeonly image2D dst; +#else layout(binding = 1, r11f_g11f_b10f) uniform writeonly image2D dst; -layout(push_constant) uniform P { ivec2 size; } pc; +#endif +// pc.linear (the upscaler before the game's bloom and tone mapping): 1, src is linear HDR light already, written as it is +// into the scene's colour target (no square); 2, src is the tone mapped picture's square root, squared (either pass). +layout(push_constant) uniform P { ivec2 size; int linear; } pc; void main() { const ivec2 g = ivec2(gl_GlobalInvocationID.xy); if (any(greaterThanEqual(g, pc.size))) return; vec3 c = all(equal(textureSize(src, 0), pc.size)) ? texelFetch(src, g, 0).rgb : textureLod(src, (vec2(g) + 0.5) / vec2(pc.size), 0.0).rgb; c = max(c, vec3(0.0)); - c *= c; + // (pc.linear: 0 the plain pass squares and -DHDR's writes as it is, as before; 1 as it is, kept inside what the + // target's format holds; 2 squared, either pass) + if (pc.linear == 1) c = min(c, vec3(64000.0)); +#ifdef HDR + else if (pc.linear == 2) c *= c; +#else + else c *= c; +#endif imageStore(dst, g, vec4(c, 1.0)); } diff --git a/gpu/vk/shaders/dlss_out_comp_spv.h b/gpu/vk/shaders/dlss_out_comp_spv.h index 56cb5a3..a83d09e 100644 --- a/gpu/vk/shaders/dlss_out_comp_spv.h +++ b/gpu/vk/shaders/dlss_out_comp_spv.h @@ -1,72 +1,81 @@ // 1116.6.0 #pragma once const uint32_t DLSS_OUT_COMP_SPV[] = { - 0x07230203,0x00010600,0x0008000b,0x0000005d,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010600,0x0008000b,0x00000069,0x00000000,0x00020011,0x00000001,0x00020011, 0x00000031,0x00020011,0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e, 0x00000000,0x0003000e,0x00000000,0x00000001,0x0009000f,0x00000005,0x00000004,0x6e69616d, - 0x00000000,0x0000000d,0x00000015,0x00000028,0x00000051,0x00060010,0x00000004,0x00000011, + 0x00000000,0x0000000d,0x00000015,0x00000028,0x0000005d,0x00060010,0x00000004,0x00000011, 0x00000008,0x00000008,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004, 0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d,0x475f6c67, 0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000013,0x00000050, - 0x00050006,0x00000013,0x00000000,0x657a6973,0x00000000,0x00030005,0x00000015,0x00006370, - 0x00030005,0x00000024,0x00000063,0x00030005,0x00000028,0x00637273,0x00030005,0x00000051, - 0x00747364,0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00030047,0x00000013,0x00000002, - 0x00050048,0x00000013,0x00000000,0x00000023,0x00000000,0x00040047,0x00000028,0x00000021, - 0x00000000,0x00040047,0x00000028,0x00000022,0x00000000,0x00030047,0x00000051,0x00000019, - 0x00040047,0x00000051,0x00000021,0x00000001,0x00040047,0x00000051,0x00000022,0x00000000, - 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020, - 0x00000001,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, - 0x00000007,0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a, - 0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d, - 0x00000001,0x00040017,0x0000000e,0x0000000a,0x00000002,0x0003001e,0x00000013,0x00000007, - 0x00040020,0x00000014,0x00000009,0x00000013,0x0004003b,0x00000014,0x00000015,0x00000009, - 0x0004002b,0x00000006,0x00000016,0x00000000,0x00040020,0x00000017,0x00000009,0x00000007, - 0x00020014,0x0000001a,0x00040017,0x0000001b,0x0000001a,0x00000002,0x00030016,0x00000021, - 0x00000020,0x00040017,0x00000022,0x00000021,0x00000003,0x00040020,0x00000023,0x00000007, - 0x00000022,0x00090019,0x00000025,0x00000021,0x00000001,0x00000000,0x00000000,0x00000000, - 0x00000001,0x00000000,0x0003001b,0x00000026,0x00000025,0x00040020,0x00000027,0x00000000, - 0x00000026,0x0004003b,0x00000027,0x00000028,0x00000000,0x00040017,0x00000036,0x00000021, - 0x00000004,0x00040017,0x0000003c,0x00000021,0x00000002,0x0004002b,0x00000021,0x0000003e, - 0x3f000000,0x0004002b,0x00000021,0x00000045,0x00000000,0x0006002c,0x00000022,0x0000004a, - 0x00000045,0x00000045,0x00000045,0x00090019,0x0000004f,0x00000021,0x00000001,0x00000000, - 0x00000000,0x00000000,0x00000002,0x00000008,0x00040020,0x00000050,0x00000000,0x0000004f, - 0x0004003b,0x00000050,0x00000051,0x00000000,0x0004002b,0x00000021,0x00000055,0x3f800000, - 0x0004002b,0x0000000a,0x0000005a,0x00000008,0x0004002b,0x0000000a,0x0000005b,0x00000001, - 0x0006002c,0x0000000b,0x0000005c,0x0000005a,0x0000005a,0x0000005b,0x00050036,0x00000002, - 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009, - 0x00000007,0x0004003b,0x00000023,0x00000024,0x00000007,0x0004003b,0x00000023,0x00000030, - 0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010, - 0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010, - 0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041, - 0x00000017,0x00000018,0x00000015,0x00000016,0x0004003d,0x00000007,0x00000019,0x00000018, - 0x000500af,0x0000001b,0x0000001c,0x00000012,0x00000019,0x0004009a,0x0000001a,0x0000001d, - 0x0000001c,0x000300f7,0x0000001f,0x00000000,0x000400fa,0x0000001d,0x0000001e,0x0000001f, - 0x000200f8,0x0000001e,0x000100fd,0x000200f8,0x0000001f,0x0004003d,0x00000026,0x00000029, - 0x00000028,0x00040064,0x00000025,0x0000002a,0x00000029,0x00050067,0x00000007,0x0000002b, - 0x0000002a,0x00000016,0x00050041,0x00000017,0x0000002c,0x00000015,0x00000016,0x0004003d, - 0x00000007,0x0000002d,0x0000002c,0x000500aa,0x0000001b,0x0000002e,0x0000002b,0x0000002d, - 0x0004009b,0x0000001a,0x0000002f,0x0000002e,0x000300f7,0x00000032,0x00000000,0x000400fa, - 0x0000002f,0x00000031,0x00000039,0x000200f8,0x00000031,0x0004003d,0x00000026,0x00000033, - 0x00000028,0x0004003d,0x00000007,0x00000034,0x00000009,0x00040064,0x00000025,0x00000035, - 0x00000033,0x0007005f,0x00000036,0x00000037,0x00000035,0x00000034,0x00000002,0x00000016, - 0x0008004f,0x00000022,0x00000038,0x00000037,0x00000037,0x00000000,0x00000001,0x00000002, - 0x0003003e,0x00000030,0x00000038,0x000200f9,0x00000032,0x000200f8,0x00000039,0x0004003d, - 0x00000026,0x0000003a,0x00000028,0x0004003d,0x00000007,0x0000003b,0x00000009,0x0004006f, - 0x0000003c,0x0000003d,0x0000003b,0x00050050,0x0000003c,0x0000003f,0x0000003e,0x0000003e, - 0x00050081,0x0000003c,0x00000040,0x0000003d,0x0000003f,0x00050041,0x00000017,0x00000041, - 0x00000015,0x00000016,0x0004003d,0x00000007,0x00000042,0x00000041,0x0004006f,0x0000003c, - 0x00000043,0x00000042,0x00050088,0x0000003c,0x00000044,0x00000040,0x00000043,0x00070058, - 0x00000036,0x00000046,0x0000003a,0x00000044,0x00000002,0x00000045,0x0008004f,0x00000022, - 0x00000047,0x00000046,0x00000046,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000030, - 0x00000047,0x000200f9,0x00000032,0x000200f8,0x00000032,0x0004003d,0x00000022,0x00000048, - 0x00000030,0x0003003e,0x00000024,0x00000048,0x0004003d,0x00000022,0x00000049,0x00000024, - 0x0007000c,0x00000022,0x0000004b,0x00000001,0x00000028,0x00000049,0x0000004a,0x0003003e, - 0x00000024,0x0000004b,0x0004003d,0x00000022,0x0000004c,0x00000024,0x0004003d,0x00000022, - 0x0000004d,0x00000024,0x00050085,0x00000022,0x0000004e,0x0000004d,0x0000004c,0x0003003e, - 0x00000024,0x0000004e,0x0004003d,0x0000004f,0x00000052,0x00000051,0x0004003d,0x00000007, - 0x00000053,0x00000009,0x0004003d,0x00000022,0x00000054,0x00000024,0x00050051,0x00000021, - 0x00000056,0x00000054,0x00000000,0x00050051,0x00000021,0x00000057,0x00000054,0x00000001, - 0x00050051,0x00000021,0x00000058,0x00000054,0x00000002,0x00070050,0x00000036,0x00000059, - 0x00000056,0x00000057,0x00000058,0x00000055,0x00040063,0x00000052,0x00000053,0x00000059, - 0x000100fd,0x00010038 + 0x00050006,0x00000013,0x00000000,0x657a6973,0x00000000,0x00050006,0x00000013,0x00000001, + 0x656e696c,0x00007261,0x00030005,0x00000015,0x00006370,0x00030005,0x00000024,0x00000063, + 0x00030005,0x00000028,0x00637273,0x00030005,0x0000005d,0x00747364,0x00040047,0x0000000d, + 0x0000000b,0x0000001c,0x00030047,0x00000013,0x00000002,0x00050048,0x00000013,0x00000000, + 0x00000023,0x00000000,0x00050048,0x00000013,0x00000001,0x00000023,0x00000008,0x00040047, + 0x00000028,0x00000021,0x00000000,0x00040047,0x00000028,0x00000022,0x00000000,0x00030047, + 0x0000005d,0x00000019,0x00040047,0x0000005d,0x00000021,0x00000001,0x00040047,0x0000005d, + 0x00000022,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015, + 0x00000006,0x00000020,0x00000001,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020, + 0x00000008,0x00000007,0x00000007,0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017, + 0x0000000b,0x0000000a,0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b, + 0x0000000c,0x0000000d,0x00000001,0x00040017,0x0000000e,0x0000000a,0x00000002,0x0004001e, + 0x00000013,0x00000007,0x00000006,0x00040020,0x00000014,0x00000009,0x00000013,0x0004003b, + 0x00000014,0x00000015,0x00000009,0x0004002b,0x00000006,0x00000016,0x00000000,0x00040020, + 0x00000017,0x00000009,0x00000007,0x00020014,0x0000001a,0x00040017,0x0000001b,0x0000001a, + 0x00000002,0x00030016,0x00000021,0x00000020,0x00040017,0x00000022,0x00000021,0x00000003, + 0x00040020,0x00000023,0x00000007,0x00000022,0x00090019,0x00000025,0x00000021,0x00000001, + 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000026,0x00000025, + 0x00040020,0x00000027,0x00000000,0x00000026,0x0004003b,0x00000027,0x00000028,0x00000000, + 0x00040017,0x00000036,0x00000021,0x00000004,0x00040017,0x0000003c,0x00000021,0x00000002, + 0x0004002b,0x00000021,0x0000003e,0x3f000000,0x0004002b,0x00000021,0x00000045,0x00000000, + 0x0006002c,0x00000022,0x0000004a,0x00000045,0x00000045,0x00000045,0x0004002b,0x00000006, + 0x0000004c,0x00000001,0x00040020,0x0000004d,0x00000009,0x00000006,0x0004002b,0x00000021, + 0x00000054,0x477a0000,0x0006002c,0x00000022,0x00000055,0x00000054,0x00000054,0x00000054, + 0x00090019,0x0000005b,0x00000021,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002, + 0x00000008,0x00040020,0x0000005c,0x00000000,0x0000005b,0x0004003b,0x0000005c,0x0000005d, + 0x00000000,0x0004002b,0x00000021,0x00000061,0x3f800000,0x0004002b,0x0000000a,0x00000066, + 0x00000008,0x0004002b,0x0000000a,0x00000067,0x00000001,0x0006002c,0x0000000b,0x00000068, + 0x00000066,0x00000066,0x00000067,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003, + 0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000023, + 0x00000024,0x00000007,0x0004003b,0x00000023,0x00000030,0x00000007,0x0004003d,0x0000000b, + 0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000, + 0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011, + 0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041,0x00000017,0x00000018,0x00000015, + 0x00000016,0x0004003d,0x00000007,0x00000019,0x00000018,0x000500af,0x0000001b,0x0000001c, + 0x00000012,0x00000019,0x0004009a,0x0000001a,0x0000001d,0x0000001c,0x000300f7,0x0000001f, + 0x00000000,0x000400fa,0x0000001d,0x0000001e,0x0000001f,0x000200f8,0x0000001e,0x000100fd, + 0x000200f8,0x0000001f,0x0004003d,0x00000026,0x00000029,0x00000028,0x00040064,0x00000025, + 0x0000002a,0x00000029,0x00050067,0x00000007,0x0000002b,0x0000002a,0x00000016,0x00050041, + 0x00000017,0x0000002c,0x00000015,0x00000016,0x0004003d,0x00000007,0x0000002d,0x0000002c, + 0x000500aa,0x0000001b,0x0000002e,0x0000002b,0x0000002d,0x0004009b,0x0000001a,0x0000002f, + 0x0000002e,0x000300f7,0x00000032,0x00000000,0x000400fa,0x0000002f,0x00000031,0x00000039, + 0x000200f8,0x00000031,0x0004003d,0x00000026,0x00000033,0x00000028,0x0004003d,0x00000007, + 0x00000034,0x00000009,0x00040064,0x00000025,0x00000035,0x00000033,0x0007005f,0x00000036, + 0x00000037,0x00000035,0x00000034,0x00000002,0x00000016,0x0008004f,0x00000022,0x00000038, + 0x00000037,0x00000037,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000030,0x00000038, + 0x000200f9,0x00000032,0x000200f8,0x00000039,0x0004003d,0x00000026,0x0000003a,0x00000028, + 0x0004003d,0x00000007,0x0000003b,0x00000009,0x0004006f,0x0000003c,0x0000003d,0x0000003b, + 0x00050050,0x0000003c,0x0000003f,0x0000003e,0x0000003e,0x00050081,0x0000003c,0x00000040, + 0x0000003d,0x0000003f,0x00050041,0x00000017,0x00000041,0x00000015,0x00000016,0x0004003d, + 0x00000007,0x00000042,0x00000041,0x0004006f,0x0000003c,0x00000043,0x00000042,0x00050088, + 0x0000003c,0x00000044,0x00000040,0x00000043,0x00070058,0x00000036,0x00000046,0x0000003a, + 0x00000044,0x00000002,0x00000045,0x0008004f,0x00000022,0x00000047,0x00000046,0x00000046, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x00000030,0x00000047,0x000200f9,0x00000032, + 0x000200f8,0x00000032,0x0004003d,0x00000022,0x00000048,0x00000030,0x0003003e,0x00000024, + 0x00000048,0x0004003d,0x00000022,0x00000049,0x00000024,0x0007000c,0x00000022,0x0000004b, + 0x00000001,0x00000028,0x00000049,0x0000004a,0x0003003e,0x00000024,0x0000004b,0x00050041, + 0x0000004d,0x0000004e,0x00000015,0x0000004c,0x0004003d,0x00000006,0x0000004f,0x0000004e, + 0x000500aa,0x0000001a,0x00000050,0x0000004f,0x0000004c,0x000300f7,0x00000052,0x00000000, + 0x000400fa,0x00000050,0x00000051,0x00000057,0x000200f8,0x00000051,0x0004003d,0x00000022, + 0x00000053,0x00000024,0x0007000c,0x00000022,0x00000056,0x00000001,0x00000025,0x00000053, + 0x00000055,0x0003003e,0x00000024,0x00000056,0x000200f9,0x00000052,0x000200f8,0x00000057, + 0x0004003d,0x00000022,0x00000058,0x00000024,0x0004003d,0x00000022,0x00000059,0x00000024, + 0x00050085,0x00000022,0x0000005a,0x00000059,0x00000058,0x0003003e,0x00000024,0x0000005a, + 0x000200f9,0x00000052,0x000200f8,0x00000052,0x0004003d,0x0000005b,0x0000005e,0x0000005d, + 0x0004003d,0x00000007,0x0000005f,0x00000009,0x0004003d,0x00000022,0x00000060,0x00000024, + 0x00050051,0x00000021,0x00000062,0x00000060,0x00000000,0x00050051,0x00000021,0x00000063, + 0x00000060,0x00000001,0x00050051,0x00000021,0x00000064,0x00000060,0x00000002,0x00070050, + 0x00000036,0x00000065,0x00000062,0x00000063,0x00000064,0x00000061,0x00040063,0x0000005e, + 0x0000005f,0x00000065,0x000100fd,0x00010038 }; diff --git a/gpu/vk/shaders/dlss_out_hdr_comp_spv.h b/gpu/vk/shaders/dlss_out_hdr_comp_spv.h new file mode 100644 index 0000000..ecde058 --- /dev/null +++ b/gpu/vk/shaders/dlss_out_hdr_comp_spv.h @@ -0,0 +1,85 @@ + // 1116.6.0 + #pragma once +const uint32_t DLSS_OUT_HDR_COMP_SPV[] = { + 0x07230203,0x00010600,0x0008000b,0x0000006f,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x0009000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d, + 0x00000015,0x00000028,0x00000063,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008, + 0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000, + 0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d,0x475f6c67,0x61626f6c,0x766e496c, + 0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000013,0x00000050,0x00050006,0x00000013, + 0x00000000,0x657a6973,0x00000000,0x00050006,0x00000013,0x00000001,0x656e696c,0x00007261, + 0x00030005,0x00000015,0x00006370,0x00030005,0x00000024,0x00000063,0x00030005,0x00000028, + 0x00637273,0x00030005,0x00000063,0x00747364,0x00040047,0x0000000d,0x0000000b,0x0000001c, + 0x00030047,0x00000013,0x00000002,0x00050048,0x00000013,0x00000000,0x00000023,0x00000000, + 0x00050048,0x00000013,0x00000001,0x00000023,0x00000008,0x00040047,0x00000028,0x00000021, + 0x00000000,0x00040047,0x00000028,0x00000022,0x00000000,0x00030047,0x00000063,0x00000019, + 0x00040047,0x00000063,0x00000021,0x00000001,0x00040047,0x00000063,0x00000022,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020, + 0x00000001,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a, + 0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d, + 0x00000001,0x00040017,0x0000000e,0x0000000a,0x00000002,0x0004001e,0x00000013,0x00000007, + 0x00000006,0x00040020,0x00000014,0x00000009,0x00000013,0x0004003b,0x00000014,0x00000015, + 0x00000009,0x0004002b,0x00000006,0x00000016,0x00000000,0x00040020,0x00000017,0x00000009, + 0x00000007,0x00020014,0x0000001a,0x00040017,0x0000001b,0x0000001a,0x00000002,0x00030016, + 0x00000021,0x00000020,0x00040017,0x00000022,0x00000021,0x00000003,0x00040020,0x00000023, + 0x00000007,0x00000022,0x00090019,0x00000025,0x00000021,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x00000026,0x00000025,0x00040020,0x00000027, + 0x00000000,0x00000026,0x0004003b,0x00000027,0x00000028,0x00000000,0x00040017,0x00000036, + 0x00000021,0x00000004,0x00040017,0x0000003c,0x00000021,0x00000002,0x0004002b,0x00000021, + 0x0000003e,0x3f000000,0x0004002b,0x00000021,0x00000045,0x00000000,0x0006002c,0x00000022, + 0x0000004a,0x00000045,0x00000045,0x00000045,0x0004002b,0x00000006,0x0000004c,0x00000001, + 0x00040020,0x0000004d,0x00000009,0x00000006,0x0004002b,0x00000021,0x00000054,0x477a0000, + 0x0006002c,0x00000022,0x00000055,0x00000054,0x00000054,0x00000054,0x0004002b,0x00000006, + 0x0000005a,0x00000002,0x00090019,0x00000061,0x00000021,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000002,0x00000002,0x00040020,0x00000062,0x00000000,0x00000061,0x0004003b, + 0x00000062,0x00000063,0x00000000,0x0004002b,0x00000021,0x00000067,0x3f800000,0x0004002b, + 0x0000000a,0x0000006c,0x00000008,0x0004002b,0x0000000a,0x0000006d,0x00000001,0x0006002c, + 0x0000000b,0x0000006e,0x0000006c,0x0000006c,0x0000006d,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007, + 0x0004003b,0x00000023,0x00000024,0x00000007,0x0004003b,0x00000023,0x00000030,0x00000007, + 0x0004003d,0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f, + 0x0000000f,0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e, + 0x00000009,0x00000011,0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041,0x00000017, + 0x00000018,0x00000015,0x00000016,0x0004003d,0x00000007,0x00000019,0x00000018,0x000500af, + 0x0000001b,0x0000001c,0x00000012,0x00000019,0x0004009a,0x0000001a,0x0000001d,0x0000001c, + 0x000300f7,0x0000001f,0x00000000,0x000400fa,0x0000001d,0x0000001e,0x0000001f,0x000200f8, + 0x0000001e,0x000100fd,0x000200f8,0x0000001f,0x0004003d,0x00000026,0x00000029,0x00000028, + 0x00040064,0x00000025,0x0000002a,0x00000029,0x00050067,0x00000007,0x0000002b,0x0000002a, + 0x00000016,0x00050041,0x00000017,0x0000002c,0x00000015,0x00000016,0x0004003d,0x00000007, + 0x0000002d,0x0000002c,0x000500aa,0x0000001b,0x0000002e,0x0000002b,0x0000002d,0x0004009b, + 0x0000001a,0x0000002f,0x0000002e,0x000300f7,0x00000032,0x00000000,0x000400fa,0x0000002f, + 0x00000031,0x00000039,0x000200f8,0x00000031,0x0004003d,0x00000026,0x00000033,0x00000028, + 0x0004003d,0x00000007,0x00000034,0x00000009,0x00040064,0x00000025,0x00000035,0x00000033, + 0x0007005f,0x00000036,0x00000037,0x00000035,0x00000034,0x00000002,0x00000016,0x0008004f, + 0x00000022,0x00000038,0x00000037,0x00000037,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x00000030,0x00000038,0x000200f9,0x00000032,0x000200f8,0x00000039,0x0004003d,0x00000026, + 0x0000003a,0x00000028,0x0004003d,0x00000007,0x0000003b,0x00000009,0x0004006f,0x0000003c, + 0x0000003d,0x0000003b,0x00050050,0x0000003c,0x0000003f,0x0000003e,0x0000003e,0x00050081, + 0x0000003c,0x00000040,0x0000003d,0x0000003f,0x00050041,0x00000017,0x00000041,0x00000015, + 0x00000016,0x0004003d,0x00000007,0x00000042,0x00000041,0x0004006f,0x0000003c,0x00000043, + 0x00000042,0x00050088,0x0000003c,0x00000044,0x00000040,0x00000043,0x00070058,0x00000036, + 0x00000046,0x0000003a,0x00000044,0x00000002,0x00000045,0x0008004f,0x00000022,0x00000047, + 0x00000046,0x00000046,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000030,0x00000047, + 0x000200f9,0x00000032,0x000200f8,0x00000032,0x0004003d,0x00000022,0x00000048,0x00000030, + 0x0003003e,0x00000024,0x00000048,0x0004003d,0x00000022,0x00000049,0x00000024,0x0007000c, + 0x00000022,0x0000004b,0x00000001,0x00000028,0x00000049,0x0000004a,0x0003003e,0x00000024, + 0x0000004b,0x00050041,0x0000004d,0x0000004e,0x00000015,0x0000004c,0x0004003d,0x00000006, + 0x0000004f,0x0000004e,0x000500aa,0x0000001a,0x00000050,0x0000004f,0x0000004c,0x000300f7, + 0x00000052,0x00000000,0x000400fa,0x00000050,0x00000051,0x00000057,0x000200f8,0x00000051, + 0x0004003d,0x00000022,0x00000053,0x00000024,0x0007000c,0x00000022,0x00000056,0x00000001, + 0x00000025,0x00000053,0x00000055,0x0003003e,0x00000024,0x00000056,0x000200f9,0x00000052, + 0x000200f8,0x00000057,0x00050041,0x0000004d,0x00000058,0x00000015,0x0000004c,0x0004003d, + 0x00000006,0x00000059,0x00000058,0x000500aa,0x0000001a,0x0000005b,0x00000059,0x0000005a, + 0x000300f7,0x0000005d,0x00000000,0x000400fa,0x0000005b,0x0000005c,0x0000005d,0x000200f8, + 0x0000005c,0x0004003d,0x00000022,0x0000005e,0x00000024,0x0004003d,0x00000022,0x0000005f, + 0x00000024,0x00050085,0x00000022,0x00000060,0x0000005f,0x0000005e,0x0003003e,0x00000024, + 0x00000060,0x000200f9,0x0000005d,0x000200f8,0x0000005d,0x000200f9,0x00000052,0x000200f8, + 0x00000052,0x0004003d,0x00000061,0x00000064,0x00000063,0x0004003d,0x00000007,0x00000065, + 0x00000009,0x0004003d,0x00000022,0x00000066,0x00000024,0x00050051,0x00000021,0x00000068, + 0x00000066,0x00000000,0x00050051,0x00000021,0x00000069,0x00000066,0x00000001,0x00050051, + 0x00000021,0x0000006a,0x00000066,0x00000002,0x00070050,0x00000036,0x0000006b,0x00000068, + 0x00000069,0x0000006a,0x00000067,0x00040063,0x00000064,0x00000065,0x0000006b,0x000100fd, + 0x00010038 +}; diff --git a/gpu/vk/shaders/dlss_prep.comp b/gpu/vk/shaders/dlss_prep.comp index 9975970..19129f1 100644 --- a/gpu/vk/shaders/dlss_prep.comp +++ b/gpu/vk/shaders/dlss_prep.comp @@ -8,7 +8,14 @@ // frame before's, from the camera's two matrices, its jitter taken off). Only the camera's motion: what moves by itself gets // the motion of what is behind it, until vk_dlss.cpp's actor motion draws the skinned draws' own over it (dlss_actor.vert). pc.flags bit 0: motion (none on the first frame); // bit 1: the motion shown as the colour instead (RX_VK_DLSS_DEBUG=motion); bit 2: only that, from the motion image as it is -// then (after vk_dlss.cpp's actor motion drew into it: dlss_actor.vert) +// then (after vk_dlss.cpp's actor motion drew into it: dlss_actor.vert); bit 3 with bit 2 (RX_VK_DLSS_DEBUG=characters): +// grey, and blue where shaders/dlss_actor.frag marked a draw's own motion (x under -20000, y how far it is from the +// camera's: brighter up to 8 px), the motion then none +// (local, RenoDX port) -DHDR (dlss_prep_hdr_comp_spv.h), for an RGBA16F scene whose values pass 1: the colour is the input +// squared, linear HDR with nothing clamped at 1, which DLSS takes as HDR colour. +// pc.flags bit 4 (the upscaler before the game's bloom and tone mapping, vk_temporal.cpp temporal_pre_tonemap; the plain +// pass, whichever format the scene's target has): the scene is its colour target itself, linear HDR light: taken as it +// is, nothing clamped at 1, and the engine told it is HDR. // The game's clip space: depth from -1 to 1 (NVN's default), y up, the picture's rows top down. layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D scene; @@ -29,11 +36,24 @@ void main() { const vec2 uv = (vec2(g) + 0.5) / size; if ((pc.flags & 4) != 0) { const vec2 m = imageLoad(motion, g).xy; + if ((pc.flags & 8) != 0) { + const vec3 c = m.x < -20000.0 ? mix(vec3(0.02, 0.10, 0.45), vec3(0.15, 0.45, 1.0), clamp(m.y / 8.0, 0.0, 1.0)) + : vec3(0.18); + imageStore(color, g, vec4(c, 1.0)); + imageStore(motion, g, vec4(0.0)); + return; + } imageStore(color, g, vec4(clamp(abs(m) / 16.0, 0.0, 1.0), textureLod(scene_depth, uv, 0.0).r, 1.0)); return; } const vec3 c = textureLod(scene, uv, 0.0).rgb; - imageStore(color, g, vec4(clamp(c, 0.0, 1.0), 1.0)); +#ifdef HDR + const vec3 root = max(c, vec3(0.0)); + imageStore(color, g, vec4(root * root, 1.0)); +#else + // (min, max: a NaN in the scene goes no further, max of it and 0 being 0) + imageStore(color, g, vec4((pc.flags & 16) != 0 ? min(max(c, vec3(0.0)), vec3(64000.0)) : clamp(c, 0.0, 1.0), 1.0)); +#endif const float d = textureLod(scene_depth, uv, 0.0).r; imageStore(depth, g, vec4(d)); vec2 mv = vec2(0.0); diff --git a/gpu/vk/shaders/dlss_prep_comp_spv.h b/gpu/vk/shaders/dlss_prep_comp_spv.h index fcd1b77..fcc7fcf 100644 --- a/gpu/vk/shaders/dlss_prep_comp_spv.h +++ b/gpu/vk/shaders/dlss_prep_comp_spv.h @@ -1,10 +1,10 @@ // 1116.6.0 #pragma once const uint32_t DLSS_PREP_COMP_SPV[] = { - 0x07230203,0x00010600,0x0008000b,0x000000ec,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010600,0x0008000b,0x00000127,0x00000000,0x00020011,0x00000001,0x00020011, 0x00000031,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, 0x00000000,0x00000001,0x000c000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d, - 0x00000019,0x0000003f,0x00000046,0x00000056,0x00000063,0x0000007a,0x00060010,0x00000004, + 0x00000019,0x0000003f,0x0000006d,0x00000086,0x00000090,0x000000b6,0x00060010,0x00000004, 0x00000011,0x00000008,0x00000008,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, 0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d, 0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000017, @@ -12,167 +12,206 @@ const uint32_t DLSS_PREP_COMP_SPV[] = { 0x00000017,0x00000001,0x7474696a,0x00007265,0x00050006,0x00000017,0x00000002,0x657a6973, 0x00000000,0x00050006,0x00000017,0x00000003,0x67616c66,0x00000073,0x00030005,0x00000019, 0x00006370,0x00040005,0x00000026,0x657a6973,0x00000000,0x00030005,0x0000002a,0x00007675, - 0x00030005,0x0000003c,0x0000006d,0x00040005,0x0000003f,0x69746f6d,0x00006e6f,0x00040005, - 0x00000046,0x6f6c6f63,0x00000072,0x00050005,0x00000056,0x6e656373,0x65645f65,0x00687470, - 0x00030005,0x00000062,0x00000063,0x00040005,0x00000063,0x6e656373,0x00000065,0x00030005, - 0x00000073,0x00000064,0x00040005,0x0000007a,0x74706564,0x00000068,0x00030005,0x0000007f, - 0x0000766d,0x00040005,0x0000008f,0x70696c63,0x00000000,0x00040005,0x0000009e,0x6f666562, - 0x00006572,0x00040005,0x000000ab,0x6e656874,0x00000000,0x00030005,0x000000b2,0x00776f6e, - 0x00030005,0x000000b9,0x00007870,0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00030047, - 0x00000017,0x00000002,0x00040048,0x00000017,0x00000000,0x00000004,0x00050048,0x00000017, - 0x00000000,0x00000007,0x00000010,0x00050048,0x00000017,0x00000000,0x00000023,0x00000000, - 0x00050048,0x00000017,0x00000001,0x00000023,0x00000040,0x00050048,0x00000017,0x00000002, - 0x00000023,0x00000048,0x00050048,0x00000017,0x00000003,0x00000023,0x00000050,0x00040047, - 0x0000003f,0x00000021,0x00000004,0x00040047,0x0000003f,0x00000022,0x00000000,0x00030047, - 0x00000046,0x00000019,0x00040047,0x00000046,0x00000021,0x00000002,0x00040047,0x00000046, - 0x00000022,0x00000000,0x00040047,0x00000056,0x00000021,0x00000001,0x00040047,0x00000056, - 0x00000022,0x00000000,0x00040047,0x00000063,0x00000021,0x00000000,0x00040047,0x00000063, - 0x00000022,0x00000000,0x00030047,0x0000007a,0x00000019,0x00040047,0x0000007a,0x00000021, - 0x00000003,0x00040047,0x0000007a,0x00000022,0x00000000,0x00020013,0x00000002,0x00030021, - 0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007, - 0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040015,0x0000000a, - 0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a,0x00000003,0x00040020,0x0000000c, - 0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040017,0x0000000e, - 0x0000000a,0x00000002,0x00030016,0x00000013,0x00000020,0x00040017,0x00000014,0x00000013, - 0x00000004,0x00040018,0x00000015,0x00000014,0x00000004,0x00040017,0x00000016,0x00000013, - 0x00000002,0x0006001e,0x00000017,0x00000015,0x00000016,0x00000007,0x00000006,0x00040020, - 0x00000018,0x00000009,0x00000017,0x0004003b,0x00000018,0x00000019,0x00000009,0x0004002b, - 0x00000006,0x0000001a,0x00000002,0x00040020,0x0000001b,0x00000009,0x00000007,0x00020014, - 0x0000001e,0x00040017,0x0000001f,0x0000001e,0x00000002,0x00040020,0x00000025,0x00000007, - 0x00000016,0x0004002b,0x00000013,0x0000002d,0x3f000000,0x0004002b,0x00000006,0x00000032, - 0x00000003,0x00040020,0x00000033,0x00000009,0x00000006,0x0004002b,0x00000006,0x00000036, - 0x00000004,0x0004002b,0x00000006,0x00000038,0x00000000,0x00090019,0x0000003d,0x00000013, - 0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000007,0x00040020,0x0000003e, - 0x00000000,0x0000003d,0x0004003b,0x0000003e,0x0000003f,0x00000000,0x00090019,0x00000044, - 0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000002,0x00040020, - 0x00000045,0x00000000,0x00000044,0x0004003b,0x00000045,0x00000046,0x00000000,0x0004002b, - 0x00000013,0x0000004b,0x41800000,0x0004002b,0x00000013,0x0000004e,0x00000000,0x0004002b, - 0x00000013,0x0000004f,0x3f800000,0x00090019,0x00000053,0x00000013,0x00000001,0x00000000, - 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000054,0x00000053,0x00040020, - 0x00000055,0x00000000,0x00000054,0x0004003b,0x00000055,0x00000056,0x00000000,0x0004002b, - 0x0000000a,0x0000005a,0x00000000,0x00040017,0x00000060,0x00000013,0x00000003,0x00040020, - 0x00000061,0x00000007,0x00000060,0x0004003b,0x00000055,0x00000063,0x00000000,0x00040020, - 0x00000072,0x00000007,0x00000013,0x00090019,0x00000078,0x00000013,0x00000001,0x00000000, - 0x00000000,0x00000000,0x00000002,0x00000003,0x00040020,0x00000079,0x00000000,0x00000078, - 0x0004003b,0x00000079,0x0000007a,0x00000000,0x0005002c,0x00000016,0x00000080,0x0000004e, - 0x0000004e,0x0004002b,0x00000006,0x00000083,0x00000001,0x00040020,0x0000008e,0x00000007, - 0x00000014,0x0004002b,0x00000013,0x00000092,0x40000000,0x0004002b,0x0000000a,0x00000095, - 0x00000001,0x00040020,0x0000009f,0x00000009,0x00000015,0x0004002b,0x0000000a,0x000000a4, - 0x00000003,0x0004002b,0x00000013,0x000000a7,0x358637bd,0x00040020,0x000000b5,0x00000009, - 0x00000016,0x0004002b,0x00000013,0x000000ca,0x46800000,0x0005002c,0x00000016,0x000000cb, - 0x000000ca,0x000000ca,0x0004002b,0x0000000a,0x000000ea,0x00000008,0x0006002c,0x0000000b, - 0x000000eb,0x000000ea,0x000000ea,0x00000095,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00030005,0x0000003c,0x0000006d,0x00040005,0x0000003f,0x69746f6d,0x00006e6f,0x00030005, + 0x0000004d,0x00000063,0x00040005,0x0000006d,0x6f6c6f63,0x00000072,0x00050005,0x00000086, + 0x6e656373,0x65645f65,0x00687470,0x00030005,0x0000008f,0x00000063,0x00040005,0x00000090, + 0x6e656373,0x00000065,0x00030005,0x000000af,0x00000064,0x00040005,0x000000b6,0x74706564, + 0x00000068,0x00030005,0x000000bb,0x0000766d,0x00040005,0x000000cb,0x70696c63,0x00000000, + 0x00040005,0x000000d9,0x6f666562,0x00006572,0x00040005,0x000000e6,0x6e656874,0x00000000, + 0x00030005,0x000000ed,0x00776f6e,0x00030005,0x000000f4,0x00007870,0x00040047,0x0000000d, + 0x0000000b,0x0000001c,0x00030047,0x00000017,0x00000002,0x00040048,0x00000017,0x00000000, + 0x00000004,0x00050048,0x00000017,0x00000000,0x00000007,0x00000010,0x00050048,0x00000017, + 0x00000000,0x00000023,0x00000000,0x00050048,0x00000017,0x00000001,0x00000023,0x00000040, + 0x00050048,0x00000017,0x00000002,0x00000023,0x00000048,0x00050048,0x00000017,0x00000003, + 0x00000023,0x00000050,0x00040047,0x0000003f,0x00000021,0x00000004,0x00040047,0x0000003f, + 0x00000022,0x00000000,0x00030047,0x0000006d,0x00000019,0x00040047,0x0000006d,0x00000021, + 0x00000002,0x00040047,0x0000006d,0x00000022,0x00000000,0x00040047,0x00000086,0x00000021, + 0x00000001,0x00040047,0x00000086,0x00000022,0x00000000,0x00040047,0x00000090,0x00000021, + 0x00000000,0x00040047,0x00000090,0x00000022,0x00000000,0x00030047,0x000000b6,0x00000019, + 0x00040047,0x000000b6,0x00000021,0x00000003,0x00040047,0x000000b6,0x00000022,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020, + 0x00000001,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007, + 0x00000007,0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a, + 0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d, + 0x00000001,0x00040017,0x0000000e,0x0000000a,0x00000002,0x00030016,0x00000013,0x00000020, + 0x00040017,0x00000014,0x00000013,0x00000004,0x00040018,0x00000015,0x00000014,0x00000004, + 0x00040017,0x00000016,0x00000013,0x00000002,0x0006001e,0x00000017,0x00000015,0x00000016, + 0x00000007,0x00000006,0x00040020,0x00000018,0x00000009,0x00000017,0x0004003b,0x00000018, + 0x00000019,0x00000009,0x0004002b,0x00000006,0x0000001a,0x00000002,0x00040020,0x0000001b, + 0x00000009,0x00000007,0x00020014,0x0000001e,0x00040017,0x0000001f,0x0000001e,0x00000002, + 0x00040020,0x00000025,0x00000007,0x00000016,0x0004002b,0x00000013,0x0000002d,0x3f000000, + 0x0004002b,0x00000006,0x00000032,0x00000003,0x00040020,0x00000033,0x00000009,0x00000006, + 0x0004002b,0x00000006,0x00000036,0x00000004,0x0004002b,0x00000006,0x00000038,0x00000000, + 0x00090019,0x0000003d,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002, + 0x00000007,0x00040020,0x0000003e,0x00000000,0x0000003d,0x0004003b,0x0000003e,0x0000003f, + 0x00000000,0x0004002b,0x00000006,0x00000046,0x00000008,0x00040017,0x0000004b,0x00000013, + 0x00000003,0x00040020,0x0000004c,0x00000007,0x0000004b,0x0004002b,0x0000000a,0x0000004e, + 0x00000000,0x00040020,0x0000004f,0x00000007,0x00000013,0x0004002b,0x00000013,0x00000052, + 0xc69c4000,0x0004002b,0x00000013,0x00000057,0x3ca3d70a,0x0004002b,0x00000013,0x00000058, + 0x3dcccccd,0x0004002b,0x00000013,0x00000059,0x3ee66666,0x0006002c,0x0000004b,0x0000005a, + 0x00000057,0x00000058,0x00000059,0x0004002b,0x00000013,0x0000005b,0x3e19999a,0x0004002b, + 0x00000013,0x0000005c,0x3f800000,0x0006002c,0x0000004b,0x0000005d,0x0000005b,0x00000059, + 0x0000005c,0x0004002b,0x0000000a,0x0000005e,0x00000001,0x0004002b,0x00000013,0x00000061, + 0x41000000,0x0004002b,0x00000013,0x00000063,0x00000000,0x0004002b,0x00000013,0x00000068, + 0x3e3851ec,0x0006002c,0x0000004b,0x00000069,0x00000068,0x00000068,0x00000068,0x00090019, + 0x0000006b,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000002, + 0x00040020,0x0000006c,0x00000000,0x0000006b,0x0004003b,0x0000006c,0x0000006d,0x00000000, + 0x0007002c,0x00000014,0x00000077,0x00000063,0x00000063,0x00000063,0x00000063,0x0004002b, + 0x00000013,0x0000007d,0x41800000,0x00090019,0x00000083,0x00000013,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000084,0x00000083,0x00040020, + 0x00000085,0x00000000,0x00000084,0x0004003b,0x00000085,0x00000086,0x00000000,0x0004003b, + 0x00000085,0x00000090,0x00000000,0x0004002b,0x00000006,0x00000099,0x00000010,0x0006002c, + 0x0000004b,0x000000a0,0x00000063,0x00000063,0x00000063,0x0004002b,0x00000013,0x000000a2, + 0x477a0000,0x0006002c,0x0000004b,0x000000a3,0x000000a2,0x000000a2,0x000000a2,0x00090019, + 0x000000b4,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000003, + 0x00040020,0x000000b5,0x00000000,0x000000b4,0x0004003b,0x000000b5,0x000000b6,0x00000000, + 0x0005002c,0x00000016,0x000000bc,0x00000063,0x00000063,0x0004002b,0x00000006,0x000000bf, + 0x00000001,0x00040020,0x000000ca,0x00000007,0x00000014,0x0004002b,0x00000013,0x000000ce, + 0x40000000,0x00040020,0x000000da,0x00000009,0x00000015,0x0004002b,0x0000000a,0x000000df, + 0x00000003,0x0004002b,0x00000013,0x000000e2,0x358637bd,0x00040020,0x000000f0,0x00000009, + 0x00000016,0x0004002b,0x00000013,0x00000105,0x46800000,0x0005002c,0x00000016,0x00000106, + 0x00000105,0x00000105,0x0004002b,0x0000000a,0x00000125,0x00000008,0x0006002c,0x0000000b, + 0x00000126,0x00000125,0x00000125,0x0000005e,0x00050036,0x00000002,0x00000004,0x00000000, 0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b, 0x00000025,0x00000026,0x00000007,0x0004003b,0x00000025,0x0000002a,0x00000007,0x0004003b, - 0x00000025,0x0000003c,0x00000007,0x0004003b,0x00000061,0x00000062,0x00000007,0x0004003b, - 0x00000072,0x00000073,0x00000007,0x0004003b,0x00000025,0x0000007f,0x00000007,0x0004003b, - 0x0000008e,0x0000008f,0x00000007,0x0004003b,0x0000008e,0x0000009e,0x00000007,0x0004003b, - 0x00000025,0x000000ab,0x00000007,0x0004003b,0x00000025,0x000000b2,0x00000007,0x0004003b, - 0x00000025,0x000000b9,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d,0x0007004f, - 0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004007c,0x00000007, - 0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000007,0x00000012, - 0x00000009,0x00050041,0x0000001b,0x0000001c,0x00000019,0x0000001a,0x0004003d,0x00000007, - 0x0000001d,0x0000001c,0x000500af,0x0000001f,0x00000020,0x00000012,0x0000001d,0x0004009a, - 0x0000001e,0x00000021,0x00000020,0x000300f7,0x00000023,0x00000000,0x000400fa,0x00000021, - 0x00000022,0x00000023,0x000200f8,0x00000022,0x000100fd,0x000200f8,0x00000023,0x00050041, - 0x0000001b,0x00000027,0x00000019,0x0000001a,0x0004003d,0x00000007,0x00000028,0x00000027, - 0x0004006f,0x00000016,0x00000029,0x00000028,0x0003003e,0x00000026,0x00000029,0x0004003d, - 0x00000007,0x0000002b,0x00000009,0x0004006f,0x00000016,0x0000002c,0x0000002b,0x00050050, - 0x00000016,0x0000002e,0x0000002d,0x0000002d,0x00050081,0x00000016,0x0000002f,0x0000002c, - 0x0000002e,0x0004003d,0x00000016,0x00000030,0x00000026,0x00050088,0x00000016,0x00000031, - 0x0000002f,0x00000030,0x0003003e,0x0000002a,0x00000031,0x00050041,0x00000033,0x00000034, - 0x00000019,0x00000032,0x0004003d,0x00000006,0x00000035,0x00000034,0x000500c7,0x00000006, - 0x00000037,0x00000035,0x00000036,0x000500ab,0x0000001e,0x00000039,0x00000037,0x00000038, - 0x000300f7,0x0000003b,0x00000000,0x000400fa,0x00000039,0x0000003a,0x0000003b,0x000200f8, - 0x0000003a,0x0004003d,0x0000003d,0x00000040,0x0000003f,0x0004003d,0x00000007,0x00000041, - 0x00000009,0x00050062,0x00000014,0x00000042,0x00000040,0x00000041,0x0007004f,0x00000016, - 0x00000043,0x00000042,0x00000042,0x00000000,0x00000001,0x0003003e,0x0000003c,0x00000043, - 0x0004003d,0x00000044,0x00000047,0x00000046,0x0004003d,0x00000007,0x00000048,0x00000009, - 0x0004003d,0x00000016,0x00000049,0x0000003c,0x0006000c,0x00000016,0x0000004a,0x00000001, - 0x00000004,0x00000049,0x00050050,0x00000016,0x0000004c,0x0000004b,0x0000004b,0x00050088, - 0x00000016,0x0000004d,0x0000004a,0x0000004c,0x00050050,0x00000016,0x00000050,0x0000004e, - 0x0000004e,0x00050050,0x00000016,0x00000051,0x0000004f,0x0000004f,0x0008000c,0x00000016, - 0x00000052,0x00000001,0x0000002b,0x0000004d,0x00000050,0x00000051,0x0004003d,0x00000054, - 0x00000057,0x00000056,0x0004003d,0x00000016,0x00000058,0x0000002a,0x00070058,0x00000014, - 0x00000059,0x00000057,0x00000058,0x00000002,0x0000004e,0x00050051,0x00000013,0x0000005b, - 0x00000059,0x00000000,0x00050051,0x00000013,0x0000005c,0x00000052,0x00000000,0x00050051, - 0x00000013,0x0000005d,0x00000052,0x00000001,0x00070050,0x00000014,0x0000005e,0x0000005c, - 0x0000005d,0x0000005b,0x0000004f,0x00040063,0x00000047,0x00000048,0x0000005e,0x000100fd, - 0x000200f8,0x0000003b,0x0004003d,0x00000054,0x00000064,0x00000063,0x0004003d,0x00000016, - 0x00000065,0x0000002a,0x00070058,0x00000014,0x00000066,0x00000064,0x00000065,0x00000002, - 0x0000004e,0x0008004f,0x00000060,0x00000067,0x00000066,0x00000066,0x00000000,0x00000001, - 0x00000002,0x0003003e,0x00000062,0x00000067,0x0004003d,0x00000044,0x00000068,0x00000046, - 0x0004003d,0x00000007,0x00000069,0x00000009,0x0004003d,0x00000060,0x0000006a,0x00000062, - 0x00060050,0x00000060,0x0000006b,0x0000004e,0x0000004e,0x0000004e,0x00060050,0x00000060, - 0x0000006c,0x0000004f,0x0000004f,0x0000004f,0x0008000c,0x00000060,0x0000006d,0x00000001, - 0x0000002b,0x0000006a,0x0000006b,0x0000006c,0x00050051,0x00000013,0x0000006e,0x0000006d, - 0x00000000,0x00050051,0x00000013,0x0000006f,0x0000006d,0x00000001,0x00050051,0x00000013, - 0x00000070,0x0000006d,0x00000002,0x00070050,0x00000014,0x00000071,0x0000006e,0x0000006f, - 0x00000070,0x0000004f,0x00040063,0x00000068,0x00000069,0x00000071,0x0004003d,0x00000054, - 0x00000074,0x00000056,0x0004003d,0x00000016,0x00000075,0x0000002a,0x00070058,0x00000014, - 0x00000076,0x00000074,0x00000075,0x00000002,0x0000004e,0x00050051,0x00000013,0x00000077, - 0x00000076,0x00000000,0x0003003e,0x00000073,0x00000077,0x0004003d,0x00000078,0x0000007b, - 0x0000007a,0x0004003d,0x00000007,0x0000007c,0x00000009,0x0004003d,0x00000013,0x0000007d, - 0x00000073,0x00070050,0x00000014,0x0000007e,0x0000007d,0x0000007d,0x0000007d,0x0000007d, - 0x00040063,0x0000007b,0x0000007c,0x0000007e,0x0003003e,0x0000007f,0x00000080,0x00050041, - 0x00000033,0x00000081,0x00000019,0x00000032,0x0004003d,0x00000006,0x00000082,0x00000081, - 0x000500c7,0x00000006,0x00000084,0x00000082,0x00000083,0x000500ab,0x0000001e,0x00000085, - 0x00000084,0x00000038,0x0004003d,0x00000013,0x00000086,0x00000073,0x000500be,0x0000001e, - 0x00000087,0x00000086,0x0000004e,0x000500a7,0x0000001e,0x00000088,0x00000085,0x00000087, - 0x0004003d,0x00000013,0x00000089,0x00000073,0x000500bc,0x0000001e,0x0000008a,0x00000089, - 0x0000004f,0x000500a7,0x0000001e,0x0000008b,0x00000088,0x0000008a,0x000300f7,0x0000008d, - 0x00000000,0x000400fa,0x0000008b,0x0000008c,0x0000008d,0x000200f8,0x0000008c,0x00050041, - 0x00000072,0x00000090,0x0000002a,0x0000005a,0x0004003d,0x00000013,0x00000091,0x00000090, - 0x00050085,0x00000013,0x00000093,0x00000091,0x00000092,0x00050083,0x00000013,0x00000094, - 0x00000093,0x0000004f,0x00050041,0x00000072,0x00000096,0x0000002a,0x00000095,0x0004003d, - 0x00000013,0x00000097,0x00000096,0x00050085,0x00000013,0x00000098,0x00000097,0x00000092, - 0x00050083,0x00000013,0x00000099,0x0000004f,0x00000098,0x0004003d,0x00000013,0x0000009a, - 0x00000073,0x00050085,0x00000013,0x0000009b,0x0000009a,0x00000092,0x00050083,0x00000013, - 0x0000009c,0x0000009b,0x0000004f,0x00070050,0x00000014,0x0000009d,0x00000094,0x00000099, - 0x0000009c,0x0000004f,0x0003003e,0x0000008f,0x0000009d,0x00050041,0x0000009f,0x000000a0, - 0x00000019,0x00000038,0x0004003d,0x00000015,0x000000a1,0x000000a0,0x0004003d,0x00000014, - 0x000000a2,0x0000008f,0x00050091,0x00000014,0x000000a3,0x000000a1,0x000000a2,0x0003003e, - 0x0000009e,0x000000a3,0x00050041,0x00000072,0x000000a5,0x0000009e,0x000000a4,0x0004003d, - 0x00000013,0x000000a6,0x000000a5,0x000500ba,0x0000001e,0x000000a8,0x000000a6,0x000000a7, - 0x000300f7,0x000000aa,0x00000000,0x000400fa,0x000000a8,0x000000a9,0x000000aa,0x000200f8, - 0x000000a9,0x0004003d,0x00000014,0x000000ac,0x0000009e,0x0007004f,0x00000016,0x000000ad, - 0x000000ac,0x000000ac,0x00000000,0x00000001,0x00050041,0x00000072,0x000000ae,0x0000009e, - 0x000000a4,0x0004003d,0x00000013,0x000000af,0x000000ae,0x00050050,0x00000016,0x000000b0, - 0x000000af,0x000000af,0x00050088,0x00000016,0x000000b1,0x000000ad,0x000000b0,0x0003003e, - 0x000000ab,0x000000b1,0x0004003d,0x00000014,0x000000b3,0x0000008f,0x0007004f,0x00000016, - 0x000000b4,0x000000b3,0x000000b3,0x00000000,0x00000001,0x00050041,0x000000b5,0x000000b6, - 0x00000019,0x00000083,0x0004003d,0x00000016,0x000000b7,0x000000b6,0x00050083,0x00000016, - 0x000000b8,0x000000b4,0x000000b7,0x0003003e,0x000000b2,0x000000b8,0x00050041,0x00000072, - 0x000000ba,0x000000ab,0x0000005a,0x0004003d,0x00000013,0x000000bb,0x000000ba,0x00050041, - 0x00000072,0x000000bc,0x000000b2,0x0000005a,0x0004003d,0x00000013,0x000000bd,0x000000bc, - 0x00050083,0x00000013,0x000000be,0x000000bb,0x000000bd,0x00050041,0x00000072,0x000000bf, - 0x000000b2,0x00000095,0x0004003d,0x00000013,0x000000c0,0x000000bf,0x00050041,0x00000072, - 0x000000c1,0x000000ab,0x00000095,0x0004003d,0x00000013,0x000000c2,0x000000c1,0x00050083, - 0x00000013,0x000000c3,0x000000c0,0x000000c2,0x00050050,0x00000016,0x000000c4,0x000000be, - 0x000000c3,0x0005008e,0x00000016,0x000000c5,0x000000c4,0x0000002d,0x0004003d,0x00000016, - 0x000000c6,0x00000026,0x00050085,0x00000016,0x000000c7,0x000000c5,0x000000c6,0x0003003e, - 0x000000b9,0x000000c7,0x0004003d,0x00000016,0x000000c8,0x000000b9,0x0006000c,0x00000016, - 0x000000c9,0x00000001,0x00000004,0x000000c8,0x000500b8,0x0000001f,0x000000cc,0x000000c9, - 0x000000cb,0x0004009b,0x0000001e,0x000000cd,0x000000cc,0x000300f7,0x000000cf,0x00000000, - 0x000400fa,0x000000cd,0x000000ce,0x000000cf,0x000200f8,0x000000ce,0x0004003d,0x00000016, - 0x000000d0,0x000000b9,0x0003003e,0x0000007f,0x000000d0,0x000200f9,0x000000cf,0x000200f8, - 0x000000cf,0x000200f9,0x000000aa,0x000200f8,0x000000aa,0x000200f9,0x0000008d,0x000200f8, - 0x0000008d,0x0004003d,0x0000003d,0x000000d1,0x0000003f,0x0004003d,0x00000007,0x000000d2, - 0x00000009,0x0004003d,0x00000016,0x000000d3,0x0000007f,0x00050051,0x00000013,0x000000d4, - 0x000000d3,0x00000000,0x00050051,0x00000013,0x000000d5,0x000000d3,0x00000001,0x00070050, - 0x00000014,0x000000d6,0x000000d4,0x000000d5,0x0000004e,0x0000004e,0x00040063,0x000000d1, - 0x000000d2,0x000000d6,0x00050041,0x00000033,0x000000d7,0x00000019,0x00000032,0x0004003d, - 0x00000006,0x000000d8,0x000000d7,0x000500c7,0x00000006,0x000000d9,0x000000d8,0x0000001a, - 0x000500ab,0x0000001e,0x000000da,0x000000d9,0x00000038,0x000300f7,0x000000dc,0x00000000, - 0x000400fa,0x000000da,0x000000db,0x000000dc,0x000200f8,0x000000db,0x0004003d,0x00000044, - 0x000000dd,0x00000046,0x0004003d,0x00000007,0x000000de,0x00000009,0x0004003d,0x00000016, - 0x000000df,0x0000007f,0x0006000c,0x00000016,0x000000e0,0x00000001,0x00000004,0x000000df, - 0x00050050,0x00000016,0x000000e1,0x0000004b,0x0000004b,0x00050088,0x00000016,0x000000e2, - 0x000000e0,0x000000e1,0x00050050,0x00000016,0x000000e3,0x0000004e,0x0000004e,0x00050050, - 0x00000016,0x000000e4,0x0000004f,0x0000004f,0x0008000c,0x00000016,0x000000e5,0x00000001, - 0x0000002b,0x000000e2,0x000000e3,0x000000e4,0x0004003d,0x00000013,0x000000e6,0x00000073, - 0x00050051,0x00000013,0x000000e7,0x000000e5,0x00000000,0x00050051,0x00000013,0x000000e8, - 0x000000e5,0x00000001,0x00070050,0x00000014,0x000000e9,0x000000e7,0x000000e8,0x000000e6, - 0x0000004f,0x00040063,0x000000dd,0x000000de,0x000000e9,0x000200f9,0x000000dc,0x000200f8, - 0x000000dc,0x000100fd,0x00010038 + 0x00000025,0x0000003c,0x00000007,0x0004003b,0x0000004c,0x0000004d,0x00000007,0x0004003b, + 0x0000004c,0x00000054,0x00000007,0x0004003b,0x0000004c,0x0000008f,0x00000007,0x0004003b, + 0x0000004c,0x0000009c,0x00000007,0x0004003b,0x0000004f,0x000000af,0x00000007,0x0004003b, + 0x00000025,0x000000bb,0x00000007,0x0004003b,0x000000ca,0x000000cb,0x00000007,0x0004003b, + 0x000000ca,0x000000d9,0x00000007,0x0004003b,0x00000025,0x000000e6,0x00000007,0x0004003b, + 0x00000025,0x000000ed,0x00000007,0x0004003b,0x00000025,0x000000f4,0x00000007,0x0004003d, + 0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f, + 0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009, + 0x00000011,0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041,0x0000001b,0x0000001c, + 0x00000019,0x0000001a,0x0004003d,0x00000007,0x0000001d,0x0000001c,0x000500af,0x0000001f, + 0x00000020,0x00000012,0x0000001d,0x0004009a,0x0000001e,0x00000021,0x00000020,0x000300f7, + 0x00000023,0x00000000,0x000400fa,0x00000021,0x00000022,0x00000023,0x000200f8,0x00000022, + 0x000100fd,0x000200f8,0x00000023,0x00050041,0x0000001b,0x00000027,0x00000019,0x0000001a, + 0x0004003d,0x00000007,0x00000028,0x00000027,0x0004006f,0x00000016,0x00000029,0x00000028, + 0x0003003e,0x00000026,0x00000029,0x0004003d,0x00000007,0x0000002b,0x00000009,0x0004006f, + 0x00000016,0x0000002c,0x0000002b,0x00050050,0x00000016,0x0000002e,0x0000002d,0x0000002d, + 0x00050081,0x00000016,0x0000002f,0x0000002c,0x0000002e,0x0004003d,0x00000016,0x00000030, + 0x00000026,0x00050088,0x00000016,0x00000031,0x0000002f,0x00000030,0x0003003e,0x0000002a, + 0x00000031,0x00050041,0x00000033,0x00000034,0x00000019,0x00000032,0x0004003d,0x00000006, + 0x00000035,0x00000034,0x000500c7,0x00000006,0x00000037,0x00000035,0x00000036,0x000500ab, + 0x0000001e,0x00000039,0x00000037,0x00000038,0x000300f7,0x0000003b,0x00000000,0x000400fa, + 0x00000039,0x0000003a,0x0000003b,0x000200f8,0x0000003a,0x0004003d,0x0000003d,0x00000040, + 0x0000003f,0x0004003d,0x00000007,0x00000041,0x00000009,0x00050062,0x00000014,0x00000042, + 0x00000040,0x00000041,0x0007004f,0x00000016,0x00000043,0x00000042,0x00000042,0x00000000, + 0x00000001,0x0003003e,0x0000003c,0x00000043,0x00050041,0x00000033,0x00000044,0x00000019, + 0x00000032,0x0004003d,0x00000006,0x00000045,0x00000044,0x000500c7,0x00000006,0x00000047, + 0x00000045,0x00000046,0x000500ab,0x0000001e,0x00000048,0x00000047,0x00000038,0x000300f7, + 0x0000004a,0x00000000,0x000400fa,0x00000048,0x00000049,0x0000004a,0x000200f8,0x00000049, + 0x00050041,0x0000004f,0x00000050,0x0000003c,0x0000004e,0x0004003d,0x00000013,0x00000051, + 0x00000050,0x000500b8,0x0000001e,0x00000053,0x00000051,0x00000052,0x000300f7,0x00000056, + 0x00000000,0x000400fa,0x00000053,0x00000055,0x00000067,0x000200f8,0x00000055,0x00050041, + 0x0000004f,0x0000005f,0x0000003c,0x0000005e,0x0004003d,0x00000013,0x00000060,0x0000005f, + 0x00050088,0x00000013,0x00000062,0x00000060,0x00000061,0x0008000c,0x00000013,0x00000064, + 0x00000001,0x0000002b,0x00000062,0x00000063,0x0000005c,0x00060050,0x0000004b,0x00000065, + 0x00000064,0x00000064,0x00000064,0x0008000c,0x0000004b,0x00000066,0x00000001,0x0000002e, + 0x0000005a,0x0000005d,0x00000065,0x0003003e,0x00000054,0x00000066,0x000200f9,0x00000056, + 0x000200f8,0x00000067,0x0003003e,0x00000054,0x00000069,0x000200f9,0x00000056,0x000200f8, + 0x00000056,0x0004003d,0x0000004b,0x0000006a,0x00000054,0x0003003e,0x0000004d,0x0000006a, + 0x0004003d,0x0000006b,0x0000006e,0x0000006d,0x0004003d,0x00000007,0x0000006f,0x00000009, + 0x0004003d,0x0000004b,0x00000070,0x0000004d,0x00050051,0x00000013,0x00000071,0x00000070, + 0x00000000,0x00050051,0x00000013,0x00000072,0x00000070,0x00000001,0x00050051,0x00000013, + 0x00000073,0x00000070,0x00000002,0x00070050,0x00000014,0x00000074,0x00000071,0x00000072, + 0x00000073,0x0000005c,0x00040063,0x0000006e,0x0000006f,0x00000074,0x0004003d,0x0000003d, + 0x00000075,0x0000003f,0x0004003d,0x00000007,0x00000076,0x00000009,0x00040063,0x00000075, + 0x00000076,0x00000077,0x000100fd,0x000200f8,0x0000004a,0x0004003d,0x0000006b,0x00000079, + 0x0000006d,0x0004003d,0x00000007,0x0000007a,0x00000009,0x0004003d,0x00000016,0x0000007b, + 0x0000003c,0x0006000c,0x00000016,0x0000007c,0x00000001,0x00000004,0x0000007b,0x00050050, + 0x00000016,0x0000007e,0x0000007d,0x0000007d,0x00050088,0x00000016,0x0000007f,0x0000007c, + 0x0000007e,0x00050050,0x00000016,0x00000080,0x00000063,0x00000063,0x00050050,0x00000016, + 0x00000081,0x0000005c,0x0000005c,0x0008000c,0x00000016,0x00000082,0x00000001,0x0000002b, + 0x0000007f,0x00000080,0x00000081,0x0004003d,0x00000084,0x00000087,0x00000086,0x0004003d, + 0x00000016,0x00000088,0x0000002a,0x00070058,0x00000014,0x00000089,0x00000087,0x00000088, + 0x00000002,0x00000063,0x00050051,0x00000013,0x0000008a,0x00000089,0x00000000,0x00050051, + 0x00000013,0x0000008b,0x00000082,0x00000000,0x00050051,0x00000013,0x0000008c,0x00000082, + 0x00000001,0x00070050,0x00000014,0x0000008d,0x0000008b,0x0000008c,0x0000008a,0x0000005c, + 0x00040063,0x00000079,0x0000007a,0x0000008d,0x000100fd,0x000200f8,0x0000003b,0x0004003d, + 0x00000084,0x00000091,0x00000090,0x0004003d,0x00000016,0x00000092,0x0000002a,0x00070058, + 0x00000014,0x00000093,0x00000091,0x00000092,0x00000002,0x00000063,0x0008004f,0x0000004b, + 0x00000094,0x00000093,0x00000093,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000008f, + 0x00000094,0x0004003d,0x0000006b,0x00000095,0x0000006d,0x0004003d,0x00000007,0x00000096, + 0x00000009,0x00050041,0x00000033,0x00000097,0x00000019,0x00000032,0x0004003d,0x00000006, + 0x00000098,0x00000097,0x000500c7,0x00000006,0x0000009a,0x00000098,0x00000099,0x000500ab, + 0x0000001e,0x0000009b,0x0000009a,0x00000038,0x000300f7,0x0000009e,0x00000000,0x000400fa, + 0x0000009b,0x0000009d,0x000000a5,0x000200f8,0x0000009d,0x0004003d,0x0000004b,0x0000009f, + 0x0000008f,0x0007000c,0x0000004b,0x000000a1,0x00000001,0x00000028,0x0000009f,0x000000a0, + 0x0007000c,0x0000004b,0x000000a4,0x00000001,0x00000025,0x000000a1,0x000000a3,0x0003003e, + 0x0000009c,0x000000a4,0x000200f9,0x0000009e,0x000200f8,0x000000a5,0x0004003d,0x0000004b, + 0x000000a6,0x0000008f,0x00060050,0x0000004b,0x000000a7,0x00000063,0x00000063,0x00000063, + 0x00060050,0x0000004b,0x000000a8,0x0000005c,0x0000005c,0x0000005c,0x0008000c,0x0000004b, + 0x000000a9,0x00000001,0x0000002b,0x000000a6,0x000000a7,0x000000a8,0x0003003e,0x0000009c, + 0x000000a9,0x000200f9,0x0000009e,0x000200f8,0x0000009e,0x0004003d,0x0000004b,0x000000aa, + 0x0000009c,0x00050051,0x00000013,0x000000ab,0x000000aa,0x00000000,0x00050051,0x00000013, + 0x000000ac,0x000000aa,0x00000001,0x00050051,0x00000013,0x000000ad,0x000000aa,0x00000002, + 0x00070050,0x00000014,0x000000ae,0x000000ab,0x000000ac,0x000000ad,0x0000005c,0x00040063, + 0x00000095,0x00000096,0x000000ae,0x0004003d,0x00000084,0x000000b0,0x00000086,0x0004003d, + 0x00000016,0x000000b1,0x0000002a,0x00070058,0x00000014,0x000000b2,0x000000b0,0x000000b1, + 0x00000002,0x00000063,0x00050051,0x00000013,0x000000b3,0x000000b2,0x00000000,0x0003003e, + 0x000000af,0x000000b3,0x0004003d,0x000000b4,0x000000b7,0x000000b6,0x0004003d,0x00000007, + 0x000000b8,0x00000009,0x0004003d,0x00000013,0x000000b9,0x000000af,0x00070050,0x00000014, + 0x000000ba,0x000000b9,0x000000b9,0x000000b9,0x000000b9,0x00040063,0x000000b7,0x000000b8, + 0x000000ba,0x0003003e,0x000000bb,0x000000bc,0x00050041,0x00000033,0x000000bd,0x00000019, + 0x00000032,0x0004003d,0x00000006,0x000000be,0x000000bd,0x000500c7,0x00000006,0x000000c0, + 0x000000be,0x000000bf,0x000500ab,0x0000001e,0x000000c1,0x000000c0,0x00000038,0x0004003d, + 0x00000013,0x000000c2,0x000000af,0x000500be,0x0000001e,0x000000c3,0x000000c2,0x00000063, + 0x000500a7,0x0000001e,0x000000c4,0x000000c1,0x000000c3,0x0004003d,0x00000013,0x000000c5, + 0x000000af,0x000500bc,0x0000001e,0x000000c6,0x000000c5,0x0000005c,0x000500a7,0x0000001e, + 0x000000c7,0x000000c4,0x000000c6,0x000300f7,0x000000c9,0x00000000,0x000400fa,0x000000c7, + 0x000000c8,0x000000c9,0x000200f8,0x000000c8,0x00050041,0x0000004f,0x000000cc,0x0000002a, + 0x0000004e,0x0004003d,0x00000013,0x000000cd,0x000000cc,0x00050085,0x00000013,0x000000cf, + 0x000000cd,0x000000ce,0x00050083,0x00000013,0x000000d0,0x000000cf,0x0000005c,0x00050041, + 0x0000004f,0x000000d1,0x0000002a,0x0000005e,0x0004003d,0x00000013,0x000000d2,0x000000d1, + 0x00050085,0x00000013,0x000000d3,0x000000d2,0x000000ce,0x00050083,0x00000013,0x000000d4, + 0x0000005c,0x000000d3,0x0004003d,0x00000013,0x000000d5,0x000000af,0x00050085,0x00000013, + 0x000000d6,0x000000d5,0x000000ce,0x00050083,0x00000013,0x000000d7,0x000000d6,0x0000005c, + 0x00070050,0x00000014,0x000000d8,0x000000d0,0x000000d4,0x000000d7,0x0000005c,0x0003003e, + 0x000000cb,0x000000d8,0x00050041,0x000000da,0x000000db,0x00000019,0x00000038,0x0004003d, + 0x00000015,0x000000dc,0x000000db,0x0004003d,0x00000014,0x000000dd,0x000000cb,0x00050091, + 0x00000014,0x000000de,0x000000dc,0x000000dd,0x0003003e,0x000000d9,0x000000de,0x00050041, + 0x0000004f,0x000000e0,0x000000d9,0x000000df,0x0004003d,0x00000013,0x000000e1,0x000000e0, + 0x000500ba,0x0000001e,0x000000e3,0x000000e1,0x000000e2,0x000300f7,0x000000e5,0x00000000, + 0x000400fa,0x000000e3,0x000000e4,0x000000e5,0x000200f8,0x000000e4,0x0004003d,0x00000014, + 0x000000e7,0x000000d9,0x0007004f,0x00000016,0x000000e8,0x000000e7,0x000000e7,0x00000000, + 0x00000001,0x00050041,0x0000004f,0x000000e9,0x000000d9,0x000000df,0x0004003d,0x00000013, + 0x000000ea,0x000000e9,0x00050050,0x00000016,0x000000eb,0x000000ea,0x000000ea,0x00050088, + 0x00000016,0x000000ec,0x000000e8,0x000000eb,0x0003003e,0x000000e6,0x000000ec,0x0004003d, + 0x00000014,0x000000ee,0x000000cb,0x0007004f,0x00000016,0x000000ef,0x000000ee,0x000000ee, + 0x00000000,0x00000001,0x00050041,0x000000f0,0x000000f1,0x00000019,0x000000bf,0x0004003d, + 0x00000016,0x000000f2,0x000000f1,0x00050083,0x00000016,0x000000f3,0x000000ef,0x000000f2, + 0x0003003e,0x000000ed,0x000000f3,0x00050041,0x0000004f,0x000000f5,0x000000e6,0x0000004e, + 0x0004003d,0x00000013,0x000000f6,0x000000f5,0x00050041,0x0000004f,0x000000f7,0x000000ed, + 0x0000004e,0x0004003d,0x00000013,0x000000f8,0x000000f7,0x00050083,0x00000013,0x000000f9, + 0x000000f6,0x000000f8,0x00050041,0x0000004f,0x000000fa,0x000000ed,0x0000005e,0x0004003d, + 0x00000013,0x000000fb,0x000000fa,0x00050041,0x0000004f,0x000000fc,0x000000e6,0x0000005e, + 0x0004003d,0x00000013,0x000000fd,0x000000fc,0x00050083,0x00000013,0x000000fe,0x000000fb, + 0x000000fd,0x00050050,0x00000016,0x000000ff,0x000000f9,0x000000fe,0x0005008e,0x00000016, + 0x00000100,0x000000ff,0x0000002d,0x0004003d,0x00000016,0x00000101,0x00000026,0x00050085, + 0x00000016,0x00000102,0x00000100,0x00000101,0x0003003e,0x000000f4,0x00000102,0x0004003d, + 0x00000016,0x00000103,0x000000f4,0x0006000c,0x00000016,0x00000104,0x00000001,0x00000004, + 0x00000103,0x000500b8,0x0000001f,0x00000107,0x00000104,0x00000106,0x0004009b,0x0000001e, + 0x00000108,0x00000107,0x000300f7,0x0000010a,0x00000000,0x000400fa,0x00000108,0x00000109, + 0x0000010a,0x000200f8,0x00000109,0x0004003d,0x00000016,0x0000010b,0x000000f4,0x0003003e, + 0x000000bb,0x0000010b,0x000200f9,0x0000010a,0x000200f8,0x0000010a,0x000200f9,0x000000e5, + 0x000200f8,0x000000e5,0x000200f9,0x000000c9,0x000200f8,0x000000c9,0x0004003d,0x0000003d, + 0x0000010c,0x0000003f,0x0004003d,0x00000007,0x0000010d,0x00000009,0x0004003d,0x00000016, + 0x0000010e,0x000000bb,0x00050051,0x00000013,0x0000010f,0x0000010e,0x00000000,0x00050051, + 0x00000013,0x00000110,0x0000010e,0x00000001,0x00070050,0x00000014,0x00000111,0x0000010f, + 0x00000110,0x00000063,0x00000063,0x00040063,0x0000010c,0x0000010d,0x00000111,0x00050041, + 0x00000033,0x00000112,0x00000019,0x00000032,0x0004003d,0x00000006,0x00000113,0x00000112, + 0x000500c7,0x00000006,0x00000114,0x00000113,0x0000001a,0x000500ab,0x0000001e,0x00000115, + 0x00000114,0x00000038,0x000300f7,0x00000117,0x00000000,0x000400fa,0x00000115,0x00000116, + 0x00000117,0x000200f8,0x00000116,0x0004003d,0x0000006b,0x00000118,0x0000006d,0x0004003d, + 0x00000007,0x00000119,0x00000009,0x0004003d,0x00000016,0x0000011a,0x000000bb,0x0006000c, + 0x00000016,0x0000011b,0x00000001,0x00000004,0x0000011a,0x00050050,0x00000016,0x0000011c, + 0x0000007d,0x0000007d,0x00050088,0x00000016,0x0000011d,0x0000011b,0x0000011c,0x00050050, + 0x00000016,0x0000011e,0x00000063,0x00000063,0x00050050,0x00000016,0x0000011f,0x0000005c, + 0x0000005c,0x0008000c,0x00000016,0x00000120,0x00000001,0x0000002b,0x0000011d,0x0000011e, + 0x0000011f,0x0004003d,0x00000013,0x00000121,0x000000af,0x00050051,0x00000013,0x00000122, + 0x00000120,0x00000000,0x00050051,0x00000013,0x00000123,0x00000120,0x00000001,0x00070050, + 0x00000014,0x00000124,0x00000122,0x00000123,0x00000121,0x0000005c,0x00040063,0x00000118, + 0x00000119,0x00000124,0x000200f9,0x00000117,0x000200f8,0x00000117,0x000100fd,0x00010038 }; diff --git a/gpu/vk/shaders/dlss_prep_hdr_comp_spv.h b/gpu/vk/shaders/dlss_prep_hdr_comp_spv.h new file mode 100644 index 0000000..edb314a --- /dev/null +++ b/gpu/vk/shaders/dlss_prep_hdr_comp_spv.h @@ -0,0 +1,209 @@ + // 1116.6.0 + #pragma once +const uint32_t DLSS_PREP_HDR_COMP_SPV[] = { + 0x07230203,0x00010600,0x0008000b,0x0000011a,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000031,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x000c000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d, + 0x00000019,0x0000003f,0x0000006d,0x00000086,0x00000090,0x000000a9,0x00060010,0x00000004, + 0x00000011,0x00000008,0x00000008,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d, + 0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000017, + 0x00000050,0x00060006,0x00000017,0x00000000,0x72706572,0x63656a6f,0x00000074,0x00050006, + 0x00000017,0x00000001,0x7474696a,0x00007265,0x00050006,0x00000017,0x00000002,0x657a6973, + 0x00000000,0x00050006,0x00000017,0x00000003,0x67616c66,0x00000073,0x00030005,0x00000019, + 0x00006370,0x00040005,0x00000026,0x657a6973,0x00000000,0x00030005,0x0000002a,0x00007675, + 0x00030005,0x0000003c,0x0000006d,0x00040005,0x0000003f,0x69746f6d,0x00006e6f,0x00030005, + 0x0000004d,0x00000063,0x00040005,0x0000006d,0x6f6c6f63,0x00000072,0x00050005,0x00000086, + 0x6e656373,0x65645f65,0x00687470,0x00030005,0x0000008f,0x00000063,0x00040005,0x00000090, + 0x6e656373,0x00000065,0x00040005,0x00000095,0x746f6f72,0x00000000,0x00030005,0x000000a2, + 0x00000064,0x00040005,0x000000a9,0x74706564,0x00000068,0x00030005,0x000000ae,0x0000766d, + 0x00040005,0x000000be,0x70696c63,0x00000000,0x00040005,0x000000cc,0x6f666562,0x00006572, + 0x00040005,0x000000d9,0x6e656874,0x00000000,0x00030005,0x000000e0,0x00776f6e,0x00030005, + 0x000000e7,0x00007870,0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00030047,0x00000017, + 0x00000002,0x00040048,0x00000017,0x00000000,0x00000004,0x00050048,0x00000017,0x00000000, + 0x00000007,0x00000010,0x00050048,0x00000017,0x00000000,0x00000023,0x00000000,0x00050048, + 0x00000017,0x00000001,0x00000023,0x00000040,0x00050048,0x00000017,0x00000002,0x00000023, + 0x00000048,0x00050048,0x00000017,0x00000003,0x00000023,0x00000050,0x00040047,0x0000003f, + 0x00000021,0x00000004,0x00040047,0x0000003f,0x00000022,0x00000000,0x00030047,0x0000006d, + 0x00000019,0x00040047,0x0000006d,0x00000021,0x00000002,0x00040047,0x0000006d,0x00000022, + 0x00000000,0x00040047,0x00000086,0x00000021,0x00000001,0x00040047,0x00000086,0x00000022, + 0x00000000,0x00040047,0x00000090,0x00000021,0x00000000,0x00040047,0x00000090,0x00000022, + 0x00000000,0x00030047,0x000000a9,0x00000019,0x00040047,0x000000a9,0x00000021,0x00000003, + 0x00040047,0x000000a9,0x00000022,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003, + 0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007,0x00000006, + 0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040015,0x0000000a,0x00000020, + 0x00000000,0x00040017,0x0000000b,0x0000000a,0x00000003,0x00040020,0x0000000c,0x00000001, + 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040017,0x0000000e,0x0000000a, + 0x00000002,0x00030016,0x00000013,0x00000020,0x00040017,0x00000014,0x00000013,0x00000004, + 0x00040018,0x00000015,0x00000014,0x00000004,0x00040017,0x00000016,0x00000013,0x00000002, + 0x0006001e,0x00000017,0x00000015,0x00000016,0x00000007,0x00000006,0x00040020,0x00000018, + 0x00000009,0x00000017,0x0004003b,0x00000018,0x00000019,0x00000009,0x0004002b,0x00000006, + 0x0000001a,0x00000002,0x00040020,0x0000001b,0x00000009,0x00000007,0x00020014,0x0000001e, + 0x00040017,0x0000001f,0x0000001e,0x00000002,0x00040020,0x00000025,0x00000007,0x00000016, + 0x0004002b,0x00000013,0x0000002d,0x3f000000,0x0004002b,0x00000006,0x00000032,0x00000003, + 0x00040020,0x00000033,0x00000009,0x00000006,0x0004002b,0x00000006,0x00000036,0x00000004, + 0x0004002b,0x00000006,0x00000038,0x00000000,0x00090019,0x0000003d,0x00000013,0x00000001, + 0x00000000,0x00000000,0x00000000,0x00000002,0x00000007,0x00040020,0x0000003e,0x00000000, + 0x0000003d,0x0004003b,0x0000003e,0x0000003f,0x00000000,0x0004002b,0x00000006,0x00000046, + 0x00000008,0x00040017,0x0000004b,0x00000013,0x00000003,0x00040020,0x0000004c,0x00000007, + 0x0000004b,0x0004002b,0x0000000a,0x0000004e,0x00000000,0x00040020,0x0000004f,0x00000007, + 0x00000013,0x0004002b,0x00000013,0x00000052,0xc69c4000,0x0004002b,0x00000013,0x00000057, + 0x3ca3d70a,0x0004002b,0x00000013,0x00000058,0x3dcccccd,0x0004002b,0x00000013,0x00000059, + 0x3ee66666,0x0006002c,0x0000004b,0x0000005a,0x00000057,0x00000058,0x00000059,0x0004002b, + 0x00000013,0x0000005b,0x3e19999a,0x0004002b,0x00000013,0x0000005c,0x3f800000,0x0006002c, + 0x0000004b,0x0000005d,0x0000005b,0x00000059,0x0000005c,0x0004002b,0x0000000a,0x0000005e, + 0x00000001,0x0004002b,0x00000013,0x00000061,0x41000000,0x0004002b,0x00000013,0x00000063, + 0x00000000,0x0004002b,0x00000013,0x00000068,0x3e3851ec,0x0006002c,0x0000004b,0x00000069, + 0x00000068,0x00000068,0x00000068,0x00090019,0x0000006b,0x00000013,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000002,0x00000002,0x00040020,0x0000006c,0x00000000,0x0000006b, + 0x0004003b,0x0000006c,0x0000006d,0x00000000,0x0007002c,0x00000014,0x00000077,0x00000063, + 0x00000063,0x00000063,0x00000063,0x0004002b,0x00000013,0x0000007d,0x41800000,0x00090019, + 0x00000083,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x00000084,0x00000083,0x00040020,0x00000085,0x00000000,0x00000084,0x0004003b, + 0x00000085,0x00000086,0x00000000,0x0004003b,0x00000085,0x00000090,0x00000000,0x0006002c, + 0x0000004b,0x00000097,0x00000063,0x00000063,0x00000063,0x00090019,0x000000a7,0x00000013, + 0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000003,0x00040020,0x000000a8, + 0x00000000,0x000000a7,0x0004003b,0x000000a8,0x000000a9,0x00000000,0x0005002c,0x00000016, + 0x000000af,0x00000063,0x00000063,0x0004002b,0x00000006,0x000000b2,0x00000001,0x00040020, + 0x000000bd,0x00000007,0x00000014,0x0004002b,0x00000013,0x000000c1,0x40000000,0x00040020, + 0x000000cd,0x00000009,0x00000015,0x0004002b,0x0000000a,0x000000d2,0x00000003,0x0004002b, + 0x00000013,0x000000d5,0x358637bd,0x00040020,0x000000e3,0x00000009,0x00000016,0x0004002b, + 0x00000013,0x000000f8,0x46800000,0x0005002c,0x00000016,0x000000f9,0x000000f8,0x000000f8, + 0x0004002b,0x0000000a,0x00000118,0x00000008,0x0006002c,0x0000000b,0x00000119,0x00000118, + 0x00000118,0x0000005e,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, + 0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000025,0x00000026, + 0x00000007,0x0004003b,0x00000025,0x0000002a,0x00000007,0x0004003b,0x00000025,0x0000003c, + 0x00000007,0x0004003b,0x0000004c,0x0000004d,0x00000007,0x0004003b,0x0000004c,0x00000054, + 0x00000007,0x0004003b,0x0000004c,0x0000008f,0x00000007,0x0004003b,0x0000004c,0x00000095, + 0x00000007,0x0004003b,0x0000004f,0x000000a2,0x00000007,0x0004003b,0x00000025,0x000000ae, + 0x00000007,0x0004003b,0x000000bd,0x000000be,0x00000007,0x0004003b,0x000000bd,0x000000cc, + 0x00000007,0x0004003b,0x00000025,0x000000d9,0x00000007,0x0004003b,0x00000025,0x000000e0, + 0x00000007,0x0004003b,0x00000025,0x000000e7,0x00000007,0x0004003d,0x0000000b,0x0000000f, + 0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001, + 0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d, + 0x00000007,0x00000012,0x00000009,0x00050041,0x0000001b,0x0000001c,0x00000019,0x0000001a, + 0x0004003d,0x00000007,0x0000001d,0x0000001c,0x000500af,0x0000001f,0x00000020,0x00000012, + 0x0000001d,0x0004009a,0x0000001e,0x00000021,0x00000020,0x000300f7,0x00000023,0x00000000, + 0x000400fa,0x00000021,0x00000022,0x00000023,0x000200f8,0x00000022,0x000100fd,0x000200f8, + 0x00000023,0x00050041,0x0000001b,0x00000027,0x00000019,0x0000001a,0x0004003d,0x00000007, + 0x00000028,0x00000027,0x0004006f,0x00000016,0x00000029,0x00000028,0x0003003e,0x00000026, + 0x00000029,0x0004003d,0x00000007,0x0000002b,0x00000009,0x0004006f,0x00000016,0x0000002c, + 0x0000002b,0x00050050,0x00000016,0x0000002e,0x0000002d,0x0000002d,0x00050081,0x00000016, + 0x0000002f,0x0000002c,0x0000002e,0x0004003d,0x00000016,0x00000030,0x00000026,0x00050088, + 0x00000016,0x00000031,0x0000002f,0x00000030,0x0003003e,0x0000002a,0x00000031,0x00050041, + 0x00000033,0x00000034,0x00000019,0x00000032,0x0004003d,0x00000006,0x00000035,0x00000034, + 0x000500c7,0x00000006,0x00000037,0x00000035,0x00000036,0x000500ab,0x0000001e,0x00000039, + 0x00000037,0x00000038,0x000300f7,0x0000003b,0x00000000,0x000400fa,0x00000039,0x0000003a, + 0x0000003b,0x000200f8,0x0000003a,0x0004003d,0x0000003d,0x00000040,0x0000003f,0x0004003d, + 0x00000007,0x00000041,0x00000009,0x00050062,0x00000014,0x00000042,0x00000040,0x00000041, + 0x0007004f,0x00000016,0x00000043,0x00000042,0x00000042,0x00000000,0x00000001,0x0003003e, + 0x0000003c,0x00000043,0x00050041,0x00000033,0x00000044,0x00000019,0x00000032,0x0004003d, + 0x00000006,0x00000045,0x00000044,0x000500c7,0x00000006,0x00000047,0x00000045,0x00000046, + 0x000500ab,0x0000001e,0x00000048,0x00000047,0x00000038,0x000300f7,0x0000004a,0x00000000, + 0x000400fa,0x00000048,0x00000049,0x0000004a,0x000200f8,0x00000049,0x00050041,0x0000004f, + 0x00000050,0x0000003c,0x0000004e,0x0004003d,0x00000013,0x00000051,0x00000050,0x000500b8, + 0x0000001e,0x00000053,0x00000051,0x00000052,0x000300f7,0x00000056,0x00000000,0x000400fa, + 0x00000053,0x00000055,0x00000067,0x000200f8,0x00000055,0x00050041,0x0000004f,0x0000005f, + 0x0000003c,0x0000005e,0x0004003d,0x00000013,0x00000060,0x0000005f,0x00050088,0x00000013, + 0x00000062,0x00000060,0x00000061,0x0008000c,0x00000013,0x00000064,0x00000001,0x0000002b, + 0x00000062,0x00000063,0x0000005c,0x00060050,0x0000004b,0x00000065,0x00000064,0x00000064, + 0x00000064,0x0008000c,0x0000004b,0x00000066,0x00000001,0x0000002e,0x0000005a,0x0000005d, + 0x00000065,0x0003003e,0x00000054,0x00000066,0x000200f9,0x00000056,0x000200f8,0x00000067, + 0x0003003e,0x00000054,0x00000069,0x000200f9,0x00000056,0x000200f8,0x00000056,0x0004003d, + 0x0000004b,0x0000006a,0x00000054,0x0003003e,0x0000004d,0x0000006a,0x0004003d,0x0000006b, + 0x0000006e,0x0000006d,0x0004003d,0x00000007,0x0000006f,0x00000009,0x0004003d,0x0000004b, + 0x00000070,0x0000004d,0x00050051,0x00000013,0x00000071,0x00000070,0x00000000,0x00050051, + 0x00000013,0x00000072,0x00000070,0x00000001,0x00050051,0x00000013,0x00000073,0x00000070, + 0x00000002,0x00070050,0x00000014,0x00000074,0x00000071,0x00000072,0x00000073,0x0000005c, + 0x00040063,0x0000006e,0x0000006f,0x00000074,0x0004003d,0x0000003d,0x00000075,0x0000003f, + 0x0004003d,0x00000007,0x00000076,0x00000009,0x00040063,0x00000075,0x00000076,0x00000077, + 0x000100fd,0x000200f8,0x0000004a,0x0004003d,0x0000006b,0x00000079,0x0000006d,0x0004003d, + 0x00000007,0x0000007a,0x00000009,0x0004003d,0x00000016,0x0000007b,0x0000003c,0x0006000c, + 0x00000016,0x0000007c,0x00000001,0x00000004,0x0000007b,0x00050050,0x00000016,0x0000007e, + 0x0000007d,0x0000007d,0x00050088,0x00000016,0x0000007f,0x0000007c,0x0000007e,0x00050050, + 0x00000016,0x00000080,0x00000063,0x00000063,0x00050050,0x00000016,0x00000081,0x0000005c, + 0x0000005c,0x0008000c,0x00000016,0x00000082,0x00000001,0x0000002b,0x0000007f,0x00000080, + 0x00000081,0x0004003d,0x00000084,0x00000087,0x00000086,0x0004003d,0x00000016,0x00000088, + 0x0000002a,0x00070058,0x00000014,0x00000089,0x00000087,0x00000088,0x00000002,0x00000063, + 0x00050051,0x00000013,0x0000008a,0x00000089,0x00000000,0x00050051,0x00000013,0x0000008b, + 0x00000082,0x00000000,0x00050051,0x00000013,0x0000008c,0x00000082,0x00000001,0x00070050, + 0x00000014,0x0000008d,0x0000008b,0x0000008c,0x0000008a,0x0000005c,0x00040063,0x00000079, + 0x0000007a,0x0000008d,0x000100fd,0x000200f8,0x0000003b,0x0004003d,0x00000084,0x00000091, + 0x00000090,0x0004003d,0x00000016,0x00000092,0x0000002a,0x00070058,0x00000014,0x00000093, + 0x00000091,0x00000092,0x00000002,0x00000063,0x0008004f,0x0000004b,0x00000094,0x00000093, + 0x00000093,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000008f,0x00000094,0x0004003d, + 0x0000004b,0x00000096,0x0000008f,0x0007000c,0x0000004b,0x00000098,0x00000001,0x00000028, + 0x00000096,0x00000097,0x0003003e,0x00000095,0x00000098,0x0004003d,0x0000006b,0x00000099, + 0x0000006d,0x0004003d,0x00000007,0x0000009a,0x00000009,0x0004003d,0x0000004b,0x0000009b, + 0x00000095,0x0004003d,0x0000004b,0x0000009c,0x00000095,0x00050085,0x0000004b,0x0000009d, + 0x0000009b,0x0000009c,0x00050051,0x00000013,0x0000009e,0x0000009d,0x00000000,0x00050051, + 0x00000013,0x0000009f,0x0000009d,0x00000001,0x00050051,0x00000013,0x000000a0,0x0000009d, + 0x00000002,0x00070050,0x00000014,0x000000a1,0x0000009e,0x0000009f,0x000000a0,0x0000005c, + 0x00040063,0x00000099,0x0000009a,0x000000a1,0x0004003d,0x00000084,0x000000a3,0x00000086, + 0x0004003d,0x00000016,0x000000a4,0x0000002a,0x00070058,0x00000014,0x000000a5,0x000000a3, + 0x000000a4,0x00000002,0x00000063,0x00050051,0x00000013,0x000000a6,0x000000a5,0x00000000, + 0x0003003e,0x000000a2,0x000000a6,0x0004003d,0x000000a7,0x000000aa,0x000000a9,0x0004003d, + 0x00000007,0x000000ab,0x00000009,0x0004003d,0x00000013,0x000000ac,0x000000a2,0x00070050, + 0x00000014,0x000000ad,0x000000ac,0x000000ac,0x000000ac,0x000000ac,0x00040063,0x000000aa, + 0x000000ab,0x000000ad,0x0003003e,0x000000ae,0x000000af,0x00050041,0x00000033,0x000000b0, + 0x00000019,0x00000032,0x0004003d,0x00000006,0x000000b1,0x000000b0,0x000500c7,0x00000006, + 0x000000b3,0x000000b1,0x000000b2,0x000500ab,0x0000001e,0x000000b4,0x000000b3,0x00000038, + 0x0004003d,0x00000013,0x000000b5,0x000000a2,0x000500be,0x0000001e,0x000000b6,0x000000b5, + 0x00000063,0x000500a7,0x0000001e,0x000000b7,0x000000b4,0x000000b6,0x0004003d,0x00000013, + 0x000000b8,0x000000a2,0x000500bc,0x0000001e,0x000000b9,0x000000b8,0x0000005c,0x000500a7, + 0x0000001e,0x000000ba,0x000000b7,0x000000b9,0x000300f7,0x000000bc,0x00000000,0x000400fa, + 0x000000ba,0x000000bb,0x000000bc,0x000200f8,0x000000bb,0x00050041,0x0000004f,0x000000bf, + 0x0000002a,0x0000004e,0x0004003d,0x00000013,0x000000c0,0x000000bf,0x00050085,0x00000013, + 0x000000c2,0x000000c0,0x000000c1,0x00050083,0x00000013,0x000000c3,0x000000c2,0x0000005c, + 0x00050041,0x0000004f,0x000000c4,0x0000002a,0x0000005e,0x0004003d,0x00000013,0x000000c5, + 0x000000c4,0x00050085,0x00000013,0x000000c6,0x000000c5,0x000000c1,0x00050083,0x00000013, + 0x000000c7,0x0000005c,0x000000c6,0x0004003d,0x00000013,0x000000c8,0x000000a2,0x00050085, + 0x00000013,0x000000c9,0x000000c8,0x000000c1,0x00050083,0x00000013,0x000000ca,0x000000c9, + 0x0000005c,0x00070050,0x00000014,0x000000cb,0x000000c3,0x000000c7,0x000000ca,0x0000005c, + 0x0003003e,0x000000be,0x000000cb,0x00050041,0x000000cd,0x000000ce,0x00000019,0x00000038, + 0x0004003d,0x00000015,0x000000cf,0x000000ce,0x0004003d,0x00000014,0x000000d0,0x000000be, + 0x00050091,0x00000014,0x000000d1,0x000000cf,0x000000d0,0x0003003e,0x000000cc,0x000000d1, + 0x00050041,0x0000004f,0x000000d3,0x000000cc,0x000000d2,0x0004003d,0x00000013,0x000000d4, + 0x000000d3,0x000500ba,0x0000001e,0x000000d6,0x000000d4,0x000000d5,0x000300f7,0x000000d8, + 0x00000000,0x000400fa,0x000000d6,0x000000d7,0x000000d8,0x000200f8,0x000000d7,0x0004003d, + 0x00000014,0x000000da,0x000000cc,0x0007004f,0x00000016,0x000000db,0x000000da,0x000000da, + 0x00000000,0x00000001,0x00050041,0x0000004f,0x000000dc,0x000000cc,0x000000d2,0x0004003d, + 0x00000013,0x000000dd,0x000000dc,0x00050050,0x00000016,0x000000de,0x000000dd,0x000000dd, + 0x00050088,0x00000016,0x000000df,0x000000db,0x000000de,0x0003003e,0x000000d9,0x000000df, + 0x0004003d,0x00000014,0x000000e1,0x000000be,0x0007004f,0x00000016,0x000000e2,0x000000e1, + 0x000000e1,0x00000000,0x00000001,0x00050041,0x000000e3,0x000000e4,0x00000019,0x000000b2, + 0x0004003d,0x00000016,0x000000e5,0x000000e4,0x00050083,0x00000016,0x000000e6,0x000000e2, + 0x000000e5,0x0003003e,0x000000e0,0x000000e6,0x00050041,0x0000004f,0x000000e8,0x000000d9, + 0x0000004e,0x0004003d,0x00000013,0x000000e9,0x000000e8,0x00050041,0x0000004f,0x000000ea, + 0x000000e0,0x0000004e,0x0004003d,0x00000013,0x000000eb,0x000000ea,0x00050083,0x00000013, + 0x000000ec,0x000000e9,0x000000eb,0x00050041,0x0000004f,0x000000ed,0x000000e0,0x0000005e, + 0x0004003d,0x00000013,0x000000ee,0x000000ed,0x00050041,0x0000004f,0x000000ef,0x000000d9, + 0x0000005e,0x0004003d,0x00000013,0x000000f0,0x000000ef,0x00050083,0x00000013,0x000000f1, + 0x000000ee,0x000000f0,0x00050050,0x00000016,0x000000f2,0x000000ec,0x000000f1,0x0005008e, + 0x00000016,0x000000f3,0x000000f2,0x0000002d,0x0004003d,0x00000016,0x000000f4,0x00000026, + 0x00050085,0x00000016,0x000000f5,0x000000f3,0x000000f4,0x0003003e,0x000000e7,0x000000f5, + 0x0004003d,0x00000016,0x000000f6,0x000000e7,0x0006000c,0x00000016,0x000000f7,0x00000001, + 0x00000004,0x000000f6,0x000500b8,0x0000001f,0x000000fa,0x000000f7,0x000000f9,0x0004009b, + 0x0000001e,0x000000fb,0x000000fa,0x000300f7,0x000000fd,0x00000000,0x000400fa,0x000000fb, + 0x000000fc,0x000000fd,0x000200f8,0x000000fc,0x0004003d,0x00000016,0x000000fe,0x000000e7, + 0x0003003e,0x000000ae,0x000000fe,0x000200f9,0x000000fd,0x000200f8,0x000000fd,0x000200f9, + 0x000000d8,0x000200f8,0x000000d8,0x000200f9,0x000000bc,0x000200f8,0x000000bc,0x0004003d, + 0x0000003d,0x000000ff,0x0000003f,0x0004003d,0x00000007,0x00000100,0x00000009,0x0004003d, + 0x00000016,0x00000101,0x000000ae,0x00050051,0x00000013,0x00000102,0x00000101,0x00000000, + 0x00050051,0x00000013,0x00000103,0x00000101,0x00000001,0x00070050,0x00000014,0x00000104, + 0x00000102,0x00000103,0x00000063,0x00000063,0x00040063,0x000000ff,0x00000100,0x00000104, + 0x00050041,0x00000033,0x00000105,0x00000019,0x00000032,0x0004003d,0x00000006,0x00000106, + 0x00000105,0x000500c7,0x00000006,0x00000107,0x00000106,0x0000001a,0x000500ab,0x0000001e, + 0x00000108,0x00000107,0x00000038,0x000300f7,0x0000010a,0x00000000,0x000400fa,0x00000108, + 0x00000109,0x0000010a,0x000200f8,0x00000109,0x0004003d,0x0000006b,0x0000010b,0x0000006d, + 0x0004003d,0x00000007,0x0000010c,0x00000009,0x0004003d,0x00000016,0x0000010d,0x000000ae, + 0x0006000c,0x00000016,0x0000010e,0x00000001,0x00000004,0x0000010d,0x00050050,0x00000016, + 0x0000010f,0x0000007d,0x0000007d,0x00050088,0x00000016,0x00000110,0x0000010e,0x0000010f, + 0x00050050,0x00000016,0x00000111,0x00000063,0x00000063,0x00050050,0x00000016,0x00000112, + 0x0000005c,0x0000005c,0x0008000c,0x00000016,0x00000113,0x00000001,0x0000002b,0x00000110, + 0x00000111,0x00000112,0x0004003d,0x00000013,0x00000114,0x000000a2,0x00050051,0x00000013, + 0x00000115,0x00000113,0x00000000,0x00050051,0x00000013,0x00000116,0x00000113,0x00000001, + 0x00070050,0x00000014,0x00000117,0x00000115,0x00000116,0x00000114,0x0000005c,0x00040063, + 0x0000010b,0x0000010c,0x00000117,0x000200f9,0x0000010a,0x000200f8,0x0000010a,0x000100fd, + 0x00010038 +}; diff --git a/gpu/vk/shaders/fsr3_prep.comp b/gpu/vk/shaders/fsr3_prep.comp index 0e35851..ed44db4 100644 --- a/gpu/vk/shaders/fsr3_prep.comp +++ b/gpu/vk/shaders/fsr3_prep.comp @@ -10,6 +10,8 @@ // taken back to clip space and through pc.reproject (this frame's jittered clip space to the frame before's without its // jitter: dlss_math.h). The camera's motion only, as #841's before its actor motion: what moves by itself gets the motion // of what is behind it. pc.flags bit 0: motion (none on the first frame of a history) +// pc.flags bit 2 (FSR before the game's bloom and tone mapping, vk_temporal.cpp temporal_pre_tonemap): the scene is its +// colour target itself, linear HDR light: taken as it is, nothing clamped at 1 (the passes are compiled for HDR colour). // The game's clip space: depth from -1 to 1 (NVN's default), y up, the picture's rows top down. layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D scene; @@ -30,7 +32,7 @@ void main() { const vec2 uv = (vec2(g) + 0.5) / size; vec3 c = textureLod(scene, uv, 0.0).rgb; c = mix(c, vec3(0.0), isnan(c)); - imageStore(color, g, vec4(clamp(c, 0.0, 1.0), 1.0)); + imageStore(color, g, vec4((pc.flags & 4) != 0 ? min(max(c, vec3(0.0)), vec3(64000.0)) : clamp(c, 0.0, 1.0), 1.0)); const float d = textureLod(scene_depth, uv, 0.0).r; imageStore(depth, g, vec4((pc.flags & 2) != 0 ? 1.0 - d : d)); vec2 mv = vec2(0.0); diff --git a/gpu/vk/shaders/fsr3_prep_comp_spv.h b/gpu/vk/shaders/fsr3_prep_comp_spv.h index 869e73d..4362f49 100644 --- a/gpu/vk/shaders/fsr3_prep_comp_spv.h +++ b/gpu/vk/shaders/fsr3_prep_comp_spv.h @@ -1,10 +1,10 @@ - // 1116.2.0 + // 1116.6.0 #pragma once const uint32_t FSR3_PREP_COMP_SPV[] = { - 0x07230203,0x00010600,0x0008000b,0x000000cc,0x00000000,0x00020011,0x00000001,0x00020011, + 0x07230203,0x00010600,0x0008000b,0x000000db,0x00000000,0x00020011,0x00000001,0x00020011, 0x00000031,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, 0x00000000,0x00000001,0x000c000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d, - 0x00000019,0x00000038,0x00000046,0x00000054,0x0000005c,0x000000c3,0x00060010,0x00000004, + 0x00000019,0x00000038,0x00000046,0x00000066,0x0000006e,0x000000d2,0x00060010,0x00000004, 0x00000011,0x00000008,0x00000008,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, 0x00000004,0x6e69616d,0x00000000,0x00030005,0x00000009,0x00000067,0x00080005,0x0000000d, 0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x00000017, @@ -13,11 +13,11 @@ const uint32_t FSR3_PREP_COMP_SPV[] = { 0x00000000,0x00050006,0x00000017,0x00000003,0x67616c66,0x00000073,0x00030005,0x00000019, 0x00006370,0x00040005,0x00000026,0x657a6973,0x00000000,0x00030005,0x0000002a,0x00007675, 0x00030005,0x00000034,0x00000063,0x00040005,0x00000038,0x6e656373,0x00000065,0x00040005, - 0x00000046,0x6f6c6f63,0x00000072,0x00030005,0x00000053,0x00000064,0x00050005,0x00000054, - 0x6e656373,0x65645f65,0x00687470,0x00040005,0x0000005c,0x74706564,0x00000068,0x00030005, - 0x0000006f,0x0000766d,0x00040005,0x0000007f,0x70696c63,0x00000000,0x00040005,0x0000008e, - 0x6f666562,0x00006572,0x00040005,0x0000009b,0x6e656874,0x00000000,0x00030005,0x000000a2, - 0x00776f6e,0x00030005,0x000000a9,0x00007870,0x00040005,0x000000c3,0x69746f6d,0x00006e6f, + 0x00000046,0x6f6c6f63,0x00000072,0x00030005,0x00000065,0x00000064,0x00050005,0x00000066, + 0x6e656373,0x65645f65,0x00687470,0x00040005,0x0000006e,0x74706564,0x00000068,0x00030005, + 0x0000007e,0x0000766d,0x00040005,0x0000008e,0x70696c63,0x00000000,0x00040005,0x0000009d, + 0x6f666562,0x00006572,0x00040005,0x000000aa,0x6e656874,0x00000000,0x00030005,0x000000b1, + 0x00776f6e,0x00030005,0x000000b8,0x00007870,0x00040005,0x000000d2,0x69746f6d,0x00006e6f, 0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00030047,0x00000017,0x00000002,0x00040048, 0x00000017,0x00000000,0x00000004,0x00050048,0x00000017,0x00000000,0x00000007,0x00000010, 0x00050048,0x00000017,0x00000000,0x00000023,0x00000000,0x00050048,0x00000017,0x00000001, @@ -25,10 +25,10 @@ const uint32_t FSR3_PREP_COMP_SPV[] = { 0x00000017,0x00000003,0x00000023,0x00000050,0x00040047,0x00000038,0x00000021,0x00000000, 0x00040047,0x00000038,0x00000022,0x00000000,0x00030047,0x00000046,0x00000019,0x00040047, 0x00000046,0x00000021,0x00000002,0x00040047,0x00000046,0x00000022,0x00000000,0x00040047, - 0x00000054,0x00000021,0x00000001,0x00040047,0x00000054,0x00000022,0x00000000,0x00030047, - 0x0000005c,0x00000019,0x00040047,0x0000005c,0x00000021,0x00000003,0x00040047,0x0000005c, - 0x00000022,0x00000000,0x00030047,0x000000c3,0x00000019,0x00040047,0x000000c3,0x00000021, - 0x00000004,0x00040047,0x000000c3,0x00000022,0x00000000,0x00020013,0x00000002,0x00030021, + 0x00000066,0x00000021,0x00000001,0x00040047,0x00000066,0x00000022,0x00000000,0x00030047, + 0x0000006e,0x00000019,0x00040047,0x0000006e,0x00000021,0x00000003,0x00040047,0x0000006e, + 0x00000022,0x00000000,0x00030047,0x000000d2,0x00000019,0x00040047,0x000000d2,0x00000021, + 0x00000004,0x00040047,0x000000d2,0x00000022,0x00000000,0x00020013,0x00000002,0x00030021, 0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007, 0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00040015,0x0000000a, 0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a,0x00000003,0x00040020,0x0000000c, @@ -47,111 +47,121 @@ const uint32_t FSR3_PREP_COMP_SPV[] = { 0x0000003b,0x0000003b,0x0000003b,0x00040017,0x00000041,0x0000001e,0x00000003,0x00090019, 0x00000044,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000002, 0x00040020,0x00000045,0x00000000,0x00000044,0x0004003b,0x00000045,0x00000046,0x00000000, - 0x0004002b,0x00000013,0x0000004a,0x3f800000,0x00040020,0x00000052,0x00000007,0x00000013, - 0x0004003b,0x00000037,0x00000054,0x00000000,0x0004002b,0x0000000a,0x00000058,0x00000000, - 0x00090019,0x0000005a,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002, - 0x00000003,0x00040020,0x0000005b,0x00000000,0x0000005a,0x0004003b,0x0000005b,0x0000005c, - 0x00000000,0x0004002b,0x00000006,0x0000005f,0x00000003,0x00040020,0x00000060,0x00000009, - 0x00000006,0x0004002b,0x00000006,0x00000064,0x00000000,0x0005002c,0x00000016,0x00000070, - 0x0000003b,0x0000003b,0x0004002b,0x00000006,0x00000073,0x00000001,0x00040020,0x0000007e, - 0x00000007,0x00000014,0x0004002b,0x00000013,0x00000082,0x40000000,0x0004002b,0x0000000a, - 0x00000085,0x00000001,0x00040020,0x0000008f,0x00000009,0x00000015,0x0004002b,0x0000000a, - 0x00000094,0x00000003,0x0004002b,0x00000013,0x00000097,0x358637bd,0x00040020,0x000000a5, - 0x00000009,0x00000016,0x0004002b,0x00000013,0x000000ba,0x46800000,0x0005002c,0x00000016, - 0x000000bb,0x000000ba,0x000000ba,0x00090019,0x000000c1,0x00000013,0x00000001,0x00000000, - 0x00000000,0x00000000,0x00000002,0x00000007,0x00040020,0x000000c2,0x00000000,0x000000c1, - 0x0004003b,0x000000c2,0x000000c3,0x00000000,0x0004002b,0x0000000a,0x000000ca,0x00000008, - 0x0006002c,0x0000000b,0x000000cb,0x000000ca,0x000000ca,0x00000085,0x00050036,0x00000002, - 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009, - 0x00000007,0x0004003b,0x00000025,0x00000026,0x00000007,0x0004003b,0x00000025,0x0000002a, - 0x00000007,0x0004003b,0x00000033,0x00000034,0x00000007,0x0004003b,0x00000052,0x00000053, - 0x00000007,0x0004003b,0x00000052,0x00000066,0x00000007,0x0004003b,0x00000025,0x0000006f, - 0x00000007,0x0004003b,0x0000007e,0x0000007f,0x00000007,0x0004003b,0x0000007e,0x0000008e, - 0x00000007,0x0004003b,0x00000025,0x0000009b,0x00000007,0x0004003b,0x00000025,0x000000a2, - 0x00000007,0x0004003b,0x00000025,0x000000a9,0x00000007,0x0004003d,0x0000000b,0x0000000f, - 0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001, - 0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d, - 0x00000007,0x00000012,0x00000009,0x00050041,0x0000001b,0x0000001c,0x00000019,0x0000001a, - 0x0004003d,0x00000007,0x0000001d,0x0000001c,0x000500af,0x0000001f,0x00000020,0x00000012, - 0x0000001d,0x0004009a,0x0000001e,0x00000021,0x00000020,0x000300f7,0x00000023,0x00000000, - 0x000400fa,0x00000021,0x00000022,0x00000023,0x000200f8,0x00000022,0x000100fd,0x000200f8, - 0x00000023,0x00050041,0x0000001b,0x00000027,0x00000019,0x0000001a,0x0004003d,0x00000007, - 0x00000028,0x00000027,0x0004006f,0x00000016,0x00000029,0x00000028,0x0003003e,0x00000026, - 0x00000029,0x0004003d,0x00000007,0x0000002b,0x00000009,0x0004006f,0x00000016,0x0000002c, - 0x0000002b,0x00050050,0x00000016,0x0000002e,0x0000002d,0x0000002d,0x00050081,0x00000016, - 0x0000002f,0x0000002c,0x0000002e,0x0004003d,0x00000016,0x00000030,0x00000026,0x00050088, - 0x00000016,0x00000031,0x0000002f,0x00000030,0x0003003e,0x0000002a,0x00000031,0x0004003d, - 0x00000036,0x00000039,0x00000038,0x0004003d,0x00000016,0x0000003a,0x0000002a,0x00070058, - 0x00000014,0x0000003c,0x00000039,0x0000003a,0x00000002,0x0000003b,0x0008004f,0x00000032, - 0x0000003d,0x0000003c,0x0000003c,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000034, - 0x0000003d,0x0004003d,0x00000032,0x0000003e,0x00000034,0x0004003d,0x00000032,0x00000040, - 0x00000034,0x0004009c,0x00000041,0x00000042,0x00000040,0x000600a9,0x00000032,0x00000043, - 0x00000042,0x0000003f,0x0000003e,0x0003003e,0x00000034,0x00000043,0x0004003d,0x00000044, - 0x00000047,0x00000046,0x0004003d,0x00000007,0x00000048,0x00000009,0x0004003d,0x00000032, - 0x00000049,0x00000034,0x00060050,0x00000032,0x0000004b,0x0000003b,0x0000003b,0x0000003b, - 0x00060050,0x00000032,0x0000004c,0x0000004a,0x0000004a,0x0000004a,0x0008000c,0x00000032, - 0x0000004d,0x00000001,0x0000002b,0x00000049,0x0000004b,0x0000004c,0x00050051,0x00000013, - 0x0000004e,0x0000004d,0x00000000,0x00050051,0x00000013,0x0000004f,0x0000004d,0x00000001, - 0x00050051,0x00000013,0x00000050,0x0000004d,0x00000002,0x00070050,0x00000014,0x00000051, - 0x0000004e,0x0000004f,0x00000050,0x0000004a,0x00040063,0x00000047,0x00000048,0x00000051, - 0x0004003d,0x00000036,0x00000055,0x00000054,0x0004003d,0x00000016,0x00000056,0x0000002a, - 0x00070058,0x00000014,0x00000057,0x00000055,0x00000056,0x00000002,0x0000003b,0x00050051, - 0x00000013,0x00000059,0x00000057,0x00000000,0x0003003e,0x00000053,0x00000059,0x0004003d, - 0x0000005a,0x0000005d,0x0000005c,0x0004003d,0x00000007,0x0000005e,0x00000009,0x00050041, - 0x00000060,0x00000061,0x00000019,0x0000005f,0x0004003d,0x00000006,0x00000062,0x00000061, - 0x000500c7,0x00000006,0x00000063,0x00000062,0x0000001a,0x000500ab,0x0000001e,0x00000065, - 0x00000063,0x00000064,0x000300f7,0x00000068,0x00000000,0x000400fa,0x00000065,0x00000067, - 0x0000006b,0x000200f8,0x00000067,0x0004003d,0x00000013,0x00000069,0x00000053,0x00050083, - 0x00000013,0x0000006a,0x0000004a,0x00000069,0x0003003e,0x00000066,0x0000006a,0x000200f9, - 0x00000068,0x000200f8,0x0000006b,0x0004003d,0x00000013,0x0000006c,0x00000053,0x0003003e, - 0x00000066,0x0000006c,0x000200f9,0x00000068,0x000200f8,0x00000068,0x0004003d,0x00000013, - 0x0000006d,0x00000066,0x00070050,0x00000014,0x0000006e,0x0000006d,0x0000006d,0x0000006d, - 0x0000006d,0x00040063,0x0000005d,0x0000005e,0x0000006e,0x0003003e,0x0000006f,0x00000070, - 0x00050041,0x00000060,0x00000071,0x00000019,0x0000005f,0x0004003d,0x00000006,0x00000072, - 0x00000071,0x000500c7,0x00000006,0x00000074,0x00000072,0x00000073,0x000500ab,0x0000001e, - 0x00000075,0x00000074,0x00000064,0x0004003d,0x00000013,0x00000076,0x00000053,0x000500be, - 0x0000001e,0x00000077,0x00000076,0x0000003b,0x000500a7,0x0000001e,0x00000078,0x00000075, - 0x00000077,0x0004003d,0x00000013,0x00000079,0x00000053,0x000500bc,0x0000001e,0x0000007a, - 0x00000079,0x0000004a,0x000500a7,0x0000001e,0x0000007b,0x00000078,0x0000007a,0x000300f7, - 0x0000007d,0x00000000,0x000400fa,0x0000007b,0x0000007c,0x0000007d,0x000200f8,0x0000007c, - 0x00050041,0x00000052,0x00000080,0x0000002a,0x00000058,0x0004003d,0x00000013,0x00000081, - 0x00000080,0x00050085,0x00000013,0x00000083,0x00000081,0x00000082,0x00050083,0x00000013, - 0x00000084,0x00000083,0x0000004a,0x00050041,0x00000052,0x00000086,0x0000002a,0x00000085, - 0x0004003d,0x00000013,0x00000087,0x00000086,0x00050085,0x00000013,0x00000088,0x00000087, - 0x00000082,0x00050083,0x00000013,0x00000089,0x0000004a,0x00000088,0x0004003d,0x00000013, - 0x0000008a,0x00000053,0x00050085,0x00000013,0x0000008b,0x0000008a,0x00000082,0x00050083, - 0x00000013,0x0000008c,0x0000008b,0x0000004a,0x00070050,0x00000014,0x0000008d,0x00000084, - 0x00000089,0x0000008c,0x0000004a,0x0003003e,0x0000007f,0x0000008d,0x00050041,0x0000008f, - 0x00000090,0x00000019,0x00000064,0x0004003d,0x00000015,0x00000091,0x00000090,0x0004003d, - 0x00000014,0x00000092,0x0000007f,0x00050091,0x00000014,0x00000093,0x00000091,0x00000092, - 0x0003003e,0x0000008e,0x00000093,0x00050041,0x00000052,0x00000095,0x0000008e,0x00000094, - 0x0004003d,0x00000013,0x00000096,0x00000095,0x000500ba,0x0000001e,0x00000098,0x00000096, - 0x00000097,0x000300f7,0x0000009a,0x00000000,0x000400fa,0x00000098,0x00000099,0x0000009a, - 0x000200f8,0x00000099,0x0004003d,0x00000014,0x0000009c,0x0000008e,0x0007004f,0x00000016, - 0x0000009d,0x0000009c,0x0000009c,0x00000000,0x00000001,0x00050041,0x00000052,0x0000009e, - 0x0000008e,0x00000094,0x0004003d,0x00000013,0x0000009f,0x0000009e,0x00050050,0x00000016, - 0x000000a0,0x0000009f,0x0000009f,0x00050088,0x00000016,0x000000a1,0x0000009d,0x000000a0, - 0x0003003e,0x0000009b,0x000000a1,0x0004003d,0x00000014,0x000000a3,0x0000007f,0x0007004f, - 0x00000016,0x000000a4,0x000000a3,0x000000a3,0x00000000,0x00000001,0x00050041,0x000000a5, - 0x000000a6,0x00000019,0x00000073,0x0004003d,0x00000016,0x000000a7,0x000000a6,0x00050083, - 0x00000016,0x000000a8,0x000000a4,0x000000a7,0x0003003e,0x000000a2,0x000000a8,0x00050041, - 0x00000052,0x000000aa,0x0000009b,0x00000058,0x0004003d,0x00000013,0x000000ab,0x000000aa, - 0x00050041,0x00000052,0x000000ac,0x000000a2,0x00000058,0x0004003d,0x00000013,0x000000ad, - 0x000000ac,0x00050083,0x00000013,0x000000ae,0x000000ab,0x000000ad,0x00050041,0x00000052, - 0x000000af,0x000000a2,0x00000085,0x0004003d,0x00000013,0x000000b0,0x000000af,0x00050041, - 0x00000052,0x000000b1,0x0000009b,0x00000085,0x0004003d,0x00000013,0x000000b2,0x000000b1, - 0x00050083,0x00000013,0x000000b3,0x000000b0,0x000000b2,0x00050050,0x00000016,0x000000b4, - 0x000000ae,0x000000b3,0x0005008e,0x00000016,0x000000b5,0x000000b4,0x0000002d,0x0004003d, - 0x00000016,0x000000b6,0x00000026,0x00050085,0x00000016,0x000000b7,0x000000b5,0x000000b6, - 0x0003003e,0x000000a9,0x000000b7,0x0004003d,0x00000016,0x000000b8,0x000000a9,0x0006000c, - 0x00000016,0x000000b9,0x00000001,0x00000004,0x000000b8,0x000500b8,0x0000001f,0x000000bc, - 0x000000b9,0x000000bb,0x0004009b,0x0000001e,0x000000bd,0x000000bc,0x000300f7,0x000000bf, - 0x00000000,0x000400fa,0x000000bd,0x000000be,0x000000bf,0x000200f8,0x000000be,0x0004003d, - 0x00000016,0x000000c0,0x000000a9,0x0003003e,0x0000006f,0x000000c0,0x000200f9,0x000000bf, - 0x000200f8,0x000000bf,0x000200f9,0x0000009a,0x000200f8,0x0000009a,0x000200f9,0x0000007d, - 0x000200f8,0x0000007d,0x0004003d,0x000000c1,0x000000c4,0x000000c3,0x0004003d,0x00000007, - 0x000000c5,0x00000009,0x0004003d,0x00000016,0x000000c6,0x0000006f,0x00050051,0x00000013, - 0x000000c7,0x000000c6,0x00000000,0x00050051,0x00000013,0x000000c8,0x000000c6,0x00000001, - 0x00070050,0x00000014,0x000000c9,0x000000c7,0x000000c8,0x0000003b,0x0000003b,0x00040063, - 0x000000c4,0x000000c5,0x000000c9,0x000100fd,0x00010038 + 0x0004002b,0x00000006,0x00000049,0x00000003,0x00040020,0x0000004a,0x00000009,0x00000006, + 0x0004002b,0x00000006,0x0000004d,0x00000004,0x0004002b,0x00000006,0x0000004f,0x00000000, + 0x0004002b,0x00000013,0x00000056,0x477a0000,0x0006002c,0x00000032,0x00000057,0x00000056, + 0x00000056,0x00000056,0x0004002b,0x00000013,0x0000005b,0x3f800000,0x00040020,0x00000064, + 0x00000007,0x00000013,0x0004003b,0x00000037,0x00000066,0x00000000,0x0004002b,0x0000000a, + 0x0000006a,0x00000000,0x00090019,0x0000006c,0x00000013,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000002,0x00000003,0x00040020,0x0000006d,0x00000000,0x0000006c,0x0004003b, + 0x0000006d,0x0000006e,0x00000000,0x0005002c,0x00000016,0x0000007f,0x0000003b,0x0000003b, + 0x0004002b,0x00000006,0x00000082,0x00000001,0x00040020,0x0000008d,0x00000007,0x00000014, + 0x0004002b,0x00000013,0x00000091,0x40000000,0x0004002b,0x0000000a,0x00000094,0x00000001, + 0x00040020,0x0000009e,0x00000009,0x00000015,0x0004002b,0x0000000a,0x000000a3,0x00000003, + 0x0004002b,0x00000013,0x000000a6,0x358637bd,0x00040020,0x000000b4,0x00000009,0x00000016, + 0x0004002b,0x00000013,0x000000c9,0x46800000,0x0005002c,0x00000016,0x000000ca,0x000000c9, + 0x000000c9,0x00090019,0x000000d0,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000, + 0x00000002,0x00000007,0x00040020,0x000000d1,0x00000000,0x000000d0,0x0004003b,0x000000d1, + 0x000000d2,0x00000000,0x0004002b,0x0000000a,0x000000d9,0x00000008,0x0006002c,0x0000000b, + 0x000000da,0x000000d9,0x000000d9,0x00000094,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b, + 0x00000025,0x00000026,0x00000007,0x0004003b,0x00000025,0x0000002a,0x00000007,0x0004003b, + 0x00000033,0x00000034,0x00000007,0x0004003b,0x00000033,0x00000051,0x00000007,0x0004003b, + 0x00000064,0x00000065,0x00000007,0x0004003b,0x00000064,0x00000075,0x00000007,0x0004003b, + 0x00000025,0x0000007e,0x00000007,0x0004003b,0x0000008d,0x0000008e,0x00000007,0x0004003b, + 0x0000008d,0x0000009d,0x00000007,0x0004003b,0x00000025,0x000000aa,0x00000007,0x0004003b, + 0x00000025,0x000000b1,0x00000007,0x0004003b,0x00000025,0x000000b8,0x00000007,0x0004003d, + 0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f, + 0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009, + 0x00000011,0x0004003d,0x00000007,0x00000012,0x00000009,0x00050041,0x0000001b,0x0000001c, + 0x00000019,0x0000001a,0x0004003d,0x00000007,0x0000001d,0x0000001c,0x000500af,0x0000001f, + 0x00000020,0x00000012,0x0000001d,0x0004009a,0x0000001e,0x00000021,0x00000020,0x000300f7, + 0x00000023,0x00000000,0x000400fa,0x00000021,0x00000022,0x00000023,0x000200f8,0x00000022, + 0x000100fd,0x000200f8,0x00000023,0x00050041,0x0000001b,0x00000027,0x00000019,0x0000001a, + 0x0004003d,0x00000007,0x00000028,0x00000027,0x0004006f,0x00000016,0x00000029,0x00000028, + 0x0003003e,0x00000026,0x00000029,0x0004003d,0x00000007,0x0000002b,0x00000009,0x0004006f, + 0x00000016,0x0000002c,0x0000002b,0x00050050,0x00000016,0x0000002e,0x0000002d,0x0000002d, + 0x00050081,0x00000016,0x0000002f,0x0000002c,0x0000002e,0x0004003d,0x00000016,0x00000030, + 0x00000026,0x00050088,0x00000016,0x00000031,0x0000002f,0x00000030,0x0003003e,0x0000002a, + 0x00000031,0x0004003d,0x00000036,0x00000039,0x00000038,0x0004003d,0x00000016,0x0000003a, + 0x0000002a,0x00070058,0x00000014,0x0000003c,0x00000039,0x0000003a,0x00000002,0x0000003b, + 0x0008004f,0x00000032,0x0000003d,0x0000003c,0x0000003c,0x00000000,0x00000001,0x00000002, + 0x0003003e,0x00000034,0x0000003d,0x0004003d,0x00000032,0x0000003e,0x00000034,0x0004003d, + 0x00000032,0x00000040,0x00000034,0x0004009c,0x00000041,0x00000042,0x00000040,0x000600a9, + 0x00000032,0x00000043,0x00000042,0x0000003f,0x0000003e,0x0003003e,0x00000034,0x00000043, + 0x0004003d,0x00000044,0x00000047,0x00000046,0x0004003d,0x00000007,0x00000048,0x00000009, + 0x00050041,0x0000004a,0x0000004b,0x00000019,0x00000049,0x0004003d,0x00000006,0x0000004c, + 0x0000004b,0x000500c7,0x00000006,0x0000004e,0x0000004c,0x0000004d,0x000500ab,0x0000001e, + 0x00000050,0x0000004e,0x0000004f,0x000300f7,0x00000053,0x00000000,0x000400fa,0x00000050, + 0x00000052,0x00000059,0x000200f8,0x00000052,0x0004003d,0x00000032,0x00000054,0x00000034, + 0x0007000c,0x00000032,0x00000055,0x00000001,0x00000028,0x00000054,0x0000003f,0x0007000c, + 0x00000032,0x00000058,0x00000001,0x00000025,0x00000055,0x00000057,0x0003003e,0x00000051, + 0x00000058,0x000200f9,0x00000053,0x000200f8,0x00000059,0x0004003d,0x00000032,0x0000005a, + 0x00000034,0x00060050,0x00000032,0x0000005c,0x0000003b,0x0000003b,0x0000003b,0x00060050, + 0x00000032,0x0000005d,0x0000005b,0x0000005b,0x0000005b,0x0008000c,0x00000032,0x0000005e, + 0x00000001,0x0000002b,0x0000005a,0x0000005c,0x0000005d,0x0003003e,0x00000051,0x0000005e, + 0x000200f9,0x00000053,0x000200f8,0x00000053,0x0004003d,0x00000032,0x0000005f,0x00000051, + 0x00050051,0x00000013,0x00000060,0x0000005f,0x00000000,0x00050051,0x00000013,0x00000061, + 0x0000005f,0x00000001,0x00050051,0x00000013,0x00000062,0x0000005f,0x00000002,0x00070050, + 0x00000014,0x00000063,0x00000060,0x00000061,0x00000062,0x0000005b,0x00040063,0x00000047, + 0x00000048,0x00000063,0x0004003d,0x00000036,0x00000067,0x00000066,0x0004003d,0x00000016, + 0x00000068,0x0000002a,0x00070058,0x00000014,0x00000069,0x00000067,0x00000068,0x00000002, + 0x0000003b,0x00050051,0x00000013,0x0000006b,0x00000069,0x00000000,0x0003003e,0x00000065, + 0x0000006b,0x0004003d,0x0000006c,0x0000006f,0x0000006e,0x0004003d,0x00000007,0x00000070, + 0x00000009,0x00050041,0x0000004a,0x00000071,0x00000019,0x00000049,0x0004003d,0x00000006, + 0x00000072,0x00000071,0x000500c7,0x00000006,0x00000073,0x00000072,0x0000001a,0x000500ab, + 0x0000001e,0x00000074,0x00000073,0x0000004f,0x000300f7,0x00000077,0x00000000,0x000400fa, + 0x00000074,0x00000076,0x0000007a,0x000200f8,0x00000076,0x0004003d,0x00000013,0x00000078, + 0x00000065,0x00050083,0x00000013,0x00000079,0x0000005b,0x00000078,0x0003003e,0x00000075, + 0x00000079,0x000200f9,0x00000077,0x000200f8,0x0000007a,0x0004003d,0x00000013,0x0000007b, + 0x00000065,0x0003003e,0x00000075,0x0000007b,0x000200f9,0x00000077,0x000200f8,0x00000077, + 0x0004003d,0x00000013,0x0000007c,0x00000075,0x00070050,0x00000014,0x0000007d,0x0000007c, + 0x0000007c,0x0000007c,0x0000007c,0x00040063,0x0000006f,0x00000070,0x0000007d,0x0003003e, + 0x0000007e,0x0000007f,0x00050041,0x0000004a,0x00000080,0x00000019,0x00000049,0x0004003d, + 0x00000006,0x00000081,0x00000080,0x000500c7,0x00000006,0x00000083,0x00000081,0x00000082, + 0x000500ab,0x0000001e,0x00000084,0x00000083,0x0000004f,0x0004003d,0x00000013,0x00000085, + 0x00000065,0x000500be,0x0000001e,0x00000086,0x00000085,0x0000003b,0x000500a7,0x0000001e, + 0x00000087,0x00000084,0x00000086,0x0004003d,0x00000013,0x00000088,0x00000065,0x000500bc, + 0x0000001e,0x00000089,0x00000088,0x0000005b,0x000500a7,0x0000001e,0x0000008a,0x00000087, + 0x00000089,0x000300f7,0x0000008c,0x00000000,0x000400fa,0x0000008a,0x0000008b,0x0000008c, + 0x000200f8,0x0000008b,0x00050041,0x00000064,0x0000008f,0x0000002a,0x0000006a,0x0004003d, + 0x00000013,0x00000090,0x0000008f,0x00050085,0x00000013,0x00000092,0x00000090,0x00000091, + 0x00050083,0x00000013,0x00000093,0x00000092,0x0000005b,0x00050041,0x00000064,0x00000095, + 0x0000002a,0x00000094,0x0004003d,0x00000013,0x00000096,0x00000095,0x00050085,0x00000013, + 0x00000097,0x00000096,0x00000091,0x00050083,0x00000013,0x00000098,0x0000005b,0x00000097, + 0x0004003d,0x00000013,0x00000099,0x00000065,0x00050085,0x00000013,0x0000009a,0x00000099, + 0x00000091,0x00050083,0x00000013,0x0000009b,0x0000009a,0x0000005b,0x00070050,0x00000014, + 0x0000009c,0x00000093,0x00000098,0x0000009b,0x0000005b,0x0003003e,0x0000008e,0x0000009c, + 0x00050041,0x0000009e,0x0000009f,0x00000019,0x0000004f,0x0004003d,0x00000015,0x000000a0, + 0x0000009f,0x0004003d,0x00000014,0x000000a1,0x0000008e,0x00050091,0x00000014,0x000000a2, + 0x000000a0,0x000000a1,0x0003003e,0x0000009d,0x000000a2,0x00050041,0x00000064,0x000000a4, + 0x0000009d,0x000000a3,0x0004003d,0x00000013,0x000000a5,0x000000a4,0x000500ba,0x0000001e, + 0x000000a7,0x000000a5,0x000000a6,0x000300f7,0x000000a9,0x00000000,0x000400fa,0x000000a7, + 0x000000a8,0x000000a9,0x000200f8,0x000000a8,0x0004003d,0x00000014,0x000000ab,0x0000009d, + 0x0007004f,0x00000016,0x000000ac,0x000000ab,0x000000ab,0x00000000,0x00000001,0x00050041, + 0x00000064,0x000000ad,0x0000009d,0x000000a3,0x0004003d,0x00000013,0x000000ae,0x000000ad, + 0x00050050,0x00000016,0x000000af,0x000000ae,0x000000ae,0x00050088,0x00000016,0x000000b0, + 0x000000ac,0x000000af,0x0003003e,0x000000aa,0x000000b0,0x0004003d,0x00000014,0x000000b2, + 0x0000008e,0x0007004f,0x00000016,0x000000b3,0x000000b2,0x000000b2,0x00000000,0x00000001, + 0x00050041,0x000000b4,0x000000b5,0x00000019,0x00000082,0x0004003d,0x00000016,0x000000b6, + 0x000000b5,0x00050083,0x00000016,0x000000b7,0x000000b3,0x000000b6,0x0003003e,0x000000b1, + 0x000000b7,0x00050041,0x00000064,0x000000b9,0x000000aa,0x0000006a,0x0004003d,0x00000013, + 0x000000ba,0x000000b9,0x00050041,0x00000064,0x000000bb,0x000000b1,0x0000006a,0x0004003d, + 0x00000013,0x000000bc,0x000000bb,0x00050083,0x00000013,0x000000bd,0x000000ba,0x000000bc, + 0x00050041,0x00000064,0x000000be,0x000000b1,0x00000094,0x0004003d,0x00000013,0x000000bf, + 0x000000be,0x00050041,0x00000064,0x000000c0,0x000000aa,0x00000094,0x0004003d,0x00000013, + 0x000000c1,0x000000c0,0x00050083,0x00000013,0x000000c2,0x000000bf,0x000000c1,0x00050050, + 0x00000016,0x000000c3,0x000000bd,0x000000c2,0x0005008e,0x00000016,0x000000c4,0x000000c3, + 0x0000002d,0x0004003d,0x00000016,0x000000c5,0x00000026,0x00050085,0x00000016,0x000000c6, + 0x000000c4,0x000000c5,0x0003003e,0x000000b8,0x000000c6,0x0004003d,0x00000016,0x000000c7, + 0x000000b8,0x0006000c,0x00000016,0x000000c8,0x00000001,0x00000004,0x000000c7,0x000500b8, + 0x0000001f,0x000000cb,0x000000c8,0x000000ca,0x0004009b,0x0000001e,0x000000cc,0x000000cb, + 0x000300f7,0x000000ce,0x00000000,0x000400fa,0x000000cc,0x000000cd,0x000000ce,0x000200f8, + 0x000000cd,0x0004003d,0x00000016,0x000000cf,0x000000b8,0x0003003e,0x0000007e,0x000000cf, + 0x000200f9,0x000000ce,0x000200f8,0x000000ce,0x000200f9,0x000000a9,0x000200f8,0x000000a9, + 0x000200f9,0x0000008c,0x000200f8,0x0000008c,0x0004003d,0x000000d0,0x000000d3,0x000000d2, + 0x0004003d,0x00000007,0x000000d4,0x00000009,0x0004003d,0x00000016,0x000000d5,0x0000007e, + 0x00050051,0x00000013,0x000000d6,0x000000d5,0x00000000,0x00050051,0x00000013,0x000000d7, + 0x000000d5,0x00000001,0x00070050,0x00000014,0x000000d8,0x000000d6,0x000000d7,0x0000003b, + 0x0000003b,0x00040063,0x000000d3,0x000000d4,0x000000d8,0x000100fd,0x00010038 }; diff --git a/gpu/vk/sirit/src/stream.h b/gpu/vk/sirit/src/stream.h index 9c15c8c..84e942b 100644 --- a/gpu/vk/sirit/src/stream.h +++ b/gpu/vk/sirit/src/stream.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -158,7 +159,9 @@ public: Stream& operator<<(Id value) { if (value.value == 0) { - std::abort(); + // (super build) thrown, not std::abort(): a program whose SPIR-V would name an undefined value is not + // translated (the caller's catch says so), rather than ending the process with nothing in the log + throw std::runtime_error("sirit: an operand with no SPIR-V definition (null Id)"); } return *this << value.value; } diff --git a/gpu/vk/vk_bank.cpp b/gpu/vk/vk_bank.cpp index f84ba85..e01b274 100644 --- a/gpu/vk/vk_bank.cpp +++ b/gpu/vk/vk_bank.cpp @@ -125,9 +125,10 @@ const void* descriptor_ok(const void* p, size_t n) { if (!p) return nullptr; const uintptr_t q = (uintptr_t)p, base = (uintptr_t)host->guest_base(); if (q >= base && q + n <= base + host->guest_size()) return p; - uint64_t avail = 0; - if (const uint8_t* h = host->gpu_ptr((uint64_t)q, &avail); h && avail >= n) return h; - // (the host's own copies: registrations made before the renderer started, kept by host/rx_backend.c) + // (the host's own copies: registrations made before the renderer started, kept by host/rx_backend.c. A registration's + // pointer is a host pointer, never a GPU address: asked as one (host->gpu_ptr), a heap address between 16 MB and 512 GB, + // as Windows gives them, named guest memory, and the registration was copied from there, all zero: the game's sampler + // 258 filtered nearest and texture slot 0x102 had no image, issue 1117's blocky halos) MEMORY_BASIC_INFORMATION mi{}; if (VirtualQuery(p, &mi, sizeof mi) == sizeof mi && mi.State == MEM_COMMIT && (mi.Protect & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY)) && !(mi.Protect & PAGE_GUARD) && diff --git a/gpu/vk/vk_coopmat.cpp b/gpu/vk/vk_coopmat.cpp index 69f97ad..892e441 100644 --- a/gpu/vk/vk_coopmat.cpp +++ b/gpu/vk/vk_coopmat.cpp @@ -350,6 +350,11 @@ void coopmat_init() { if (Shader::Backend::SPIRV::frag_nan_guard) logf("vk: colour outputs NaN-guarded"); Shader::Backend::SPIRV::position_invariant = dev.props.vendorID != 0x10DE && !std::getenv("RX_VK_NO_INVARIANT"); if (Shader::Backend::SPIRV::position_invariant) logf("vk: positions invariant (not an NVIDIA card)"); + // (hookshot) the translation's vendor fixes (vk_vendor.h, dev.fixes): out-of-bounds texel fetches answer 0, NaN tests on bits + Shader::Backend::SPIRV::fetch_bounds = dev.fixes.fetch_bounds; + // (dev.features.robustBufferAccess: on exactly when robustBufferAccess2 is, vk_main.cpp create_device) + Shader::Backend::SPIRV::fetch_bounds_buffers = dev.fixes.fetch_bounds && !dev.features.robustBufferAccess; + Shader::Backend::SPIRV::nan_bits = dev.fixes.nan_bits; // (hookshot) RX_VK_MMA_SOFTWARE=1: HMMA_nx2 in a shader function on subgroup shuffles, no cooperative matrices // (emit_spirv_warp.cpp, from Lichii): the lowering still gives HMMA_nx2 (dev.native_mma) if (const char* sw = std::getenv("RX_VK_MMA_SOFTWARE"); sw && std::atoi(sw)) { diff --git a/gpu/vk/vk_dlss.cpp b/gpu/vk/vk_dlss.cpp index 72409b5..1d23eea 100644 --- a/gpu/vk/vk_dlss.cpp +++ b/gpu/vk/vk_dlss.cpp @@ -77,7 +77,12 @@ struct State { uint32_t feature_rw = 0, feature_rh = 0, feature_ow = 0, feature_oh = 0; // (its largest render size, its output) uint32_t min_rw = 0, min_rh = 0; unsigned feature_preset = ~0u; // (the preset it was made with: another one from the menu makes it again) + bool feature_hdr = false; // (made for linear HDR colour, NGX's IsHDR: the other kind of colour makes it again) uint64_t features_made = 0; // (how many times: a feature made again in play costs a stall, so each says why) + // (a feature not made for want of video memory: tried again from retry_frame on, kMemoryRetries times before it is given + // up for the run. Each try stalls as a creation does, so they are 600 frames apart) + uint64_t retry_frame = 0; + int retries = 0; }; State& st() { static State s; @@ -262,7 +267,13 @@ bool ngx_init() { g_why = needs_driver ? DLSS_NEEDS_DRIVER : !runtime ? DLSS_NO_RUNTIME : !loadable ? DLSS_RUNTIME_NOT_ASCII : DLSS_NEEDS_RTX; return false; } - if (NVSDK_NGX_FAILED(NVSDK_NGX_VULKAN_AllocateParameters(&s.params)) || !s.params) return false; + if (const NVSDK_NGX_Result ar = NVSDK_NGX_VULKAN_AllocateParameters(&s.params); NVSDK_NGX_FAILED(ar) || !s.params) { + // (a reason of its own: left unset, dlss_why went on saying DLSS could be chosen, with the engine off for the run) + logf("vk: NVIDIA DLSS: NGX gave no parameters (%#x): no DLSS", (unsigned)ar); + s.params = nullptr; + g_why = DLSS_NGX_FAILED; + return false; + } logf("vk: NVIDIA DLSS: NGX started (DLSS's runtime: the newest %s in %s)", kRuntime, where.c_str()); s.ngx_ok = true; g_why = DLSS_OK; @@ -277,13 +288,15 @@ unsigned wanted_preset() { /// DLSS's feature for this output size and preset, made when either changes (cmd: its creation's work): the engine's /// prepare (vk_temporal.h) -int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, uint32_t* in_w, uint32_t* in_h, - const char** fail) { +int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, bool hdr, uint32_t* in_w, + uint32_t* in_h, const char** fail) { State& s = st(); const unsigned preset = wanted_preset(); if (s.feature && s.feature_ow == ow && s.feature_oh == oh && rw <= s.feature_rw && rh <= s.feature_rh && - rw >= s.min_rw && rh >= s.min_rh && s.feature_preset == preset) + rw >= s.min_rw && rh >= s.min_rh && s.feature_preset == preset && s.feature_hdr == hdr) return *in_w = s.feature_rw, *in_h = s.feature_rh, 1; + static const char* const kNoMemory = "no video memory for its feature: tried again in a while"; + if (s.retry_frame && texture_frame_no() < s.retry_frame) return *fail = kNoMemory, 0; // (why it is made: in the log with its time, so a stall in play can be matched with one) char why[160]; if (!s.feature && !s.features_made) snprintf(why, sizeof why, "the first"); @@ -293,6 +306,7 @@ int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t else if (s.feature_preset != preset) snprintf(why, sizeof why, "preset %c, was %c (the DLSS model row)", upscaler_rows::preset_letter(preset), upscaler_rows::preset_letter(s.feature_preset)); + else if (s.feature_hdr != hdr) snprintf(why, sizeof why, "the colour is %s now", hdr ? "HDR" : "LDR"); else snprintf(why, sizeof why, "the render size %ux%u left its range, %ux%u to %ux%u", rw, rh, s.min_rw, s.min_rh, s.feature_rw, s.feature_rh); @@ -338,6 +352,9 @@ int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t cp.Feature.InPerfQualityValue = mode; // (LDR colour, already tonemapped: no exposure; motion at the render size, not jittered; depth not reversed) cp.InFeatureCreateFlags = NVSDK_NGX_DLSS_Feature_Flags_MVLowRes; + // (linear HDR colour, when the chain says so: the scene before the game's exposure and tone mapping, or an RGBA16F + // scene's picture (local, RenoDX port), so DLSS finds the exposure itself) + if (hdr) cp.InFeatureCreateFlags |= NVSDK_NGX_DLSS_Feature_Flags_IsHDR | NVSDK_NGX_DLSS_Feature_Flags_AutoExposure; const auto t0 = std::chrono::steady_clock::now(); ::mkwvk::rec::boundary(::mkwvk::rec::B_DIRECT); // (NGX records into cmd itself: what this thread recorded through vk_work.h reaches cmd first) const NVSDK_NGX_Result r = NGX_VULKAN_CREATE_DLSS_EXT(cmd, 1, 1, &s.feature, s.params, &cp); @@ -346,10 +363,21 @@ int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t if (NVSDK_NGX_FAILED(r) || !s.feature) { logf("vk: NVIDIA DLSS: its feature was not made (%#x) for %ux%u -> %ux%u", (unsigned)r, max_w, max_h, ow, oh); s.feature = nullptr; + // (out of video memory passes, when the game lets an area's textures go: not the end of DLSS for the run, as any + // failure was before. Anything else is) + constexpr int kMemoryRetries = 3; + if (r == NVSDK_NGX_Result_FAIL_OutOfGPUMemory && s.retries < kMemoryRetries) { + s.retries++; + s.retry_frame = texture_frame_no() + 600; + logf("vk: NVIDIA DLSS: out of video memory: the game's upscale until frame %llu, then try %d of %d", + (unsigned long long)s.retry_frame, s.retries, kMemoryRetries); + return *fail = kNoMemory, 0; + } return *fail = "its feature was not made", -1; } + s.retries = 0, s.retry_frame = 0; s.feature_rw = max_w, s.feature_rh = max_h, s.feature_ow = ow, s.feature_oh = oh, s.min_rw = min_w, s.min_rh = min_h; - s.feature_preset = preset; + s.feature_preset = preset, s.feature_hdr = hdr; s.features_made++; logf("vk: NVIDIA DLSS: feature %llu made (%s; frame %llu, %.1f ms of CPU): %ux%u (%ux%u to %ux%u) -> %ux%u, mode %d, " "preset %c%s", (unsigned long long)s.features_made, why, (unsigned long long)texture_frame_no(), made_ms, rw, rh, diff --git a/gpu/vk/vk_dlss.h b/gpu/vk/vk_dlss.h index 5038de5..6586ada 100644 --- a/gpu/vk/vk_dlss.h +++ b/gpu/vk/vk_dlss.h @@ -15,7 +15,7 @@ struct TemporalEngine; bool dlss_built(); /// Why DLSS cannot be chosen here (the Insert menu's Upscaler row says it), DLSS_OK when it can or is not known yet enum DlssWhy { DLSS_OK, DLSS_NOT_BUILT, DLSS_ENV_OFF, DLSS_NEEDS_RTX, DLSS_NEEDS_DRIVER, DLSS_NO_RUNTIME, - DLSS_RUNTIME_NOT_ASCII, DLSS_WHY_COUNT }; + DLSS_RUNTIME_NOT_ASCII, DLSS_NGX_FAILED, DLSS_WHY_COUNT }; DlssWhy dlss_why(); /// Asks NGX once whether DLSS runs on this device, so dlss_why knows before the first upscale (the menu, when it opens). /// Nothing off an NVIDIA device with NGX's extensions, or in a build without DLSS diff --git a/gpu/vk/vk_draw.cpp b/gpu/vk/vk_draw.cpp index 564d4a5..f95421d 100644 --- a/gpu/vk/vk_draw.cpp +++ b/gpu/vk/vk_draw.cpp @@ -53,6 +53,7 @@ #include "shaders/taau_upscale_comp_spv.h" #include "shaders/movie_upscale_comp_spv.h" #include "shader_recompiler/backend/spirv/mma_layout.h" +#include "vk_renodx.h" #include "vk_work.h" // (after the others: counts the commands that do GPU work, for full_barrier) namespace mkwvk { @@ -644,8 +645,9 @@ VkFormat supported_vertex_format(VkFormat f) { } // ---- pipeline layouts and pipelines ---- -// (+ the guest page table's address, a task draw's first, and the fallback's two buffer addresses) -constexpr uint32_t kPushSize = Shader::Backend::SPIRV::MESH_FALLBACK_PUSH_END; +// (+ the guest page table's address, a task draw's first, the fallback's two buffer addresses, and where a scene vertex +// stage stores its positions: push_capture) +constexpr uint32_t kPushSize = Shader::Backend::SPIRV::CAPTURE_PUSH_END; void ensure_layout(Program& p) { if (p.layout) return; @@ -678,6 +680,15 @@ void ensure_layout(Program& p) { VkPipelineLayoutCreateInfo pi{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; pi.setLayoutCount = 1; pi.pSetLayouts = &p.set_layout; + // (local, RenoDX port) a program with one of RenoDX's stages: its settings and state as set 1 (vk_renodx.h) + for (const Stage& st : p.stages) if (st.vk_stage == VK_SHADER_STAGE_FRAGMENT_BIT) p.frag_crc = st.crc; + VkDescriptorSetLayout with_renodx[2] = {p.set_layout, VK_NULL_HANDLE}; + for (const Stage& st : p.stages) + if (st.renodx && !with_renodx[1]) with_renodx[1] = renodx_set_layout(); + if (with_renodx[1]) { + for (const Stage& st : p.stages) if (st.renodx) p.renodx = st.renodx; + pi.setLayoutCount = 2, pi.pSetLayouts = with_renodx; + } pi.pushConstantRangeCount = 1; pi.pPushConstantRanges = ⦥ VkPipelineLayout layout = VK_NULL_HANDLE; @@ -693,6 +704,7 @@ void ensure_layout(Program& p) { st.info.uses_global_memory; for (const Stage& st : p.stages) p.uses_push |= (st.vk_stage & VK_SHADER_STAGE_TASK_BIT_EXT) != 0; // (its first workgroup) if (p.fallback) p.uses_push = true; // (its records' and payloads' addresses) + for (const Stage& st : p.stages) p.captures |= st.info.captures_position; // (push_capture, each draw) std::atomic_thread_fence(std::memory_order_release); // (the layout last: a thread that sees it sees the rest) p.layout = layout; } @@ -810,19 +822,123 @@ bool depth_aspect(VkFormat f) { // (hookshot) A driver's compiler that faults on a shader (amdvlk64.dll on a mesh program, Hookshot issue 26) costs that one draw, not the game #ifdef _WIN32 +// (Triforce, 11-13) Where the driver faulted: the module and offset of the faulting instruction, what it touched, and the +// callers above it, in the log. A lab start hung for good right after "the driver faulted compiling a graphics pipeline +// (exception 0xc0000005)" with nothing to say whose code it was in or what it was holding +__declspec(noinline) int driver_fault_note(EXCEPTION_POINTERS* ep, const char* what) { + const EXCEPTION_RECORD* er = ep->ExceptionRecord; + const auto where = [](uint64_t a, char* out, size_t n) { + HMODULE m = nullptr; + char path[MAX_PATH] = ""; + if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)a, &m) && m && + GetModuleFileNameA(m, path, sizeof path)) { + const char* base = strrchr(path, '\\'); + snprintf(out, n, "%s+0x%llx", base ? base + 1 : path, (unsigned long long)(a - (uint64_t)m)); + } else { + snprintf(out, n, "0x%llx", (unsigned long long)a); + } + }; + char at[320], line[900]; + where((uint64_t)er->ExceptionAddress, at, sizeof at); + int n = snprintf(line, sizeof line, "vk: the driver faulted compiling a %s pipeline (exception %#lx) at %s", what, + (unsigned long)er->ExceptionCode, at); + if (er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && er->NumberParameters >= 2) + n += snprintf(line + n, sizeof line - n, ", %s address %#llx", er->ExceptionInformation[0] == 1 ? "writing" : + er->ExceptionInformation[0] == 8 ? "executing" : "reading", (unsigned long long)er->ExceptionInformation[1]); + logf("%s: that one is left out", line); +#if defined(_M_X64) || defined(__x86_64__) + CONTEXT c = *ep->ContextRecord; + n = snprintf(line, sizeof line, "vk: the fault's callers:"); + for (int i = 0; i < 16 && c.Rip; i++) { + DWORD64 base = 0; + if (PRUNTIME_FUNCTION fe = RtlLookupFunctionEntry(c.Rip, &base, nullptr)) { + void* handler = nullptr; + DWORD64 frame = 0; + RtlVirtualUnwind(UNW_FLAG_NHANDLER, base, c.Rip, fe, &c, &handler, &frame, nullptr); + } else { + MEMORY_BASIC_INFORMATION mi{}; + if (!VirtualQuery((void*)c.Rsp, &mi, sizeof mi) || mi.State != MEM_COMMIT) break; + c.Rip = *(DWORD64*)c.Rsp, c.Rsp += 8; // (a leaf: its return address is on top) + } + if (!c.Rip) break; + where(c.Rip, at, sizeof at); + if (n < (int)sizeof line - 96) n += snprintf(line + n, sizeof line - n, " %s", at); + } + logf("%s", line); +#endif + return EXCEPTION_EXECUTE_HANDLER; +} +// (Triforce, 11-13) After a fault in the driver during the start's own shader work, the game starts again instead of going +// on. "The start screen freezes" (players, and the lab on 11-13 with every thread's stack taken): the log's last line was +// "the driver faulted compiling a compute pipeline (exception 0xc0000005) at nvoglv64.dll+0xdc2115, reading address 0x8: +// that one is left out", and then all twelve of prepare_run's workers sat in vkCreateComputePipelines for good: eleven +// waiting for a lock inside the driver (RtlAcquireSRWLockExclusive from nvoglv64.dll+0x4c1c17), one of them at the very +// call path the fault had come from (+0xdc1c01 <- +0xe0efea, 0x514 bytes before the faulting instruction), and one at +// full load inside the driver's compiler from the second of the fault on. The fault was taken with the driver's own lock +// held, the guard below unwound past it, and a lock of that kind has no owner to give it back: every later compile waits +// on it. Leaving the one pipeline out and going on is what made a crash into a freeze. +// The driver's state in this process cannot be trusted after that, and nothing of the game runs yet during the start's +// work, so: a new process of this executable with this one's command line (as host/hos_relaunch.c starts it for the +// menu's Restart now), and this one ends at once, without the orderly close that would wait on those threads. The next +// start in the lab prepared with no fault (69 s). At most two such restarts in a row (TRIFORCE_FAULT_RESTARTS, handed to +// the new process): after them, and in play (a restart there would lose the player's progress), it goes on as before. +// Not at Setup's own preparation (HOOKSHOT_PREPARE_ONLY: Setup reads that process's output). RX_VK_FAULT_RESTART=0: never. +__declspec(noinline) void driver_fault_restart() { + if (!startup_work_on.load(std::memory_order_relaxed) || getenv("HOOKSHOT_PREPARE_ONLY")) return; + static const char* const sw = getenv("RX_VK_FAULT_RESTART"); + if (sw && !atoi(sw)) return; + char before[16] = ""; + GetEnvironmentVariableA("TRIFORCE_FAULT_RESTARTS", before, sizeof before); + const int n = atoi(before); + if (n >= 2) { + static std::atomic told{false}; + if (!told.exchange(true)) + logf("vk: the driver faulted again after two restarts for it: this start goes on in this process (the driver may " + "hold its own locks now: a start hung that way)"); + return; + } + static std::atomic going{false}; + if (going.exchange(true)) Sleep(INFINITE); // (another thread's fault is starting the game again already) + logf("vk: the driver faulted during the start's shader work: it may hold its own locks for good now (a start hung that " + "way), so the game starts again (restart %d of 2 at most; RX_VK_FAULT_RESTART=0: not)", n + 1); + wchar_t exe[MAX_PATH * 4]; + const DWORD len = GetModuleFileNameW(nullptr, exe, MAX_PATH * 4); + std::wstring cmd = GetCommandLineW(); // (CreateProcessW may write into it) + char count[16]; + wchar_t pid[16]; + snprintf(count, sizeof count, "%d", n + 1); + swprintf(pid, 16, L"%lu", (unsigned long)GetCurrentProcessId()); + SetEnvironmentVariableA("TRIFORCE_FAULT_RESTARTS", count); + SetEnvironmentVariableW(L"HOS_RESTART_OF", pid); // (the new process waits for this one before it takes the log over) + STARTUPINFOW si{}; + PROCESS_INFORMATION pi{}; + si.cb = sizeof si; + if (!len || len >= MAX_PATH * 4 || !CreateProcessW(exe, cmd.data(), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) { + logf("vk: the game could not be started again (error %lu): this start goes on in this process", (unsigned long)GetLastError()); + SetEnvironmentVariableW(L"HOS_RESTART_OF", nullptr); + SetEnvironmentVariableA("TRIFORCE_FAULT_RESTARTS", before[0] ? before : nullptr); + going.store(false); + return; + } + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + memory_trial_orderly_end(); // (no verdict on the memory handling from a start ended on purpose) + if (host && host->log_flush) host->log_flush(); + TerminateProcess(GetCurrentProcess(), 0); +} __declspec(noinline) VkResult guarded_graphics(VkPipelineCache cache, const VkGraphicsPipelineCreateInfo* ci, VkPipeline* pl) { __try { return vkCreateGraphicsPipelines(dev.device, cache, 1, ci, nullptr, pl); - } __except (1) { - logf("vk: the driver faulted compiling a graphics pipeline (exception %#lx): that one is left out", (unsigned long)GetExceptionCode()); + } __except (driver_fault_note(GetExceptionInformation(), "graphics")) { + driver_fault_restart(); return VK_ERROR_UNKNOWN; } } __declspec(noinline) VkResult guarded_compute(VkPipelineCache cache, const VkComputePipelineCreateInfo* ci, VkPipeline* pl) { __try { return vkCreateComputePipelines(dev.device, cache, 1, ci, nullptr, pl); - } __except (1) { - logf("vk: the driver faulted compiling a compute pipeline (exception %#lx): that one is left out", (unsigned long)GetExceptionCode()); + } __except (driver_fault_note(GetExceptionInformation(), "compute")) { + driver_fault_restart(); return (VkResult)-77; // (a fault in the driver, told apart from what it returns) } } @@ -894,6 +1010,22 @@ bool gpl_libs_cached() { return on; } thread_local bool driver_cache_only = false; // (predict_run's: pipelines for the driver's own cache, not into ours) +// (lab, 11-13) RX_VK_TEST_DRIVER_FAULT=[,]: the n-th predicted pipeline is handed to the driver broken, so that the +// driver itself faults inside vkCreateGraphicsPipelines as it did in the lab on 11-13: what a start does after that can then be +// watched at will. Mode 1 (default): the stages' pointer names no memory; mode 2: the first stage's module is no module +void test_driver_fault(VkGraphicsPipelineCreateInfo& ci) { + static const char* e = getenv("RX_VK_TEST_DRIVER_FAULT"); + if (!e || !driver_cache_only) return; + static const int at = atoi(e); + static const int mode = strchr(e, ',') ? atoi(strchr(e, ',') + 1) : 1; + static std::atomic calls{0}; + if (++calls != at) return; + logf("vk: test: predicted pipeline %d is handed to the driver broken (mode %d, RX_VK_TEST_DRIVER_FAULT)", at, mode); + if (mode == 2 && ci.stageCount) + const_cast(ci.pStages)[0].module = reinterpret_cast((uintptr_t)0x1000); + else + ci.pStages = reinterpret_cast((uintptr_t)0x10); +} /// A target's write mask: the state's channel mask, nothing for a target the fragment shader leaves unwritten /// (Maxwell keeps its texels; Vulkan writes undefined values: TOTK's maxwell.md 1.1) @@ -1814,6 +1946,7 @@ VkPipeline build_graphics(const Program& p, const NvnState& s, const Targets& at // (measured: 21 of 21). gpl_libs_cached: RX_VK_GPL_NO_CACHE=1 keeps them out, as before) const bool lib_cached = (part == 1 || part == 2) && gpl_libs_cached(); const VkPipelineCache cache = lib_cached || (part < 0 && !driver_cache_only) ? pcache : VK_NULL_HANDLE; + test_driver_fault(ci); // (lab: RX_VK_TEST_DRIVER_FAULT) VkResult r = guarded_graphics(cache, &ci, &pl); // The AMD Windows compiler can reject ordinary graphics pipelines with its optimizer on. if (dev.props.vendorID == 0x1002 && dev.task_mesh_fallback && !p.mesh && part < 0 && r == VK_ERROR_UNKNOWN && @@ -1908,6 +2041,7 @@ VkSampler sampler_make(int id, bool compare) { if (suitable) p.aniso = std::max(p.aniso, (float)want); } uint64_t key = mix(compare ? 0xC0 : 0xAB, aniso_override()); + if (compare && getenv("RX_VK_DREF_OP")) key = mix(key, 0xD0EFull + (uint64_t)atoi(getenv("RX_VK_DREF_OP"))); const uint8_t* b = reinterpret_cast(&p); for (size_t i = 0; i < sizeof p; i += 8) { uint64_t w = 0; @@ -1974,6 +2108,9 @@ VkSampler sampler_make(int id, bool compare) { ci.maxAnisotropy = std::clamp(aniso, 1.0f, dev.props.limits.maxSamplerAnisotropy); ci.compareEnable = compare && p.cmp_mode != 0; ci.compareOp = compare_op(p.cmp_func); + // (Triforce, diagnostics) RX_VK_DREF_OP=: every depth-reference sample compares with that (0 never, + // 7 always): whether a picture's fault is in what its shadow lookups answer + static const int force_op = getenv("RX_VK_DREF_OP") ? atoi(getenv("RX_VK_DREF_OP")) : -1; { // (amd-fix) A depth-reference sample through a sampler that does not compare is undefined in Vulkan: NVIDIA's driver // compares anyway, AMD's does not (OoT samples this way: compare mode 0, function 0). A shader that compares gets // a comparing sampler: the game's function when it set one, LEQUAL otherwise. RX_VK_DREF_FROM_SAMPLER=1: as before @@ -1982,6 +2119,7 @@ VkSampler sampler_make(int id, bool compare) { ci.compareEnable = VK_TRUE; ci.compareOp = p.cmp_func >= 1 && p.cmp_func <= 8 ? compare_op(p.cmp_func) : VK_COMPARE_OP_LESS_OR_EQUAL; } + if (compare && force_op >= 0 && force_op <= 7) ci.compareEnable = VK_TRUE, ci.compareOp = (VkCompareOp)force_op; static std::mutex lm; static std::unordered_set told; std::lock_guard lg(lm); @@ -2068,7 +2206,7 @@ struct Dummies { template uint32_t handle_of(const NvnState& s, const Stage& st, const D& d, uint32_t k) { if constexpr (requires { d.handle_program; }) { // (read from a storage buffer: its handle program's) - if (d.handle_program != ~0U) return stage_handle(s, st, d.handle_program); + if (d.handle_program != ~0U) return stage_handle(s, st, d.handle_program, k); } const uint32_t step = 1u << d.size_shift; uint32_t h = stage_cbuf_word(s, st, d.cbuf_index, d.cbuf_offset + k * step); @@ -2117,6 +2255,10 @@ thread_local bool view_slot_known = true; // (Triforce: the last texture_view_ // (hookshot) RX_VK_TRACE_TEX=x,...: each draw sampling a texture of that size is logged with its state, every 30th frame, 600 lines: a // model that does not show is found by its textures, and whether the game draws it, and how, read from the line thread_local const Texture* trace_tex_hit = nullptr; +// (local) a draw being recorded once more for the temporal upscaler (vk_temporal.h temporal_pre_composite): into another +// target, one of its textures another view +thread_local bool pre_retarget_on = false; +thread_local TemporalRetarget pre_retarget; thread_local uint32_t trace_tex_mask = 0; bool trace_tex_wanted(const Texture* t) { static const std::vector> want = [] { @@ -2136,6 +2278,52 @@ bool trace_tex_wanted(const Texture* t) { return !want.empty() && trace_tex_mask == (1u << want.size()) - 1; // (a draw with all of them) } thread_local VkFormat last_view_format = VK_FORMAT_UNDEFINED; // (hookshot: RX_VK_LOG_IMG, the view last made) +/// (Triforce, diagnostics) RX_VK_LOG_TABLE=1: what the elements of a handle table name (a texture handle read from a table of +/// records, one texture an element: the water's lights' shadow maps), each (table, element, handle) once, 600 lines at most +void handle_table_log(uint64_t prog, const Shader::TextureDescriptor& d, uint32_t k, uint32_t handle) { + static const char* const want = getenv("RX_VK_LOG_TABLE"); // (1: every program; else a program key's first digits) + if (!want) return; + if (strcmp(want, "1")) { + char hex[24]; + snprintf(hex, sizeof hex, "%016llx", (unsigned long long)prog); + if (strncmp(hex, want, strlen(want))) return; + } + static std::mutex mu; + static std::unordered_set seen; + { + std::lock_guard lk(mu); + if (seen.size() >= 600 || !seen.insert((uint64_t)d.handle_program << 56 ^ (uint64_t)k << 40 ^ handle ^ prog * 0x9E3779B97F4A7C15ull).second) + return; + } + if (!handle) { + logf("vk: table prog %016llx table %u element %u: handle 0 (none)", (unsigned long long)prog, d.handle_program, k); + return; + } + nvn_tex t{}; + nvn_view v{}; + bool has_view = false; + bool known; + { + ParLock lk; + known = texture_of((int)(handle & 0xFFFFF), &t, &v, &has_view); + } + const VkFormat vf = known ? vk_format(t.d.format).format : VK_FORMAT_UNDEFINED; + { // (the element's sampler, as the game registered it) + nvn_samp_par sp{}; + const bool sk = sampler_of((int)(handle >> 20), &sp); + logf("vk: table prog %016llx table %u element %u: sampler %u %s: filters %u/%u wrap %u/%u/%u compare mode %u function %u " + "border %g %g %g %g lod %g..%g", (unsigned long long)prog, d.handle_program, k, handle >> 20, sk ? "registered" : "NOT registered", + (unsigned)sp.minf, (unsigned)sp.magf, (unsigned)sp.ws, (unsigned)sp.wt, (unsigned)sp.wr, (unsigned)sp.cmp_mode, + (unsigned)sp.cmp_func, (double)sp.border[0], (double)sp.border[1], (double)sp.border[2], (double)sp.border[3], + (double)sp.lod_min, (double)sp.lod_max); + } + logf("vk: table prog %016llx table %u element %u: handle %#x (texture slot %u, sampler %u), %s; NVN format %#x (%s), %ux%ux%u " + "levels %u, gpu %#llx; the shader samples it as %s", (unsigned long long)prog, d.handle_program, k, handle, + handle & 0xFFFFF, handle >> 20, known ? "registered" : "NOT registered", known ? t.d.format : 0, + !known ? "-" : is_depth_format(vf) ? "depth" : "colour", known ? t.d.width : 0, known ? t.d.height : 0, + known ? t.d.depth : 0, known ? t.d.levels : 0, (unsigned long long)(known ? t.gpu : 0), d.is_depth ? "depth" : "colour"); +} + bool log_img_wanted(uint64_t key) { // (hookshot) RX_VK_LOG_IMG=: its texture and image bindings, 8 times static const char* want = getenv("RX_VK_LOG_IMG"); if (!want) return false; @@ -2926,16 +3114,26 @@ void build_descriptors(const NvnState& s, const Program& p) { static const bool all_stages = getenv("RX_VK_HANDLE_POINTER_ALL") != nullptr; const uint32_t handle = ((all_stages || st.vk_stage == VK_SHADER_STAGE_FRAGMENT_BIT) && handle_is_storage_pointer(info, d, k)) ? 0u : handle_of(s, st, d, k); + if (d.handle_program != ~0U && d.count > 1) handle_table_log(p.key, d, k, handle); // (RX_VK_LOG_TABLE) desc_fp_note(handle); // (RX_VK_DESC_SLOTGEN) Texture* tex = nullptr; upload_defer_ok = st.vk_stage != VK_SHADER_STAGE_COMPUTE_BIT; // (a draw's: its new ASTC textures may wait a frame) VkImageView view = handle ? texture_view_of(handle, vt, ViewUse::Sample, VK_FORMAT_UNDEFINED, &tex) : VK_NULL_HANDLE; upload_defer_ok = false; + if (pre_retarget_on && view && tex == pre_retarget.from) view = pre_retarget.to_view; // (the engine's picture) if (dump_on()) dump_input('t', (uint32_t)(dw().imgs.size() - 0), handle, view ? tex : nullptr); if (view && tex && trace_tex_wanted(tex)) trace_tex_hit = tex; if (log_img_wanted(p.key)) { static std::atomic told{0}; + // (11-13) RX_VK_LOG_IMG_GO=: when that file appears, the next 600 bindings are said too (the ones of a + // chosen moment, not only the program's first draw); the file is taken away + static const char* const go = getenv("RX_VK_LOG_IMG_GO"); + if (go && k == 0 && GetFileAttributesA(go) != INVALID_FILE_ATTRIBUTES) { + DeleteFileA(go); + told = -600; + logf("vk: img: the bindings from here on are of the asked moment (RX_VK_LOG_IMG_GO)"); + } if (told++ < 40) logf("vk: img prog %016llx texture %u: handle %#x, shader integer %d type %d depth %d, view format " "%d, texture #%d format %d %ux%ux%u x%u levels %u sparse %d view %p", (unsigned long long)p.key, k, @@ -3093,6 +3291,8 @@ int words_same_store(const VkWriteDescriptorSet& w, uint64_t* o, const uint64_t* } bool bind_descriptors(VkCommandBuffer cmd, VkPipelineBindPoint bp, const Program& p) { + if (p.renodx) renodx_bind(cmd, bp, p.layout, p.renodx); + if (renodx_tracing.load(std::memory_order_relaxed) && bp == VK_PIPELINE_BIND_POINT_GRAPHICS) renodx_trace_draw(p.frag_crc); // (local, RenoDX port) set 1: its settings and state if (dw().writes.empty()) return true; // A failed sampler is retryable, but cannot be published to either descriptor path. // Check the entire array before updating the pushed-state cache or allocating a set. @@ -3188,7 +3388,10 @@ bool bind_descriptors(VkCommandBuffer cmd, VkPipelineBindPoint bp, const Program // ---- RX_VK_CHECKPOINTS: a marker before each draw and dispatch (VK_NV_device_diagnostic_checkpoints); when the // device is lost, the markers the GPU reached say which program it was running ---- -struct Checkpoint { uint64_t prog; uint64_t frame; uint32_t seq; char kind; }; +struct Checkpoint { uint64_t prog; uint64_t frame; uint32_t seq; char kind; uint32_t grid[3]; }; +// (Triforce, the Intel logs of 2026-11-13) the grid of the dispatch being recorded (dispatch() sets it): a device lost's report +// names it beside the program, the size of the work the GPU stopped in +thread_local uint32_t checkpoint_grid[3] = {0, 0, 0}; Checkpoint checkpoints[1 << 16]; std::atomic checkpoint_n{0}; @@ -3216,7 +3419,9 @@ void set_checkpoint(VkCommandBuffer cmd, uint32_t i, uint32_t seq) { void checkpoint(VkCommandBuffer cmd, const Program& p, char kind) { if (!checkpoints_on()) return; const uint32_t seq = ++checkpoint_n, i = (seq - 1) & 0xFFFF; - checkpoints[i] = {p.key, texture_frame_no(), seq, kind}; + const bool grid = kind == 'c' || kind == 'i'; + checkpoints[i] = {p.key, texture_frame_no(), seq, kind, + {grid ? checkpoint_grid[0] : 0, grid ? checkpoint_grid[1] : 0, grid ? checkpoint_grid[2] : 0}}; set_checkpoint(cmd, i, seq); } const char* checkpoint_kind(char c) { @@ -3226,6 +3431,14 @@ const char* checkpoint_kind(char c) { : "?"; } +// (" grid 4x4x1" for a dispatch whose grid was recorded, "" otherwise) +std::string checkpoint_grid_text(const Checkpoint& k) { + if ((k.kind != 'c' && k.kind != 'i') || !k.grid[0]) return {}; + char text[48]; + snprintf(text, sizeof text, " grid %ux%ux%u", k.grid[0], k.grid[1], k.grid[2]); + return text; +} + thread_local uint64_t fallback_payload_address = 0, fallback_records_address = 0; // (the draw's fallback buffers) thread_local uint64_t fallback_indirect_input = 0; @@ -3294,7 +3507,7 @@ void device_fault_report() { void checkpoint_mark(VkCommandBuffer cmd, uint64_t key, char kind) { if (!checkpoints_on()) return; const uint32_t seq = ++checkpoint_n, i = (seq - 1) & 0xFFFF; - checkpoints[i] = {key, texture_frame_no(), seq, kind}; + checkpoints[i] = {key, texture_frame_no(), seq, kind, {0, 0, 0}}; set_checkpoint(cmd, i, seq); } @@ -3354,8 +3567,8 @@ void buffer_markers_report() { logf("vk: device lost: %u markers set, %u reached; the last whose earlier work all finished: %u", n, reached, last_done); const auto line = [](const char* what, uint32_t s) { const Checkpoint& k = checkpoints[(s - 1) & 0xFFFF]; - logf("vk: %s: marker %u (%s %016llx, frame %llu)", what, s, checkpoint_kind(k.kind), (unsigned long long)k.prog, - (unsigned long long)k.frame); + logf("vk: %s: marker %u (%s %016llx%s, frame %llu)", what, s, checkpoint_kind(k.kind), (unsigned long long)k.prog, + checkpoint_grid_text(k).c_str(), (unsigned long long)k.frame); }; for (uint32_t s = last_done > 6 ? last_done - 6 : 1; last_done && s < last_done; s++) line("finished before", s); // (from the last finished marker to the first reached one whose earlier work did not finish: what the GPU was running) @@ -3371,7 +3584,15 @@ void checkpoints_report() { static bool done; if (done) return; done = true; - if (getenv("RX_VK_FAULT_INFO")) device_fault_report(); // (now, while the process is still alive: the faulting address) + // (Triforce, the Intel logs of 2026-11-13: an Arc B580 lost the device in a dispatch and the log could not say whether the GPU + // hung or read a bad address.) The fault info is asked for by default on a card that is not NVIDIA's, after the checkpoints + // are in the log; on NVIDIA the call has not come back after a fault, so there it stays for RX_VK_FAULT_INFO=1 to ask. + // RX_VK_FAULT_INFO=0: never; =1: before the checkpoints as well, as before + const char* fault_env = getenv("RX_VK_FAULT_INFO"); + const bool fault_first = fault_env && fault_env[0] != '0'; + static bool fault_after; + fault_after = fault_env ? fault_env[0] != '0' : dev.props.vendorID != 0x10DE && dev.device_fault; + if (fault_first) device_fault_report(); // (now, while the process is still alive: the faulting address) { // (RX_VK_FLASH_RECORD=: those programs' last draws, sizes and all) const uint64_t f = texture_frame_no(); draw_records_log(f > 6 ? f - 6 : 0, f); @@ -3380,7 +3601,7 @@ void checkpoints_report() { logf("vk: device lost: reading %s", dev.checkpoints ? "the checkpoints" : marker_words ? "the buffer markers" : "the fault info (RX_VK_CHECKPOINTS=1 for markers)"); - struct FaultLast { ~FaultLast() { if (std::getenv("RX_VK_FAULT_INFO")) device_fault_report(); } } fault_last; + struct FaultLast { ~FaultLast() { if (fault_after) device_fault_report(); } } fault_last; const auto watched = [] { std::lock_guard lk(watch_mu); for (int i = 0; i < 40; i++) @@ -3403,8 +3624,8 @@ void checkpoints_report() { if (i >= (1u << 16)) continue; const Checkpoint& k = checkpoints[i]; const auto kind = checkpoint_kind; - logf("vk: stage %#x: marker %u (%s %016llx, frame %llu)", (unsigned)c.stage, k.seq, kind(k.kind), - (unsigned long long)k.prog, (unsigned long long)k.frame); + logf("vk: stage %#x: marker %u (%s %016llx%s, frame %llu)", (unsigned)c.stage, k.seq, kind(k.kind), + (unsigned long long)k.prog, checkpoint_grid_text(k).c_str(), (unsigned long long)k.frame); // (the ones before it, for context) for (uint32_t b = 1; b <= 6; b++) { const Checkpoint& o = checkpoints[(i - b) & 0xFFFF]; @@ -5640,14 +5861,16 @@ void bind_index(VkCommandBuffer cmd, VkBuffer buffer, VkDeviceSize offset, VkInd /// (hookshot, a diagnostic for the temporal upscaler's motion: vk_temporal.cpp) RX_VK_DLSS_TRACE=: every that many frames, one frame's /// draws into targets of a size the upscaler can take as the scene (temporal_scene_size), logged: the program, its targets' formats, the geometry and the uniform buffers -static void dlss_trace_draw(const NvnState& s, const Program& p, const DrawArgs& d, const Targets& at) { +static void dlss_trace_draw(const NvnState& s, const Program& p, const DrawArgs& d, const Targets& at, const char* skin) { static const int every = getenv("RX_VK_DLSS_TRACE") ? atoi(getenv("RX_VK_DLSS_TRACE")) : 0; if (every <= 0 || !temporal_scene_size(at.width, at.height)) return; const uint64_t f = texture_frame_no(); if (f % (uint64_t)every != (uint64_t)every / 2) return; char line[3072]; - int n = snprintf(line, sizeof line, "vk: dlss-trace f%llu prog %016llx%s%s %ux%u c[", (unsigned long long)f, - (unsigned long long)p.key, d.mesh ? " mesh" : "", p.fallback ? "(fb)" : "", at.width, at.height); + // (the actor motion first, taken or why not: the log cuts long lines) + int n = snprintf(line, sizeof line, "vk: dlss-trace f%llu prog %016llx%s%s [skin: %s] %ux%u c[", (unsigned long long)f, + (unsigned long long)p.key, d.mesh ? " mesh" : "", p.fallback ? "(fb)" : "", skin ? skin : "taken", at.width, + at.height); for (int i = 0; i < at.n && n < 1800; i++) n += snprintf(line + n, sizeof line - n, "%s%d", i ? "," : "", (int)at.color_format[i]); n += snprintf(line + n, sizeof line - n, "] d%d %s n%d i%d bv%d inst%d ib%llx g%d,%d,%d ind%llx", (int)at.depth_format, d.indexed ? "idx" : "arr", d.count, d.first, d.base_vertex, d.instances, (unsigned long long)d.ibuf, @@ -5675,35 +5898,132 @@ static void dlss_trace_draw(const NvnState& s, const Program& p, const DrawArgs& /// (hookshot) A skinned draw into the scene, for the temporal upscaler's actor motion (vk_temporal.cpp: DLSS's and FSR's). OoT's characters and the things that /// move by themselves are indexed draws of one vertex stream: the position at attribute 0 (RGB32F or RGBA16F), the weights at 4 -/// (and 5, RGBA8), the joints at 6 (and 7, RGBA16UI or RGBA8UI), the bone palette in the vertex stage's uniform buffer 6 (NVN's -/// binding 3: 3 x 4 matrices, a whole number of them) and the object's origin in its buffer 4 (binding 1, at 0x40) -static void skin_check(const NvnState& s, const Program& p, const DrawArgs& d, const Targets& at) { - if (d.mesh || !d.indexed || d.indirect || d.instances != 1 || !at.n || !at.color[0] || !at.depth || - !temporal_scene_size(at.width, at.height) || at.color_format[0] != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || s.nvattr < 7 || - !temporal_wanted()) - return; +/// (and 5: RGBA8, RG8 or R8), the joints at 6 (and 7: as many, 8- or 16-bit), the bone palette in the vertex stage's uniform +/// buffer 6 (NVN's binding 3: 3 x 4 matrices, a whole number of them) and the object's origin in its buffer 4 (binding 1, at +/// 0x40). Link's model has all of them: four bones a vertex, five or six (a second set of one or two: his shoulders and +/// hair), two, and parts with one joint and no weights at all (rigid, kRigid). Only the four-bone sets were taken before, +/// and a second set of one or two was left out of the skinning: those parts got no motion of their own +/// Returns why a draw into the scene is not taken (RX_VK_DLSS_TRACE says it), or nullptr when it is +static const char* skin_check(const NvnState& s, const Program& p, const DrawArgs& d, const Targets& at) { + // (indexed or not: Link's legs and others are drawn as plain vertex arrays, and were left out when only indexed draws were taken) + if (d.mesh || d.indirect || d.instances != 1 || !at.n || !at.color[0] || !at.depth || + !temporal_scene_size(at.width, at.height) || !temporal_scene_format(at.color_format[0]) || !temporal_wanted()) + return "not a plain draw into the scene"; + if (s.nvattr < 7) return "fewer than 7 vertex attributes"; const auto attr = [&](int i) { return *reinterpret_cast(&s.vattr[i]); }; const nvn_va_st pos = attr(0); - if ((pos.fmt != NVN_FORMAT_RGB32F && pos.fmt != NVN_FORMAT_RGBA16F) || pos.stream != 0) return; + if ((pos.fmt != NVN_FORMAT_RGB32F && pos.fmt != NVN_FORMAT_RGBA16F) || pos.stream != 0) return "position format"; const nvn_p_bind_buf& bones = s.ubo[0][3]; - if (!bones.addr || bones.size < 48 || bones.size % 48) return; + // (a palette's buffer need not end on a whole matrix: Link's and others' are 16960 bytes, 353 matrices and 16 more. Its whole + // matrices are taken (temporal_note_skinned_draw); requiring a multiple of 48 left out every draw of them) + if (!bones.addr || bones.size < 48) return "no bone palette"; SkinnedDraw k; k.formats = pos.fmt == NVN_FORMAT_RGBA16F ? dlss_actor::kHalfPosition : 0; + // (a set's weights: RGBA8, RG8 or R8; its joints as many, 8- or 16-bit. Set 0 without weights and one joint: rigid) + const auto weight_count = [](int fmt) { return fmt == NVN_FORMAT_RGBA8 ? 4 : fmt == NVN_FORMAT_RG8 ? 2 : fmt == NVN_FORMAT_R8 ? 1 : 0; }; + const auto joint_count = [](int fmt, bool* bytes) { + *bytes = fmt == NVN_FORMAT_RGBA8UI || fmt == NVN_FORMAT_RG8UI || fmt == NVN_FORMAT_R8UI; + return fmt == NVN_FORMAT_RGBA16UI || fmt == NVN_FORMAT_RGBA8UI ? 4 : fmt == NVN_FORMAT_RG16UI || fmt == NVN_FORMAT_RG8UI ? 2 + : fmt == NVN_FORMAT_R16UI || fmt == NVN_FORMAT_R8UI ? 1 : 0; + }; for (int set = 0; set < 2 && 6 + set < s.nvattr; set++) { const nvn_va_st w = attr(4 + set), j = attr(6 + set); - if (w.fmt != NVN_FORMAT_RGBA8 || (j.fmt != NVN_FORMAT_RGBA16UI && j.fmt != NVN_FORMAT_RGBA8UI) || w.stream || j.stream || - w.offset % 4 || j.offset % 4) - break; - if (j.fmt == NVN_FORMAT_RGBA8UI) k.formats |= dlss_actor::kByteJoints << set; - k.weights[set] = w.offset, k.joints[set] = j.offset, k.sets = set + 1; + bool bytes = false; + const int nj = joint_count(j.fmt, &bytes), nw = weight_count(w.fmt); + const bool rigid = set == 0 && w.fmt == NVN_FORMAT_NONE && nj == 1; + if (!nj || (!rigid && nw != nj) || j.stream || (!rigid && w.stream) || (!bytes && j.offset % 2)) break; + if (bytes) k.formats |= dlss_actor::kByteJoints << set; + k.formats |= dlss_actor::count_code(nj) << (dlss_actor::kCountShift + 2 * set); + if (rigid) k.formats |= dlss_actor::kRigid; + k.weights[set] = rigid ? 0 : w.offset, k.joints[set] = j.offset, k.sets = set + 1; + if (rigid) break; // (one joint has all of the vertex) } const uint32_t stride = s.vstream[0].stride; - if (!k.sets || !stride || stride % 4 || pos.offset % 4 || !s.vbuf[0].address) return; + if (!k.sets) return "weights or joints format"; + if (!stride || stride % 4 || pos.offset % 4 || !s.vbuf[0].address) return "vertex stream"; k.depth = at.depth, k.vbuf = s.vbuf[0].address, k.vsize = s.vbuf[0].size, k.stride = stride, k.pos = pos.offset; - k.ibuf = d.ibuf, k.itype = d.itype, k.count = d.count, k.base_vertex = d.base_vertex; + if (d.indexed) k.ibuf = d.ibuf, k.itype = d.itype, k.count = d.count, k.base_vertex = d.base_vertex; + else k.ibuf = 0, k.itype = dlss_actor::kNoIndices, k.count = d.count, k.base_vertex = d.first; // (vertex i: first + i) k.bones = bones.addr, k.bones_size = bones.size, k.object = s.ubo[0][1].addr, k.object_size = s.ubo[0][1].size; + k.camera = s.ubo[0][0].addr, k.camera_size = s.ubo[0][0].size; k.program = p.key; - temporal_note_skinned_draw(k); + return temporal_note_skinned_draw(k); +} + +/// (hookshot) Where a draw's vertex stage stores its positions (Info::captures_position: every plain vertex stage), pushed +/// before each draw of such a program, also when it is nowhere (0): push constants are not kept across pipeline layouts, and +/// an address left from another draw would be written to. Only a plain, single-instance draw of triangles into the scene +/// (its colour target 0 and depth) is given a slot, by the temporal upscaler's chain when it wants positions +/// (vk_temporal.cpp capture_motion). capture: this draw may be one (false: an indirect draw, quads) +static void push_capture(VkCommandBuffer cmd, const Program& p, const NvnState& s, const DrawArgs& d, const Targets& at, + VkPrimitiveTopology topo, bool capture) { + if (!p.captures) return; + CaptureSlot slot; + if (capture && !d.mesh && !d.indirect && d.instances <= 1 && d.count > 0 && at.n && at.color[0] && at.depth && + (topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST || topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP || + topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN) && temporal_capture_wanted() && temporal_scene_size(at.width, at.height) && + temporal_scene_format(at.color_format[0])) { + CaptureDraw k; + k.depth = at.depth, k.vbuf = s.vbuf[0].address, k.program = p.key, k.count = d.count; + k.camera = s.ubo[0][0].addr, k.camera_size = s.ubo[0][0].size; + if (d.indexed) k.ibuf = d.ibuf, k.itype = d.itype, k.base_vertex = d.base_vertex; + else k.ibuf = 0, k.itype = dlss_actor::kNoIndices, k.base_vertex = d.first; // (vertex i: first + i) + // (as the draw's dynamic state has it: dyn_state) + k.topology = topo; + k.restart = s.restart && topo != VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + temporal_capture_draw(k, &slot); + } + uint8_t data[16]; + std::memcpy(data, &slot.address, 8), std::memcpy(data + 8, &slot.first, 4), std::memcpy(data + 12, &slot.count, 4); + static_assert(Shader::Backend::SPIRV::CAPTURE_FIRST_PUSH_OFFSET == Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET + 8 && + Shader::Backend::SPIRV::CAPTURE_COUNT_PUSH_OFFSET == Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET + 12, + "push_capture's layout"); + vkCmdPushConstants(cmd, p.layout, p.push_stages, Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET, sizeof data, data); +} + +static bool writes_memory(const Program& p) { + for (const Stage& st : p.stages) { + const auto& info = st.info; + const auto written = [](const auto& ds) { + return std::any_of(ds.begin(), ds.end(), [](const auto& d) { return d.is_written; }); + }; + if (info.stores_global_memory || written(info.storage_buffers_descriptors) || + written(info.image_buffer_descriptors) || written(info.image_descriptors)) + return true; + } + return false; +} + +// A mesh fallback's colour draws are left out until their pipelines build (minutes each on an Iris Xe), while the smaller +// depth-only draws of the same culled list (same indirect arguments) are already built. Depth with no colour lets the sky show +// through the grass, so a depth-only draw is held while its list's colour draw is. RX_VK_FALLBACK_DEPTH_HOLD=0 turns this off. +enum class FallbackRole { None, DepthOnly, Colour }; +static FallbackRole fallback_role_of(const Program& p, const NvnState& s, const Targets& at, const DrawArgs& d) { + static const bool on = !getenv("RX_VK_FALLBACK_DEPTH_HOLD") || atoi(getenv("RX_VK_FALLBACK_DEPTH_HOLD")) != 0; + if (!on || !d.indirect || writes_memory(p)) return FallbackRole::None; + uint32_t wm = 0; + for (int i = 0; i < at.n; i++) + if (at.color[i]) wm |= target_write_mask(p, s, i); + if (wm) return FallbackRole::Colour; + return at.depth && s.ds.dw ? FallbackRole::DepthOnly : FallbackRole::None; +} +static std::mutex fallback_held_mu; +// Indirect-argument address -> frame its colour draw was last left out; an address is assumed to stay with one list for the hold. +static std::unordered_map fallback_held; +/// Marks the list's colour draw as left out (held) or recorded (!held) this frame. +static void fallback_list_hold(uint64_t list, bool held) { + std::lock_guard lk(fallback_held_mu); + if (held) fallback_held[list] = texture_frame_no(); + else fallback_held.erase(list); +} +/// True while the list's colour draw was left out in the last 120 frames (so a list no colour draw uses any more is released). +static bool fallback_list_held(uint64_t list) { + std::lock_guard lk(fallback_held_mu); + const auto it = fallback_held.find(list); + if (it == fallback_held.end()) return false; + if (texture_frame_no() - it->second <= 120) return true; + fallback_held.erase(it); + return false; } void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { @@ -5717,8 +6037,14 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { if (d.prim >= 0 && d.prim < 32 && logged[d.prim]++ < 2) logf("vk: draws of NVN primitive %d are left out", d.prim); SKIP_HERE(); } - const Targets at = bare_targets(s, targets(s)); + Targets at = bare_targets(s, targets(s)); if (!at.width || !at.height) SKIP_HERE(); + if (pre_retarget_on) { // (local: this draw into the upscale's output, at its size, without the depth target) + at = Targets{}; + at.color[0] = pre_retarget.target, at.color_view[0] = pre_retarget.target_view; + at.color_format[0] = pre_retarget.target->format, at.n = 1; + at.width = pre_retarget.width, at.height = pre_retarget.height; + } // (hookshot) the scene's camera and depth for the temporal upscalers: NVIDIA DLSS and AMD FSR 4 (vk_temporal.cpp) and AMD // FSR 3.1 (vk_fsr3_inputs.cpp). The vertex stage's uniform buffer 3 (NVN's binding 0) if (at.n && at.color[0] && at.depth) { @@ -5763,6 +6089,45 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { if (cp->key == 0x1a7482c0ec9991eaULL) world_drawn_at.store(presents_now, std::memory_order_relaxed); if (cp->key == 0x02ff9920c2571cc2ULL) wheel_drawn_at.store(presents_now, std::memory_order_relaxed); if (skip_live(cp->key)) return; // (EvilOOT, RX_VK_SKIP_FILE) + // (local) NVIDIA DLAA before the game's bloom and tone mapping (vk_temporal.h): at the first draw after the scene's last, + // the engine draws into the scene's colour target, outside a pass; its pipeline, viewport and descriptors were its own + bool pre_late = false; + const bool pre_now = at.n && at.color[0] && temporal_pre_point(at.color[0], cp->key, &pre_late); + if (pre_late && (getenv("RX_VK_DUMP_DIR") || getenv("RX_VK_SHOTS"))) dump_request(presents_now + 1, 1); + if (pre_now) { + end_pass(cmd); + if (Texture* scene = temporal_pre_tonemap(cmd)) { + ParLock lk; + texture_written(scene, "the upscaler before the bloom"); + } + last_dyn_valid = false, last_desc_valid = false, last_vb_valid = false, last_pipeline = VK_NULL_HANDLE; + vertex_set.on = false, last_ib.on = false; + } + // (local) and the game's tone mapping after it, when the engine scaled up: recorded once more, at the output's size from + // the engine's picture, into the upscale's output; then as the game has it + if (!pre_retarget_on && at.n == 1 && at.color[0]) { + TemporalRetarget k; + if (temporal_pre_composite(at.color[0], at.width, at.height, &k)) { + end_pass(cmd); + k.to_view = temporal_pre_merged(cmd); + const float fx = (float)k.width / (float)at.width, fy = (float)k.height / (float)at.height; + float vp[4]; + int32_t sc[4]; + std::memcpy(vp, s.viewport[0], sizeof vp), std::memcpy(sc, s.scissor, sizeof sc); + s.viewport[0][0] *= fx, s.viewport[0][2] *= fx, s.viewport[0][1] *= fy, s.viewport[0][3] *= fy; + s.scissor[0] = (int32_t)((float)sc[0] * fx + 0.5f), s.scissor[2] = (int32_t)((float)sc[2] * fx + 0.5f); + s.scissor[1] = (int32_t)((float)sc[1] * fy + 0.5f), s.scissor[3] = (int32_t)((float)sc[3] * fy + 0.5f); + const int64_t skipped = st_skipped; + pre_retarget = k, pre_retarget_on = true; + last_dyn_valid = false, last_desc_valid = false; + draw(cmd, s, d); + pre_retarget_on = false; + end_pass(cmd); + std::memcpy(s.viewport[0], vp, sizeof vp), std::memcpy(s.scissor, sc, sizeof sc); + last_dyn_valid = false, last_desc_valid = false; + temporal_pre_composited(st_skipped == skipped); + } + } { // (hookshot, RX_VK_SKIP_PROG=: draws too, their native code keys logged once; =-: none) // (OoT's 53509044401d78d2, by default only while its targets have no view: 128 draws, once while an area loads, that render // the slices of two 64^3 BC4 noise volumes through raw RGBA16UI views. Those views were not made (no attachment usage) and @@ -5878,27 +6243,17 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { pe = graphics_pipeline(p, s, at, topo, types); } if (!pe->ready.load(std::memory_order_acquire)) { - bool may_skip = !always_wait && targets_persistent(at); - if (may_skip) - for (const Stage& st : p.stages) { - const auto& info = st.info; - const auto written = [](const auto& ds) { - return std::any_of(ds.begin(), ds.end(), [](const auto& d) { return d.is_written; }); - }; - if (info.stores_global_memory || written(info.storage_buffers_descriptors) || - written(info.image_buffer_descriptors) || written(info.image_descriptors)) { - may_skip = false; - break; - } - } + const bool may_skip = !always_wait && targets_persistent(at) && !writes_memory(p); if (may_skip) return void(st_pending_skips++); wait_for(pe->ready); } const VkPipeline pl = pe->pipeline; if (!pl) SKIP_HERE(); cur_program = &p; - dlss_trace_draw(s, p, d, at); - skin_check(s, p, d, at); + { + const char* skin = skin_check(s, p, d, at); + dlss_trace_draw(s, p, d, at, skin); + } if (!record_progs().empty() && std::find(record_progs().begin(), record_progs().end(), p.key) != record_progs().end()) record_draw(s, p, d, at); // (RX_VK_DUMP_EACH=,...: in a dump, the pass ends after each draw of those programs, so every one of them is @@ -6052,7 +6407,14 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { mesh_args = {mesh_args_buffer, (VkDeviceSize)mesh_args_at * 16, (VkDeviceSize)n * 16, 0}; } } - if (p.fallback && d.mesh && !fallback_record(cmd, p, d)) SKIP_HERE(); + const FallbackRole fallback_role = p.fallback && d.mesh ? fallback_role_of(p, s, at, d) : FallbackRole::None; + if (fallback_role == FallbackRole::DepthOnly && fallback_list_held(d.indirect)) SKIP_HERE(); + if (p.fallback && d.mesh && !fallback_record(cmd, p, d)) { + if (fallback_role == FallbackRole::Colour && p.compute_state.load(std::memory_order_acquire) == 1) + fallback_list_hold(d.indirect, true); + SKIP_HERE(); + } + if (fallback_role == FallbackRole::Colour) fallback_list_hold(d.indirect, false); { FINE_SCOPE(FT_HAZARD); begin_pass(cmd, at); @@ -6372,6 +6734,7 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { std::memcpy(out + q * 6, tri, sizeof tri); } bind_index(cmd, cur->stream, at6, VK_INDEX_TYPE_UINT32); + push_capture(cmd, p, s, d, at, topo, false); vkCmdDrawIndexed(cmd, quads * 6, (uint32_t)std::max(1, d.instances), 0, d.indexed ? d.base_vertex : 0, (uint32_t)d.base_instance); st_draws++, pass().draws++; @@ -6385,6 +6748,7 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { BufferRef args = gpu_buffer_bind(d.indirect, (uint64_t)std::max(d.max, 1) * (uint64_t)ind_stride, false); BufferRef cnt = d.count_addr ? gpu_buffer_bind(d.count_addr, 4, false) : BufferRef{}; if (!args) SKIP_HERE(); + push_capture(cmd, p, s, d, at, topo, false); if (d.indexed) { BufferRef ib = gpu_buffer_bind(d.ibuf, 4, false); if (!ib) SKIP_HERE(); @@ -6405,9 +6769,11 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { FINE_N(FC_IBIND, 1); bind_index(cmd, ib.buffer, ib.offset, itype); } + push_capture(cmd, p, s, d, at, topo, true); FINE_SCOPE(FT_DRAWCALL); vkCmdDrawIndexed(cmd, (uint32_t)d.count, (uint32_t)std::max(1, d.instances), 0, d.base_vertex, (uint32_t)d.base_instance); } else { + push_capture(cmd, p, s, d, at, topo, true); FINE_SCOPE(FT_DRAWCALL); vkCmdDraw(cmd, (uint32_t)d.count, (uint32_t)std::max(1, d.instances), (uint32_t)d.first, (uint32_t)d.base_instance); } @@ -6530,6 +6896,20 @@ static bool temporal_rejected_network(VkCommandBuffer cmd, uint64_t key, Texture bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { static const bool off = getenv("RX_VK_NO_UPSCALE_STUB") != nullptr; if (off) return false; + // (Triforce, the Intel logs of 2026-11-13: an Arc A750 left out the networks of the Render resolution's other shares and its + // log had no line saying what drew their upscale, or that nothing did.) Each program's first outcome here is logged: why no + // upscale stood in for it (its dispatch is then left out: for a network's last pass, the picture is never written), or + // which path drew it. 48 programs + const auto told = [key](const char* what) { + static std::mutex told_mu; + static std::unordered_set told_keys; + std::lock_guard lk(told_mu); + return told_keys.size() < 48 && told_keys.insert(key).second ? what : nullptr; + }; + const auto declined = [&](const char* why) { + if (told(why)) logf("vk: rejected compute %016llx: no upscale stands in for it (%s)", (unsigned long long)key, why); + return false; + }; nvn_tex out{}, in{}; uint64_t out_area = 0, in_area = 0, in_h = 0, out_h = 0; uint64_t img_gpu[32]{}, tex_gpu[128]{}; @@ -6553,7 +6933,7 @@ bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { const uint64_t a = (uint64_t)t.d.width * t.d.height; if (t.d.depth <= 1 && a > out_area) out = t, out_area = a, out_h = s.img[5][i]; } - if (!out_area) return false; + if (!out_area) return declined("it writes no image it does not also sample"); for (uint32_t i = 0; i < ntex_slots; i++) { nvn_tex t; nvn_view v; @@ -6564,12 +6944,13 @@ bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { const uint64_t a = (uint64_t)t.d.width * t.d.height; if (a > in_area) in = t, in_area = a, in_h = s.tex[5][i]; } - if (!in_area || out_area <= in_area) return false; + if (!in_area) return declined("it samples no texture of its output's kind that it does not also write"); + if (out_area <= in_area) return declined("its output is no larger than its input: not an upscale's last pass"); Texture* src = texture_get(&in, true); Texture* dst = texture_get(&out, false); if (!src || !dst || !src->image || !dst->image || (src->aspect | dst->aspect) != VK_IMAGE_ASPECT_COLOR_BIT || src->bc || dst->bc || src->samples != VK_SAMPLE_COUNT_1_BIT || dst->samples != VK_SAMPLE_COUNT_1_BIT) - return false; + return declined("its input or output has no plain colour image"); // (hookshot) an upscale network that did not translate here (the Render resolution's fixed shares have one each, and on a // GPU without cooperative matrices they are left out): the temporal upscaler is offered it first, as temporal_stand_in // offers the networks that did translate. It takes only the scene into the picture; anything else goes on below @@ -6579,7 +6960,7 @@ bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { vkGetPhysicalDeviceFormatProperties(dev.physical, dst->format, &fd); if (!(fs.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) || !(fd.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT) || !(fs.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)) - return false; + return declined("the card cannot blit between its input's and output's formats"); end_pass(cmd); full_barrier(cmd); if (dst->format == VK_FORMAT_R8G8B8A8_UNORM && movie_upscale(cmd, in_h, out_h, dst)) { @@ -6619,6 +7000,10 @@ bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { typed_upscale(cmd, input_view, output_view, dst, 0, key, "generic RGB9E5 fallback", false)) { full_barrier(cmd); texture_written(dst); + if (told("typed")) + logf("vk: program %016llx does not translate: its dispatch replaced by the typed upscale of %#llx %ux%u (NVN %#x) " + "into %#llx %ux%u (NVN %#x)", (unsigned long long)key, (unsigned long long)in.gpu, in.d.width, in.d.height, + (unsigned)in.d.format, (unsigned long long)out.gpu, out.d.width, out.d.height, (unsigned)out.d.format); if (gameplay_taau) { static std::atomic logged_gameplay_upscale{false}; if (!logged_gameplay_upscale.exchange(true, std::memory_order_relaxed)) @@ -6862,13 +7247,17 @@ static bool temporal_rejected_network(VkCommandBuffer cmd, uint64_t key, Texture end_pass(cmd); VkFormat in_format = VK_FORMAT_UNDEFINED, out_format = VK_FORMAT_UNDEFINED; const VkImageView in_view = texture_view(src, in, nullptr, VK_IMAGE_VIEW_TYPE_2D, ViewUse::Sample, &in_format); - const VkImageView out_view = texture_view(dst, out, nullptr, VK_IMAGE_VIEW_TYPE_2D, ViewUse::Storage, &out_format, - VK_FORMAT_B10G11R11_UFLOAT_PACK32); + // (local, RenoDX port) an RGBA16F scene (the host's choice for the run, vk_temporal.h temporal_scene_format): its picture + // is RGBA16F too, and so is the view the temporal upscaler's HDR output pass writes + const bool wide = src->format == VK_FORMAT_R16G16B16A16_SFLOAT && dst->format == VK_FORMAT_R16G16B16A16_SFLOAT; + const VkFormat picture = wide ? VK_FORMAT_R16G16B16A16_SFLOAT : VK_FORMAT_B10G11R11_UFLOAT_PACK32; + const VkImageView out_view = texture_view(dst, out, nullptr, VK_IMAGE_VIEW_TYPE_2D, ViewUse::Storage, &out_format, picture); // (the gameplay networks' own formats: their input is the square root of the scene colour, which the fixed shares' networks // sample as RGB9E5 from the B10G11R11 image it is kept in (shaders/taau_upscale.comp), the 3/4 one as B10G11R11. Decoded, // both are what the temporal upscaler's prep pass takes. The movies' (RGBA8) are not the scene) - if (!in_view || !out_view || out_format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || - (in_format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 && in_format != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) + if (!in_view || !out_view || out_format != picture || + (wide ? in_format != VK_FORMAT_R16G16B16A16_SFLOAT + : in_format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 && in_format != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) return false; const bool done = temporal_upscale(cmd, key, false, src, in_view, dst, out_view, 0); last_dyn_valid = false, last_desc_valid = false, last_vb_valid = false, last_pipeline = VK_NULL_HANDLE; @@ -7612,16 +8001,90 @@ void precompile_run(void (*progress)(size_t done, size_t total)) { // (hookshot) The pipelines the notes predict for the programs no note names (vk_predict.cpp), after a prepare that prepared: each built // once for the driver's own cache and let go. Not into ours (mkw_vk_pipelines.bin, read whole at every start: ~40000 more pipelines made // it 1.7 GB), nor kept: each program is borrowed from triforce_programs.bin for its pipelines and let go +// ---- (Triforce, 11-12) The predicted pipelines to their end ---- +// predict_run stops at its time budget, and only a start that prepared the shaders runs it. A lab start on an RTX 4070 SUPER: +// "predicted 24182 pipelines ... for 23484 program variants no note names: 16296 made in 95.5 s (the time budget ran out)": a +// third left even there. On AMD's driver a pipeline whose shaders it has never compiled takes seconds (two players' RX 9070 +// XT, v0.3.3 and v0.3.4: 18 new pipelines in 56.3 s, 9 in 62.8 s, 4 in 17.3 s), so the budget covers a few hundred of the +// 24000 there, and each program first drawn after that froze the game while its pipeline was built (55.9 s when a horse was +// called: the draws that write memory wait for their pipeline, #1573). The pipeline list covers what somebody has drawn +// (6183 of the game's 34681 graphics programs on 11-12); the prediction is the net under it for the rest. +// So the programs whose predicted pipelines are built are kept in a record (triforce_pipelines.bin.predicted, for this +// translator and driver), a later predict_run leaves them out, and predict_background builds the rest behind the game: every +// start, a minute in, on idle threads, until the record has them all. RX_VK_PREDICT_BG=0: not; RX_VK_PREDICT_BG_THREADS= +// (a sixth of the processors, 1 to 3); RX_VK_PREDICT_BG_AFTER_S= (60). +namespace { +std::mutex predicted_mu; +FILE* predicted_file = nullptr; +uint64_t predicted_file_stamp = 0; +constexpr uint64_t kPredictedAll = 0xA11D09EC0FFEE001ull; // (in the record: every predicted program was built) +std::string predicted_path() { return pipe_notes_path() + ".predicted"; } +std::unordered_set predicted_read(uint64_t stamp) { + std::unordered_set keys; + if (FILE* f = fopen(predicted_path().c_str(), "rb")) { + uint64_t v = 0; + if (fread(&v, 8, 1, f) == 1 && v == stamp) + while (fread(&v, 8, 1, f) == 1) keys.insert(v); + fclose(f); + } + return keys; +} +// (the plan: what is predicted, kept from the one time the programs' file was gone through whole for it) +std::string plan_path() { return pipe_notes_path() + ".plan"; } +void plan_write(const std::vector& plan) { + if (FILE* f = fopen(plan_path().c_str(), "wb")) { + const uint64_t head[2] = {program_cache_stamp(), plan.size()}; + fwrite(head, 8, 2, f); + if (!plan.empty()) fwrite(plan.data(), sizeof(PredictPlan), plan.size(), f); + fclose(f); + } +} +bool plan_read(std::vector* plan) { + bool ok = false; + if (FILE* f = fopen(plan_path().c_str(), "rb")) { + uint64_t head[2] = {0, 0}; + if (fread(head, 8, 2, f) == 2 && head[0] == program_cache_stamp() && head[1] < (1u << 24)) { + plan->resize((size_t)head[1]); + ok = plan->empty() || fread(plan->data(), sizeof(PredictPlan), plan->size(), f) == plan->size(); + } + fclose(f); + } + if (!ok) plan->clear(); + return ok; +} +void predicted_done(uint64_t stamp, uint64_t key) { + std::lock_guard lk(predicted_mu); + if (!predicted_file || predicted_file_stamp != stamp) { + if (predicted_file) fclose(predicted_file), predicted_file = nullptr; + uint64_t v = 0; + bool same = false; + if (FILE* f = fopen(predicted_path().c_str(), "rb")) { + same = fread(&v, 8, 1, f) == 1 && v == stamp; + fclose(f); + } + predicted_file = fopen(predicted_path().c_str(), same ? "ab" : "wb"); + if (predicted_file && !same) fwrite(&stamp, 8, 1, predicted_file); + predicted_file_stamp = stamp; + } + if (predicted_file) fwrite(&key, 8, 1, predicted_file), fflush(predicted_file); +} +} // namespace + void predict_run(void (*progress)(size_t done, size_t total)) { const auto t0 = std::chrono::steady_clock::now(); const std::vector> notes = pipe_notes_read(); if (notes.empty() || getenv("RX_VK_NO_PREDICT")) return; size_t programs = 0; - const std::vector> predicted = predict_pipelines(notes, &programs); + std::vector plan; + const std::vector> predicted = predict_pipelines(notes, &programs, &plan); + plan_write(plan); // (for predict_background: after the precompile the programs' file cannot be gone through whole) std::unordered_map> by_program; for (const auto& n : predicted) by_program[n->prog].push_back(n.get()); + const uint64_t pstamp = warmed_stamp(gpl_wanted()); + const std::unordered_set had = predicted_read(pstamp); // (built by an earlier start, for this driver) std::vector keys; - for (const auto& kv : by_program) keys.push_back(kv.first); + for (const auto& kv : by_program) + if (!had.count(kv.first)) keys.push_back(kv.first); std::atomic next{0}, done{0}, made{0}; // (hookshot) A time budget, RX_VK_PREDICT_S (90 s by default; 0: none): once #1051 let the prediction find its programs again it // predicted ~28000 pipelines, and a first start after an update spent many minutes on them before the game's first frame (20 with @@ -7648,6 +8111,7 @@ void predict_run(void (*progress)(size_t done, size_t total)) { if (const VkPipeline pl = build_graphics(p, n->s, note_targets(*n), (VkPrimitiveTopology)n->topo)) vkDestroyPipeline(dev.device, pl, nullptr), made++; }); + predicted_done(pstamp, keys[i]); done += list.size(); } }; @@ -7661,7 +8125,97 @@ void predict_run(void (*progress)(size_t done, size_t total)) { for (std::thread& t : threads) t.join(); logf("vk: predicted %zu pipelines from %zu notes for %zu program variants no note names: %zu made in %.1f s%s", predicted.size(), notes.size(), programs, made.load(), std::chrono::duration(std::chrono::steady_clock::now() - t0).count(), - out_of_time.load() ? " (the time budget, RX_VK_PREDICT_S, ran out: the rest are built in play)" : ""); + out_of_time.load() ? " (the time budget, RX_VK_PREDICT_S, ran out: the rest are built behind the game)" : ""); + if (!out_of_time.load() && !prepare_stopped()) predicted_done(pstamp, kPredictedAll); +} + +/// (Triforce) The plan made when there is none for these shaders, before the precompile takes the noted programs out of the +/// programs' file's list: an install prepared by an older build has none (predict_run writes it from now on). The programs' +/// file is read whole for it once (seconds on an SSD), said in the log with its time +void predict_plan_ensure() { + const char* e = getenv("RX_VK_PREDICT_BG"); + if ((e && !atoi(e)) || getenv("RX_VK_NO_PREDICT")) return; + if (predicted_read(warmed_stamp(gpl_wanted())).count(kPredictedAll)) return; + std::vector plan; + if (plan_read(&plan)) return; + const auto t0 = std::chrono::steady_clock::now(); + const std::vector> notes = pipe_notes_read(); + if (notes.empty()) return; + size_t programs = 0; + const std::vector> predicted = predict_pipelines(notes, &programs, &plan); + plan_write(plan); + logf("vk: predicted pipelines: the plan was made from %zu notes: %zu pipelines for %zu program variants no note names, in " + "%.1f s (once for these shaders)", notes.size(), plan.size(), programs, + std::chrono::duration(std::chrono::steady_clock::now() - t0).count()); +} + +/// (Triforce) The predicted pipelines predict_run did not get to, built behind the game: see above +void predict_background() { + static std::atomic started{false}; + const char* e = getenv("RX_VK_PREDICT_BG"); + if ((e && !atoi(e)) || getenv("RX_VK_NO_PREDICT") || started.exchange(true)) return; + std::thread([] { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); + static const int after_s = getenv("RX_VK_PREDICT_BG_AFTER_S") ? atoi(getenv("RX_VK_PREDICT_BG_AFTER_S")) : 60; + for (int i = 0; i < after_s * 10 && !prepare_stopped(); i++) Sleep(100); // (past the start's own loading) + if (prepare_stopped()) return; + const auto t0 = std::chrono::steady_clock::now(); + const uint64_t pstamp = warmed_stamp(gpl_wanted()); + const std::unordered_set had = predicted_read(pstamp); + if (had.count(kPredictedAll)) return; // (all built for this driver: the programs' file is not read for it again) + const std::vector> notes = pipe_notes_read(); + if (notes.empty()) return; + std::vector plan; + if (!plan_read(&plan)) { + logf("vk: predicted pipelines: no plan for these shaders yet (predict_plan_ensure makes it before the precompile)"); + return; + } + const std::vector> predicted = predict_rebuild(notes, plan); + std::unordered_map> by_program; + for (const auto& n : predicted) by_program[n->prog].push_back(n.get()); + std::vector keys; + for (const auto& kv : by_program) + if (!had.count(kv.first)) keys.push_back(kv.first); + if (keys.empty()) { + predicted_done(pstamp, kPredictedAll); + return; + } + const unsigned cpus = std::max(1u, std::thread::hardware_concurrency()); + static const unsigned nthreads = getenv("RX_VK_PREDICT_BG_THREADS") + ? (unsigned)std::clamp(atoi(getenv("RX_VK_PREDICT_BG_THREADS")), 1, 32) : std::clamp(cpus / 6, 1u, 3u); + logf("vk: predicted pipelines: %zu programs' are still to build for this driver (%zu were built by earlier starts): built " + "behind the game on %u idle thread(s) (RX_VK_PREDICT_BG=0: not)", keys.size(), had.size(), nthreads); + std::atomic next{0}, made{0}, programs_done{0}; + const auto worker = [&] { + ub_thread_off(); // (a background thread: see ub_thread_off) + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); + driver_cache_only = true; + for (;;) { + if (prepare_stopped()) return; + const size_t i = next++; + if (i >= keys.size()) return; + const auto& list = by_program[keys[i]]; + program_cache_borrow(keys[i], [&](Program& p) { + ensure_layout(p); + for (const PipeNote* n : list) + if (n->variant == p.variant) + if (const VkPipeline pl = build_graphics(p, n->s, note_targets(*n), (VkPrimitiveTopology)n->topo)) + vkDestroyPipeline(dev.device, pl, nullptr), made++; + }); + predicted_done(pstamp, keys[i]); + if (++programs_done % 2000 == 0) + logf("vk: predicted pipelines: %zu of %zu programs built behind the game so far", programs_done.load(), keys.size()); + } + }; + std::vector threads; + for (unsigned i = 0; i < nthreads; i++) threads.emplace_back(worker); + for (std::thread& t : threads) t.join(); + const bool all = programs_done.load() >= keys.size() && !prepare_stopped(); + if (all) predicted_done(pstamp, kPredictedAll); + logf("vk: predicted pipelines: %zu built behind the game for %zu programs in %.0f s%s", made.load(), programs_done.load(), + std::chrono::duration(std::chrono::steady_clock::now() - t0).count(), + all ? ": every predicted program is built for this driver now" : " (stopped: the rest at the next start)"); + }).detach(); } void dispatch(VkCommandBuffer cmd, NvnState& s, uint32_t x, uint32_t y, uint32_t z, uint64_t indirect) { @@ -7672,6 +8226,7 @@ void dispatch(VkCommandBuffer cmd, NvnState& s, uint32_t x, uint32_t y, uint32_t uint32_t g[3] = {1, 1, 1}; if (memory_read_as_submitted(indirect, g, 12)) s.grid[0] = g[0], s.grid[1] = g[1], s.grid[2] = g[2]; } + checkpoint_grid[0] = s.grid[0], checkpoint_grid[1] = s.grid[1], checkpoint_grid[2] = s.grid[2]; const uint8_t types[8]{}; const Program* cp = program_for(s, ProgramKind::Compute, types); dclock.t_prog = slow_dispatch_timing() ? std::chrono::steady_clock::now() : std::chrono::steady_clock::time_point{}; diff --git a/gpu/vk/vk_draw.h b/gpu/vk/vk_draw.h index 482571e..7a62173 100644 --- a/gpu/vk/vk_draw.h +++ b/gpu/vk/vk_draw.h @@ -19,7 +19,17 @@ struct PipeNote { NvnState s; }; /// (vk_predict.cpp) The pipelines the notes predict for the kept graphics program variants no note names (key 0: not made yet) -std::vector> predict_pipelines(const std::vector>& notes, size_t* programs); +/// (Triforce) A predicted pipeline as what it is made from: the program variant, the note whose vertex layout it takes and +/// the note whose targets and state it takes. 32 bytes against a note's ~26 KB: the plan is kept in a file, and the notes +/// are made again from it (predict_rebuild) when the programs' file can no longer be gone through whole (after the +/// precompile took the noted programs out of its list) +struct PredictPlan { + uint64_t prog, variant, vertex_note, output_note; +}; +std::vector> predict_pipelines(const std::vector>& notes, size_t* programs, + std::vector* plan = nullptr); +std::vector> predict_rebuild(const std::vector>& notes, + const std::vector& plan); } #include @@ -83,6 +93,8 @@ uint64_t ub_generation(); void ub_thread_off(); /// The pipeline cache to disk (force: whatever was built since the last save; else only after a few new ones) void pipeline_cache_save(bool force); +/// (vk_memory.cpp) The menu's Restart and Exit, before the window closes: no verdict on the memory trial for a session ended on purpose +void memory_trial_orderly_end(); /// The stream's uniform updates (UPDATE_UB, vk_replay.cpp) that overlap [addr, addr + n) and may not be in guest /// memory yet when the GPU reads it: a copy of the range with them applied, at the offset alloc returns in the diff --git a/gpu/vk/vk_framegen.cpp b/gpu/vk/vk_framegen.cpp index b2e7f00..e0be811 100644 --- a/gpu/vk/vk_framegen.cpp +++ b/gpu/vk/vk_framegen.cpp @@ -564,7 +564,12 @@ VkImage framegen_scale(VkCommandBuffer cmd, VkImageView src, VkImage image, uint } drop_img(scale.scaled); scale.scaled_w = scale.scaled_h = 0; - if (!make_img(scale.scaled, dw, dh, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT)) { + // (Triforce, 11-13: SAMPLED too. On an HDR10 display the HDR pass (framegen_hdr) samples this image whenever the + // picture was scaled or sharpened first; made without that usage, sampling it is not allowed, and the window was + // black with Sharpness or Upscaling on ("Sharpness slider deletes all visuals", RTX 3060 Ti on an HDR10 surface; + // shown in the lab with RX_VK_TEST_HDR_PASS=1: the window's mean brightness 0 with Sharpness 70, 131 with 0)) + if (!make_img(scale.scaled, dw, dh, VK_FORMAT_R8G8B8A8_UNORM, + VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)) { drop_img(scale.scaled); return VK_NULL_HANDLE; } diff --git a/gpu/vk/vk_fsr3.cpp b/gpu/vk/vk_fsr3.cpp index 0b8af0f..050dcff 100644 --- a/gpu/vk/vk_fsr3.cpp +++ b/gpu/vk/vk_fsr3.cpp @@ -18,6 +18,7 @@ #include "vk_fsr3.h" #include "vk_fsr3_inputs.h" +#include "vk_fsr3fi.h" // (frames_wanted: not before the bloom with frame interpolation on) #include "vk_draw.h" // (descriptors_disturbed) #include "vk_gprof.h" // (RX_VK_PASS_TIMING: a span per pass, so the report names them) #include "vk_menu.h" @@ -719,7 +720,7 @@ bool make_out_pipeline() { li.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR; li.bindingCount = 2, li.pBindings = b; if (vkCreateDescriptorSetLayout(dev.device, &li, nullptr, &o.set) != VK_SUCCESS) return false; - const VkPushConstantRange pr{VK_SHADER_STAGE_COMPUTE_BIT, 0, 8}; + const VkPushConstantRange pr{VK_SHADER_STAGE_COMPUTE_BIT, 0, 12}; // (dlss_out.comp's size and linear) VkPipelineLayoutCreateInfo pi{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; pi.setLayoutCount = 1, pi.pSetLayouts = &o.set, pi.pushConstantRangeCount = 1, pi.pPushConstantRanges = ≺ if (vkCreatePipelineLayout(dev.device, &pi, nullptr, &o.layout) != VK_SUCCESS) return false; @@ -761,16 +762,61 @@ bool fsr3_wanted() { return (env > 0 || (opts.dlss == upscaler_rows::FSR3 && !temporal_env_chosen())) && fsr3::supported(); } +bool fsr3_pre_wanted() { return fsr3_wanted() && fsr3fi::frames_wanted() == 0; } + +bool fsr3_pre(VkCommandBuffer cmd, Texture* scene, VkImageView scene_view, uint32_t ow, uint32_t oh, VkImageView* picture) { + if (!fsr3_pre_wanted() || !scene || !scene_view) return false; + fsr3_inputs::Frame f; + if (!fsr3_inputs::prepare(cmd, scene, scene_view, f, true)) return fail("its inputs could not be made"); + Out& o = out_state(); + std::lock_guard lk(o.mu); + if (ow < f.width || oh < f.height) return fail("unexpected output"); + fsr3::Inputs ai; + ai.color = f.color, ai.depth = f.depth, ai.motion = f.motion; + ai.render_width = f.width, ai.render_height = f.height; + ai.upscale_width = ow, ai.upscale_height = oh; + ai.jitter[0] = f.jitter[0], ai.jitter[1] = f.jitter[1]; + ai.jitter_phases = fsr3_inputs::jitter_size(2) ? fsr3_inputs::jitter_size(2) : 8; + ai.camera = f.camera; + ai.frame_time_ms = f.frame_ms; + ai.reset = f.reset; + if (!fsr3::upscale(cmd, ai)) return fail("its passes could not be recorded"); + fsr3_inputs::upscaled(f.width, f.height, ow, oh); + if (++o.drawn % 600 == 0) + logf("vk: fsr3: %llu frames drawn, %ux%u -> %ux%u before the bloom, this one's jitter %+.3f %+.3f px of %u phases", + (unsigned long long)o.drawn, f.width, f.height, ow, oh, f.jitter[0], f.jitter[1], ai.jitter_phases); + if (o.reason) logf("vk: fsr3: FSR 3.1 draws the upscale again (frame %llu)", (unsigned long long)f.frame); + o.reason = nullptr; + static bool told; + if (!told) + told = true, logf("vk: fsr3 %ux%u -> %ux%u before the game's bloom and tone mapping, from the scene's linear HDR colour " + "(jitter %+.3f %+.3f px, %u phases)", f.width, f.height, ow, oh, f.jitter[0], f.jitter[1], + ai.jitter_phases); + *picture = fsr3::output_view(); + return true; +} + bool fsr3_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, uint32_t out_level) { const bool upscaling = fsr3_wanted(); if (!upscaling && !fsr3_inputs::wanted()) return false; if (!in || !in_view || !out || !out_view) return false; + // (FSR drew before the game's bloom and tone mapping this frame, into this dispatch's input: the tone mapped picture is in + // the output, or copied there (vk_temporal.cpp). Asked before the scene's camera is, which that pass took) + if (upscaling && temporal_pre_dispatch(cmd, in, in_view, out, out_view, out_level, false)) return true; + // (local, RenoDX port) an RGBA16F picture: FSR's own passes at this dispatch do not take it, but before the bloom they do + // (the scene's target keeps the game's format), and the dispatch above then has the picture. So in a frame they did not + // draw there, the point is learnt here for the next, and the game's upscale runs this once + if (upscaling && in->format == VK_FORMAT_R16G16B16A16_SFLOAT && out->format == VK_FORMAT_R16G16B16A16_SFLOAT && + temporal_scene_format(in->format) && (out->width >> out_level) >= in->width && fsr3_inputs::is_scene(in)) + return temporal_pre_dispatch(cmd, in, in_view, out, out_view, out_level, true); // (another network of the upscale's shape, as temporal_upscale takes them: only the scene into the picture. The gameplay // networks sample the scene's B10G11R11 colour and write the B10G11R11 picture) if (!known && (in->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || (out->width >> out_level) <= in->width || !fsr3_inputs::is_scene(in))) return false; + // (it did not: the point learnt for the next frame) + if (upscaling && temporal_pre_dispatch(cmd, in, in_view, out, out_view, out_level, true)) return true; fsr3_inputs::Frame f; if (!fsr3_inputs::prepare(cmd, in, in_view, f)) return upscaling ? fail("its inputs could not be made") : false; if (!upscaling) return false; // (frame interpolation's inputs alone: the network or DLSS upscales) @@ -793,7 +839,7 @@ bool fsr3_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in, Vk ai.reset = f.reset; if (!fsr3::upscale(cmd, ai)) return fail("its passes could not be recorded"); { - const int32_t pc[2] = {(int32_t)ow, (int32_t)oh}; + const int32_t pc[3] = {(int32_t)ow, (int32_t)oh, 0}; const VkDescriptorImageInfo info[2] = {{o.point, fsr3::output_view(), VK_IMAGE_LAYOUT_GENERAL}, {VK_NULL_HANDLE, out_view, VK_IMAGE_LAYOUT_GENERAL}}; VkWriteDescriptorSet w[2]{{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}, {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}}; diff --git a/gpu/vk/vk_fsr3.h b/gpu/vk/vk_fsr3.h index 604f789..65a5a6e 100644 --- a/gpu/vk/vk_fsr3.h +++ b/gpu/vk/vk_fsr3.h @@ -64,6 +64,13 @@ bool fsr3_wanted(); /// way). With FSR 3.1's frame interpolation on, the dispatch's input and this frame's camera become its inputs here /// (vk_fsr3_inputs.h) whichever upscaler runs. true: FSR 3.1 wrote the output (the dispatch is left out); false: the network /// (or DLSS) runs, the reason logged when it changes +/// FSR 3.1 before the game's bloom and tone mapping (vk_temporal.h temporal_pre_tonemap, which calls this at the bloom's +/// first pass): its inputs from the scene's colour target (linear HDR light) and its passes, at ow x oh. *picture: its +/// picture, linear HDR at that size, which the chain writes back into the scene and the tone mapping draws from. Not +/// with FSR's frame interpolation on (fsr3_pre_wanted), whose inputs are made at the upscale's dispatch +bool fsr3_pre_wanted(); +bool fsr3_pre(VkCommandBuffer cmd, Texture* scene, VkImageView scene_view, uint32_t ow, uint32_t oh, VkImageView* picture); + bool fsr3_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, uint32_t out_level); diff --git a/gpu/vk/vk_fsr3_inputs.cpp b/gpu/vk/vk_fsr3_inputs.cpp index 6e16840..eec2291 100644 --- a/gpu/vk/vk_fsr3_inputs.cpp +++ b/gpu/vk/vk_fsr3_inputs.cpp @@ -240,7 +240,7 @@ bool is_scene(const Texture* in) { in->height == s.cam.height; } -bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out) { +bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out, bool linear) { State& s = st(); std::lock_guard lk(s.mu); free_dead(); @@ -287,7 +287,7 @@ bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out) const bool motion = !reset && dlss_math::reprojection(cam.current, previous, pc.reproject); pc.jitter[0] = cam.jitter[0], pc.jitter[1] = cam.jitter[1]; pc.size[0] = (int32_t)rw, pc.size[1] = (int32_t)rh; - pc.flags = (motion ? 1 : 0) | (camera.flip_depth ? 2 : 0); + pc.flags = (motion ? 1 : 0) | (camera.flip_depth ? 2 : 0) | (linear ? 4 : 0); full_barrier(cmd); // (the scene's colour and depth, written before) { diff --git a/gpu/vk/vk_fsr3_inputs.h b/gpu/vk/vk_fsr3_inputs.h index 73345e6..f0d9be7 100644 --- a/gpu/vk/vk_fsr3_inputs.h +++ b/gpu/vk/vk_fsr3_inputs.h @@ -54,7 +54,8 @@ bool is_scene(const Texture* in); /// At the gameplay upscale's dispatch: its input as the network samples it (in, in_view), this frame's camera and depth into /// FSR's inputs (shaders/fsr3_prep.comp). False when they cannot be made (no camera this frame, another size, ...): the /// reason is logged when it changes -bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out); +/// linear: in is the scene's colour target itself, linear HDR light (FSR before the game's bloom and tone mapping) +bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out, bool linear = false); /// The frame prepare made last, for frame interpolation at the present, once: false when none was made since the last take /// (or it is older than the frame before), so a present never interpolates with another frame's depth and motion diff --git a/gpu/vk/vk_fsr4.cpp b/gpu/vk/vk_fsr4.cpp index f76b977..4814c17 100644 --- a/gpu/vk/vk_fsr4.cpp +++ b/gpu/vk/vk_fsr4.cpp @@ -101,6 +101,7 @@ struct Context { ffxCreateContextDescUpscale upscale{}; ffxContext context = nullptr; uint32_t width = 0, height = 0; // (its output, which is also the most the render size can be) + bool hdr = false; // (made for linear HDR colour: the other kind of colour makes it again) uint64_t memory = 0; // (what AMD's library says it holds) ~Context() { if (context) lib().destroy(&context, nullptr); @@ -243,7 +244,7 @@ bool load() { /// A context for outputs of w x h, any render size up to that (the game's dynamic resolution and the Render resolution row /// change it every so often: one context takes them all) -std::shared_ptr make_context(uint32_t w, uint32_t h) { +std::shared_ptr make_context(uint32_t w, uint32_t h, bool hdr) { Library& l = lib(); auto c = std::make_shared(); c->backend.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK; @@ -265,6 +266,11 @@ std::shared_ptr make_context(uint32_t w, uint32_t h) { // (the chain's colour is tonemapped and square-root encoded already: LDR, perceptual, no auto exposure; depth not // inverted. The render size changes under the one context) c->upscale.flags = FFX_UPSCALE_ENABLE_NON_LINEAR_COLORSPACE | FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION; + // (hdr, the chain before the game's bloom and tone mapping: the scene's linear HDR light, before the game's exposure, + // so FSR finds the exposure itself) + if (hdr) + c->upscale.flags = FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE | + FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION; c->upscale.maxRenderSize = {w, h}; c->upscale.maxUpscaleSize = {w, h}; c->upscale.fpMessage = &on_message; @@ -276,7 +282,7 @@ std::shared_ptr make_context(uint32_t w, uint32_t h) { c->context = nullptr; return nullptr; } - c->width = w, c->height = h; + c->width = w, c->height = h, c->hdr = hdr; FfxApiEffectMemoryUsage usage{}; ffxQueryDescUpscaleGetGPUMemoryUsage mem{}; mem.header.type = FFX_API_QUERY_DESC_TYPE_UPSCALE_GPU_MEMORY_USAGE; @@ -285,8 +291,8 @@ std::shared_ptr make_context(uint32_t w, uint32_t h) { ffxQueryGetProviderVersion provider{}; provider.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION; const bool known = l.query(&c->context, &provider.header) == FFX_API_RETURN_OK && provider.versionName; - logf("vk: AMD FSR 4: FSR %s made for outputs of %ux%u (frame %llu, %.1f ms of CPU; its own %llu MB)", - known ? provider.versionName : "?", w, h, (unsigned long long)texture_frame_no(), made_ms, + logf("vk: AMD FSR 4: FSR %s made for outputs of %ux%u, %s colour (frame %llu, %.1f ms of CPU; its own %llu MB)", + known ? provider.versionName : "?", w, h, hdr ? "HDR" : "LDR", (unsigned long long)texture_frame_no(), made_ms, (unsigned long long)(c->memory >> 20)); return c; } @@ -354,12 +360,13 @@ void release() { s.context.reset(); } -int prepare(VkCommandBuffer, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, uint32_t* in_w, uint32_t* in_h, const char** why) { +int prepare(VkCommandBuffer, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, bool hdr, + uint32_t* in_w, uint32_t* in_h, const char** why) { State& s = st(); int made = 1; - if (!s.context || s.context->width != ow || s.context->height != oh) { + if (!s.context || s.context->width != ow || s.context->height != oh || s.context->hdr != hdr) { release(); - s.context = make_context(ow, oh); + s.context = make_context(ow, oh, hdr); if (!s.context) return *why = "its upscaler was not made", -1; s.in_w = s.in_h = 0; made = 2; @@ -411,7 +418,7 @@ bool evaluate(VkCommandBuffer cmd, const TemporalFrame& f) { d.reset = f.reset; d.cameraNear = f.near_z, d.cameraFar = f.far_z, d.cameraFovAngleVertical = f.fov_y; d.viewSpaceToMetersFactor = 1.0f; - d.flags = FFX_UPSCALE_FLAG_NON_LINEAR_COLOR_SRGB; + d.flags = s.context->hdr ? 0 : FFX_UPSCALE_FLAG_NON_LINEAR_COLOR_SRGB; // (HDR: linear light as it is) ::mkwvk::rec::boundary(::mkwvk::rec::B_DIRECT); // (ffxDispatch records into cmd itself: what this thread recorded through vk_work.h reaches cmd first) const ffxReturnCode_t r = l.dispatch(&s.context->context, &d.header); note_work(); // (AMD's dispatches: full_barrier must not take the next barrier for a repeat of the one before them) diff --git a/gpu/vk/vk_imgui.cpp b/gpu/vk/vk_imgui.cpp index 09d45aa..0f96ccf 100644 --- a/gpu/vk/vk_imgui.cpp +++ b/gpu/vk/vk_imgui.cpp @@ -246,6 +246,27 @@ ImU32 hdr10_of(ImU32 c, float white) { return (c & IM_COL32_A_MASK) | code(0.6274f * r + 0.3293f * g + 0.0433f * b) << IM_COL32_R_SHIFT | code(0.0691f * r + 0.9195f * g + 0.0114f * b) << IM_COL32_G_SHIFT | code(0.0164f * r + 0.0880f * g + 0.8956f * b) << IM_COL32_B_SHIFT; } +/// (Triforce, 11-13, the user: "Why is the [shader loading screen] so dark for me after turning hdr on?") A texture's texel +/// for an HDR10 window image. The pipeline multiplies a texel by its vertex's colour, and hdr10 below codes every vertex +/// colour, a picture's white tint too: white at the paper white is PQ code 0.65 at 400 nits (0.58 at 200), not 1. A texel +/// coded the same way came out as code * 0.65: a white texel at 0.42, about 40 nits for 400, and darker the dimmer it was. +/// Text and plain shapes were right (their texel is white coverage; the colour is the vertex's alone), every picture was ten +/// times too dark: the start-up screen's crest and its stones, the logo, the plates of the options inside the game's own +/// screen. So a texel is its HDR10 code over the code of white: times a white tint it is its own code again, exactly, and a +/// white shape under a coloured tint is the tint's code, exactly (a coloured texel under a coloured tint is still a +/// product of two codes: close, not exact; the exact way is the conversion in the fragment shader, not done) +ImU32 hdr10_texel(ImU32 c, float white) { + static unsigned char over_white[256]; + static float made_for = -1; + if (made_for != white) { + const float w = (float)(hdr10_of(IM_COL32_WHITE, white) >> IM_COL32_R_SHIFT & 0xFF); + for (int i = 0; i < 256; i++) over_white[i] = (unsigned char)std::clamp((int)(i * 255.0f / std::max(w, 1.0f) + 0.5f), 0, 255); + made_for = white; + } + const ImU32 v = hdr10_of(c, white); + return (v & IM_COL32_A_MASK) | (ImU32)over_white[v >> IM_COL32_R_SHIFT & 0xFF] << IM_COL32_R_SHIFT | + (ImU32)over_white[v >> IM_COL32_G_SHIFT & 0xFF] << IM_COL32_G_SHIFT | (ImU32)over_white[v >> IM_COL32_B_SHIFT & 0xFF] << IM_COL32_B_SHIFT; +} void hdr10(ImDrawData* dd) { const float white = (float)std::clamp(opts.hdr_white, 80, 400); for (ImDrawList* list : dd->CmdLists) @@ -273,7 +294,9 @@ void pixels(ImTextureData* tex, int x, int y, int w, int h, unsigned char* dst) for (int i = 0; i < w; i++) { ImU32 c; memcpy(&c, src + i * 4, 4); - c = hdr10_of(c, white); + // (over white's code: see hdr10_texel. RX_VK_HDR_TEXEL_OLD=1, a lab switch: coded as a colour, as before) + static const bool as_before = getenv("RX_VK_HDR_TEXEL_OLD") != nullptr; + c = as_before ? hdr10_of(c, white) : hdr10_texel(c, white); memcpy(dst + ((size_t)row * w + i) * 4, &c, 4); } } else if (tex->Format == ImTextureFormat_RGBA32) { // (the glyphs: white, their coverage in alpha, the same in any space) diff --git a/gpu/vk/vk_internal.h b/gpu/vk/vk_internal.h index c2d7902..39e5a82 100644 --- a/gpu/vk/vk_internal.h +++ b/gpu/vk/vk_internal.h @@ -10,6 +10,7 @@ #include "vk_loader.h" #include "vk_api.h" +#include "vk_vendor.h" #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) #include @@ -69,6 +70,7 @@ struct Device { VkShaderStageFlags sg32_stages = 0; // (stages that run at 32 lanes when asked: the size the translated programs assume) uint32_t subgroup_size = 32, subgroup_max = 32; // (the lanes a stage not pinned runs at, and the most it can have) VkDriverId driver_id{}; + VendorFixes fixes{}; // (hookshot) the vendor and driver workarounds this device needs (vk_vendor.h; vk_main.cpp create_device) uint32_t max_push_descriptors = 0; // no window (HOS_HEADLESS): presents go to an image of their own, which RX_VK_SHOTS can write out bool offscreen = false; @@ -294,6 +296,10 @@ bool memory_mirror_bind_wait(VkSemaphoreSubmitInfo* wait); // (and the wait a bool memory_trial_on(); void memory_trial_tick(); void memory_trial_device_lost(); +void memory_trial_orderly_end(); // (the menu's Restart and Exit: no verdict for a session ended on purpose) +/// (Triforce) Set while the start's own shader work runs (vk_main.cpp started_up): a fault in the driver then starts the game +/// again (vk_draw.cpp driver_fault_restart, Windows) +extern std::atomic startup_work_on; /// Device-local memory this process uses and what the driver allows it now (VK_EXT_memory_budget), summed over the /// device-local heaps; false when unknown bool vram_usage(uint64_t* used, uint64_t* budget, uint64_t* block_free = nullptr); @@ -312,6 +318,8 @@ bool prepare_run(void (*progress)(size_t done, size_t total), bool background); bool prepare_is_update(); void prepare_background(); void state_list_run(); // (an update: the state list's pipelines noted before precompile_run) +void predict_background(); // (Triforce: the predicted pipelines predict_run did not get to, built behind the game) +void predict_plan_ensure(); // (Triforce: its plan, made before the precompile when an older build prepared this install) void predict_run(void (*progress)(size_t done, size_t total)); // (after a prepare_run that prepared: the notes' predictions) /// (hookshot) The window was closed while the shaders were prepared: prepare_run and precompile_run take nothing more and return, /// what is done kept (the program cache, the driver's) and not counted as a start that ended inside them diff --git a/gpu/vk/vk_main.cpp b/gpu/vk/vk_main.cpp index 0a1d39e..03a4d39 100644 --- a/gpu/vk/vk_main.cpp +++ b/gpu/vk/vk_main.cpp @@ -395,6 +395,21 @@ bool create_device() { dev.eds3_clamp = dev.dynamic_state3 && eds3.extendedDynamicState3DepthClampEnable; dev.eds3_blend = dev.dynamic_state3 && eds3.extendedDynamicState3ColorBlendEnable && eds3.extendedDynamicState3ColorBlendEquation && eds3.extendedDynamicState3ColorWriteMask; + { // (hookshot) the vendor and driver workarounds this device needs: vk_vendor.h, each forced by its RX_VK_ switch + VkPhysicalDeviceDriverProperties drv{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; + VkPhysicalDeviceProperties2 p2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2}; + p2.pNext = &drv; + vkGetPhysicalDeviceProperties2(dev.physical, &p2); + VendorFacts facts; + facts.vendor_id = p2.properties.vendorID; + facts.driver_id = drv.driverID; + facts.device_type = p2.properties.deviceType; + facts.driver_info = drv.driverInfo; + dev.fixes = vendor_fixes(facts); + vendor_fixes_env(dev.fixes, [](const char* name) -> const char* { return getenv(name); }); + logf("vk: vendor fixes for %s (%s): out-of-bounds texel fetches 0 %d, NaN tests by bits %d, gather offset %d", + drv.driverName, drv.driverInfo, (int)dev.fixes.fetch_bounds, (int)dev.fixes.nan_bits, (int)dev.fixes.gather_offset); + } dev.eds3_a2c = dev.dynamic_state3 && eds3.extendedDynamicState3AlphaToCoverageEnable; dev.vk12 = f12; dev.vk13 = f13; @@ -432,8 +447,13 @@ bool create_device() { if (dev.mesh_fallback) logf("vk: no mesh shaders: task and mesh programs run as compute shaders (issue 640 fallback)"); bool task_mesh_fallback = false; #ifdef _WIN32 - // Navi 22 can time out on task + mesh draws in the AMD Windows driver (issue 996). - task_mesh_fallback = dev.props.vendorID == 0x1002 && dev.props.deviceID == 0x73df; + // Navi 22 can time out on task + mesh draws in the AMD Windows driver (issue 996), and so can Navi 21: on an RX 6800 XT + // (driver 0x800161) the native path lost the device within minutes at Hyrule Castle's entrance, while the fallback played + // 25 minutes there with none. Navi 21 is 0x73bf (RX 6800, 6800 XT, 6900 XT), 0x73af (RX 6900 XT, XTXH boards) and 0x73a5 + // (RX 6950 XT): the same chip on the same driver, not tested on their own. Navi 22 is 0x73df (RX 6700 XT) + task_mesh_fallback = dev.props.vendorID == 0x1002 && + (dev.props.deviceID == 0x73bf || dev.props.deviceID == 0x73af || dev.props.deviceID == 0x73a5 || + dev.props.deviceID == 0x73df); #endif if (const char* e = getenv("RX_VK_TASK_MESH_FALLBACK")) task_mesh_fallback = atoi(e) != 0; dev.task_mesh_fallback = task_mesh_fallback && dev.mesh_shader && f12.bufferDeviceAddress && !getenv("RX_VK_NO_MESH_FALLBACK"); @@ -894,7 +914,9 @@ void prepare_with_screen() { if (!prepare_stopped()) { prep_done.store(0), prep_total.store(0); prep_stage.store(2); + predict_plan_ensure(); precompile_run(prep_progress); + predict_background(); } if (prepare_stopped()) pipeline_cache_save(true); // (the driver's part built so far, for the next start) else if (update) prepare_background(); @@ -1008,6 +1030,11 @@ void prepare_with_screen() { bool started_up() { if (const char* e = getenv("RX_VK_START_DELAY")) Sleep((DWORD)atoi(e) * 1000); // (diagnosis: a long start, as the first one is) if (!replay_start()) return false; + // (Triforce, 11-13: vk_draw.cpp driver_fault_restart) + struct StartupWork { + StartupWork() { startup_work_on.store(true); } + ~StartupWork() { startup_work_on.store(false); } + } startup_work; if (prepare_only()) { // (three parts: the programs, the pipelines the notes predict, then those they name; most of the time is the first) static int part; @@ -1028,7 +1055,9 @@ bool started_up() { part = 1; if (prepared) predict_run(progress); part = 2; + predict_plan_ensure(); precompile_run(progress); + predict_background(); pipeline_cache_save(true); remove(skipped_path().c_str()); return true; @@ -1089,8 +1118,10 @@ bool started_up() { }; const bool update = prepare_is_update(); // (an update: what the notes name now, the rest in play) if (!update && prepare_run(progress, false)) predict_run(progress); + predict_plan_ensure(); if (update) state_list_run(); precompile_run(progress); + predict_background(); if (update) prepare_background(); if (console) CloseHandle(console), console = nullptr, FreeConsole(); } diff --git a/gpu/vk/vk_memory.cpp b/gpu/vk/vk_memory.cpp index 8315d66..0c90837 100644 --- a/gpu/vk/vk_memory.cpp +++ b/gpu/vk/vk_memory.cpp @@ -65,6 +65,7 @@ struct Pool { uint64_t synced_epoch = 0; // the submission that last brought it up to date uint64_t sync_seg = 0; // (and the parallel replay's segment whose uploads did) uint64_t last_value = 0; // (the newest submission that bound it: its mirror is in use until that one is done) + uint64_t imported_value = 0; // (Triforce: the recording being made when this import went into the table: imports_give_back) uint64_t direct_write_epoch = 0; // (the part that last wrote it in guest memory, before it had a mirror) uint64_t retired_value = 0; // (retired: the submission that may still use it) bool was_mirrored = false; // (its mirror was given back: its pages stay in the captures, for the next one) @@ -516,7 +517,10 @@ LONG WINAPI filter(EXCEPTION_POINTERS* info) { return prev_filter ? prev_filter(info) : EXCEPTION_CONTINUE_SEARCH; } void at_exit() { // (the window closed, or any orderly exit: no verdict, the next session tries again) - if (active && !crashed.load() && state == TRYING) write(NEW, fails, "the last session ended before the trial was over"); + if (active && !crashed.load() && state == TRYING) { + write(NEW, fails, "the last session ended before the trial was over"); + state = NEW; // (said once: the menu's exits say it before the process's own end does) + } } uint32_t vendor() { static const uint32_t v = getenv("RX_VK_TEST_VENDOR") ? (uint32_t)strtoul(getenv("RX_VK_TEST_VENDOR"), nullptr, 16) : dev.props.vendorID; @@ -557,12 +561,26 @@ bool memory_trial_on() { write(TRYING, fails, "a session has it on"); prev_filter = SetUnhandledExceptionFilter(filter); atexit(at_exit); +#ifndef _WIN32 + // (Triforce, 11-13) On Linux the game ends through _exit (host/posix ExitProcess) or, for the menu's Restart, + // through execve: neither runs atexit, so EVERY session shorter than the trial counted as one that "ended in a + // crash or without a word", and two short sessions or two restarts switched the newer memory handling off for + // good (a player's RX 9060 XT on RADV, v0.3.5: "menu: restart" twice, then "off"). ExitProcess ends through + // quick_exit now, which runs this; the menu's exits say it themselves (memory_trial_orderly_end) + at_quick_exit(at_exit); +#endif logf("vk: the newer memory handling (mirrors in pieces, compacted textures) is on trial on this card (%d earlier session(s) " "ended badly); triforce_memtrial.txt keeps the result", fails); return true; }(); return on; } +/// (Triforce) The menu's Restart and Exit, before the window closes: an orderly end, no verdict (see at_quick_exit above) +std::atomic startup_work_on{false}; // (vk_internal.h: the start's own shader work is running) +void memory_trial_orderly_end() { + std::lock_guard lk(memtrial::mu); + memtrial::at_exit(); +} /// (texture_frame, every 600 presents) the trial passed once the game has played kTrialSeconds with it on void memory_trial_tick() { using namespace memtrial; @@ -2790,6 +2808,7 @@ void bg_drain() { continue; } if (imp != imported.end()) retire_pool(imp); + p.imported_value = mem_rec_value; imported.emplace(lo, p); guest_pages_set(p.lo, p.hi, p.address); } @@ -2984,6 +3003,7 @@ Pool* pool_lookup(uint64_t guest, uint64_t size) { if (o != imported.end()) // (their mirrors' contents come with them) p.gpu_only |= o->second.gpu_only, p.gpu_written |= o->second.gpu_written, retire_pool(o); } + p.imported_value = mem_rec_value; imp = imported.emplace(p.lo, p).first; guest_pages_set(p.lo, p.hi, p.address); if (chunk) prefetch_chunks(p.lo, p.hi, chunk); @@ -4627,8 +4647,18 @@ void imports_give_back() { // (pools_mu held) std::vector::iterator> idle; for (auto it = imported.begin(); it != imported.end(); ++it) { const Pool& p = it->second; + // (Triforce, 11-13) An import counts as used from the recording it was made in. Its last_value is 0 until its first + // binding, which read as "idle since the session's start": with RAM short (this rule runs every 16 submissions then) + // an import the background thread had just made was given back before the binding that had asked for it came round + // again, which sent for it again, for good. A 16 GB player's log (RTX 4060, Hyrule Field): 1,400 imports given back + // (24 GB) in two minutes with 61 alive, every binding of theirs served from a copy meanwhile, 14-15 fps for those two + // minutes. The lab with 800 MB played as available (RX_VK_TEST_AVAIL_MB), 100 s standing there: 597 given back over + // 38 chunks, each 0 to 5 submissions after its import and never bound, 673 imports sent; with this 30 and 97. + // RX_VK_IMPORT_FRESH=0: as before + static const bool fresh = !(getenv("RX_VK_IMPORT_FRESH") && !atoi(getenv("RX_VK_IMPORT_FRESH"))); + const uint64_t last_use = fresh ? std::max(p.last_value, p.imported_value) : p.last_value; if ((p.mstate == Pool::MIRROR_NONE || p.mstate == Pool::MIRROR_REFUSED) && p.last_value <= mem_completed && - mem_rec_value > p.last_value + idle_for) + mem_rec_value > last_use + idle_for) idle.push_back(it); } std::sort(idle.begin(), idle.end(), [](auto a, auto b) { return a->second.last_value < b->second.last_value; }); @@ -4637,6 +4667,27 @@ void imports_give_back() { // (pools_mu held) for (auto it : idle) { if (freed >= want) break; Pool& p = it->second; + { // (lab, RX_VK_LOG_IMPORT_CHURN=1: what the imports given back were, every 64 of them) + static const bool churn_log = getenv("RX_VK_LOG_IMPORT_CHURN") != nullptr; + if (churn_log) { + static std::unordered_map times; + static std::vector ages, idles; + static int never, again, bg, total; + never += !p.last_value, again += times[p.lo]++ > 0, bg += p.prefetched, total++; + ages.push_back(mem_rec_value - p.imported_value); + idles.push_back(mem_rec_value - p.last_value); + if (ages.size() == 64) { + std::sort(ages.begin(), ages.end()), std::sort(idles.begin(), idles.end()); + logf("vk: import churn: %d given back so far over %zu chunks; of the last 64: %d never bound since their " + "import, %d given back before, %d made in the background and not bound; submissions since the import: " + "min %llu median %llu max %llu; since the last binding: min %llu median %llu (now %llu, %s)", + total, times.size(), never, again, bg, (unsigned long long)ages[0], (unsigned long long)ages[32], + (unsigned long long)ages[63], (unsigned long long)idles[0], (unsigned long long)idles[32], + (unsigned long long)mem_rec_value, by_heap ? "by the heap" : "by the RAM"); + ages.clear(), idles.clear(), never = again = bg = 0; + } + } + } guest_pages_set(p.lo, p.hi, 0); p.retired_value = mem_rec_value; // (this submission's recording is being made: freed once it is done) freed += p.hi - p.lo; diff --git a/gpu/vk/vk_menu.cpp b/gpu/vk/vk_menu.cpp index 48faece..173c4e1 100644 --- a/gpu/vk/vk_menu.cpp +++ b/gpu/vk/vk_menu.cpp @@ -49,6 +49,7 @@ #include "vk_fsr3fi.h" // (the Frame generation row: whether FSR 3.1 makes the frame) #include "vk_fsr4.h" #include "vk_temporal.h" +#include "vk_renodx.h" // (renodx_built: the RenoDX rows only in a build with its shaders) #include "vk_reflex.h" #include "vk_antilag.h" #include "upscaler_rows.h" @@ -213,6 +214,7 @@ const char* hn_upscaler(int v, int variant) { "DLSS and DLAA: need a newer NVIDIA driver.", "DLSS and DLAA: DLSS's runtime was not found (the game folder's ngx folder, see the readme).", "DLSS and DLAA: NVIDIA's NGX on Linux loads DLSS's runtime only from a folder named in ASCII (see the readme).", + "DLSS and DLAA: NVIDIA's NGX started but gave DLSS nothing to work with (see the log).", }; static const char* const fsr_no[FSR_WHY_COUNT] = { nullptr, @@ -283,6 +285,15 @@ const char* tx_percent(int v) { snprintf(b, sizeof b, "%d%%", v); return b; } +// (local, RenoDX port: vk_renodx.cpp) +const char* tx_rdx_tonemap(int v) { return v ? "PsychoV35" : "Vanilla"; } +const char* tx_rdx_midgray(int v) { return v == 1 ? "Vanilla" : v == 2 ? "Eye adaptation" : "Render"; } +const char* tx_rdx_space(int v) { return v == 1 ? "BT.709" : v == 2 ? "DCI-P3" : "Vanilla"; } +const char* tx_rdx_grade(int v) { + static char b[8]; + snprintf(b, sizeof b, "%d", v); + return b; +} // The output the menu's sizes are shown for: the Output resolution row's (applied at the next start), so the rows below follow a change // at once; the handheld profile runs the game's own (1536x864) struct Out { @@ -634,6 +645,38 @@ Row rows[] = { "How bright the picture's white is with HDR on. Around 200 for a normal room; higher in a bright one.", nullptr, false, true}, {TAB_DISPLAY, "HDR peak brightness", &opts.hdr_peak, 400, 4000, 100, tx_nits, "The brightest highlights with HDR on: set it to your display's peak brightness.", nullptr, false, true}, + // (Triforce, 11-13: RenoDX is in every build and off until this row turns it on. The scene's format is chosen at the + // start, host/nn_vi.c hos_scene_rgba16f: a restart) + {TAB_DISPLAY, "RenoDX HDR", &opts.renodx, 0, 1, 1, tx_onoff, + "With HDR set to Native: RenoDX's tone mapping, eye adaptation and colour grading in place of the game's own, and its " + "rows below. Off: the game's own HDR. Applies after a restart. RenoDX is by Carlos Lopez (clshortfuse), under the MIT " + "license.", nullptr, true, true}, + // (local, RenoDX port: vk_renodx.cpp. Shown with HDR Native, where its shaders run) + {TAB_DISPLAY, "RenoDX tonemapper", &opts.rdx_tonemap, 0, 1, 1, tx_rdx_tonemap, + "With HDR Native: how the scene's light is brought to the display. Vanilla: the game's own curve. PsychoV35: RenoDX's, " + "which keeps hue and saturation into the highlights, up to the peak brightness. RenoDX is by Carlos Lopez " + "(clshortfuse), under the MIT license.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX midgray", &opts.rdx_midgray, 0, 2, 1, tx_rdx_midgray, + "With PsychoV35: what the scene's middle grey is held to. Render: as rendered. Vanilla: where the game's own curve puts it. " + "Eye adaptation: it follows what is on screen over a few seconds, weighted towards the middle of the view, as eyes adjust.", + nullptr, false, true}, + {TAB_DISPLAY, "RenoDX UI brightness", &opts.rdx_ui_white, 80, 400, 10, tx_nits, + "How bright the menus' and the HUD's white is with RenoDX's tonemapper. The scene's follows HDR paper white.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX color space", &opts.rdx_space, 0, 2, 1, tx_rdx_space, + "The colours the picture is taken to be in before HDR10's. Vanilla: the game's own matrix. BT.709: as the SDR picture. " + "DCI-P3: more saturated.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX exposure", &opts.rdx_exposure, 0, 200, 5, tx_percent, + "The scene's brightness before RenoDX's tone mapping. 100% is the game's.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX highlights", &opts.rdx_highlights, 0, 100, 5, tx_rdx_grade, + "RenoDX's colour grading: the bright parts of the scene. 50 is neutral.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX shadows", &opts.rdx_shadows, 0, 100, 5, tx_rdx_grade, + "RenoDX's colour grading: the dark parts of the scene. 50 is neutral.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX contrast", &opts.rdx_contrast, 0, 100, 5, tx_rdx_grade, + "RenoDX's colour grading: the scene's contrast. 50 is neutral.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX saturation", &opts.rdx_saturation, 0, 100, 5, tx_rdx_grade, + "RenoDX's colour grading: the scene's saturation. 50 is neutral.", nullptr, false, true}, + {TAB_DISPLAY, "RenoDX bloom", &opts.rdx_bloom, 0, 100, 5, tx_rdx_grade, + "How strong the glow around bright things is. 50 is the game's.", nullptr, false, true}, {TAB_DISPLAY, "Game frame rate cap", &opts.fps_cap, 0, 5, 1, tx_fps_cap, "Limits frames rendered by the game. Generated frames are additional. Takes a restart. " "Past 60 is experimental: the game keeps real time, but some cutscenes and bosses can misbehave (Gohma, the intro's " @@ -651,6 +694,11 @@ Row rows[] = { hn_upscaler}, {TAB_GRAPHICS, "DLSS model", &opts.dlss_model, 0, ur::kModels - 1, 1, tx_dlss_model, "Which of NVIDIA's DLSS networks draws the picture.", hn_dlss_model, false, true}, + // (Triforce, 11-13: vk_temporal.cpp pre_wanted, off until asked) + {TAB_GRAPHICS, "Upscale before bloom", &opts.upscale_pre, 0, 1, 1, tx_onoff, + "With NVIDIA DLSS, DLAA or AMD FSR as the Upscaler: On, it works on the scene before the game's glow and tone mapping, " + "so both are made from the sharpened scene. Off: on the finished picture, as before. Applies after a restart.", + nullptr, true, true}, // (Triforce: read once, at the start (host/nn_vi.c): Auto -> 100% in game left the 3D at the dynamic path's size) {TAB_GRAPHICS, "Render resolution", &opts.resolution, 0, ur::kValues - 1, 1, tx_resolution, "The share of the output the 3D is drawn at; the Upscaler fills in the rest. Applies after a restart.", hn_resolution, true}, @@ -805,6 +853,14 @@ bool embed_allowed() { static const bool on = !getenv("TRIFORCE_OPTIONS_TABS") || atoi(getenv("TRIFORCE_OPTIONS_TABS")) != 0; return on; } +/// (Triforce, 11-13, the user: "Remove f1 menu (we have it in options now natively)") Whether Insert, F1, a gamepad's Home and +/// Select+Start open these options over the game from anywhere. Not any more: they are the tabs inside the game's own +/// Options screen. TRIFORCE_INGAME_MENU=1 (triforce_env.txt) brings the keys back; with TRIFORCE_OPTIONS_TABS=0 (no tabs in +/// the game's screen) they stay, or there would be no way to the options at all +bool overlay_allowed() { + static const bool on = (getenv("TRIFORCE_INGAME_MENU") && atoi(getenv("TRIFORCE_INGAME_MENU")) != 0) || !embed_allowed(); + return on; +} /// The game's Options screen ran within the last quarter second bool game_options_shown() { const int64_t t = game_options_ns.load(std::memory_order_relaxed); @@ -1013,10 +1069,20 @@ int ask_sel = 0; // (the restart question's choice: 0 Later, 1 Restart now) /// A row on its tab: the debug tools only with them on, the Upscaler only in a build with DLSS or FSR 4, or where AMD /// FSR 3.1 runs +bool rdx_row(const int* v) { // (local, RenoDX port) + return v == &opts.rdx_tonemap || v == &opts.rdx_midgray || v == &opts.rdx_ui_white || v == &opts.rdx_space || v == &opts.rdx_exposure || + v == &opts.rdx_highlights || v == &opts.rdx_shadows || v == &opts.rdx_contrast || v == &opts.rdx_saturation || + v == &opts.rdx_bloom; +} bool row_shown(int i) { return (rows[i].cheat < 0 || cheats_on()) && (rows[i].value != &opts.dlss || ur::upscaler_shown(dlss_built() || fsr4_built(), fsr3::supported())) && - (rows[i].value != &opts.dlss_model || ur::model_shown(dlss_built())); + (rows[i].value != &opts.dlss_model || ur::model_shown(dlss_built())) && + // (local, RenoDX port: its rows with HDR Native, in a build with its shaders; Triforce: and its own row on) + (!rdx_row(rows[i].value) || (opts.hdr == 2 && renodx_built() && opts.renodx)) && + (rows[i].value != &opts.renodx || renodx_built()) && + // (Triforce, 11-13: the Menu shortcut row chooses the keys that open the options from anywhere: gone with them) + (rows[i].value != &opts.menu_shortcut || overlay_allowed()); } int tab_row_count(int t) { int c = 0; @@ -2493,6 +2559,13 @@ void startup_screen(const StartupView* view) { startup_on.store(true, std::memory_order_release); } +int hdr_at_start = 0; +int renodx_at_start = 0, upscale_pre_at_start = 0; +bool renodx_chosen() { + static const char* const e = getenv("RX_VK_RENODX"); + return e && *e ? atoi(e) != 0 : renodx_at_start != 0; +} + void menu_init() { static bool done; if (done) return; @@ -2532,6 +2605,8 @@ void menu_init() { } } fclose(f); + hdr_at_start = opts.hdr; // (local, RenoDX port: vk_menu.h) + renodx_at_start = opts.renodx, upscale_pre_at_start = opts.upscale_pre; // (the saved microphone by its name, not its place; the host told the row's choice. Off or the default: no list, no SDL // audio at the start) if (!mic_want.empty()) refresh_mics(); @@ -2923,7 +2998,9 @@ void menu_tick() { // (Triforce) Setup chooses the settings before the game starts, and the menu was hidden for that. 11-10: on by default again, // for upstream's new rows that Setup has no place for yet. TRIFORCE_INGAME_MENU=0 (triforce_env.txt) hides it: Insert, F1, // Home and Select+Start then open nothing - static const bool menu_allowed = !getenv("TRIFORCE_INGAME_MENU") || atoi(getenv("TRIFORCE_INGAME_MENU")) != 0; + // (Triforce, 11-13: off by default now, overlay_allowed above. While the options are open, from inside the game's Options, + // the keys still close them) + static const bool menu_allowed = overlay_allowed(); if ((press[0] || press[6]) && open_now.load() && page == 5) { later(); } else if ((press[0] || press[6]) && open_now.load() && restart_ask()) { @@ -2953,6 +3030,7 @@ void menu_tick() { logf("menu: restart now, to apply %s", restart_list(", ").c_str()); save(); pipeline_cache_save(true); + memory_trial_orderly_end(); // (an exit on purpose: no verdict on the memory trial) open_now = false, page = 0, changed = true; PostMessageA(app_window(), WM_APP + 9, 0, 0); } @@ -3173,6 +3251,7 @@ void menu_tick() { } else { // (as Restart now: saved first, as the window's own close does not force the pipeline cache) save(); pipeline_cache_save(true); + memory_trial_orderly_end(); pending = nullptr; if (&r == &rows[kRestartRow]) { // (the restart question's Restart now: the window closes, then the game starts again) logf("menu: restart"); diff --git a/gpu/vk/vk_menu.h b/gpu/vk/vk_menu.h index 641061f..6948ffb 100644 --- a/gpu/vk/vk_menu.h +++ b/gpu/vk/vk_menu.h @@ -12,6 +12,18 @@ struct Options { int hdr = 0; // (hookshot) HDR10 out (vk_framegen.cpp framegen_hdr): 0 off, 1 the SDR picture expanded, 2 the game's own (native) HDR; when the display has it (the swapchain made again at once) int hdr_white = 200; // HDR paper white, nits (the picture's white) int hdr_peak = 1000; // HDR peak brightness, nits (its brightest highlights) + // (Triforce, 11-13: both additions of the 11-13 patches are off until their row turns them on, read once at the start) + int renodx = 0; // RenoDX HDR: 0 off, 1 RenoDX's shaders with HDR Native (host/nn_vi.c reads renodx_hdr= at the start) + int upscale_pre = 0; // Upscale before bloom: 0 the Upscaler's engine on the finished picture, as before; 1 on the scene + // before the game's bloom and tone mapping (vk_temporal.cpp pre_wanted) + // (local, RenoDX port: vk_renodx.cpp) with HDR Native, RenoDX's shaders in place of the game's tone mapping and HDR output + int rdx_tonemap = 1; // 0 Vanilla (the game's curve), 1 PsychoV35 + int rdx_midgray = 1; // what PsychoV35 holds middle grey to: 0 the render's, 1 vanilla's, 2 the eye adaptation's + int rdx_ui_white = 200; // the menus' and HUD's white, nits + int rdx_space = 1; // the output's colour space: 0 Vanilla (the game's matrix), 1 BT.709, 2 DCI-P3 + int rdx_exposure = 100; // percent, 0 to 200 + int rdx_highlights = 50, rdx_shadows = 50, rdx_contrast = 50, rdx_saturation = 50; // 0 to 100, 50 neutral + int rdx_bloom = 50; // 0 to 100, 50 the game's int fps_cap = 0; // (hookshot) Frame rate cap: 0 60 (the console's), 90, 120, 144, 165, 240 (host/nn_vi.c reads frame_rate_cap= at the start) int resolution = 0; // the 3D's (Render resolution): 0 Auto (the game's dynamic resolution), else a share of the output, // 1..6 = 100%, 75%, 67%, 50%, 58%, 33% (upscaler_rows.h; nx2/oot_patches.py) @@ -65,6 +77,14 @@ struct Options { int mic = 1; // (hookshot) the ocarina's microphone: 0 Off, 1 the system's default, 2.. a device as host->mic_name lists it (host/nn_audio_in.c) }; extern Options opts; +/// (local, RenoDX port) opts.hdr as triforce_options.ini had it at the start (menu_init), before any change in play: what +/// host/nn_vi.c hos_scene_rgba16f decided the scene's format from (vk_temporal.cpp temporal_scene_format) +extern int hdr_at_start; +/// (Triforce) opts.renodx and opts.upscale_pre as the file had them at the start: what this run does (RX_VK_RENODX and +/// RX_VK_DLSS_PRE, 0 or 1, over them) +extern int renodx_at_start, upscale_pre_at_start; +/// Whether RenoDX's shaders run in this session: the RenoDX HDR row as it was at the start, or RX_VK_RENODX +bool renodx_chosen(); /// (vk_memory.cpp) true when the quality preset's memory budgets (vram_mb, mirror_mb) are to be used: the card has no more /// video memory than the preset is for. A 4GB preset on an 8 GB card kept 256 MB of mirrors and 2.2 GB of textures: the /// game's memory was read over PCIe and the textures made again every frame, 5 fps with the CPU idle (Discord, 11-08) diff --git a/gpu/vk/vk_predict.cpp b/gpu/vk/vk_predict.cpp index d3d7fda..bacbabd 100644 --- a/gpu/vk/vk_predict.cpp +++ b/gpu/vk/vk_predict.cpp @@ -91,7 +91,34 @@ std::vector candidates(const Seen* exact, const Seen* sig) { } // namespace -std::vector> predict_pipelines(const std::vector>& notes, size_t* programs) { +namespace { +std::unique_ptr predicted_note(const PipeNote& V, const PipeNote& O, uint64_t prog, uint64_t variant) { + auto n = std::make_unique(O); + std::memcpy(n->s.vattr, V.s.vattr, sizeof n->s.vattr); + n->s.nvattr = V.s.nvattr; + std::memcpy(n->s.vstream, V.s.vstream, sizeof n->s.vstream); + n->topo = V.topo; + n->prog = prog, n->variant = variant; + n->key = 0; + return n; +} +} // namespace + +std::vector> predict_rebuild(const std::vector>& notes, + const std::vector& plan) { + std::unordered_map by_key; + for (const auto& n : notes) by_key.emplace(n->key, n.get()); + std::vector> out; + for (const PredictPlan& p : plan) { + const auto v = by_key.find(p.vertex_note), o = by_key.find(p.output_note); + if (v == by_key.end() || o == by_key.end()) continue; // (a note gone since: that pipeline is not predicted) + out.push_back(predicted_note(*v->second, *o->second, p.prog, p.variant)); + } + return out; +} + +std::vector> predict_pipelines(const std::vector>& notes, size_t* programs, + std::vector* plan) { std::unordered_map, Face, PairHash> faces; program_cache_each([&](const KeptProgram& k) { Face f; @@ -131,14 +158,9 @@ std::vector> predict_pipelines(const std::vector(*odonor.at(o)); - std::memcpy(n->s.vattr, V.s.vattr, sizeof n->s.vattr); - n->s.nvattr = V.s.nvattr; - std::memcpy(n->s.vstream, V.s.vstream, sizeof n->s.vstream); - n->topo = V.topo; - n->prog = pv.first, n->variant = pv.second; - n->key = 0; - out.push_back(std::move(n)); + const PipeNote& O = *odonor.at(o); + if (plan) plan->push_back({pv.first, pv.second, V.key, O.key}); + out.push_back(predicted_note(V, O, pv.first, pv.second)); } } return out; diff --git a/gpu/vk/vk_renodx.cpp b/gpu/vk/vk_renodx.cpp new file mode 100644 index 0000000..a1f65d0 --- /dev/null +++ b/gpu/vk/vk_renodx.cpp @@ -0,0 +1,359 @@ +// RenoDX is Carlos Lopez's (github.com/clshortfuse/renodx): Copyright (c) 2025 Carlos Lopez Jr.; its Zelda OoT mod, +// Copyright (C) 2026 Carlos Lopez. SPDX-License-Identifier: MIT. What follows is worked from that mod's addon: the +// notice and the license's text are in third_party/renodx/LICENSE.md. +// +// (local, RenoDX port) RenoDX's Zelda OoT mod (src/games/zelda-oot-oz, MIT, Carlos Lopez) inside the renderer: its replacement +// shaders (renodx_spv.h, from scripts/renodx_shaders.py) take the place of the game's scene tone mapping, HDR output encoder and +// fog when their modules are made (vk_shader.cpp make_module), and read RenoDX's settings from a second descriptor set, as its +// ReShade addon gives them (addon.cpp): set 1, bindings 0 and 1 the eye adaptation's state images (the one read, the one +// written), 2 its constants, 3 the anti-aliasing controls, 4 the settings (shared.h ShaderInjectData). +// +// The eye adaptation (adaptation.slangi) keeps its state in two 3 x 1 images, read from one and written to the other, swapped each +// present. One scene draw a frame is told to meter the picture and one fog draw to record the camera's field of view; each record +// carries its frame's generation, and a reader takes only the frame before's. The constants a frame's draws read are that frame's +// own (a ring of kRing frames of them, with a descriptor set each), since the GPU runs a frame's draws after the CPU has gone on. +// +// Not ported: the anti-aliasing and reconstruction shaders (Hookshot's own upscalers stand where they would go), the local +// exposure and SDR scene permutations, and the RGBA16F scene target the addon asks the game for. +// RX_VK_RENODX=0: off, the game's own shaders. RX_VK_RENODX_TRACE=1: every 1200th frame's draws by fragment module. +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vk_menu.h" +#include "vk_renodx.h" + +// RenoDX's shaders are not part of Hookshot: a build that asks for them fetches and compiles them (scripts/renodx_shaders.py +// into HOOKSHOT_RENODX's renodx_spv.h, which compiles this file with HOOKSHOT_RENODX). Without it only the stubs at the end +// are here: nothing is replaced, and the game keeps its own tone mapping and scene format. +#ifdef HOOKSHOT_RENODX + +#include "renodx_spv.h" +#include "vk_work.h" // (last: counts the commands that do GPU work, for full_barrier) + +namespace mkwvk { +namespace { + +// (shared.h ShaderInjectData: 17 floats, scalar layout) +struct Injection { + float tone_map_type, peak_white_nits, diffuse_white_nits, graphics_white_nits; + float tone_map_highlights, tone_map_shadows, tone_map_contrast, tone_map_saturation, tone_map_cone_contrast; + float bloom_strength, custom_hue_clip, custom_flags, local_exposure, tone_map_exposure; + float adaptation_target, adaptation_min_stops, adaptation_max_stops; +}; +static_assert(sizeof(Injection) == 17 * sizeof(float)); + +constexpr size_t kShaders = sizeof RENODX_SHADERS / sizeof RENODX_SHADERS[0]; +// (a draw's part in the eye adaptation, which picks its constants: renodx_spv.h's kinds 1 the fog, 2 the scene) +enum { kPlain = 0, kFog = 1, kMeter = 2, kKinds = 3 }; +constexpr uint32_t kRing = 8; // (frames of constants kept apart; even, so a frame's images follow from its place in the ring) +constexpr uint64_t kSlot = 256; // (a uniform range's place: a multiple of any minUniformBufferOffsetAlignment) +constexpr uint64_t kInjectionAt = 0, kAaAt = kSlot, kSeedAt = 2 * kSlot, kAdaptationAt = 4 * kSlot; +constexpr uint64_t kBufferSize = kAdaptationAt + kRing * kKinds * kSlot; +constexpr uint32_t kGenerations = 1048576u; // (shared.h RENODX_ADAPTATION_GENERATION_COUNT) + +struct State { + bool tried = false, ok = false; + VkDescriptorSetLayout layout = VK_NULL_HANDLE; + VkDescriptorPool pool = VK_NULL_HANDLE; + VkDescriptorSet sets[kRing][kKinds]{}; + VkImage images[2]{}; + VmaAllocation image_allocs[2]{}; + VkImageView views[2]{}; + VkBuffer buffer = VK_NULL_HANDLE; + VmaAllocation buffer_alloc = nullptr; + void* mapped = nullptr; + std::chrono::steady_clock::time_point last_present = std::chrono::steady_clock::now(); +}; +State st; +std::mutex mu; +std::atomic frame{0}; // (the frame being recorded: presents so far) +std::atomic meter_claimed{false}, fog_claimed{false}; // (this frame's one metering draw and one fog record) +std::atomic binds[kShaders]; // (draws through each of RenoDX's shaders since the last report) +std::atomic meters{0}, fogs{0}; // (frames metered and field-of-view records made since the last report) + +bool enabled() { // (Triforce, 11-13: the RenoDX HDR row as it was at the start; RX_VK_RENODX=0 or 1 over it) + return renodx_chosen(); +} +std::atomic replaced_modules{0}; // (modules of the game's that RenoDX's took the place of, this run) +bool adapting() { return opts.rdx_tonemap && opts.rdx_midgray == 2; } + +/// The settings from the Insert menu's rows, parsed as addon.cpp parses its own (0 to 100 with 50 neutral is 0 to 2), and the +/// constants of frame f's draws (delta: the time since the frame before) +void write_settings(uint64_t f, float delta_seconds) { + Injection in{}; + in.tone_map_type = opts.rdx_tonemap ? 9.0f : 0.0f; // (RENODX_TONE_MAP_TYPE_PSYCHOV35, _VANILLA) + in.peak_white_nits = (float)opts.hdr_peak; + in.diffuse_white_nits = (float)opts.hdr_white; + in.graphics_white_nits = (float)opts.rdx_ui_white; + in.tone_map_highlights = opts.rdx_highlights * 0.02f, in.tone_map_shadows = opts.rdx_shadows * 0.02f; + in.tone_map_contrast = opts.rdx_contrast * 0.02f, in.tone_map_saturation = opts.rdx_saturation * 0.02f; + in.tone_map_cone_contrast = 1.0f; + in.bloom_strength = opts.rdx_bloom * 0.02f; + in.custom_hue_clip = 0.5f; + // (midgray: 0 the render's, 1 vanilla's, 16 the eye adaptation's; 2: match the tone slope; the colour space in bits 2 and 3) + const uint32_t midgray = opts.rdx_midgray == 2 ? 16u : opts.rdx_midgray == 1 ? 1u : 0u; + const uint32_t flags = midgray | 2u | ((uint32_t)std::clamp(opts.rdx_space, 0, 2) << 2); + std::memcpy(&in.custom_flags, &flags, sizeof flags); + in.local_exposure = 0.0f; + in.tone_map_exposure = opts.rdx_exposure * 0.01f; + in.adaptation_target = 0.18f, in.adaptation_min_stops = -4.0f, in.adaptation_max_stops = 2.0f; + const float aa[2] = {1.0f, 0.0f}; // (AA strength, reconstruction: native) + uint8_t* m = (uint8_t*)st.mapped; + std::memcpy(m + kInjectionAt, &in, sizeof in); + std::memcpy(m + kAaAt, aa, sizeof aa); + for (int kind = 0; kind < kKinds; kind++) { // (adaptation.slangi: delta_seconds, generation, capture_fov, meter_draw) + const float adaptation[4] = {delta_seconds, (float)(f % kGenerations), kind == kFog ? 1.0f : 0.0f, kind == kMeter ? 1.0f : 0.0f}; + std::memcpy(m + kAdaptationAt + ((f % kRing) * kKinds + kind) * kSlot, adaptation, sizeof adaptation); + } + flush_mapped(st.buffer_alloc, kBufferSize); +} + +/// The state images' seed copied in, on the replay's queue, waited for (once) +bool seed_images() { + VkCommandPoolCreateInfo pi{VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO}; + pi.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT; + pi.queueFamilyIndex = dev.queue_family; + VkCommandPool pool = VK_NULL_HANDLE; + if (vkCreateCommandPool(dev.device, &pi, nullptr, &pool) != VK_SUCCESS) return false; + VkCommandBufferAllocateInfo ai{VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO}; + ai.commandPool = pool, ai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, ai.commandBufferCount = 1; + VkCommandBuffer cmd = VK_NULL_HANDLE; + VkFenceCreateInfo fi{VK_STRUCTURE_TYPE_FENCE_CREATE_INFO}; + VkFence fence = VK_NULL_HANDLE; + bool ok = vkAllocateCommandBuffers(dev.device, &ai, &cmd) == VK_SUCCESS && + vkCreateFence(dev.device, &fi, nullptr, &fence) == VK_SUCCESS; + if (ok) { + VkCommandBufferBeginInfo bi{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; + bi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; + vkBeginCommandBuffer(cmd, &bi); + for (const VkImage image : st.images) { + VkImageMemoryBarrier2 b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2}; + b.srcStageMask = VK_PIPELINE_STAGE_2_NONE; + b.dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT; + b.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT | VK_ACCESS_2_MEMORY_WRITE_BIT; + b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, b.newLayout = VK_IMAGE_LAYOUT_GENERAL; + b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + b.image = image; + b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + VkDependencyInfo di{VK_STRUCTURE_TYPE_DEPENDENCY_INFO}; + di.imageMemoryBarrierCount = 1, di.pImageMemoryBarriers = &b; + vkCmdPipelineBarrier2(cmd, &di); + const VkBufferImageCopy c{kSeedAt, 0, 0, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, {0, 0, 0}, {3, 1, 1}}; + vkCmdCopyBufferToImage(cmd, st.buffer, image, VK_IMAGE_LAYOUT_GENERAL, 1, &c); + } + vkEndCommandBuffer(cmd); + VkCommandBufferSubmitInfo cb{VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO}; + cb.commandBuffer = cmd; + VkSubmitInfo2 si{VK_STRUCTURE_TYPE_SUBMIT_INFO_2}; + si.commandBufferInfoCount = 1, si.pCommandBufferInfos = &cb; + { + std::lock_guard qk(dev.present_mu); // (the queue's lock) + queue_flush_locked(); + ok = vkQueueSubmit2(dev.queue, 1, &si, fence) == VK_SUCCESS; + } + if (ok) vkWaitForFences(dev.device, 1, &fence, VK_TRUE, UINT64_MAX); + } + if (fence) vkDestroyFence(dev.device, fence, nullptr); + vkDestroyCommandPool(dev.device, pool, nullptr); + return ok; +} + +bool make() { + const VkShaderStageFlags stages = VK_SHADER_STAGE_FRAGMENT_BIT | VK_SHADER_STAGE_COMPUTE_BIT; + const VkDescriptorSetLayoutBinding bindings[5] = { + {0, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, stages, nullptr}, + {1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, stages, nullptr}, + {2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, stages, nullptr}, + {3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, stages, nullptr}, + {4, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, stages, nullptr}, + }; + VkDescriptorSetLayoutCreateInfo li{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO}; + li.bindingCount = 5, li.pBindings = bindings; + if (vkCreateDescriptorSetLayout(dev.device, &li, nullptr, &st.layout) != VK_SUCCESS) return false; + constexpr uint32_t kSets = kRing * kKinds; + const VkDescriptorPoolSize sizes[2] = {{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 2 * kSets}, {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3 * kSets}}; + VkDescriptorPoolCreateInfo pi{VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO}; + pi.maxSets = kSets, pi.poolSizeCount = 2, pi.pPoolSizes = sizes; + if (vkCreateDescriptorPool(dev.device, &pi, nullptr, &st.pool) != VK_SUCCESS) return false; + if (!create_buffer(kBufferSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, st.buffer, + st.buffer_alloc, &st.mapped) || !st.mapped) + return false; + // (addon.cpp's seed. Pixel 0: the linear anchor, log2 fast, log2 slow, generation; 1: the FOV capture; 2: the log2 filtered + // target, the bleached fraction, reserved, generation. log2(0.18); the negative generations make these records stale) + const float seed[12] = {0.18f, -2.473931188332412f, -2.473931188332412f, -1.0f, 0.0f, 0.0f, 0.0f, -2.0f, + -2.473931188332412f, 0.0f, 0.0f, -2.0f}; + std::memcpy((uint8_t*)st.mapped + kSeedAt, seed, sizeof seed); + write_settings(frame.load(), 1.0f / 60.0f); + for (int i = 0; i < 2; i++) { + VkImageCreateInfo ic{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO}; + ic.imageType = VK_IMAGE_TYPE_2D, ic.format = VK_FORMAT_R32G32B32A32_SFLOAT, ic.extent = {3, 1, 1}; + ic.mipLevels = ic.arrayLayers = 1, ic.samples = VK_SAMPLE_COUNT_1_BIT, ic.tiling = VK_IMAGE_TILING_OPTIMAL; + ic.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if (!create_image(ic, st.images[i], st.image_allocs[i])) return false; + VkImageViewCreateInfo vi{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; + vi.image = st.images[i], vi.viewType = VK_IMAGE_VIEW_TYPE_2D, vi.format = ic.format; + vi.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + if (vkCreateImageView(dev.device, &vi, nullptr, &st.views[i]) != VK_SUCCESS) return false; + } + if (!seed_images()) return false; + for (uint32_t ring = 0; ring < kRing; ring++) { + for (int kind = 0; kind < kKinds; kind++) { + VkDescriptorSetAllocateInfo ai{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO}; + ai.descriptorPool = st.pool, ai.descriptorSetCount = 1, ai.pSetLayouts = &st.layout; + if (vkAllocateDescriptorSets(dev.device, &ai, &st.sets[ring][kind]) != VK_SUCCESS) return false; + // (the image the frame before wrote, then the one this frame writes) + const VkDescriptorImageInfo images[2] = {{VK_NULL_HANDLE, st.views[ring & 1], VK_IMAGE_LAYOUT_GENERAL}, + {VK_NULL_HANDLE, st.views[(ring & 1) ^ 1], VK_IMAGE_LAYOUT_GENERAL}}; + const VkDescriptorBufferInfo buffers[3] = {{st.buffer, kAdaptationAt + (ring * kKinds + kind) * kSlot, 16}, + {st.buffer, kAaAt, 8}, + {st.buffer, kInjectionAt, sizeof(Injection)}}; + VkWriteDescriptorSet w[5]; + for (uint32_t i = 0; i < 5; i++) { + w[i] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + w[i].dstSet = st.sets[ring][kind], w[i].dstBinding = i, w[i].descriptorCount = 1; + if (i < 2) w[i].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, w[i].pImageInfo = &images[i]; + else w[i].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, w[i].pBufferInfo = &buffers[i - 2]; + } + vkUpdateDescriptorSets(dev.device, 5, w, 0, nullptr); + } + } + return true; +} + +bool ready() { + std::lock_guard lk(mu); + if (!st.tried) { + st.tried = true; + st.ok = make(); + logf(st.ok ? "vk: RenoDX: its settings and state made (set 1); peak %d nits, paper white %d nits" + : "vk: RenoDX: its settings could not be made: the replaced shaders read nothing there", + opts.hdr_peak, opts.hdr_white); + } + return st.ok; +} + +std::mutex trace_mu; +std::vector traced; + +} // namespace + +std::atomic renodx_tracing{false}; + +const std::vector* renodx_replacement(uint32_t crc) { + if (!enabled()) return nullptr; + static const std::unordered_map> table = [] { + std::unordered_map> out; + for (const auto& s : RENODX_SHADERS) out.emplace(s.crc, std::vector(s.words, s.words + s.count)); + return out; + }(); + const auto it = table.find(crc); + if (it != table.end()) replaced_modules.fetch_add(1, std::memory_order_relaxed); + return it == table.end() ? nullptr : &it->second; +} + +VkDescriptorSetLayout renodx_set_layout() { + return ready() ? st.layout : VK_NULL_HANDLE; +} + +void renodx_bind(VkCommandBuffer cmd, VkPipelineBindPoint bp, VkPipelineLayout layout, uint32_t crc) { + if (!ready()) return; + int kind = kPlain; + for (size_t i = 0; i < kShaders; i++) { + if (RENODX_SHADERS[i].crc != crc) continue; + binds[i].fetch_add(1, std::memory_order_relaxed); + // (addon.cpp PrepareAdaptationDraw, OnDrawAdaptationFog: with the eye adaptation on, the frame's first scene draw + // meters and its first fog draw records the field of view) + if (!adapting()) break; + if (RENODX_SHADERS[i].kind == 2 && !meter_claimed.exchange(true)) kind = kMeter, meters.fetch_add(1, std::memory_order_relaxed); + if (RENODX_SHADERS[i].kind == 1 && !fog_claimed.exchange(true)) kind = kFog, fogs.fetch_add(1, std::memory_order_relaxed); + break; + } + vkCmdBindDescriptorSets(cmd, bp, layout, 1, 1, &st.sets[frame.load(std::memory_order_relaxed) % kRing][kind], 0, nullptr); +} + +void renodx_trace_draw(uint32_t frag_crc) { + std::lock_guard lk(trace_mu); + traced.push_back(frag_crc); +} + +void renodx_present() { + { // (RX_VK_RENODX_TRACE=1: every 1200th frame's draws, in order, by fragment module) + static const bool trace = getenv("RX_VK_RENODX_TRACE") != nullptr; + static int64_t frames; + if (trace) { + if (renodx_tracing.exchange(false)) { + std::lock_guard lk(trace_mu); + // (the frame's last 120 draws, 40 a line: the tone mapping and what follows it close the frame, and a + // longer line is cut by the log) + const size_t from = traced.size() > 120 ? traced.size() - 120 : 0; + logf("vk: RenoDX trace: a frame of %zu draws; by fragment module from draw %zu:", traced.size(), from); + for (size_t at = from; at < traced.size(); at += 40) { + std::string line; + char b[16]; + for (size_t k = at; k < std::min(at + 40, traced.size()); k++) snprintf(b, sizeof b, " %08X", traced[k]), line += b; + logf("vk: RenoDX trace:%s", line.c_str()); + } + traced.clear(); + } + if (++frames % 1200 == 0) renodx_tracing.store(true); + } + } + { // (Triforce, 11-13) RenoDX chosen and nothing of the game's replaced half a minute in: said, once. Its shaders are + // named by the CRC-32 of the module this translator makes, so another translation of the same program (a later + // change to the emitter, another card's fixes) silently leaves the game's own HDR running + static std::atomic presents{0}; + if (enabled() && presents.fetch_add(1, std::memory_order_relaxed) == 1800 && !replaced_modules.load(std::memory_order_relaxed)) + logf("vk: RenoDX: on, and none of its four shaders has replaced one of the game's in 1800 presents: the game's own " + "picture runs. Either HDR is not Native on an HDR10 display (its shaders are the native HDR ones), or this " + "build names them by other checksums (scripts/renodx_shaders.py SHADERS: match them again)"); + } + std::lock_guard lk(mu); + if (!st.ok) return; + const auto now = std::chrono::steady_clock::now(); + const float delta = std::chrono::duration(now - st.last_present).count(); + st.last_present = now; + // (the next frame: its constants written before any of its draws is recorded; its place in the ring was last read kRing + // frames ago) + const uint64_t next = frame.load() + 1; + write_settings(next, delta); + frame.store(next); + meter_claimed.store(false), fog_claimed.store(false); + // (how much of the picture goes through it. A scene draw and the output encoder each frame is the whole of it; the scene at 0 + // means a permutation of the game's tone mapping that RenoDX has no replacement for) + if (next % 600 == 0) { + char line[256]; + int n = 0; + for (size_t i = 0; i < kShaders && n < (int)sizeof line - 32; i++) + n += snprintf(line + n, sizeof line - n, " %08X %.2f", RENODX_SHADERS[i].crc, + (double)binds[i].exchange(0, std::memory_order_relaxed) / 600.0); + logf("vk: RenoDX: draws a frame through its shaders over the last 600 presents:%s; eye adaptation %s, %lld frames metered, " + "%lld field-of-view records", + line, adapting() ? "on" : "off", (long long)meters.exchange(0), (long long)fogs.exchange(0)); + } +} +bool renodx_built() { return true; } + +} // namespace mkwvk + +#else // (no RenoDX shaders in this build: nothing is replaced) + +namespace mkwvk { + +std::atomic renodx_tracing{false}; +bool renodx_built() { return false; } +const std::vector* renodx_replacement(uint32_t) { return nullptr; } +VkDescriptorSetLayout renodx_set_layout() { return VK_NULL_HANDLE; } +void renodx_bind(VkCommandBuffer, VkPipelineBindPoint, VkPipelineLayout, uint32_t) {} +void renodx_trace_draw(uint32_t) {} +void renodx_present() {} + +} // namespace mkwvk + +#endif diff --git a/gpu/vk/vk_renodx.h b/gpu/vk/vk_renodx.h new file mode 100644 index 0000000..2b0ee40 --- /dev/null +++ b/gpu/vk/vk_renodx.h @@ -0,0 +1,27 @@ +// (local, RenoDX port) RenoDX's Zelda OoT shaders in place of the game's own tone mapping and HDR output (vk_renodx.cpp). +#pragma once + +#include +#include +#include + +#include "vk_internal.h" + +namespace mkwvk { + +/// Whether this build has RenoDX's shaders in it (HOOKSHOT_RENODX, scripts/renodx_shaders.py): the Insert menu's RenoDX rows +bool renodx_built(); +/// RenoDX's module for the one of Hookshot's whose CRC-32 this is, or null (none, or RX_VK_RENODX=0) +const std::vector* renodx_replacement(uint32_t crc); +/// Set 1 of a program with a replaced stage (RenoDX's settings, its eye adaptation's state); null: it could not be made +VkDescriptorSetLayout renodx_set_layout(); +/// Before a draw of such a program (crc: its replaced module's, Stage::renodx): set 1 bound +void renodx_bind(VkCommandBuffer cmd, VkPipelineBindPoint bp, VkPipelineLayout layout, uint32_t crc); +/// (RX_VK_RENODX_TRACE=1) while set, one frame's draws are noted by their fragment module's CRC-32, and logged at its present: +/// which of the game's tone-mapping permutations a scene uses +extern std::atomic renodx_tracing; +void renodx_trace_draw(uint32_t frag_crc); +/// Each present: the settings as the menu has them now +void renodx_present(); + +} // namespace mkwvk diff --git a/gpu/vk/vk_replay.cpp b/gpu/vk/vk_replay.cpp index 3e58ba7..d27dd23 100644 --- a/gpu/vk/vk_replay.cpp +++ b/gpu/vk/vk_replay.cpp @@ -49,6 +49,7 @@ #include "vk_present_trace.h" #include "vk_internal.h" +#include "vk_renodx.h" #include "vk_work.h" // (after the others: counts the commands that do GPU work, for full_barrier) namespace mkwvk { @@ -3004,6 +3005,21 @@ void status_tick() { } std::atomic present_native_pq{false}; // (do_present: the game's picture is already HDR10) +// (local fix, from the old HDR port) a colour format's bytes a texel, for the present's copy between formats of one size (0: not one of these) +static uint32_t present_texel_bytes(VkFormat f) { + switch (f) { + case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_R8G8B8A8_SRGB: case VK_FORMAT_B8G8R8A8_UNORM: case VK_FORMAT_B8G8R8A8_SRGB: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: case VK_FORMAT_A2R10G10B10_UNORM_PACK32: case VK_FORMAT_B10G11R11_UFLOAT_PACK32: + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: case VK_FORMAT_R16G16_SFLOAT: case VK_FORMAT_R16G16_UNORM: case VK_FORMAT_R32_SFLOAT: + return 4; + case VK_FORMAT_R16G16B16A16_SFLOAT: case VK_FORMAT_R16G16B16A16_UNORM: case VK_FORMAT_R32G32_SFLOAT: + return 8; + case VK_FORMAT_R32G32B32A32_SFLOAT: + return 16; + default: + return 0; + } +} uint64_t present_value = 0; // (the present job's value, handed out as it came; 0: the next one) struct PendingShot { bool on = false; @@ -3023,6 +3039,7 @@ void do_present(const nvn_tex* t, const int crop[4]) { // (hookshot) NVIDIA Reflex (vk_reflex.cpp): this frame's simulation ended, its submission starts; on the way out (after the // present) the driver's sleep until the next frame should begin. AMD Anti-Lag 2 (vk_antilag.cpp) waits there as well: the // next frame's input stage + renodx_present(); // (local, RenoDX port) its settings as the menu has them now temporal_idle(); // (DLSS, FSR: their video memory let go once not used for a while) status_tick(); // (the status line, and the video-memory warning) reflex_present_begins(); @@ -3058,9 +3075,64 @@ void do_present(const nvn_tex* t, const int crop[4]) { t ? t->d.width : 0, t ? t->d.height : 0, t ? t->d.format : 0, tex ? (tex->gpu_written ? "rendered" : "never rendered") : "no image"); if (tex) src = tex->image, sw = tex->width, sh = tex->height; + // (local fix, from the old HDR port) the present's own format, when the image found at the window texture's storage was + // made in another format of the same texel size: HDR turned to Native in play, the game writes RGB10A2 into the window + // textures that were made as RGBA8. Their bits are copied as they are into an image of the present's format, so a + // blit reads them as what they are. Each change of the presented format is logged + const VkFormat want_fmt = t ? vk_format((int)t->d.format).format : VK_FORMAT_UNDEFINED; + { + static uint32_t last_fmt = ~0u; + if (t && (uint32_t)t->d.format != last_fmt) { + last_fmt = (uint32_t)t->d.format; + logf("vk: present format %#x (vk %d): the image there is vk %d, %s", (unsigned)t->d.format, (int)want_fmt, + tex ? (int)tex->format : -1, tex ? (tex->gpu_written ? "rendered" : "never rendered") : "no image"); + } + } + if (tex && src && !dev.offscreen) { + const uint32_t bytes = present_texel_bytes(want_fmt); + if (want_fmt != VK_FORMAT_UNDEFINED && tex->format != want_fmt && bytes && bytes == present_texel_bytes(tex->format)) { + struct Retyped { VkImage image = VK_NULL_HANDLE; VmaAllocation alloc = nullptr; VkFormat f = VK_FORMAT_UNDEFINED; uint32_t w = 0, h = 0; }; + static Retyped ring[4]; // (frames in flight: the display thread blits one while the next is recorded) + static unsigned at_ring; + Retyped& rt = ring[at_ring++ % 4]; + if (rt.f != want_fmt || rt.w != sw || rt.h != sh) { + if (rt.image) { + { + std::lock_guard qk(dev.present_mu); // (the old one may still be in a blit) + device_wait_idle_locked(); + } + destroy_image(rt.image, rt.alloc); + rt = Retyped{}; + } + VkImageCreateInfo ic{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO}; + ic.imageType = VK_IMAGE_TYPE_2D, ic.format = want_fmt, ic.extent = {sw, sh, 1}, ic.mipLevels = 1, ic.arrayLayers = 1; + ic.samples = VK_SAMPLE_COUNT_1_BIT, ic.tiling = VK_IMAGE_TILING_OPTIMAL; + ic.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + if (create_image(ic, rt.image, rt.alloc)) { + rt.f = want_fmt, rt.w = sw, rt.h = sh; + image_barrier(r.cmd, rt.image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL); + static int told; + if (told++ < 4) logf("vk: present: the window texture's image is vk format %d, the present's %d: copied as %d", + (int)tex->format, (int)want_fmt, (int)want_fmt); + } else { + rt = Retyped{}; + } + } + if (rt.image) { + full_barrier(r.cmd); + VkImageCopy c{}; + c.srcSubresource = c.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + c.extent = {sw, sh, 1}; + vkCmdCopyImage(r.cmd, src, VK_IMAGE_LAYOUT_GENERAL, rt.image, VK_IMAGE_LAYOUT_GENERAL, 1, &c); + full_barrier(r.cmd); + src = rt.image; + } + } + } // (the Insert menu's HDR set to Native: the game, told its display is HDR10, presents PQ codes in RGB10A2 (vk - // A2B10G10R10); that picture goes to the HDR10 swapchain as it is, not through the SDR-to-HDR pass) - present_native_pq.store(tex && dev.hdr && opts.hdr == 2 && tex->format == VK_FORMAT_A2B10G10R10_UNORM_PACK32, + // A2B10G10R10); that picture goes to the HDR10 swapchain as it is, not through the SDR-to-HDR pass. Local fix: by the + // format the game presents, not the cached image's, which stays RGBA8 when HDR is turned on in play) + present_native_pq.store(tex && dev.hdr && opts.hdr == 2 && want_fmt == VK_FORMAT_A2B10G10R10_UNORM_PACK32, std::memory_order_relaxed); if (tex && !dev.offscreen && (opts.upscale || opts.sharpness || dev.hdr || wide_sides_possible())) { // (and ultrawide's menu sides) // Keep the sampled view with the same cached image as the direct present, before advancing its age. @@ -3658,7 +3730,10 @@ void present_image(VkImage src, uint32_t sw, uint32_t sh, const int crop[4], VkI } const VkImage scaled = src && view ? framegen_scale(f.cmd, view, src, sw, sh, crop, rect.w, rect.h) : VK_NULL_HANDLE; // (hookshot) the Insert menu's HDR: the picture (scaled, or the game's own with its crop) to HDR10, copied in as the SDR one is - const VkImage hdr_image = dev.hdr && src && view && !present_native_pq.load(std::memory_order_relaxed) + // (lab, 11-13) RX_VK_TEST_HDR_PASS=1: the HDR pass on a screen that is not HDR (its colours are wrong there, by design): + // whether the pass gets a picture at all can be seen without an HDR display + static const bool test_hdr = getenv("RX_VK_TEST_HDR_PASS") != nullptr; + const VkImage hdr_image = (dev.hdr || test_hdr) && src && view && !present_native_pq.load(std::memory_order_relaxed) ? (scaled ? framegen_hdr(f.cmd, framegen_scaled_view(), rect.w, rect.h, nullptr, rect.w, rect.h) : framegen_hdr(f.cmd, view, sw, sh, crop, rect.w, rect.h)) : VK_NULL_HANDLE; diff --git a/gpu/vk/vk_shader.cpp b/gpu/vk/vk_shader.cpp index 3ab9e4a..43c6376 100644 --- a/gpu/vk/vk_shader.cpp +++ b/gpu/vk/vk_shader.cpp @@ -581,6 +581,9 @@ Shader::Profile make_profile() { // (RX_VK_FRAG_SHUFFLE_FALLBACK=0 or 1, a test: the fragment stages' shuffles native or through broadcasts, whatever the // driver; in the cache's stamp) if (const char* e = getenv("RX_VK_FRAG_SHUFFLE_FALLBACK")) p.has_broken_spirv_fragment_shuffle = e[0] == '1'; + // (hookshot) gathers nudged by 1/512 of a texel on AMD's and Intel's drivers, as Eden and Lichii have it (vk_vendor.h; in the + // cache's stamp) + p.need_gather_subpixel_offset = dev.fixes.gather_offset; p.min_ssbo_alignment = dev.props.limits.minStorageBufferOffsetAlignment; return p; } @@ -603,6 +606,9 @@ Shader::HostTranslateInfo host_info() { /// A translated stage: its IR program (kept for the next stage's inputs) and the pools its IR lives in struct Translation { + uint32_t fallbacks = 0; // (texture handles no handle program followed: Shader::Optimization::TakeHandleFallbacks) + uint32_t tables = 0; // (Triforce: texture handles read from a table of records, one texture an element) + std::string fallback_ops; Shader::ObjectPool insts; Shader::ObjectPool blocks; Shader::ObjectPool flow_blocks; @@ -615,15 +621,69 @@ std::unique_ptr translate(Env& env, bool graphics, bool one_exit = Shader::Maxwell::Flow::CFG cfg{env, t->flow_blocks, env.StartAddress() + (graphics ? static_cast(sizeof(Shader::ProgramHeader)) : 0u), one_exit}; + Shader::Optimization::TakeHandleFallbacks(t->fallback_ops); // (none from an earlier one on this thread) + Shader::Optimization::TakeHandleTables(); t->program = Shader::Maxwell::TranslateProgram(t->insts, t->blocks, env, cfg, host_info()); + t->fallbacks = Shader::Optimization::TakeHandleFallbacks(t->fallback_ops); + t->tables = Shader::Optimization::TakeHandleTables(); return t; } -VkShaderModule make_module(const std::vector& spirv) { +} // namespace +} // namespace mkwvk +#include "vk_renodx.h" +namespace mkwvk { +namespace { + +/// (local, RenoDX port) The CRC-32 of a module's words as the bytes they are: RenoDX names the shaders it replaces by it +uint32_t spirv_crc32(const std::vector& spirv) { + static const std::array table = [] { + std::array out{}; + for (uint32_t i = 0; i < 256; i++) { + uint32_t k = i; + for (int j = 0; j < 8; j++) k = k & 1 ? 0xEDB88320u ^ (k >> 1) : k >> 1; + out[i] = k; + } + return out; + }(); + uint32_t c = 0xFFFFFFFFu; + const uint8_t* p = (const uint8_t*)spirv.data(); + for (size_t i = 0, n = spirv.size() * 4; i < n; i++) c = table[(c ^ p[i]) & 0xFF] ^ (c >> 8); + return c ^ 0xFFFFFFFFu; +} + +/// (local, RenoDX port) *renodx: set when RenoDX has a replacement for this module, which is made in its place (vk_renodx.h) +VkShaderModule make_module(const std::vector& spirv, uint32_t* renodx = nullptr, uint32_t* crc_out = nullptr) { + const uint32_t crc = spirv_crc32(spirv); + if (crc_out) *crc_out = crc; + // (local, RenoDX port) RX_VK_DUMP_ALL_SPV=: every module made, as .spv + if (static const char* dir = getenv("RX_VK_DUMP_ALL_SPV"); dir) { + char path[512]; + snprintf(path, sizeof path, "%s/%08X.spv", dir, crc); + if (FILE* f = fopen(path, "wb")) fwrite(spirv.data(), 4, spirv.size(), f), fclose(f); + } + const std::vector* const other = renodx ? renodx_replacement(crc) : nullptr; + if (other) { + *renodx = crc; + static std::atomic told{0}; + if (told++ < 16) logf("vk: RenoDX: module %08X replaced (%zu words for %zu)", crc, other->size(), spirv.size()); + } + const std::vector& code = other ? *other : spirv; VkShaderModuleCreateInfo ci{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; - ci.codeSize = spirv.size() * 4; - ci.pCode = spirv.data(); + ci.codeSize = code.size() * 4; + ci.pCode = code.data(); VkShaderModule m = VK_NULL_HANDLE; + // (lab, 11-13) EDEN_SPV_SALT=: every module's generator word (the header's third, free for the generator's use) carries + // n, so the driver's own cache on disk has met none of them: a start that compiles everything again, at will, without + // touching that cache. An EDEN_ name: in the program cache's stamp + static const uint32_t salt = getenv("EDEN_SPV_SALT") ? (uint32_t)strtoul(getenv("EDEN_SPV_SALT"), nullptr, 0) : 0; + if (salt && spirv.size() > 5) { + std::vector salted = spirv; + salted[2] ^= salt; + ci.pCode = salted.data(); + vkCreateShaderModule(dev.device, &ci, nullptr, &m); + return m; + } vkCreateShaderModule(dev.device, &ci, nullptr, &m); return m; } @@ -655,7 +715,7 @@ uint32_t stage_cbuf_word(const NvnState& s, const Stage& st, uint32_t index, uin return 0; } -uint32_t stage_handle(const NvnState& s, const Stage& st, uint32_t program) { +uint32_t stage_handle(const NvnState& s, const Stage& st, uint32_t program, uint32_t element) { if (program >= st.info.handle_programs.size()) return 0; return Shader::EvaluateHandleProgram( st.info.handle_programs[program], @@ -667,12 +727,17 @@ uint32_t stage_handle(const NvnState& s, const Stage& st, uint32_t program) { (uint64_t)stage_cbuf_word(s, st, d.cbuf_index, d.cbuf_offset + 4) << 32; uint32_t v = 0; static const bool live = getenv("RX_VK_HANDLES_LIVE") != nullptr; + // (hookshot #3047) a handle table's elements past the buffer's bound size: none (they named textures + // the shader never samples, and uploaded them) + const uint32_t size = stage_cbuf_word(s, st, d.cbuf_index, d.cbuf_offset + 8); + if (size && (uint64_t)offset + 4 > size) return 0U; if (base) { if (live) host->gpu_read(base + offset, &v, 4); else ub_read(base + offset, &v, 4); } return v; - }) + }, + element) .value_or(0U); } @@ -933,6 +998,24 @@ void log_program_stages(const NvnState& s, const char* why) { namespace { +/// (hookshot) A stage whose texture handles no handle program followed: they sample the first constant buffer word on their +/// path, which is rarely the texture (the water's lights in OoT: squares on the water, #2509). Once for each translation +void note_fallbacks(const Program& p, const char* stage, const Translation& t) { + // (Triforce: a prepare translates 38000 programs: the first few of each kind are named, then every 200th with the count) + static std::atomic table_stages{0}, fallback_stages{0}; + if (t.tables) { + const uint32_t n = ++table_stages; + if (n <= 8 || n % 200 == 0) + logf("vk: program %016llx, %s stage: %u texture handle(s) read from a table of records, one texture an element " + "(RX_VK_HANDLE_TABLE=0: one for all, as before); %u stages so far", (unsigned long long)p.key, stage, t.tables, n); + } + if (!t.fallbacks) return; + const uint32_t n = ++fallback_stages; + if (n <= 8 || n % 200 == 0) + logf("vk: program %016llx, %s stage: %u texture handle(s) not followed per draw (stopped at %s): the first constant word " + "on the path is sampled; %u stages so far", (unsigned long long)p.key, stage, t.fallbacks, t.fallback_ops.c_str(), n); +} + /// RX_VK_IR=[,...] (hex, a prefix is enough): the stages' Eden IR written to ir__.txt in the /// working folder when the program is translated (diagnostics) void dump_ir(const Program& p, const char* stage, const Shader::IR::Program& prog, uint64_t code_key = 0) { @@ -982,11 +1065,21 @@ void oot_visual(Shader::IR::Program& program, uint64_t key) { /// With RX_VK_NO_PROGRAM_CACHE=1 void frag_probe(Shader::IR::Program& program, uint64_t key) { static const char* e = getenv("RX_VK_FRAG_PROBE"); - if (!e) return; + // (11-13) RX_VK_FRAG_SET=:=[,=...]: the value numbered %n in the RX_VK_IR dump is + // replaced by a constant wherever it is used, in any block (a light's term taken out to see what it carried). : a + // number (a U32 value takes the float's bits, a U1 true unless 0) or x, the bits themselves. With or without a probe + static const char* set_e = getenv("RX_VK_FRAG_SET"); + if (!e && !set_e) return; char hex[24]; snprintf(hex, sizeof hex, "%016llx", (unsigned long long)key); - const char* colon = strchr(e, ':'); - if (!colon || strncmp(hex, e, (size_t)(colon - e)) != 0) return; + const auto mine = [&](const char* v) -> const char* { + const char* c = v ? strchr(v, ':') : nullptr; + return c && !strncmp(hex, v, (size_t)(c - v)) ? c : nullptr; + }; + const char* set_colon = mine(set_e); + const char* colon = mine(e); + if (!colon && !set_colon) return; + if (!colon) colon = ":"; // (no probe for this program: the sets alone) using namespace Shader::IR; int n = -1; const bool attr = sscanf(colon + 1, "attr%d", &n) == 1 && n >= 0 && n < 32; @@ -995,7 +1088,7 @@ void frag_probe(Shader::IR::Program& program, uint64_t key) { // arguments as met), saturated, as red, green, blue; one number: grey. Values whose block dominates the colour write's only) int vn[3] = {-1, -1, -1}; const int nv = colon[1] == 'v' ? sscanf(colon + 2, "%d,%d,%d", &vn[0], &vn[1], &vn[2]) : 0; - if (!attr && !flag && nv <= 0) return; + if (!attr && !flag && nv <= 0 && !set_colon) return; // (which blocks dominate which: a value may stand in for the colour only where every path to the write passes its block) std::unordered_map block_index; for (size_t i = 0; i < program.blocks.size(); i++) block_index[program.blocks[i]] = i; @@ -1026,7 +1119,7 @@ void frag_probe(Shader::IR::Program& program, uint64_t key) { }; std::map by_index; std::unordered_map block_of; - if (nv > 0) { + if (nv > 0 || set_colon) { size_t index = program.blocks.size(); std::map seen; const auto number = [&](const Inst* i) { @@ -1042,6 +1135,76 @@ void frag_probe(Shader::IR::Program& program, uint64_t key) { } } } + // (what the numbers name, said in the log: the dump the numbers were read from may be of another translation) + const auto named = [&](int want) { + const auto f = by_index.find((size_t)want); + if (f == by_index.end()) return std::string("nothing"); + const auto b = block_index.find(block_of[f->second]); + return std::string(NameOf(f->second->GetOpcode())) + " in block " + std::to_string(b == block_index.end() ? -1 : (long long)b->second); + }; + for (int i = 0; i < nv; i++) logf("vk: probe: %%%d is %s", vn[i], named(vn[i]).c_str()); + if (set_colon) { + // (the instructions first, then the changes: a replaced value's users no longer meet it, and the numbers after it move) + std::vector> sets; + for (const char* q = set_colon + 1; *q;) { + const char* end = q; + while (*end && *end != ',') end++; + int want = -1; + char text[40] = ""; + if (sscanf(q, "%d=%39[^,]", &want, text) == 2) { + const auto f = by_index.find((size_t)want); + logf("vk: set: %%%d (%s) = %s%s", want, named(want).c_str(), text, f == by_index.end() ? ": left out" : ""); + if (f != by_index.end()) sets.push_back({f->second, text}); + } + q = *end ? end + 1 : end; + } + for (const auto& [inst, text] : sets) { + if (!strncmp(text.c_str(), "sub", 3)) { + // (=sub: %n's users get %m - %n, two F32 values of one block, %m first: a coordinate mirrored where it is used) + const auto fm = by_index.find((size_t)atoi(text.c_str() + 3)); + Block* const b = block_of[inst]; + if (fm == by_index.end() || !b || inst->Type() != Type::F32 || fm->second->Type() != Type::F32) { + logf("vk: set: sub needs two F32 values: left out"); + continue; + } + // (the users first: the two instructions made below read %n themselves and must go on reading it) + std::vector> before; + for (Block* other : program.blocks) + for (Inst& user : other->Instructions()) + for (size_t a = 0; a < user.NumArgs(); a++) { + const Value arg = user.Arg(a); + if (arg.IsEmpty() || (arg.IsImmediate() && !arg.IsIdentity())) continue; + if (arg.Inst() == inst) before.push_back({&user, a}); + } + Inst* made = nullptr; + for (auto it = b->Instructions().begin(); it != b->Instructions().end(); ++it) + if (&*it == inst) { + IREmitter ir{*b, std::next(it)}; + made = F32{ir.FPAdd(F32{Value{fm->second}}, F32{ir.FPNeg(F32{Value{inst}})})}.Inst(); + break; + } + int users = 0; + if (made) + for (const auto& [user, a] : before) user->SetArg(a, Value{made}), users++; + logf("vk: set: %d users now read the mirrored value", users); + continue; + } + const bool raw = text[0] == 'x'; + const float fv = raw ? 0.0f : (float)atof(text.c_str()); + uint32_t bits = raw ? (uint32_t)strtoul(text.c_str() + 1, nullptr, 16) : 0; + if (!raw) memcpy(&bits, &fv, 4); + float as_float; + memcpy(&as_float, &bits, 4); + const Type t = inst->Type(); + if (t == Type::F32) inst->ReplaceUsesWith(Value{as_float}); + else if (t == Type::U32) inst->ReplaceUsesWith(Value{bits}); + else if (t == Type::U1) inst->ReplaceUsesWith(Value{bits != 0}); + else logf("vk: set: a value of that type is not replaced"); + } + } + if (!attr && !flag && nv <= 0) return; + // (RX_VK_FRAG_PROBE_SCALE=: the probed values times s before they are shown, small ones made visible) + static const float probe_scale = getenv("RX_VK_FRAG_PROBE_SCALE") ? (float)atof(getenv("RX_VK_FRAG_PROBE_SCALE")) : 1.0f; int edits = 0; for (Block* block : program.blocks) for (auto it = block->Instructions().begin(); it != block->Instructions().end(); ++it) { @@ -1069,6 +1232,7 @@ void frag_probe(Shader::IR::Program& program, uint64_t key) { // (RX_VK_FRAG_PROBE_NEG=1: minus the value, to see negative ones) static const bool neg = getenv("RX_VK_FRAG_PROBE_NEG") != nullptr; if (neg) x = F32{ir.FPNeg(x)}; + if (probe_scale != 1.0f) x = F32{ir.FPMul(x, ir.Imm32(probe_scale))}; // (RX_VK_FRAG_PROBE_NAN=1: white where the value is NaN or beyond +-1e30, black elsewhere) static const bool nan = getenv("RX_VK_FRAG_PROBE_NAN") != nullptr; if (nan) { @@ -1245,7 +1409,10 @@ uint64_t disk_stamp() { // NaN guard, the matrix layout measured on this device. Without them a cache made on one GPU was used on another (a laptop's // integrated and dedicated GPUs), and RX_VK_NO_INVARIANT / RX_VK_NO_NAN_GUARD did nothing for programs already cached) using namespace Shader::Backend::SPIRV; - const uint32_t flags = (position_invariant ? 1u : 0u) | (frag_nan_guard ? 2u : 0u) | (mma_software ? 4u : 0u); + // (and the vendor fixes of the translation, vk_vendor.h: out-of-bounds fetches, NaN tests, the gather offset) + const uint32_t flags = (position_invariant ? 1u : 0u) | (frag_nan_guard ? 2u : 0u) | (mma_software ? 4u : 0u) | + (fetch_bounds ? 16u : 0u) | (nan_bits ? 32u : 0u) | + (profile().need_gather_subpixel_offset ? 64u : 0u) | (fetch_bounds_buffers ? 128u : 0u); add(&flags, sizeof flags); add(mma_order_a.data(), sizeof(uint32_t) * mma_order_a.size()); add(mma_order_b.data(), sizeof(uint32_t) * mma_order_b.size()); @@ -1254,7 +1421,7 @@ uint64_t disk_stamp() { // (RX_VK_GP_, not RX_VK_GP: that took RX_VK_GPL with it, which changes no translation, and switching the stage libraries on // threw the whole program cache away. What the libraries are good for is the prepare's second stamp, vk_draw.cpp warmed_stamp) for (char** e = _environ; e && *e; e++) - for (const char* pre : {"RX_VK_OOT", "RX_VK_MMA", "RX_VK_NATIVE", "RX_VK_NAN", "RX_VK_TASK_CAP", "RX_VK_NETWORK", "RX_VK_GP_", "RX_VK_FOLLOW", "RX_VK_NO_FOLLOW", "RX_VK_NO_F16", "RX_VK_SHARED", "RX_VK_MESH", "RX_VK_NO_INVARIANT", "RX_VK_NO_NAN_GUARD", "RX_VK_MARKERS", "EDEN_"}) + for (const char* pre : {"RX_VK_OOT", "RX_VK_MMA", "RX_VK_NATIVE", "RX_VK_NAN", "RX_VK_TASK_CAP", "RX_VK_NETWORK", "RX_VK_GP_", "RX_VK_FOLLOW", "RX_VK_NO_FOLLOW", "RX_VK_NO_F16", "RX_VK_SHARED", "RX_VK_MESH", "RX_VK_NO_INVARIANT", "RX_VK_NO_NAN_GUARD", "RX_VK_MARKERS", "RX_VK_HANDLE_TABLE", "RX_VK_DLSS_CAPTURE", "EDEN_"}) if (!strncmp(*e, pre, strlen(pre))) add(*e, strlen(*e)); return h; } @@ -1527,9 +1694,23 @@ void get_info(Reader& r, Shader::Info& i) { if (!descriptor_counts_fit(i)) r.bad = true; // (left out, and translated again) } +/// (11-13) A program RX_VK_FRAG_PROBE or RX_VK_FRAG_SET names is translated at its first draw and never kept: the probe is +/// in the translation, and the kept program has none (it needed RX_VK_NO_PROGRAM_CACHE=1 before, every program translated again) +bool probe_names(uint64_t key) { + static const char* const envs[2] = {getenv("RX_VK_FRAG_PROBE"), getenv("RX_VK_FRAG_SET")}; + if (!envs[0] && !envs[1]) return false; + char hex[24]; + snprintf(hex, sizeof hex, "%016llx", (unsigned long long)key); + for (const char* v : envs) { + const char* c = v ? strchr(v, ':') : nullptr; + if (c && c > v && !strncmp(hex, v, (size_t)(c - v))) return true; + } + return false; +} + void program_cache_save(const Program& p, const std::vector>& spirv) { disk_init(); - if (!disk_on || spirv.size() != p.stages.size()) return; + if (!disk_on || spirv.size() != p.stages.size() || probe_names(p.key)) return; std::vector o; o.reserve(256 << 10); put_head(o, p); @@ -1599,7 +1780,7 @@ void program_cache_read(FILE* in, std::mutex* mu, uint64_t key, const std::vecto ok = false; break; } - st.module = make_module(spirv); + st.module = make_module(spirv, st.vk_stage == VK_SHADER_STAGE_FRAGMENT_BIT ? &st.renodx : nullptr, &st.crc); ok = ok && st.module; } ok = ok && answers_fit(*p, p->answers); // (hookshot: an answer past the stages or their slots: not this record) @@ -1626,7 +1807,7 @@ void program_cache_read(FILE* in, std::mutex* mu, uint64_t key, const std::vecto /// (shader_mu held) the kept variants of key go to its list, ready, once void program_cache_load(uint64_t key, std::vector>& variants, bool keep = false) { disk_init(); - if (!disk_on) return; + if (!disk_on || probe_names(key)) return; std::vector recs; { std::lock_guard lk(disk_mu); @@ -1691,6 +1872,7 @@ void translate_into(Program& p, const NvnState& s, const Code* vsc, const Code* questions += env.texture_questions; oot_visual(t->program, csc->key); Shader::RuntimeInfo rt{}; + note_fallbacks(p, "compute", *t); dump_ir(p, "compute", t->program); // (before the SPIR-V: the programs it fails on are the ones to read) if (getenv("RX_VK_IR")) logf("vk: compute %016llx: workgroup %ux%ux%u, shared memory %u bytes, local memory %u", (unsigned long long)p.key, @@ -1742,20 +1924,47 @@ void translate_into(Program& p, const NvnState& s, const Code* vsc, const Code* Env vs_env{s, *vsc, Shader::Stage::VertexB}; auto vs = translate(vs_env, true); questions += vs_env.texture_questions; + std::unique_ptr fs; + if (fsc) { + Env fs_env{s, *fsc, Shader::Stage::Fragment}; + fs = translate(fs_env, true); + questions += fs_env.texture_questions; + } Shader::RuntimeInfo vrt{}; + Shader::RuntimeInfo frt{}; if (!vs->program.info.stores[Shader::IR::Attribute::PointSize]) vrt.fixed_state_point_size = 1.0f; // (an attribute the draw leaves unset: build_graphics gives it a stream of (0, 0, 0, 1). It took Disabled here, under the // same key) for (int i = 0; i < 16; i++) vrt.generic_input_types[i] = attribute_type_of(s.vattr[i]); vrt.previous_stage_stores.mask.set(); vrt.convert_depth_mode = host->depth_minus_w() != 0; + // (hookshot) the stage also stores its positions where a draw pushes an address: the temporal upscaler's motion + // of what the game moves in its vertex shaders (vk_temporal.cpp capture_motion; vk_draw.cpp push_capture). + // RX_VK_DLSS_CAPTURE=0: not (in the cache's stamp), the motion then the bones' (RX_VK_DLSS_ACTORS=bones) + static const bool capture = !getenv("RX_VK_DLSS_CAPTURE") || atoi(getenv("RX_VK_DLSS_CAPTURE")) != 0; + vrt.capture_position = capture; // Deku Tree web (#455): with DontInline, NVIDIA's compiled vertex shader substitutes the grid-origin // load result for the grid dimensions in the coordinate clamps. The SPIR-V names the right result. constexpr uint64_t kDekuWebVertexCode = 0xb449bcdb69b36a8aull; vrt.inline_global_128_loads = dev.props.vendorID == 0x10DE && vsc->key == kDekuWebVertexCode; + // (OoT's Royal Family Tomb water writes clip.xy/clip.w as a noperspective varying. Clipping a + // vertex with w close to zero then makes AMD interpolate the wrong depth, whose exp2 overflows + // into the red dotted line. Write it times Position.w and interpolate perspective-correct in + // the fragment stage, where multiplying by FragCoord.w restores the screen-linear value.) + // Indexed fragment reads cannot undo that multiply, transform feedback would capture the + // scaled value, and mesh pipelines keep their existing per-primitive interpolation. + if (fs && !fs->program.info.loads_indexed_attributes && vrt.xfb_count == 0) { + for (size_t i = 0; i < fs->program.info.interpolation.size(); ++i) { + if (fs->program.info.interpolation[i] == Shader::Interpolation::NoPerspective) { + vrt.noperspective_outputs.set(i); + } + } + frt.scaled_noperspective_inputs = vrt.noperspective_outputs.any(); + } Stage v; v.nvn_stage = 0; const std::vector vspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_VERTEX_BIT), vrt, vs->program, bindings); + note_fallbacks(p, "vertex", *vs); dump_ir(p, "vertex", vs->program); { // (the programs that read the draw's parameters from the driver bank, each once) const auto& ld = vs->program.info.loads; @@ -1772,13 +1981,9 @@ void translate_into(Program& p, const NvnState& s, const Code* vsc, const Code* v.vk_stage = VK_SHADER_STAGE_VERTEX_BIT; v.c1 = vsc->c1; p.stages.push_back(std::move(v)); - if (fsc) { - Env fs_env{s, *fsc, Shader::Stage::Fragment}; - auto fs = translate(fs_env, true); - questions += fs_env.texture_questions; + if (fs) { oot_visual(fs->program, fsc->key); frag_probe(fs->program, p.key); - Shader::RuntimeInfo frt{}; frt.previous_stage_stores = vs->program.info.stores; for (int i = 0; i < 8; i++) frt.color_output_types[i] = static_cast(color_types[i]); static const bool nan_guard = !getenv("RX_VK_NAN_GUARD") || atoi(getenv("RX_VK_NAN_GUARD")) != 0; @@ -1789,11 +1994,12 @@ void translate_into(Program& p, const NvnState& s, const Code* vsc, const Code* Shader::Optimization::GuardFragmentOutputs(fs->program, float_targets); } const std::vector fspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_FRAGMENT_BIT), frt, fs->program, bindings); + note_fallbacks(p, "fragment", *fs); dump_ir(p, "fragment", fs->program); Stage f; f.nvn_stage = 1; f.info = fs->program.info; - f.module = make_module(fspirv); + f.module = make_module(fspirv, &f.renodx, &f.crc); kept.push_back(fspirv); f.vk_stage = VK_SHADER_STAGE_FRAGMENT_BIT; f.c1 = fsc->c1; @@ -1886,6 +2092,7 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const env.set_mesh(mesh_regs, nullptr); task_t = translate(env, true, true); mesh_nocull(task_t->program, task->key); + note_fallbacks(p, "task", *task_t); dump_ir(p, "task", task_t->program, task->key); Shader::RuntimeInfo rt{}; rt.previous_stage_stores.mask.set(); @@ -2009,7 +2216,7 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const Stage f; f.nvn_stage = 1; f.info = fs->program.info; - f.module = make_module(fspirv); + f.module = make_module(fspirv, &f.renodx, &f.crc); f.vk_stage = VK_SHADER_STAGE_FRAGMENT_BIT; f.c1 = fsc->c1; p.stages.push_back(std::move(f)); diff --git a/gpu/vk/vk_shader.h b/gpu/vk/vk_shader.h index 81f1835..8afdf90 100644 --- a/gpu/vk/vk_shader.h +++ b/gpu/vk/vk_shader.h @@ -23,11 +23,13 @@ struct Stage { VkShaderModule module = VK_NULL_HANDLE; Shader::Info info; std::vector c1; // its c1 constants (the code area's tail) + uint32_t crc = 0; // (local, RenoDX port) the CRC-32 of the module the translation gave (fragment stages) + uint32_t renodx = 0; // (local, RenoDX port) its module is RenoDX's replacement, named by the CRC-32 of the one replaced (0: not): the program takes set 1 (vk_renodx.h) }; /// A texture handle the stage reads from a storage buffer: its handle program (Shader::Info::handle_programs, Eden's /// recompiler) run over the stage's constant banks and storage buffers as the draw has them -uint32_t stage_handle(const NvnState& s, const Stage& st, uint32_t program); +uint32_t stage_handle(const NvnState& s, const Stage& st, uint32_t program, uint32_t element = 0); /// A translated program variant: its stages, in descriptor order. The pipeline layout and pipelines made for it live /// in vk_pipeline.cpp (keyed by key). @@ -47,9 +49,12 @@ struct Program { std::atomic compute_state{0}; mutable std::atomic dispatched{false}; // (hookshot) noted in triforce_computes.bin (vk_draw.cpp compute_note) bool push = false; // its set is pushed (VK_KHR_push_descriptor) + uint32_t frag_crc = 0; // (local, RenoDX port) its fragment stage's Stage::crc, for RX_VK_RENODX_TRACE + uint32_t renodx = 0; // (local, RenoDX port) a stage is RenoDX's (its Stage::renodx): its layout has set 1, bound before each draw VkShaderStageFlags push_stages = 0; bool uses_render_area = false; bool uses_push = true; // (a stage reads the push constants: render area or rescaling) + bool captures = false; // (hookshot) its vertex stage stores its positions where pushed (vk_draw.cpp push_capture) bool mesh = false; // task / mesh stages (VK_EXT_mesh_shader) // (hookshot) the GPU has no mesh shaders: the task and mesh stages are compute pipelines, and a generated vertex // stage reads the records they write. Its stages are (task,) mesh, vertex, fragment. diff --git a/gpu/vk/vk_temporal.cpp b/gpu/vk/vk_temporal.cpp index 91b77fb..6ec3a99 100644 --- a/gpu/vk/vk_temporal.cpp +++ b/gpu/vk/vk_temporal.cpp @@ -18,8 +18,14 @@ // Link, the other characters, the animals, what the game animates with bones) are drawn again over that motion, each // vertex skinned with this frame's bones and the frame before's, so their pixels get their own motion. Their poses are // copied on the GPU from where the game has them into two buffers that take turns; a pixel is the draw's where its depth is -// the scene's (within RX_VK_DLSS_ACTOR_TOL steps, default 64). What moves without bones (particles, water, foliage moved in +// the scene's (its distance within RX_VK_DLSS_ACTOR_TOL thousandths of the scene's, default 10: 1%). What moves without bones (particles, water, foliage moved in // its vertex shader, mesh-shader draws) keeps the camera's motion. RX_VK_DLSS_ACTORS=0: camera motion alone. +// That is the fallback now (RX_VK_DLSS_ACTORS=bones): by default every plain draw of triangles into the scene is drawn +// again from the positions its own vertex stage stored as the game drew it (capture_motion, shaders/dlss_capture.vert): +// the shader recompiler gives every plain vertex stage a store of its final position at a pushed address +// (RuntimeInfo::capture_position; vk_draw.cpp push_capture asks temporal_capture_draw for a slot), into a buffer of the +// frame's (a ring of kCaptureBuffers). The frame before's positions of the same draw (dlss_actor::key) give the motion, +// exactly what the game's shader did: bones, waves along normals, morphs, rigid objects moving. The same depth test. // - the engine scales them to the output's size; shaders/dlss_out.comp squares that back to linear colour into the // network's output. // Anything unexpected (no camera this frame, other sizes, the engine not there or failing) leaves the network to run, the @@ -30,7 +36,8 @@ // (vk_fsr3.cpp, the row's value 3 or RX_VK_FSR=1) has inputs of its own (vk_fsr3_inputs.cpp): while it upscales, this chain // stands aside. // RX_VK_DLSS_DEBUG=motion: the motion vectors shown instead of the picture (|x|, |y| over 16 px as red and green, the actors' -// in it); =alternate: every other frame the game's own upscale (a test's reference beside the engine's). (The names are +// in it); =characters: a grey picture, blue where a draw moves by itself (not as the camera moves what is there: a still +// character is grey), brighter the further apart, up to 8 px; =alternate: every other frame the game's own upscale (a test's reference beside the engine's). (The names are // DLSS's from before FSR came: they apply to either engine.) #include "vk_temporal.h" @@ -55,11 +62,16 @@ #include "vk_fsr3.h" // (fsr3_wanted: AMD FSR 3.1 upscales with inputs of its own) #include "vk_fsr4.h" #include "vk_menu.h" +#include "vk_renodx.h" // (renodx_built: temporal_scene_format) #include "vk_texture.h" #include "shaders/dlss_actor_frag_spv.h" +#include "shaders/dlss_capture_vert_spv.h" #include "shaders/dlss_actor_vert_spv.h" +#include "shaders/dlss_merge_comp_spv.h" #include "shaders/dlss_out_comp_spv.h" +#include "shaders/dlss_out_hdr_comp_spv.h" +#include "shaders/dlss_prep_hdr_comp_spv.h" #include "shaders/dlss_prep_comp_spv.h" #include "vk_work.h" // (after the others: counts the commands that do GPU work, for full_barrier) @@ -100,6 +112,9 @@ int temporal_mode() { return v; } bool temporal_wanted() { return temporal_mode() != ur::GAME; } +namespace { +bool pre_wanted(int mode); // (below: the engine, or AMD FSR 3.1, before the game's bloom and tone mapping) +} bool temporal_full_scale() { return ur::full_scale(temporal_mode()); } namespace { @@ -115,9 +130,12 @@ struct Image { struct Camera { float current[16]{}; // (its view-projection) + float view[12]{}, proj[16]{}; // (its view, 3 x 4, and projection apart: the buffer's 0x00 and 0x70, row major) float jitter[2]{}; // (the projection's offset of the picture's centre, in clip space: nx2/oot_jitter.py) float near_z = 0, far_z = 0, fov_y = 0; // (its projection's, 0 when it is not a plain perspective one) uint32_t width = 0, height = 0; + VkFormat format = VK_FORMAT_UNDEFINED; // (the scene's colour target's: for the log) + const Texture* color = nullptr; // (the scene's colour target itself: temporal_pre_tonemap draws into it) Texture* depth = nullptr; uint64_t depth_gen = 0; // (texture_destroy_generation when taken: a depth texture destroyed since is not used) uint64_t frame = 0; // (texture_frame_no when taken) @@ -136,11 +154,54 @@ struct State { Engine engines[2]; // (DLSS, FSR: engine_of) const TemporalEngine* drawing = nullptr; // (the engine that drew last: another one starts a new history) Image color, depth, motion, output; + // (the engine before the bloom, scaling up: the scene's colour target as its pass left it, in the scene's format; and + // the engine's picture with what the game drew into the scene since: shaders/dlss_merge.comp) + Image base, merged; + VkDescriptorSetLayout merge_set = VK_NULL_HANDLE; + VkPipelineLayout merge_layout = VK_NULL_HANDLE; + VkPipeline merge = VK_NULL_HANDLE; + bool pre_touched = false; // (a draw into the scene since the engine's pass, this frame) + // (the picture drawn before the bloom this frame, linear HDR: an engine's (output), or AMD FSR 3.1's own) + struct { + VkImageView view = VK_NULL_HANDLE; + uint32_t width = 0, height = 0; + } pre_picture; VkDescriptorSetLayout prep_set = VK_NULL_HANDLE, out_set = VK_NULL_HANDLE; VkPipelineLayout prep_layout = VK_NULL_HANDLE, out_layout = VK_NULL_HANDLE; + // (local, RenoDX port) the same passes for an RGBA16F scene (the shaders' -DHDR): linear HDR colour in and out. The + // plain ones' layouts; made at the first HDR frame + VkPipeline prep_hdr = VK_NULL_HANDLE, out_hdr = VK_NULL_HANDLE; VkPipeline prep = VK_NULL_HANDLE, out = VK_NULL_HANDLE; VkSampler point = VK_NULL_HANDLE, linear = VK_NULL_HANDLE; Camera cam; // (this frame's, since the last upscale) + // (the engine before the game's bloom and tone mapping, temporal_pre_point: the program of the first draw after the + // scene's last, as the frame before had it (the bloom's first pass); this frame's so far; whether the engine drew there + // this frame, the upscale's dispatch still to come; the scene it drew into; draws into the scene after it) + // (a draw as the point is known by: its program and its colour target 0's format and size. The pause screen draws the + // bloom's program too, into other targets, in frames that have no upscale: not the point) + struct PrePoint { + uint64_t program = 0; + VkFormat format = VK_FORMAT_UNDEFINED; + uint32_t width = 0, height = 0; + bool operator==(const PrePoint& o) const { + return program == o.program && format == o.format && width == o.width && height == o.height; + } + }; + PrePoint pre_key, pre_candidate; + bool pre_pending = false; + uint64_t pre_frame = 0; // (the frame the engine drew there: pending from an earlier frame had no upscale after it) + // (after it, the game's tone mapping draw (temporal_pre_composite): the target it draws into, the picture before the + // game's own edge anti-aliasing; whether it was drawn again into the upscale's output at the output's size, from the + // engine's picture (an engine that scales up); that output as the upscale's dispatch last had it) + const Texture* pre_final = nullptr; + bool pre_direct = false; + Texture* pre_out = nullptr; + uint64_t pre_out_gen = 0; + const Texture* pre_scene = nullptr; + uint64_t pre_late = 0, pre_drawn = 0, pre_missed = 0; + int pre_miss_run = 0; // (frames in a row without the point) + uint64_t pre_late_frame = 0; + int pre_late_dumps = 0; // (the gameplay upscale's output, as last seen: the scene sizes the upscaler can take follow from it, // temporal_scene_size. Read on the game's draws without the lock) std::atomic out_w{0}, out_h{0}; @@ -161,11 +222,15 @@ struct State { SkinnedDraw k; uint64_t key = 0; uint32_t nbones = 0; + // (its pose as the draw had it, read when it was recorded: the origin (12 bytes, 4 more), then the bones. Empty: not + // readable, copied on the GPU at the upscale instead) + std::vector pose; }; std::vector skins; struct Pose { uint32_t at = 0, nbones = 0; // (bytes into its buffer: the origin, then the bones from at + 16) uint64_t frame = 0; + int buf = 0; // (which of pose_buffers) }; std::unordered_map poses; std::unordered_map model_bones; // (by model: the bones its vertices use, 0 when unreadable) @@ -173,11 +238,60 @@ struct State { VkBuffer buffer = VK_NULL_HANDLE; VmaAllocation memory = nullptr; uint64_t address = 0; - } pose_buffers[2]; + uint8_t* map = nullptr; + } pose_buffers[6]; // (a ring, written by the CPU: one a frame, read that frame and the next, then left for frames + // still in flight, as uploads) int pose_at = 0; // (this frame's) - VkPipelineLayout actor_layout = VK_NULL_HANDLE; - VkPipeline actor = VK_NULL_HANDLE; - bool actor_tried = false; + VkPipelineLayout actor_layout = VK_NULL_HANDLE; // (the redraws': the bones' and the stored positions') + VkPipeline actor = VK_NULL_HANDLE, capture = VK_NULL_HANDLE; + bool actor_tried = false, capture_tried = false, layout_tried = false; + // (capture motion: the draws that stored their positions since the last upscale, where (temporal_capture_draw); the + // frame before's, by draw (dlss_actor::key), from the upscale at captured_frame; the buffers they are in, a ring, each a + // frame's: written by the scene's draws, read at that frame's upscale and the next one's, then left for frames in flight) + struct Captured { + CaptureDraw k; + uint64_t key = 0; + uint64_t address = 0; + uint32_t first = 0, count = 0; + float jitter[2]{}; // (its own camera's, when own: dlss_actor::camera_jitter; else the scene's is used) + bool own = false; + }; + // (the camera read last for a stored draw, most draws of a frame having the same one) + uint64_t capture_camera = 0, capture_camera_view = 0; + float capture_camera_jitter[2]{}; + bool capture_camera_own = false; + uint64_t capture_unjittered = 0; // (stored draws whose own camera's jitter is not the scene's, since the last status line) + std::vector captured; + std::unordered_map captured_models; // (by model: its draws so far this frame, for the key's nth) + std::unordered_map captured_before; + uint64_t captured_frame = 0; + struct CaptureBuffer { + VkBuffer buffer = VK_NULL_HANDLE; + VmaAllocation memory = nullptr; + uint64_t address = 0, size = 0; + } capture_buffers[4]; + int capture_at = 0; // (this frame's) + uint64_t capture_used = 0; // (bytes of it given out) + uint64_t capture_frame = 0; // (the frame its first draw was recorded in: stale once that is over a frame ago) + uint64_t capture_want = 0; // (the size the next ones are made at: grown when a frame ran out) + bool capture_full = false; // (this frame's ran out: a draw was given no slot) + int capture_ok = -1; // (buffer device addresses and 64-bit integers in shaders: -1 not asked yet) + // (by index buffer, count and type: the least and greatest index, read once (dlss_actor::index_range); unreadable: none) + struct IndexRange { uint32_t lo = 0, hi = 0; bool ok = false; }; + std::unordered_map index_ranges; + uint64_t capture_slots = 0, capture_draws = 0, capture_bytes_peak = 0; // (since the last status line) + // (a diagnostic, RX_VK_DLSS_PROBE=1: the first positions of the frame's largest stored draw, this frame's and the frame + // before's, copied back and compared a few frames later with the camera's motion of the same vertices, in the log) + struct Probe { + VkBuffer buffer = VK_NULL_HANDLE; + VmaAllocation memory = nullptr; + void* map = nullptr; + uint64_t frame = 0, key = 0; + uint32_t count = 0; + float reproject[16]{}, jitter_now[2]{}, jitter_before[2]{}, size[2]{}; + bool used = false; + } probes[8]; + int probe_at = 0, probes_told = 0; struct Upload { VkBuffer buffer = VK_NULL_HANDLE; VmaAllocation memory = nullptr; @@ -290,6 +404,21 @@ bool make_image(VkCommandBuffer cmd, Image& im, VkFormat format, uint32_t w, uin return true; } +/// One compute pipeline of a layout; pipe stays null when it fails +bool make_compute(const uint32_t* code, size_t size, VkPipelineLayout layout, VkPipeline& pipe) { + VkShaderModuleCreateInfo mi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; + mi.codeSize = size, mi.pCode = code; + VkShaderModule m{}; + if (vkCreateShaderModule(dev.device, &mi, nullptr, &m) != VK_SUCCESS) return false; + VkComputePipelineCreateInfo ci{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; + ci.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, m, "main", nullptr}; + ci.layout = layout; + const bool ok = vkCreateComputePipelines(dev.device, VK_NULL_HANDLE, 1, &ci, nullptr, &pipe) == VK_SUCCESS; + vkDestroyShaderModule(dev.device, m, nullptr); + if (!ok) pipe = VK_NULL_HANDLE; + return ok; +} + /// One compute pipeline with push descriptors; what it made is destroyed again when a step fails bool make_pipeline(const uint32_t* code, size_t size, const VkDescriptorType* types, uint32_t n, uint32_t push, VkDescriptorSetLayout& set, VkPipelineLayout& layout, VkPipeline& pipe) { @@ -309,28 +438,24 @@ bool make_pipeline(const uint32_t* code, size_t size, const VkDescriptorType* ty VkPipelineLayoutCreateInfo pi{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; pi.setLayoutCount = 1, pi.pSetLayouts = &set, pi.pushConstantRangeCount = 1, pi.pPushConstantRanges = ≺ if (vkCreatePipelineLayout(dev.device, &pi, nullptr, &layout) != VK_SUCCESS) return layout = VK_NULL_HANDLE, undo(); - VkShaderModuleCreateInfo mi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; - mi.codeSize = size, mi.pCode = code; - VkShaderModule m{}; - if (vkCreateShaderModule(dev.device, &mi, nullptr, &m) != VK_SUCCESS) return undo(); - VkComputePipelineCreateInfo ci{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; - ci.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, m, "main", nullptr}; - ci.layout = layout; - const bool ok = vkCreateComputePipelines(dev.device, VK_NULL_HANDLE, 1, &ci, nullptr, &pipe) == VK_SUCCESS; - vkDestroyShaderModule(dev.device, m, nullptr); - return ok || undo(); + return make_compute(code, size, layout, pipe) || undo(); } -/// The two passes' pipelines and the samplers, once (temporal_upscale stops trying when this fails) -bool make_pipelines() { +/// The two passes' pipelines and the samplers, once (temporal_upscale stops trying when this fails). hdr: their HDR +/// variants too, which an RGBA16F scene draws with +bool make_pipelines(bool hdr) { State& s = st(); - if (s.prep && s.out && s.point && s.linear) return true; + if (s.prep && s.out && s.point && s.linear && (!hdr || (s.prep_hdr && s.out_hdr))) return true; if (!dev.push_descriptor || !vkCmdPushDescriptorSetKHR) return false; const VkDescriptorType S = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, I = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; const VkDescriptorType prep_types[5] = {S, S, I, I, I}, out_types[2] = {S, I}; if (!s.prep && !make_pipeline(DLSS_PREP_COMP_SPV, sizeof DLSS_PREP_COMP_SPV, prep_types, 5, 84, s.prep_set, s.prep_layout, s.prep)) return false; - if (!s.out && !make_pipeline(DLSS_OUT_COMP_SPV, sizeof DLSS_OUT_COMP_SPV, out_types, 2, 8, s.out_set, s.out_layout, s.out)) + if (!s.out && !make_pipeline(DLSS_OUT_COMP_SPV, sizeof DLSS_OUT_COMP_SPV, out_types, 2, 12, s.out_set, s.out_layout, s.out)) + return false; + if (hdr && !s.prep_hdr && !make_compute(DLSS_PREP_HDR_COMP_SPV, sizeof DLSS_PREP_HDR_COMP_SPV, s.prep_layout, s.prep_hdr)) + return false; + if (hdr && !s.out_hdr && !make_compute(DLSS_OUT_HDR_COMP_SPV, sizeof DLSS_OUT_HDR_COMP_SPV, s.out_layout, s.out_hdr)) return false; VkSamplerCreateInfo si{VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO}; si.magFilter = si.minFilter = VK_FILTER_NEAREST; @@ -341,7 +466,8 @@ bool make_pipelines() { return true; } -/// A view of a depth texture's depth alone, for sampling (made once per image) +/// A view of a depth texture's depth alone, for sampling (made once per image); of a colour texture, its colour (the +/// scene's target, sampled and written by temporal_pre_tonemap) VkImageView depth_view(Texture* t) { State& s = st(); const uint64_t gen = texture_destroy_generation(); @@ -356,7 +482,8 @@ VkImageView depth_view(Texture* t) { if (auto it = s.depth_views.find(t->image); it != s.depth_views.end()) return it->second; VkImageViewCreateInfo vc{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; vc.image = t->image, vc.viewType = VK_IMAGE_VIEW_TYPE_2D, vc.format = t->format; - vc.subresourceRange = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, 1}; + vc.subresourceRange = {(t->aspect & VK_IMAGE_ASPECT_DEPTH_BIT) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT, + 0, 1, 0, 1}; VkImageView v = VK_NULL_HANDLE; if (vkCreateImageView(dev.device, &vc, nullptr, &v) != VK_SUCCESS) v = VK_NULL_HANDLE; s.depth_views[t->image] = v; @@ -365,14 +492,40 @@ VkImageView depth_view(Texture* t) { // ---- actor motion: the skinned draws drawn again into the motion, each pixel they show moved by its own bones ---- +/// RX_VK_DLSS_ACTORS: what gives what moves by itself its own motion. 0: nothing (the camera's motion alone); bones (or 2): +/// the skinned draws from their bones (actor_motion), as before; else (unset, 1) every draw from the positions its vertex +/// stage stored (capture_motion), or the bones when the stages store none (RX_VK_DLSS_CAPTURE=0, vk_shader.cpp) +enum MotionMode { kMotionCamera = 0, kMotionCapture = 1, kMotionBones = 2 }; +std::atomic bench_upscales{0}; // (the upscales an engine drew: RX_VK_DLSS_BENCH's clock) +constexpr uint64_t kBenchFrames = 300; // (a mode's turn) +MotionMode motion_mode() { + // (RX_VK_DLSS_BENCH=1, a measurement: the three take turns of kBenchFrames upscales each, the camera's motion alone, the + // bones, the stored positions, and each turn's frame time is logged: temporal_upscale) + static const bool bench = env_switch("RX_VK_DLSS_BENCH") > 0; + if (bench) { + static const MotionMode turns[3] = {kMotionCamera, kMotionBones, kMotionCapture}; + return turns[(bench_upscales.load(std::memory_order_relaxed) / kBenchFrames) % 3]; + } + static const MotionMode m = [] { + const char* e = getenv("RX_VK_DLSS_ACTORS"); + const char* c = getenv("RX_VK_DLSS_CAPTURE"); + const bool stored = !c || atoi(c) != 0; + if (e && (!strcmp(e, "bones") || !strcmp(e, "2"))) return kMotionBones; + if (e && *e && atoi(e) == 0) return kMotionCamera; + return stored ? kMotionCapture : kMotionBones; + }(); + return m; +} + using ActorPush = dlss_actor::Push; -/// Its pipeline, once (false: none, the motion stays the camera's) -bool make_actor_pipeline() { +/// The redraws' layout, once: the cameras' buffer and the scene's depth (pushed), and the vertex stage's push constants (the +/// bones' Push, the stored positions' CapturePush in its first bytes). False: none, the motion stays the camera's +bool make_redraw_layout() { State& s = st(); - if (s.actor) return true; - if (s.actor_tried) return false; - s.actor_tried = true; + if (s.actor_layout) return true; + if (s.layout_tried) return false; + s.layout_tried = true; VkPhysicalDeviceFeatures2 f{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; vkGetPhysicalDeviceFeatures2(dev.physical, &f); if (!dev.vk12.bufferDeviceAddress || !f.features.shaderInt64) { // (its shaders read the game's buffers by their addresses) @@ -387,17 +540,28 @@ bool make_actor_pipeline() { li.bindingCount = 2, li.pBindings = b; VkDescriptorSetLayout set{}; if (vkCreateDescriptorSetLayout(dev.device, &li, nullptr, &set) != VK_SUCCESS) return false; + static_assert(sizeof(ActorPush) >= sizeof(dlss_actor::CapturePush), "the redraws' push constants"); const VkPushConstantRange pr{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(ActorPush)}; VkPipelineLayoutCreateInfo pi{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; pi.setLayoutCount = 1, pi.pSetLayouts = &set, pi.pushConstantRangeCount = 1, pi.pPushConstantRanges = ≺ - if (vkCreatePipelineLayout(dev.device, &pi, nullptr, &s.actor_layout) != VK_SUCCESS) return false; + if (vkCreatePipelineLayout(dev.device, &pi, nullptr, &s.actor_layout) != VK_SUCCESS) return s.actor_layout = VK_NULL_HANDLE, false; + return true; +} + +/// A redraw's pipeline: a vertex stage, then dlss_actor.frag into the motion (RG16F). per_draw: the topology and primitive +/// restart set for each draw, as the game drew it (the stored positions'; the bones' draw triangle lists) +VkPipeline make_redraw(const uint32_t* vcode, size_t vsize, bool per_draw) { + State& s = st(); VkShaderModule m[2]{}; - const uint32_t* code[2] = {DLSS_ACTOR_VERT_SPV, DLSS_ACTOR_FRAG_SPV}; - const size_t size[2] = {sizeof DLSS_ACTOR_VERT_SPV, sizeof DLSS_ACTOR_FRAG_SPV}; + const uint32_t* code[2] = {vcode, DLSS_ACTOR_FRAG_SPV}; + const size_t size[2] = {vsize, sizeof DLSS_ACTOR_FRAG_SPV}; for (int i = 0; i < 2; i++) { VkShaderModuleCreateInfo mi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; mi.codeSize = size[i], mi.pCode = code[i]; - if (vkCreateShaderModule(dev.device, &mi, nullptr, &m[i]) != VK_SUCCESS) return false; + if (vkCreateShaderModule(dev.device, &mi, nullptr, &m[i]) != VK_SUCCESS) { + if (i) vkDestroyShaderModule(dev.device, m[0], nullptr); + return VK_NULL_HANDLE; + } } VkPipelineShaderStageCreateInfo stages[2]{}; for (int i = 0; i < 2; i++) { @@ -418,9 +582,10 @@ bool make_actor_pipeline() { ba.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT; VkPipelineColorBlendStateCreateInfo cb{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; cb.attachmentCount = 1, cb.pAttachments = &ba; - const VkDynamicState dyn[2] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR}; + const VkDynamicState dyn[4] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, + VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE}; VkPipelineDynamicStateCreateInfo ds{VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO}; - ds.dynamicStateCount = 2, ds.pDynamicStates = dyn; + ds.dynamicStateCount = per_draw ? 4 : 2, ds.pDynamicStates = dyn; const VkFormat format = VK_FORMAT_R16G16_SFLOAT; VkPipelineRenderingCreateInfo ri{VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO}; ri.colorAttachmentCount = 1, ri.pColorAttachmentFormats = &format; @@ -429,10 +594,34 @@ bool make_actor_pipeline() { gi.stageCount = 2, gi.pStages = stages; gi.pVertexInputState = &vi, gi.pInputAssemblyState = &ia, gi.pViewportState = &vp, gi.pRasterizationState = &rs; gi.pMultisampleState = &ms, gi.pColorBlendState = &cb, gi.pDynamicState = &ds, gi.layout = s.actor_layout; - const bool ok = vkCreateGraphicsPipelines(dev.device, VK_NULL_HANDLE, 1, &gi, nullptr, &s.actor) == VK_SUCCESS; + VkPipeline pipe = VK_NULL_HANDLE; + if (vkCreateGraphicsPipelines(dev.device, VK_NULL_HANDLE, 1, &gi, nullptr, &pipe) != VK_SUCCESS) pipe = VK_NULL_HANDLE; for (VkShaderModule x : m) vkDestroyShaderModule(dev.device, x, nullptr); - if (!ok) s.actor = VK_NULL_HANDLE, logf("vk: upscaler: the actor motion's pipeline was not made: camera motion alone"); - return ok; + return pipe; +} + +/// The bones' redraw pipeline, once (false: none, the motion stays the camera's) +bool make_actor_pipeline() { + State& s = st(); + if (s.actor) return true; + if (s.actor_tried) return false; + s.actor_tried = true; + if (!make_redraw_layout()) return false; + s.actor = make_redraw(DLSS_ACTOR_VERT_SPV, sizeof DLSS_ACTOR_VERT_SPV, false); + if (!s.actor) logf("vk: upscaler: the actor motion's pipeline was not made: camera motion alone"); + return s.actor != VK_NULL_HANDLE; +} + +/// The stored positions' redraw pipeline, once (false: none) +bool make_capture_pipeline() { + State& s = st(); + if (s.capture) return true; + if (s.capture_tried) return false; + s.capture_tried = true; + if (!make_redraw_layout()) return false; + s.capture = make_redraw(DLSS_CAPTURE_VERT_SPV, sizeof DLSS_CAPTURE_VERT_SPV, true); + if (!s.capture) logf("vk: upscaler: the captured motion's pipeline was not made: camera motion alone"); + return s.capture != VK_NULL_HANDLE; } /// A range of guest memory as this recording binds it, by its device address (the pools and their mirrors have them) @@ -444,103 +633,50 @@ uint64_t device_address(const BufferRef& r) { return base ? base + r.offset : 0; } -constexpr uint64_t kPoseBytes = 4 << 20; // (a pose buffer: 280 bones of 48 bytes are 13 KB a draw, 300 of them) +/// The redraws' tolerance word (dlss_actor.h kToleranceWord): a pixel is the draw's where its distance from the camera is +/// within this many thousandths of the scene's there (1%; RX_VK_DLSS_ACTOR_TOL). In depth buffer steps (64) as before, the +/// redrawn characters met the scene in stripes, rounding apart; in distance a character is still told from a wall behind +/// it. Without a plain perspective projection: 64 steps. RX_VK_DLSS_DEBUG=actors: the pixels given their own motion marked +uint32_t redraw_tolerance() { + static const uint32_t tolerance = env_switch("RX_VK_DLSS_ACTOR_TOL") >= 0 ? (uint32_t)env_switch("RX_VK_DLSS_ACTOR_TOL") : 10; + static const char* const debug = getenv("RX_VK_DLSS_DEBUG"); + static const bool own = debug && !strcmp(debug, "characters"); // (=characters: the marks alone, on grey) + static const bool mark = own || (debug && !strcmp(debug, "actors")); + return (tolerance & ~(dlss_actor::kMarkBit | dlss_actor::kOwnBit)) | (mark ? dlss_actor::kMarkBit : 0u) | + (own ? dlss_actor::kOwnBit : 0u); +} -/// The skinned draws into the scene (cam's depth) with a pose of the frame before (the engine's last), drawn into the motion -/// image over the camera's motion. Each one's bones and origin are copied on the GPU, from where the game has them, into -/// this frame's pose buffer, for this frame and the next. before: the frame before's camera without its jitter. history: -/// the engine has the frame before. Returns the draws drawn -int actor_motion(VkCommandBuffer cmd, const Camera& cam, const float* before, uint32_t rw, uint32_t rh, VkImageView dview, - bool history) { +/// A redraw into the motion begun: the cameras' buffer written (this frame's as drawn, the frame before's without its jitter +/// (before), this frame's jitter, the render size, the view and projection, the planes, the tolerance, the frame before's +/// jitter (jitter_before: the stored positions'; null none), the prep pass's reproject), pipe bound with it and the scene's depth, the motion the +/// target. False: nothing begun +bool begin_redraw(VkCommandBuffer cmd, VkPipeline pipe, const Camera& cam, const float* before, const float* jitter_before, + const float* reproject, uint32_t rw, uint32_t rh, VkImageView dview) { State& s = st(); - struct Timed { - State& s; - std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); - ~Timed() { s.actor_ns += (std::chrono::steady_clock::now() - t0).count(); } - } timed{s}; - std::vector skins = std::move(s.skins); - s.skins.clear(); - std::unordered_map old = std::move(s.poses); - s.poses.clear(); - static const bool off = env_switch("RX_VK_DLSS_ACTORS") == 0; - if (off || skins.empty() || !make_actor_pipeline()) return 0; - for (auto& b : s.pose_buffers) - if (!b.buffer) { - if (!create_device_buffer(kPoseBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, - b.buffer, b.memory)) - return b = {}, 0; - b.address = device_address({b.buffer, 0, kPoseBytes, 0}); - } - const uint64_t now = texture_frame_no(); - const State::PoseBuffer& here = s.pose_buffers[s.pose_at]; - const State::PoseBuffer& there = s.pose_buffers[s.pose_at ^ 1]; - static const uint32_t tolerance = env_switch("RX_VK_DLSS_ACTOR_TOL") >= 0 ? (uint32_t)env_switch("RX_VK_DLSS_ACTOR_TOL") : 64; - std::vector draws; - std::vector counts; - uint32_t at = 0; - for (const auto& k : skins) { - if (k.k.depth != cam.depth) continue; - const uint32_t bytes = 16 + k.nbones * 48; - if (at + bytes > kPoseBytes) break; - // (this frame's pose, from where the game has it: its bones, then its origin at the object's 0x40) - const BufferRef bones = gpu_buffer_bind(k.k.bones, (uint64_t)k.nbones * 48, false); - const BufferRef origin = gpu_buffer_bind(k.k.object + 0x40, 12, false); - if (!bones || !origin) { - s.actor_skipped++; - continue; - } - const VkBufferCopy c0{origin.offset, at, 12}, c1{bones.offset, at + 16, (uint64_t)k.nbones * 48}; - vkCmdCopyBuffer(cmd, origin.buffer, here.buffer, 1, &c0); - vkCmdCopyBuffer(cmd, bones.buffer, here.buffer, 1, &c1); - s.poses[k.key] = {at, k.nbones, now}; - const uint32_t mine = at; - at += (bytes + 15) & ~15u; - const auto it = old.find(k.key); - if (!history || it == old.end() || it->second.frame != s.last_frame || it->second.nbones != k.nbones) { - s.actor_skipped++; - continue; - } - // (the vertices and indices where the game has them: its buffers as this recording binds them) - const uint64_t va = device_address(gpu_buffer_bind(k.k.vbuf, k.k.vsize, false)); - const uint64_t ia = device_address(gpu_buffer_bind(k.k.ibuf, (uint64_t)k.k.count << k.k.itype, false)); - if (!va || !ia || va % 4 || k.k.count <= 0 || k.k.itype < 0 || k.k.itype > 2) { - s.actor_skipped++; - continue; - } - ActorPush a{}; - a.vertices = va, a.count = (uint32_t)std::min(k.k.vsize / k.k.stride, UINT32_MAX); - dlss_actor::index_start(ia, k.k.itype, &a.indices, &a.first); - a.origins[0] = here.address + mine, a.origins[1] = there.address + it->second.at; - a.bones[0] = a.origins[0] + 16, a.bones[1] = a.origins[1] + 16; - a.nbones = k.nbones; - a.itype = (uint32_t)k.k.itype, a.base_vertex = k.k.base_vertex; - a.stride = k.k.stride / 4, a.pos = k.k.pos, a.sets = (uint32_t)k.k.sets; - for (int i = 0; i < 2; i++) a.joints[i] = k.k.joints[i], a.weights[i] = k.k.weights[i]; - a.formats = k.k.formats; - a.tolerance = tolerance; - draws.push_back(a); - counts.push_back((uint32_t)k.k.count); - } - s.pose_at ^= 1; - if (draws.empty()) return 0; - // (the cameras: this frame's as drawn, the frame before's without its jitter, the jitter, the render size) State::Upload& u = s.uploads[s.upload_at]; s.upload_at = (s.upload_at + 1) % (int)(sizeof s.uploads / sizeof s.uploads[0]); if (!u.buffer && !create_buffer_cached(dlss_actor::kHeadWords * 4, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, u.buffer, u.memory, &u.map)) - return u = {}, 0; + return u = {}, false; float* head = (float*)u.map; + std::memset(head, 0, dlss_actor::kHeadWords * 4); std::memcpy(head, cam.current, 64); std::memcpy(head + 16, before, 64); head[32] = cam.jitter[0], head[33] = cam.jitter[1], head[34] = (float)rw, head[35] = (float)rh; + std::memcpy(head + 36, cam.view, sizeof cam.view), std::memcpy(head + 48, cam.proj, sizeof cam.proj); + head[64] = cam.near_z, head[65] = cam.far_z; + const uint32_t tolerance = redraw_tolerance(); + std::memcpy(head + dlss_actor::kToleranceWord, &tolerance, 4); + if (jitter_before) head[dlss_actor::kJitterBeforeWord] = jitter_before[0], head[dlss_actor::kJitterBeforeWord + 1] = jitter_before[1]; + // (this frame's clip space to the frame before's, as the prep pass has it: the mark's comparison) + std::memcpy(head + dlss_actor::kReprojectWord, reproject, 64); flush_mapped(u.memory, dlss_actor::kHeadWords * 4); - full_barrier(cmd); // (the poses copied) VkRenderingAttachmentInfo ca{VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO}; ca.imageView = s.motion.view, ca.imageLayout = VK_IMAGE_LAYOUT_GENERAL; ca.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, ca.storeOp = VK_ATTACHMENT_STORE_OP_STORE; VkRenderingInfo ri{VK_STRUCTURE_TYPE_RENDERING_INFO}; ri.renderArea = {{0, 0}, {rw, rh}}, ri.layerCount = 1, ri.colorAttachmentCount = 1, ri.pColorAttachments = &ca; vkCmdBeginRendering(cmd, &ri); - vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, s.actor); + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe); const VkViewport viewport{0, 0, (float)rw, (float)rh, 0.0f, 1.0f}; const VkRect2D scissor{{0, 0}, {rw, rh}}; vkCmdSetViewport(cmd, 0, 1, &viewport); @@ -552,6 +688,129 @@ int actor_motion(VkCommandBuffer cmd, const Camera& cam, const float* before, ui w[1].dstBinding = 1, w[1].descriptorCount = 1, w[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; w[1].pImageInfo = ⅈ vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, s.actor_layout, 0, 2, w); + return true; +} + +constexpr uint64_t kPoseBytes = 4 << 20; // (a pose buffer: 280 bones of 48 bytes are 13 KB a draw, 300 of them) + +/// The skinned draws into the scene (cam's depth) with a pose of the frame before (the engine's last), drawn into the motion +/// image over the camera's motion. Each one's bones and origin, as the draw had them (read when it was recorded: +/// temporal_note_skinned_draw), go into this frame's pose buffer, for this frame and the next. They were copied on the GPU +/// at the upscale before, from where the game has them; by then the game could have written the next frame's pose there, +/// and the limbs that moved most were drawn where the scene was not: no motion of their own. before: the frame before's camera without its jitter. history: +/// the engine has the frame before. Returns the draws drawn +int actor_motion(VkCommandBuffer cmd, const Camera& cam, const float* before, const float* reproject, uint32_t rw, + uint32_t rh, VkImageView dview, bool history) { + State& s = st(); + struct Timed { + State& s; + std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); + ~Timed() { s.actor_ns += (std::chrono::steady_clock::now() - t0).count(); } + } timed{s}; + std::vector skins = std::move(s.skins); + s.skins.clear(); + std::unordered_map old = std::move(s.poses); + s.poses.clear(); + if (motion_mode() != kMotionBones || skins.empty() || !make_actor_pipeline()) return 0; + for (auto& b : s.pose_buffers) + if (!b.buffer) { + void* map = nullptr; + if (!create_buffer_cached(kPoseBytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | + VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, b.buffer, b.memory, &map) || !map) + return b = {}, 0; + b.map = (uint8_t*)map; + b.address = device_address({b.buffer, 0, kPoseBytes, 0}); + } + const uint64_t now = texture_frame_no(); + const State::PoseBuffer& here = s.pose_buffers[s.pose_at]; + std::vector draws; + std::vector counts; + uint32_t at = 0; + // (RX_VK_DLSS_TRACE=: on vk_draw.cpp's traced frames, each skinned draw left out here and why) + static const int trace_every = env_switch("RX_VK_DLSS_TRACE"); + const bool trace = trace_every > 0 && now % (uint64_t)trace_every == (uint64_t)trace_every / 2; + const auto left = [&](const State::Skin& k, const char* why) { + if (trace) logf("vk: dlss-trace actor left out: prog %016llx vb %llx n%d bones %llx: %s", (unsigned long long)k.k.program, + (unsigned long long)k.k.vbuf, k.k.count, (unsigned long long)k.k.bones, why); + }; + for (const auto& k : skins) { + if (k.k.depth != cam.depth) { + left(k, "another depth target than the scene's"); + continue; + } + const uint32_t bytes = dlss_actor::kPoseHead + k.nbones * 48; + if (at + bytes > kPoseBytes) { + left(k, "the pose buffer is full"); + break; + } + // (this frame's pose: as the draw had it; else from where the game has it now, its bones and its origin at the + // object's 0x40) + if (k.pose.size() == bytes) { + std::memcpy(here.map + at, k.pose.data(), bytes); + // (said a few times a run: a draw whose camera is not the scene's, which the redraw follows now) + static int told_camera = 0; + if (told_camera < 4 && (std::memcmp(k.pose.data() + 64, cam.proj, sizeof cam.proj) || + std::memcmp(k.pose.data() + 16, cam.view, sizeof cam.view))) { + told_camera++; + const float* p = (const float*)(k.pose.data() + 64); + logf("vk: upscaler: actor %016llx drawn with another camera than the scene's: its projection z row %g %g %g %g, " + "the scene's %g %g %g %g%s", (unsigned long long)k.k.program, p[8], p[9], p[10], p[11], cam.proj[8], + cam.proj[9], cam.proj[10], cam.proj[11], + std::memcmp(k.pose.data() + 16, cam.view, sizeof cam.view) ? " (its view too)" : ""); + } + } else { + const BufferRef bones = gpu_buffer_bind(k.k.bones, (uint64_t)k.nbones * 48, false); + const BufferRef origin = gpu_buffer_bind(k.k.object + 0x40, 12, false); + if (!bones || !origin) { + s.actor_skipped++; + left(k, "its bones or origin are not bound"); + continue; + } + const VkBufferCopy c0{origin.offset, at, 12}, c1{bones.offset, at + dlss_actor::kPoseHead, (uint64_t)k.nbones * 48}; + vkCmdCopyBuffer(cmd, origin.buffer, here.buffer, 1, &c0); + vkCmdCopyBuffer(cmd, bones.buffer, here.buffer, 1, &c1); + // (the camera: the scene's, as before) + std::memcpy(here.map + at + 16, cam.view, sizeof cam.view), std::memcpy(here.map + at + 64, cam.proj, sizeof cam.proj); + } + s.poses[k.key] = {at, k.nbones, now, s.pose_at}; + const uint32_t mine = at; + at += (bytes + 15) & ~15u; + const auto it = old.find(k.key); + if (!history || it == old.end() || it->second.frame != s.last_frame || it->second.nbones != k.nbones) { + s.actor_skipped++; + left(k, !history ? "no history" : it == old.end() ? "not drawn the frame before (its key)" + : it->second.frame != s.last_frame ? "its pose is older than the frame before" : "another bone count the frame before"); + continue; + } + // (the vertices and indices where the game has them: its buffers as this recording binds them) + const uint64_t va = device_address(gpu_buffer_bind(k.k.vbuf, k.k.vsize, false)); + const bool arrays = k.k.itype == dlss_actor::kNoIndices; // (no indices: a plain vertex array) + const uint64_t ia = arrays ? 0 : device_address(gpu_buffer_bind(k.k.ibuf, (uint64_t)k.k.count << k.k.itype, false)); + if (!va || (!arrays && !ia) || va % 4 || k.k.count <= 0 || k.k.itype < 0 || k.k.itype > dlss_actor::kNoIndices) { + s.actor_skipped++; + left(k, "its vertices or indices are not bound"); + continue; + } + ActorPush a{}; + a.vertices = va, a.count = (uint32_t)std::min(k.k.vsize / k.k.stride, UINT32_MAX); + if (arrays) a.indices = 0, a.first = 0; + else dlss_actor::index_start(ia, k.k.itype, &a.indices, &a.first); + a.origins[0] = here.address + mine, a.origins[1] = s.pose_buffers[it->second.buf].address + it->second.at; + a.bones[0] = a.origins[0] + dlss_actor::kPoseHead, a.bones[1] = a.origins[1] + dlss_actor::kPoseHead; + a.nbones = k.nbones; + a.itype = (uint32_t)k.k.itype, a.base_vertex = k.k.base_vertex; + a.stride = k.k.stride / 4, a.pos = k.k.pos, a.sets = (uint32_t)k.k.sets; + for (int i = 0; i < 2; i++) a.joints[i] = k.k.joints[i], a.weights[i] = k.k.weights[i]; + a.formats = k.k.formats; + a.tolerance = redraw_tolerance(); // (dlss_actor.frag reads it from the cameras' buffer: begin_redraw) + draws.push_back(a); + counts.push_back((uint32_t)k.k.count); + } + if (at) flush_mapped_range(here.memory, 0, at); // (the poses written here, for the GPU) + s.pose_at = (s.pose_at + 1) % (int)(sizeof s.pose_buffers / sizeof s.pose_buffers[0]); + if (draws.empty()) return 0; + full_barrier(cmd); // (the poses copied) + if (!begin_redraw(cmd, s.actor, cam, before, nullptr, reproject, rw, rh, dview)) return 0; for (size_t i = 0; i < draws.size(); i++) { // (vertex i of a draw is its i-th index) vkCmdPushConstants(cmd, s.actor_layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof draws[i], &draws[i]); vkCmdDraw(cmd, counts[i], 1, 0, 0); @@ -561,17 +820,212 @@ int actor_motion(VkCommandBuffer cmd, const Camera& cam, const float* before, ui return (int)draws.size(); } +// ---- capture motion: every draw into the scene drawn again from the positions its vertex stage stored ---- + +constexpr int kCaptureBuffers = (int)(sizeof(State::capture_buffers) / sizeof(State::CaptureBuffer)); +constexpr uint64_t kCaptureMost = 256ull << 20; // (a frame's buffer grows to this at most) +constexpr uint32_t kCaptureMostSlots = 1u << 20; // (a draw's) + +/// This frame's stored draws, taken at its upscale; the ring moves on (the next frame's go into the next buffer, made again +/// larger when this one ran out) +std::vector take_captures() { + State& s = st(); + std::vector c = std::move(s.captured); + s.captured.clear(), s.captured_models.clear(); + s.capture_bytes_peak = std::max(s.capture_bytes_peak, s.capture_used); + s.capture_at = (s.capture_at + 1) % kCaptureBuffers; + s.capture_used = 0; + if (s.capture_full && s.capture_want && s.capture_want < kCaptureMost) { + s.capture_want = std::min(s.capture_want * 2, kCaptureMost); + logf("vk: upscaler: a frame's draws stored more positions than their buffer holds: %llu MB from now on", + (unsigned long long)(s.capture_want >> 20)); + } + s.capture_full = false; + State::CaptureBuffer& next = s.capture_buffers[s.capture_at]; + if (next.buffer && next.size < s.capture_want) { // (a few frames old: let go, made again at the size wanted) + const State::CaptureBuffer gone = next; + later([gone] { destroy_buffer(gone.buffer, gone.memory); }); + next = {}; + } + return c; +} + +/// The draws that stored their positions this frame (caps) drawn again into the motion over the camera's, where they were +/// drawn the frame before too (the same draw: dlss_actor::key), from those positions: their own motion, whatever moved +/// them. before: the frame before's camera without its jitter; history: the engine has the frame before. Returns the +/// draws drawn +int capture_motion(VkCommandBuffer cmd, const Camera& cam, const float* before, const float* reproject, uint32_t rw, + uint32_t rh, VkImageView dview, bool history, const std::vector& caps) { + State& s = st(); + struct Timed { + State& s; + std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); + ~Timed() { s.actor_ns += (std::chrono::steady_clock::now() - t0).count(); } + } timed{s}; + std::unordered_map old = std::move(s.captured_before); + s.captured_before.clear(); + // (the frame before's are of the frame the engine last drew: else a gap, and their positions are older) + const bool old_ok = history && s.captured_frame && s.captured_frame == s.last_frame; + s.captured_frame = texture_frame_no(); + for (const auto& c : caps) + if (c.k.depth == cam.depth) s.captured_before[c.key] = c; + // (RX_VK_DLSS_TRACE=: on vk_draw.cpp's traced frames, each stored draw left out here and why) + static const int trace_every = env_switch("RX_VK_DLSS_TRACE"); + const uint64_t now = texture_frame_no(); + const bool trace = trace_every > 0 && now % (uint64_t)trace_every == (uint64_t)trace_every / 2; + const auto left = [&](const State::Captured& c, const char* why) { + if (trace) logf("vk: dlss-trace capture left out: prog %016llx vb %llx ib %llx n%d: %s", (unsigned long long)c.k.program, + (unsigned long long)c.k.vbuf, (unsigned long long)c.k.ibuf, c.k.count, why); + }; + if (caps.empty() || !make_capture_pipeline()) return 0; + struct Redraw { + dlss_actor::CapturePush push; + const State::Captured* c; + BufferRef ib; + }; + std::vector draws; + draws.reserve(caps.size()); + for (const auto& c : caps) { + if (c.k.depth != cam.depth) { + left(c, "another depth target than the scene's"); + continue; + } + const auto it = old_ok ? old.find(c.key) : old.end(); + if (it == old.end()) { + s.actor_skipped++; + left(c, !old_ok ? "no history" : "not drawn the frame before (its key)"); + continue; + } + // (its indices where the game has them, as this recording binds them: the same as it drew with) + BufferRef ib{}; + if (c.k.itype != dlss_actor::kNoIndices) { + ib = gpu_buffer_bind(c.k.ibuf, (uint64_t)c.k.count << c.k.itype, false); + if (!ib) { + s.actor_skipped++; + left(c, "its indices are not bound"); + continue; + } + } + const State::Captured& o = it->second; + dlss_actor::CapturePush push{c.address, o.address, c.first, o.first, c.count, o.count, {}, {}}; + for (int i = 0; i < 2; i++) { + push.jitter_now[i] = c.own ? c.jitter[i] : cam.jitter[i]; + push.jitter_before[i] = o.own ? o.jitter[i] : s.last_jitter[i]; + } + if (c.own && (c.jitter[0] != cam.jitter[0] || c.jitter[1] != cam.jitter[1])) s.capture_unjittered++; + draws.push_back({push, &c, ib}); + } + if (draws.empty()) return 0; + static const bool probe_on = env_switch("RX_VK_DLSS_PROBE") > 0; + constexpr uint32_t kProbeSlots = 256; + if (probe_on && s.probes_told < 300) { + State::Probe& pr = s.probes[s.probe_at]; + s.probe_at = (s.probe_at + 1) % 8; + if (pr.used) { // (eight frames old: the GPU is past it) + // (each vertex: its own motion, from where it is to where it was, and the camera's, its position now through the + // reprojection, both in render pixels as the passes make them) + const float* v = (const float*)pr.map; + double most = 0.0, sum = 0.0, moved = 0.0; + double worst[4]{}; + int n = 0; + for (uint32_t i = 0; i < pr.count; i++) { + const float* a = v + i * 4; + const float* b = v + (kProbeSlots + i) * 4; + if (!(a[3] > 0.2f) || !(b[3] > 0.2f)) continue; + const double nx = a[0] / a[3], ny = a[1] / a[3]; + if (std::fabs(nx) > 1.0 || std::fabs(ny) > 1.0) continue; // (on screen) + const double clip[4] = {a[0], a[1], 2.0 * a[2] - a[3], a[3]}; // (depth -1 to 1 again) + double was[4]; + for (int r = 0; r < 4; r++) { + was[r] = 0.0; + for (int c = 0; c < 4; c++) was[r] += (double)pr.reproject[r * 4 + c] * clip[c]; + } + if (!(was[3] > 1e-6)) continue; + const double now_x = nx - pr.jitter_now[0], now_y = ny - pr.jitter_now[1]; + const double own_x = ((b[0] - pr.jitter_before[0] * b[3]) / b[3] - now_x) * 0.5 * pr.size[0]; + const double own_y = (now_y - (b[1] - pr.jitter_before[1] * b[3]) / b[3]) * 0.5 * pr.size[1]; + const double cam_x = (was[0] / was[3] - now_x) * 0.5 * pr.size[0]; + const double cam_y = (now_y - was[1] / was[3]) * 0.5 * pr.size[1]; + const double apart = std::max(std::fabs(own_x - cam_x), std::fabs(own_y - cam_y)); + if (apart > most) most = apart, worst[0] = own_x, worst[1] = own_y, worst[2] = cam_x, worst[3] = cam_y; + sum += apart, moved = std::max(moved, std::max(std::fabs(cam_x), std::fabs(cam_y))), n++; + } + if (n && moved > 2.0) { + s.probes_told++; + logf("vk: capture probe: frame %llu draw %016llx, %d vertices on screen: its own motion and the camera's are at " + "most %.3f px apart (%.3f on average; the camera's motion up to %.1f px); the worst: own %.2f %.2f, the " + "camera's %.2f %.2f", (unsigned long long)pr.frame, (unsigned long long)pr.key, n, most, sum / n, moved, + worst[0], worst[1], worst[2], worst[3]); + } + pr.used = false; + } + if (!pr.buffer && !create_buffer_cached(kProbeSlots * 32, VK_BUFFER_USAGE_TRANSFER_DST_BIT, pr.buffer, pr.memory, &pr.map)) + pr = {}; + // (the draw with the most indices: a large piece of the world) + const Redraw* big = &draws[0]; + for (const Redraw& d : draws) + if (d.c->k.count > big->c->k.count) big = &d; + const auto holder = [&](uint64_t address, uint64_t bytes) -> const State::CaptureBuffer* { + for (const auto& b : s.capture_buffers) + if (b.buffer && address >= b.address && address + bytes <= b.address + b.size) return &b; + return nullptr; + }; + // (the same vertices in both: the slots both frames have, from the later first) + const uint32_t first = std::max(big->push.first_now, big->push.first_before); + const uint32_t skip_now = first - big->push.first_now, skip_before = first - big->push.first_before; + const uint32_t count = skip_now < big->push.count_now && skip_before < big->push.count_before + ? std::min({big->push.count_now - skip_now, big->push.count_before - skip_before, kProbeSlots}) : 0; + const uint64_t from_now = big->push.now + (uint64_t)skip_now * 16, from_before = big->push.before + (uint64_t)skip_before * 16; + const State::CaptureBuffer* bn = holder(from_now, (uint64_t)count * 16); + const State::CaptureBuffer* bb = holder(from_before, (uint64_t)count * 16); + if (pr.buffer && count && bn && bb) { + const VkBufferCopy c0{from_now - bn->address, 0, (uint64_t)count * 16}; + const VkBufferCopy c1{from_before - bb->address, kProbeSlots * 16, (uint64_t)count * 16}; + vkCmdCopyBuffer(cmd, bn->buffer, pr.buffer, 1, &c0); + vkCmdCopyBuffer(cmd, bb->buffer, pr.buffer, 1, &c1); + pr.frame = now, pr.key = big->c->key, pr.count = count; + std::memcpy(pr.reproject, reproject, sizeof pr.reproject); + for (int i = 0; i < 2; i++) pr.jitter_now[i] = big->push.jitter_now[i], pr.jitter_before[i] = big->push.jitter_before[i]; + pr.size[0] = (float)rw, pr.size[1] = (float)rh; + pr.used = true; + full_barrier(cmd); + } + } + // (the positions the scene's draws stored: the prep pass's barrier is after them) + if (!begin_redraw(cmd, s.capture, cam, before, s.last_jitter, reproject, rw, rh, dview)) return 0; + for (const Redraw& d : draws) { // (the same indices, base vertex and topology: VertexIndex names the same vertex) + const CaptureDraw& k = d.c->k; + vkCmdPushConstants(cmd, s.actor_layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof d.push, &d.push); + vkCmdSetPrimitiveTopology(cmd, k.topology); + vkCmdSetPrimitiveRestartEnable(cmd, k.restart ? VK_TRUE : VK_FALSE); + if (k.itype != dlss_actor::kNoIndices) { + const VkIndexType type = k.itype == 0 ? VK_INDEX_TYPE_UINT8_EXT : k.itype == 1 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32; + vkCmdBindIndexBuffer(cmd, d.ib.buffer, d.ib.offset, type); + vkCmdDrawIndexed(cmd, (uint32_t)k.count, 1, 0, k.base_vertex, 0); + } else { + vkCmdDraw(cmd, (uint32_t)k.count, 1, (uint32_t)k.base_vertex, 0); + } + } + vkCmdEndRendering(cmd); + s.actor_draws += draws.size(), s.actor_frames++, s.capture_draws += caps.size(); + return (int)draws.size(); +} + /// The bones a skinned draw's vertices use (the largest joint with a weight, plus one), read once a model; 0 when its /// buffers cannot be read uint32_t bones_used(const SkinnedDraw& k) { - if (k.count <= 0 || k.count > (1 << 20) || k.itype < 0 || k.itype > 2 || !k.stride) return 0; - std::vector idx((size_t)k.count << k.itype); - if (!memory_read_as_submitted(k.ibuf, idx.data(), idx.size())) return 0; + if (k.count <= 0 || k.count > (1 << 20) || k.itype < 0 || k.itype > dlss_actor::kNoIndices || !k.stride) return 0; uint32_t lo = UINT32_MAX, hi = 0; - for (int i = 0; i < k.count; i++) { - uint32_t v = 0; - std::memcpy(&v, idx.data() + ((size_t)i << k.itype), (size_t)1 << k.itype); - lo = std::min(lo, v), hi = std::max(hi, v); + if (k.itype == dlss_actor::kNoIndices) { // (a plain vertex array: base_vertex to base_vertex + count - 1) + lo = 0, hi = (uint32_t)k.count - 1; + } else { + std::vector idx((size_t)k.count << k.itype); + if (!memory_read_as_submitted(k.ibuf, idx.data(), idx.size())) return 0; + for (int i = 0; i < k.count; i++) { + uint32_t v = 0; + std::memcpy(&v, idx.data() + ((size_t)i << k.itype), (size_t)1 << k.itype); + lo = std::min(lo, v), hi = std::max(hi, v); + } } const int64_t first = (int64_t)k.base_vertex + lo, n = (int64_t)hi - lo + 1; if (first < 0 || n > (1 << 20) || (uint64_t)(first + n) * k.stride > k.vsize) return 0; @@ -581,8 +1035,8 @@ uint32_t bones_used(const SkinnedDraw& k) { for (int64_t i = 0; i < n; i++) { const uint8_t* q = v.data() + (size_t)i * k.stride; for (int set = 0; set < k.sets; set++) - for (int j = 0; j < 4; j++) { - if (!q[k.weights[set] + j]) continue; + for (int j = 0; j < dlss_actor::set_count(k.formats, set); j++) { // (1, 2 or 4; rigid: one, no weight) + if (!(k.formats & dlss_actor::kRigid) && !q[k.weights[set] + j]) continue; uint32_t joint = 0; if (k.formats & (dlss_actor::kByteJoints << set)) joint = q[k.joints[set] + j]; else std::memcpy(&joint, q + k.joints[set] + 2 * j, 2); @@ -595,7 +1049,7 @@ uint32_t bones_used(const SkinnedDraw& k) { /// The chain's images and buffers let go (the engine's own: its release) void drop_all() { State& s = st(); - for (Image* im : {&s.color, &s.depth, &s.motion, &s.output}) drop_image(*im); + for (Image* im : {&s.color, &s.depth, &s.motion, &s.output, &s.base, &s.merged}) drop_image(*im); for (auto& pb : s.pose_buffers) // (the actor motion's poses and cameras) if (pb.buffer) { const State::PoseBuffer gone = pb; @@ -608,7 +1062,21 @@ void drop_all() { later([gone] { destroy_buffer(gone.buffer, gone.memory); }); u = {}; } + for (auto& pr : s.probes) + if (pr.buffer) { + const State::Probe gone = pr; + later([gone] { destroy_buffer(gone.buffer, gone.memory); }); + pr = {}; + } + for (auto& b : s.capture_buffers) // (the stored positions) + if (b.buffer) { + const State::CaptureBuffer gone = b; + later([gone] { destroy_buffer(gone.buffer, gone.memory); }); + b = {}; + } s.poses.clear(), s.skins.clear(), s.model_bones.clear(); + s.captured.clear(), s.captured_models.clear(), s.captured_before.clear(), s.index_ranges.clear(); + s.capture_used = 0, s.captured_frame = 0; if (!s.depth_views.empty()) { auto old = std::move(s.depth_views); s.depth_views.clear(); @@ -622,13 +1090,27 @@ void drop_all() { void temporal_later(std::function f) { later(std::move(f)); } +// (local, RenoDX port) The scene's formats: the game's B10G11R11, and RGBA16F in a run where the host chose it for the scene's +// colour target (nx2/oot_patches.py patch_scene_format; host/nn_vi.c hos_scene_rgba16f, by the same rule: HOS_SCENE_RGBA16F, +// else HDR Native at the start with RenoDX's shaders in the build and not RX_VK_RENODX=0). Not the menu's HDR row as it is +// now, which can change in play while the target cannot. The scene's target can be RGBA16F while the image the upscale +// network reads, which the game's tone mapping writes, stays B10G11R11: either is the scene's here +bool temporal_scene_format(VkFormat f) { + static const bool rgba16f_run = [] { + if (const char* e = getenv("HOS_SCENE_RGBA16F")) return atoi(e) != 0; + return renodx_built() && hdr_at_start == 2 && renodx_chosen(); + }(); + return f == VK_FORMAT_B10G11R11_UFLOAT_PACK32 || (f == VK_FORMAT_R16G16B16A16_SFLOAT && rgba16f_run); +} + void temporal_note_scene_draw(const Texture* color0, uint32_t width, uint32_t height, Texture* depth, uint64_t camera, uint64_t camera_size) { // (only a size the gameplay upscale's output can come from: 1 to 3 times smaller. A smaller target with a camera (the // pause screen's model views, a reflection) is never the scene; one this size that is not either is left by the checks // below: the format, the camera's own size and perspective, the largest in the frame, and the upscale's input) if (!color0 || !depth || !camera || camera_size < 0x230 || !temporal_scene_size(width, height)) return; - if (color0->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || !temporal_wanted()) return; + // (AMD FSR 3.1 before the bloom keeps the camera here too: the point is found from the scene's target) + if (!temporal_scene_format(color0->format) || !(temporal_wanted() || pre_wanted(ur::GAME))) return; State& s = st(); std::lock_guard lk(s.mu); const uint64_t now = texture_frame_no(); @@ -642,6 +1124,7 @@ void temporal_note_scene_draw(const Texture* color0, uint32_t width, uint32_t he return; Camera& k = s.cam; std::memcpy(k.current, c + 0x30 / 4, sizeof k.current); + std::memcpy(k.view, c, sizeof k.view), std::memcpy(k.proj, c + 0x70 / 4, sizeof k.proj); // (the offset sead's projection gave the frustum, in its third column: 2 * offset, which moves the picture by -that) k.jitter[0] = -c[0x78 / 4], k.jitter[1] = -c[0x88 / 4]; // (its planes and field of view, for an engine that wants them (FSR's depth heuristics): an OpenGL-style projection, depth @@ -651,7 +1134,7 @@ void temporal_note_scene_draw(const Texture* color0, uint32_t width, uint32_t he const bool plain = std::isfinite(n) && n > 0.0f && p11 > 0.0f && (!std::isfinite(f) || f > n); k.near_z = plain ? n : 0.0f, k.far_z = plain ? (std::isfinite(f) ? f : 1e9f) : 0.0f; k.fov_y = plain ? 2.0f * std::atan(1.0f / p11) : 0.0f; - k.width = width, k.height = height, k.depth = depth, k.depth_gen = texture_destroy_generation(), k.frame = now; + k.width = width, k.height = height, k.format = color0->format, k.color = color0, k.depth = depth, k.depth_gen = texture_destroy_generation(), k.frame = now; k.valid = true; } @@ -684,25 +1167,34 @@ int temporal_status(char* b, size_t n) { if (k.failed || !k.e) return 0; // (the chain's own video memory: the images and buffers it made here, and what the engine says it holds, when it says) uint64_t own = 0; - for (const Image* im : {&s.color, &s.depth, &s.motion, &s.output}) + for (const Image* im : {&s.color, &s.depth, &s.motion, &s.output, &s.base, &s.merged}) if (im->image) own += allocation_size(im->memory); for (const auto& pb : s.pose_buffers) if (pb.buffer) own += allocation_size(pb.memory); for (const auto& u : s.uploads) if (u.buffer) own += allocation_size(u.memory); + for (const auto& b : s.capture_buffers) + if (b.buffer) own += allocation_size(b.memory); const uint64_t engine = k.e->memory(); const uint64_t draws = s.actor_draws - s.status_draws, frames = s.actor_frames - s.status_frames; char feature[48] = ""; if (engine) snprintf(feature, sizeof feature, ", its own %llu MB", (unsigned long long)(engine >> 20)); char passed[64] = ""; if (s.status_passed) snprintf(passed, sizeof passed, ", %llu left to the game's network", (unsigned long long)s.status_passed); - snprintf(b, n, "; %s: %llu frames drawn%s, %llu made, jitter %+.3f %+.3f px%s, actor motion %llu draws in %llu " + // (capture motion: the draws that stored positions, a frame, and the most a frame's took) + char stored[96] = ""; + if (motion_mode() == kMotionCapture && frames) + snprintf(stored, sizeof stored, " of %llu stored a frame (%llu vertices, %.1f MB at most; %llu with another jitter)", + (unsigned long long)(s.capture_draws / frames), (unsigned long long)(s.capture_slots / frames), + s.capture_bytes_peak / 1048576.0, (unsigned long long)(s.capture_unjittered / frames)); + snprintf(b, n, "; %s: %llu frames drawn%s, %llu made, jitter %+.3f %+.3f px%s, %s motion %llu draws%s in %llu " "frames (%.3f ms CPU a frame), its images %llu MB%s", name_of(mode), (unsigned long long)s.status_drawn, passed, (unsigned long long)s.engines_made, s.status_jitter[0], s.status_jitter[1], s.status_motion ? "" : " (no motion)", - (unsigned long long)draws, (unsigned long long)frames, frames ? s.actor_ns / 1e6 / (double)frames : 0.0, - (unsigned long long)(own >> 20), feature); + motion_mode() == kMotionCapture ? "captured" : "actor", (unsigned long long)draws, stored, + (unsigned long long)frames, frames ? s.actor_ns / 1e6 / (double)frames : 0.0, (unsigned long long)(own >> 20), feature); s.status_draws = s.actor_draws, s.status_frames = s.actor_frames, s.actor_ns = 0, s.status_drawn = s.status_passed = 0; + s.capture_draws = s.capture_slots = s.capture_bytes_peak = s.capture_unjittered = 0; return mode; } @@ -730,9 +1222,10 @@ void temporal_idle() { s.holding = !s.dead.empty(); } -void temporal_note_skinned_draw(const SkinnedDraw& k) { - static const bool off = env_switch("RX_VK_DLSS_ACTORS") == 0; - if (off || !temporal_wanted() || !k.depth || !k.bones || k.bones_size < 48 || !k.object || k.object_size < 0x4c) return; +const char* temporal_note_skinned_draw(const SkinnedDraw& k) { + if (motion_mode() == kMotionCapture) return "its stored positions are drawn instead"; + if (motion_mode() != kMotionBones || !temporal_wanted()) return "actor motion off"; + if (!k.depth || !k.bones || k.bones_size < 48 || !k.object || k.object_size < 0x4c) return "no object buffer"; State& s = st(); std::lock_guard lk(s.mu); if (s.skins.size() >= 512) s.skins.clear(); // (no upscale for a while: what was kept is stale) @@ -751,24 +1244,265 @@ void temporal_note_skinned_draw(const SkinnedDraw& k) { mb = s.model_bones.emplace(model, bones_used(k)).first; } d.nbones = (uint32_t)std::min(mb->second, std::min(k.bones_size / 48, 280)); - if (!d.nbones) return; + if (!d.nbones) return "its vertices use no bone (or its buffers could not be read)"; + // (its pose now, as the game submitted the draw: by the upscale the game may have written the next frame's there) + // (and the camera it was drawn with: its view and projection, which the redraw uses for this frame's position) + d.pose.assign(dlss_actor::kPoseHead + (size_t)d.nbones * 48, 0); + if (!memory_read_as_submitted(k.object + 0x40, d.pose.data(), 12) || + !memory_read_as_submitted(k.bones, d.pose.data() + dlss_actor::kPoseHead, (uint64_t)d.nbones * 48)) + d.pose.clear(); // (copied on the GPU at the upscale, as before) + else if (!k.camera || k.camera_size < 0xb0 || !memory_read_as_submitted(k.camera, d.pose.data() + 16, 48) || + !memory_read_as_submitted(k.camera + 0x70, d.pose.data() + 64, 64)) + d.pose.clear(); int nth = 0; // (the same model drawn twice in a frame: the n-th draw of it is the n-th the frame before) for (const auto& o : s.skins) nth += dlss_actor::same_model(o.key, model); d.key = dlss_actor::key(k.vbuf, k.ibuf, k.count, k.base_vertex, k.program, nth); s.skins.push_back(std::move(d)); + return nullptr; } +bool temporal_capture_wanted() { return motion_mode() == kMotionCapture && temporal_wanted(); } + +void temporal_capture_draw(const CaptureDraw& k, CaptureSlot* out) { + *out = {}; + if (!k.depth || k.count <= 0 || !temporal_capture_wanted()) return; + State& s = st(); + std::lock_guard lk(s.mu); + struct Timed { + State& s; + std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); + ~Timed() { s.actor_ns += (std::chrono::steady_clock::now() - t0).count(); } + } timed{s}; + if (s.capture_ok < 0) { // (the stores are by device address) + VkPhysicalDeviceFeatures2 f{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2}; + vkGetPhysicalDeviceFeatures2(dev.physical, &f); + // (and stores from a vertex stage: every desktop GPU has them, and the device is made with all it has) + s.capture_ok = dev.vk12.bufferDeviceAddress && f.features.shaderInt64 && dev.features.vertexPipelineStoresAndAtomics; + if (!s.capture_ok) logf("vk: upscaler: no stores from vertex shaders by address on this GPU: the camera's motion alone"); + } + if (!s.capture_ok) return; + // (a frame went by without an upscale taking them (a loading screen, a menu over the scene): what was kept is stale, its + // buffer given out again. Left to pile up, the buffer ran out there, and was made twice as large for nothing) + const uint64_t frame = texture_frame_no(); + if (frame > s.capture_frame + 1 || s.captured.size() >= 32768) { + s.captured.clear(), s.captured_models.clear(); + s.capture_used = 0, s.capture_full = false; + } + if (s.captured.empty()) s.capture_frame = frame; + // (an indexed draw's vertices: from its least index to its greatest, read once for its index buffer) + uint32_t lo = 0, hi = 0; + if (k.itype != dlss_actor::kNoIndices) { + if (k.itype < 0 || k.itype > 2 || k.count > (1 << 24)) return; + const uint64_t at = dlss_actor::key(k.ibuf, (uint64_t)k.itype, k.count, k.restart ? 1 : 0, 0, 0); + auto it = s.index_ranges.find(at); + if (it == s.index_ranges.end()) { + if (s.index_ranges.size() > 65536) s.index_ranges.clear(); + State::IndexRange r; + std::vector idx((size_t)k.count << k.itype); + if (memory_read_as_submitted(k.ibuf, idx.data(), idx.size())) + r.ok = dlss_actor::index_range(idx.data(), k.count, k.itype, k.restart, &r.lo, &r.hi); + it = s.index_ranges.emplace(at, r).first; + } + if (!it->second.ok) return; + lo = it->second.lo, hi = it->second.hi; + } + uint32_t first = 0, n = 0; + if (!dlss_actor::capture_span(k.itype, k.count, k.base_vertex, lo, hi, kCaptureMostSlots, &first, &n)) return; + // (this frame's buffer: RX_VK_DLSS_POSITIONS_MB, 32 MB (two million vertices) at first; more when a frame ran out) + if (!s.capture_want) { + const int mb = env_switch("RX_VK_DLSS_POSITIONS_MB"); + s.capture_want = std::min((uint64_t)(mb > 0 ? mb : 32) << 20, kCaptureMost); + } + State::CaptureBuffer& b = s.capture_buffers[s.capture_at]; + if (!b.buffer) { + if (!create_device_buffer(s.capture_want, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT, // (RX_VK_DLSS_PROBE copies from it) + b.buffer, b.memory)) { + b = {}; + s.capture_full = true; + return; + } + b.size = s.capture_want; + b.address = device_address({b.buffer, 0, b.size, 0}); + if (!b.address) { + destroy_buffer(b.buffer, b.memory); + b = {}; + s.capture_ok = 0; + return; + } + } + const uint64_t bytes = (uint64_t)n * 16; + if (s.capture_used + bytes > b.size) { + s.capture_full = true; + return; + } + // (its name across frames: as the actor motion's, the n-th draw of a model this frame the n-th the frame before) + const uint64_t model = dlss_actor::key(k.vbuf, k.ibuf, k.count, k.base_vertex, k.program, 0); + const int nth = s.captured_models[model >> 8]++; + State::Captured c; + c.k = k, c.key = dlss_actor::key(k.vbuf, k.ibuf, k.count, k.base_vertex, k.program, nth); + c.address = b.address + s.capture_used, c.first = first, c.count = n; + // (the jitter of the camera it is drawn with, as submitted: read again when the address or the captures' view changes) + if (k.camera && k.camera_size >= 0xb0) { + const uint64_t view = memory_capture_view(); + if (k.camera != s.capture_camera || view != s.capture_camera_view) { + float proj[16]; + s.capture_camera = k.camera, s.capture_camera_view = view; + s.capture_camera_own = memory_read_as_submitted(k.camera + 0x70, proj, sizeof proj) && + dlss_actor::camera_jitter(proj, s.capture_camera_jitter); + } + c.own = s.capture_camera_own; + c.jitter[0] = s.capture_camera_jitter[0], c.jitter[1] = s.capture_camera_jitter[1]; + } + s.captured.push_back(c); + s.capture_used += bytes, s.capture_slots += n; + out->address = c.address, out->first = first, out->count = n; +} + +namespace { +bool chain(VkCommandBuffer cmd, int mode, Engine& engine, const Camera& cam, const std::vector& captures, + VkImageView in_view, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, VkImageView out_view, const Texture* pre, + VkFormat in_format, VkFormat out_format); + +/// The engine before the game's bloom and tone mapping (temporal_pre_point, temporal_pre_tonemap): NVIDIA DLSS and DLAA, +/// AMD FSR 4 and its native anti-aliasing (both engines take linear HDR colour), and AMD FSR 3.1 (vk_fsr3.cpp: its own +/// inputs and passes, the rest of this the same; mode is then the game's own, as for the chain). RX_VK_DLSS_PRE=0: as before, in place of +/// the upscale's dispatch, on the tone mapped picture (the name is DLSS's from before FSR came: it applies to either) +bool pre_wanted(int mode) { + // (Triforce, 11-13: off until the Upscale before bloom row turns it on, read at the start; RX_VK_DLSS_PRE=0 or 1 over it) + static const bool on = [] { + const int e = env_switch("RX_VK_DLSS_PRE"); + return e >= 0 ? e != 0 : upscale_pre_at_start != 0; + }(); + return on && (ur::is_dlss(mode) || ur::is_fsr4(mode) || fsr3_pre_wanted()); +} + +/// The upscale's dispatch in a frame the engine drew before the bloom: the tone mapped picture into its output, nothing +/// else. From final, the tone mapping draw's own target (linear, before the game's edge anti-aliasing, which the engine +/// has done better); without it from the dispatch's input (that picture's square root after the game's anti-aliasing, as +/// the network samples it), squared. false: the game's own pass runs +bool pre_copy(VkCommandBuffer cmd, Texture* final, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, + uint32_t out_level) { + State& s = st(); + if (final) { + if (const VkImageView v = depth_view(final)) in = final, in_view = v; + else final = nullptr; + } + if (!in || !in_view || !out || !out_view || !temporal_scene_format(out->format)) return false; + const bool wide = out->format == VK_FORMAT_R16G16B16A16_SFLOAT; // (an RGBA16F picture: the pass's -DHDR layout) + if (!make_pipelines(wide)) return false; + const uint32_t ow = std::max(1u, out->width >> out_level), oh = std::max(1u, out->height >> out_level); + struct Disturbed { + ~Disturbed() { descriptors_disturbed(); } + } disturbed; + const int32_t opc[3] = {(int32_t)ow, (int32_t)oh, final ? 1 : 2}; + const VkDescriptorImageInfo info[2] = { + {in->width == ow && in->height == oh ? s.point : s.linear, in_view, VK_IMAGE_LAYOUT_GENERAL}, + {VK_NULL_HANDLE, out_view, VK_IMAGE_LAYOUT_GENERAL}}; + VkWriteDescriptorSet w[2]{{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}, {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}}; + w[0].dstBinding = 0, w[0].descriptorCount = 1, w[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + w[0].pImageInfo = &info[0]; + w[1].dstBinding = 1, w[1].descriptorCount = 1, w[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + w[1].pImageInfo = &info[1]; + full_barrier(cmd); + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, wide ? s.out_hdr : s.out); + vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out_layout, 0, 2, w); + vkCmdPushConstants(cmd, s.out_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof opc, opc); + vkCmdDispatch(cmd, (ow + 7) / 8, (oh + 7) / 8, 1); + return true; +} +/// The upscale's dispatch, for the engine before the bloom (the chain's lock held): true when the output is written (the +/// tone mapped picture drawn there at its size, or copied there), and the dispatch is left out. In a frame the engine +/// did not draw before the bloom, the point is learnt for the next +bool pre_dispatch(VkCommandBuffer cmd, int mode, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, + uint32_t out_level, bool learn = true) { + State& s = st(); + // (the engine drew before the bloom, and this is the scene's upscale: the tone mapped picture goes to the output as it + // is, or is there already, drawn at the output's size) + // (its input is the scene's own texture with the game's formats, the game packing the tone mapped picture back into it; + // with an RGBA16F picture (local, RenoDX port) it is another texture of the scene's size: known by its size and format) + if (s.pre_pending && in && s.pre_scene && in->width == s.pre_scene->width && in->height == s.pre_scene->height && + temporal_scene_format(in->format)) { + const bool direct = s.pre_direct && out && out == s.pre_out; + Texture* final = const_cast(s.pre_final); + s.pre_pending = false, s.pre_candidate = {}, s.pre_final = nullptr, s.pre_direct = false; + if (out && !out_level) s.pre_out = out, s.pre_out_gen = texture_destroy_generation(); + if (out && temporal_scene_format(out->format)) note_output(out, out_level); + return direct || pre_copy(cmd, final, in, in_view, out, out_view, out_level); + } + if (learn && pre_wanted(mode)) { // (it did not: what the first draw after the scene was, for the next frame) + if (s.pre_candidate.program && !(s.pre_candidate == s.pre_key)) { + logf("vk: %s: before the game's bloom and tone mapping from the next frame: the first draw after the scene is " + "program %016llx into %ux%u, format %d (frame %llu)", ur::is_dlss(mode) || ur::is_fsr4(mode) ? name_of(mode) : "AMD FSR 3.1", + (unsigned long long)s.pre_candidate.program, s.pre_candidate.width, s.pre_candidate.height, + (int)s.pre_candidate.format, (unsigned long long)texture_frame_no()); + s.pre_key = s.pre_candidate; + } + s.pre_candidate = {}, s.pre_missed++; + // (a frame or two without the point, between frames that had it: the tone mapped picture as it is, in place of the + // engine made again for LDR colour and then again for HDR, a stall each) + if (s.pre_drawn && ++s.pre_miss_run <= 2 && in && s.cam.valid && in->width == s.cam.width) { + s.cam.valid = false, s.skins.clear(); + (void)take_captures(); + if (out && temporal_scene_format(out->format)) note_output(out, out_level); + if (pre_copy(cmd, nullptr, in, in_view, out, out_view, out_level)) return true; + } + } + return false; +} + +/// AMD FSR 3.1 before the bloom: its picture (vk_fsr3.cpp fsr3_pre) back into the scene's colour target at the scene's +/// size, and the same into the copy when it scaled up, as the chain's own pass does for its engines +bool pre_fsr3(VkCommandBuffer cmd, Texture* scene, VkImageView view, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh) { + State& s = st(); + const bool scaled = ow != rw || oh != rh; + if (!make_pipelines(false) || (scaled && !make_image(cmd, s.base, VK_FORMAT_B10G11R11_UFLOAT_PACK32, rw, rh))) return false; + struct Disturbed { + ~Disturbed() { descriptors_disturbed(); } + } disturbed; + s.cam.valid = false, s.skins.clear(); // (each frame's own: FSR 3.1 keeps a camera of its own) + (void)take_captures(); + s.asked = texture_frame_no(), s.holding = true; + VkImageView picture = VK_NULL_HANDLE; + if (!fsr3_pre(cmd, scene, view, ow, oh, &picture) || !picture) return false; + full_barrier(cmd); + const int32_t opc[3] = {(int32_t)rw, (int32_t)rh, 1}; + VkDescriptorImageInfo info[2] = {{scaled ? s.linear : s.point, picture, VK_IMAGE_LAYOUT_GENERAL}, + {VK_NULL_HANDLE, view, VK_IMAGE_LAYOUT_GENERAL}}; + VkWriteDescriptorSet w[2]{{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}, {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}}; + w[0].dstBinding = 0, w[0].descriptorCount = 1, w[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + w[0].pImageInfo = &info[0]; + w[1].dstBinding = 1, w[1].descriptorCount = 1, w[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + w[1].pImageInfo = &info[1]; + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out); + vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out_layout, 0, 2, w); + vkCmdPushConstants(cmd, s.out_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof opc, opc); + vkCmdDispatch(cmd, (rw + 7) / 8, (rh + 7) / 8, 1); + if (scaled) { + info[1].imageView = s.base.view; + vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out_layout, 0, 2, w); + vkCmdDispatch(cmd, (rw + 7) / 8, (rh + 7) / 8, 1); + } + full_barrier(cmd); + s.pre_pending = true, s.pre_frame = texture_frame_no(), s.pre_scene = scene, s.pre_drawn++; + s.pre_final = nullptr, s.pre_direct = false, s.pre_miss_run = 0, s.pre_touched = false; + s.pre_picture = {picture, ow, oh}; + return true; +} +} // namespace + bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, uint32_t out_level) { const int mode = temporal_mode(); if (mode == ur::GAME) return false; State& s = st(); std::lock_guard lk(s.mu); + if (pre_dispatch(cmd, mode, in, in_view, out, out_view, out_level)) return true; if (!known) { // (another network of the upscale's shape: only the scene into the picture, the rest untouched and unsaid) const Camera& c = s.cam; // (the gameplay networks' own formats: they sample the scene's B10G11R11 colour and write the B10G11R11 picture. // Other cooperative-matrix networks of the same shape (one RGBA8 into A2B10G10R10, RGB9E5 into B10G11R11) are not it) - if (!in || !out || in->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || + if (!in || !out || !temporal_scene_format(in->format) || out->format != in->format || (out->width >> out_level) <= in->width) return false; note_output(out, out_level); @@ -781,13 +1515,15 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in out->height >> out_level); } free_dead(false); - if (known && out && out->format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) note_output(out, out_level); + if (known && out && temporal_scene_format(out->format)) note_output(out, out_level); const Camera cam = s.cam; s.cam.valid = false; // (each frame's own camera) struct SkinsDone { // (the skinned draws, each frame's own too: actor_motion takes them, or they go here) State& s; ~SkinsDone() { s.skins.clear(); } } skins_done{s}; + // (and the draws that stored their positions: the next frame's go into the next buffer of the ring) + const std::vector captures = take_captures(); Engine& engine = engine_of(mode); if (!engine.e || engine.failed) return fail("it failed earlier"); @@ -801,14 +1537,32 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in if (cam.depth->width != rw || cam.depth->height != rh || !(cam.depth->usage & VK_IMAGE_USAGE_SAMPLED_BIT) || cam.depth->samples != VK_SAMPLE_COUNT_1_BIT || !(cam.depth->aspect & VK_IMAGE_ASPECT_DEPTH_BIT)) return fail("unexpected scene depth"); - if (out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32 || !dlss_checks::scene_size_fits(rw, rh, ow, oh)) + if (!temporal_scene_format(out->format) || out->format != in->format || !dlss_checks::scene_size_fits(rw, rh, ow, oh)) return fail("unexpected output"); + return chain(cmd, mode, engine, cam, captures, in_view, rw, rh, ow, oh, out_view, nullptr, in->format, out->format); +} + +namespace { +/// The engine's frame: its inputs made from in_view (the scene's colour as it is sampled) and the camera's depth and motion, +/// its evaluation, and its picture written: into out_view (the upscale's output, squared back to linear), or with pre (the +/// scene's colour target, before the game's bloom and tone mapping: in_view is linear HDR light) back into pre itself, of +/// which out_view is then a view. Called with the chain's lock held +bool chain(VkCommandBuffer cmd, int mode, Engine& engine, const Camera& cam, const std::vector& captures, + VkImageView in_view, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, VkImageView out_view, const Texture* pre, + VkFormat in_format, VkFormat out_format) { + State& s = st(); + // (the engine is given linear HDR colour: before the bloom, or an RGBA16F scene's picture (local, RenoDX port), which + // only DLSS took; else the network's input, tonemapped, LDR. wide: the image the picture is written into is RGBA16F, + // the passes' -DHDR layout) + const bool hdr = pre != nullptr || in_format == VK_FORMAT_R16G16B16A16_SFLOAT; + const bool wide = out_format == VK_FORMAT_R16G16B16A16_SFLOAT; + if (hdr && !pre && !ur::is_dlss(mode)) return fail("an HDR scene: only DLSS takes it"); if (!engine.started) engine.started = true, engine.ok = engine.e->start(); if (!engine.ok) { engine.failed = true; return fail("not available"); } - if (!make_pipelines()) { + if (!make_pipelines(wide || (hdr && !pre))) { engine.failed = true; return fail("its shaders were not made"); } @@ -834,7 +1588,7 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in } disturbed; uint32_t iw = rw, ih = rh; const char* why = nullptr; - const int ready = engine.e->prepare(cmd, rw, rh, dw, dh, &iw, &ih, &why); + const int ready = engine.e->prepare(cmd, rw, rh, dw, dh, hdr, &iw, &ih, &why); if (ready < 0) { engine.failed = true; return fail(why ? why : "it could not be made"); @@ -844,7 +1598,8 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in if (!make_image(cmd, s.color, VK_FORMAT_R16G16B16A16_SFLOAT, iw, ih) || !make_image(cmd, s.depth, VK_FORMAT_R32_SFLOAT, iw, ih) || !make_image(cmd, s.motion, VK_FORMAT_R16G16_SFLOAT, iw, ih, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) || - !make_image(cmd, s.output, VK_FORMAT_R16G16B16A16_SFLOAT, dw, dh)) + !make_image(cmd, s.output, VK_FORMAT_R16G16B16A16_SFLOAT, dw, dh) || + (pre && !native && !make_image(cmd, s.base, pre->format, rw, rh))) return fail("its images were not made"); const uint64_t now = texture_frame_no(); @@ -856,7 +1611,11 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in int32_t size[2]; int32_t flags; } pc{}; - static const bool show_motion = getenv("RX_VK_DLSS_DEBUG") && !strcmp(getenv("RX_VK_DLSS_DEBUG"), "motion"); + // (RX_VK_DLSS_DEBUG=actors: the same view, the actor motion's pixels marked in it: actor_motion) + static const bool show_motion = getenv("RX_VK_DLSS_DEBUG") && (!strcmp(getenv("RX_VK_DLSS_DEBUG"), "motion") || + !strcmp(getenv("RX_VK_DLSS_DEBUG"), "actors")); + // (RX_VK_DLSS_DEBUG=characters: grey, and blue where a draw's own motion is not the camera's: redraw_tolerance) + static const bool show_own = getenv("RX_VK_DLSS_DEBUG") && !strcmp(getenv("RX_VK_DLSS_DEBUG"), "characters"); // (the motion without the jitter: from this frame's jittered clip space to the frame before's without its jitter. // A jitter moves clip x by jitter * w: taken off the previous matrix's first two rows) // (the frame before's camera as the engine last drew it: the buffer's own slot for it, 0x180, holds zeros in this version) @@ -865,7 +1624,7 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in dlss_math::unjitter(previous, s.last_jitter); const bool motion = !reset && dlss_math::reprojection(cam.current, previous, pc.reproject); pc.jitter[0] = cam.jitter[0], pc.jitter[1] = cam.jitter[1]; - pc.size[0] = (int32_t)rw, pc.size[1] = (int32_t)rh, pc.flags = (motion ? 1 : 0) | (show_motion ? 2 : 0); + pc.size[0] = (int32_t)rw, pc.size[1] = (int32_t)rh, pc.flags = (motion ? 1 : 0) | (show_motion ? 2 : 0) | (pre ? 16 : 0); const auto prep = [&] { const VkDescriptorImageInfo info[5] = {{s.point, in_view, VK_IMAGE_LAYOUT_GENERAL}, @@ -879,7 +1638,7 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in w[i].dstBinding = i, w[i].descriptorCount = 1, w[i].pImageInfo = &info[i]; w[i].descriptorType = i < 2 ? VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER : VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; } - vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.prep); + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, hdr && !pre ? s.prep_hdr : s.prep); vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.prep_layout, 0, 5, w); vkCmdPushConstants(cmd, s.prep_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, &pc); vkCmdDispatch(cmd, (rw + 7) / 8, (rh + 7) / 8, 1); @@ -887,11 +1646,14 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in full_barrier(cmd); // (the scene's colour and depth, written before) prep(); full_barrier(cmd); - // (what moves by itself: the skinned draws drawn again over the camera's motion, with their own) - const int actors = actor_motion(cmd, cam, previous, rw, rh, dview, motion); + // (what moves by itself: the draws drawn again over the camera's motion from the positions they stored, with their own; + // or the skinned draws from their bones (RX_VK_DLSS_ACTORS=bones)) + const int actors = motion_mode() == kMotionCapture + ? capture_motion(cmd, cam, previous, pc.reproject, rw, rh, dview, motion, captures) + : actor_motion(cmd, cam, previous, pc.reproject, rw, rh, dview, motion); if (actors) full_barrier(cmd); - if (show_motion && actors) { // (RX_VK_DLSS_DEBUG=motion: the motion as it is now, the actors' in it) - pc.flags = 4; + if ((show_motion && actors) || show_own) { // (RX_VK_DLSS_DEBUG=motion: the motion as it is now, the actors' in it) + pc.flags = show_own ? 4 | 8 : 4; prep(); full_barrier(cmd); } @@ -914,24 +1676,58 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in } full_barrier(cmd); { - const int32_t opc[2] = {(int32_t)ow, (int32_t)oh}; - const VkDescriptorImageInfo info[2] = {{native ? s.linear : s.point, s.output.view, VK_IMAGE_LAYOUT_GENERAL}, + // (pre: the engine's picture back into the scene's colour target, at the scene's size: scaled down when the engine + // scaled up, for the bloom and what else reads the scene. The picture itself is drawn from by the tone mapping, + // temporal_pre_composite) + if (pre) ow = rw, oh = rh; + const int32_t opc[3] = {(int32_t)ow, (int32_t)oh, pre ? 1 : 0}; + const VkDescriptorImageInfo info[2] = {{native != (pre != nullptr) ? s.linear : s.point, s.output.view, VK_IMAGE_LAYOUT_GENERAL}, {VK_NULL_HANDLE, out_view, VK_IMAGE_LAYOUT_GENERAL}}; VkWriteDescriptorSet w[2]{{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}, {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}}; w[0].dstBinding = 0, w[0].descriptorCount = 1, w[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; w[0].pImageInfo = &info[0]; w[1].dstBinding = 1, w[1].descriptorCount = 1, w[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; w[1].pImageInfo = &info[1]; - vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out); + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, wide ? s.out_hdr : s.out); vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out_layout, 0, 2, w); vkCmdPushConstants(cmd, s.out_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof opc, opc); vkCmdDispatch(cmd, (ow + 7) / 8, (oh + 7) / 8, 1); + if (pre && !native) { // (the same once more into the copy: what the scene holds now, texel for texel) + const VkDescriptorImageInfo copy{VK_NULL_HANDLE, s.base.view, VK_IMAGE_LAYOUT_GENERAL}; + w[1].pImageInfo = © + vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.out_layout, 0, 2, w); + vkCmdDispatch(cmd, (ow + 7) / 8, (oh + 7) / 8, 1); + } + } + { // (RX_VK_DLSS_BENCH=1: each mode's turn timed, from its 60th upscale to its last, and said when it ends) + static const bool bench = env_switch("RX_VK_DLSS_BENCH") > 0; + if (bench) { + static std::chrono::steady_clock::time_point from; + static uint64_t actor_draws_from = 0; + const uint64_t n = bench_upscales.load(std::memory_order_relaxed), at = n % kBenchFrames; + if (at == 60) from = std::chrono::steady_clock::now(), actor_draws_from = s.actor_draws; + if (at == kBenchFrames - 1) { + const double ms = std::chrono::duration(std::chrono::steady_clock::now() - from).count(); + const double frames = (double)(kBenchFrames - 1 - 60); + static const char* const names[3] = {"the camera's motion alone", "the bones", "the stored positions"}; + logf("vk: upscaler bench: %s: %.3f ms a frame (%.1f fps) over %d frames at %ux%u, %.0f draws drawn again a frame", + names[(n / kBenchFrames) % 3], ms / frames, 1000.0 * frames / ms, (int)frames, rw, rh, + (double)(s.actor_draws - actor_draws_from) / frames); + } + bench_upscales.fetch_add(1, std::memory_order_relaxed); + } } s.last_frame = now; s.last_jitter[0] = cam.jitter[0], s.last_jitter[1] = cam.jitter[1]; // (for the status line, temporal_status: the jitter the engine was given, in render pixels) s.status_jitter[0] = f.jitter[0], s.status_jitter[1] = f.jitter[1], s.status_motion = motion; s.status_drawn++; + if (pre) { + s.pre_pending = true, s.pre_frame = now, s.pre_scene = pre, s.pre_drawn++; + s.pre_final = nullptr, s.pre_direct = false, s.pre_miss_run = 0, s.pre_touched = false; + s.pre_picture = {s.output.view, s.output.width, s.output.height}; + full_barrier(cmd); + } std::memcpy(s.last_vp, cam.current, sizeof s.last_vp); s.jitter_w = rw, s.jitter_h = rh, s.jitter_phases = (uint32_t)dlss_jitter_phases(rw, rh, dw, dh); @@ -940,13 +1736,178 @@ bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in // (RX_VK_DLSS_DEBUG=alternate, a test's reference: every other frame the game's own upscale over the engine's, which still // draws and keeps its history. A frame of it then has the game's picture of the frames either side to be measured against) static const bool alternate = getenv("RX_VK_DLSS_DEBUG") && !strcmp(getenv("RX_VK_DLSS_DEBUG"), "alternate"); - if (alternate && (now & 1)) return false; + if (alternate && (now & 1) && !pre) return false; if (s.told_first != engine.e) { s.told_first = engine.e; - logf("vk: %s draws OoT's upscale: %ux%u -> %ux%u%s", name_of(mode), rw, rh, ow, oh, - show_motion ? " (its motion shown)" : ""); + // (the formats too: the scene's target can be RGBA16F while the network reads B10G11R11. hdr: the colour goes to the + // engine as linear HDR) + logf("vk: %s draws OoT's upscale: %ux%u -> %ux%u%s; the scene's target format %d, the network's input %d and output %d%s", + name_of(mode), rw, rh, dw, dh, show_motion ? " (its motion shown)" : "", (int)cam.format, (int)in_format, + (int)out_format, pre ? ": before the game's bloom and tone mapping, in the scene's colour target, HDR colour" : ""); } return true; } +} // namespace + +bool temporal_pre_point(const Texture* color0, uint64_t program, bool* late) { + if (!color0 || !pre_wanted(temporal_mode())) return false; + State& s = st(); + std::lock_guard lk(s.mu); + // (pending from an earlier frame: that frame had no upscale's dispatch after it. Not this frame's) + if (s.pre_pending && texture_frame_no() != s.pre_frame && color0 == s.pre_scene) s.pre_pending = false; + if (s.pre_pending) { // (the engine drew already: a draw into the scene now is one it did not see) + if (color0 == s.pre_scene) { + s.pre_touched = true; + if (s.pre_late++ < 24) + logf("vk: upscaler: program %016llx draws into the scene after the engine drew before the bloom (frame %llu)", + (unsigned long long)program, (unsigned long long)texture_frame_no()); + // (the first frames it happens in, 60 frames apart: the caller dumps the next frame, to see what they draw) + const uint64_t now = texture_frame_no(); + if (late && s.pre_late_dumps < 3 && now - s.pre_late_frame > 60) *late = true, s.pre_late_frame = now, s.pre_late_dumps++; + } + return false; + } + if (!s.cam.valid || !s.cam.color || texture_frame_no() - s.cam.frame > 1) return false; + if (color0 == s.cam.color) return s.pre_candidate = {}, false; // (the scene still being drawn) + const State::PrePoint here{program, color0->format, color0->width, color0->height}; + if (!s.pre_candidate.program) s.pre_candidate = here; + // (the point only as the first draw after the scene's last: a frame whose first is another (the point learnt from a + // frame without the bloom, whose first was the tone mapping) is left to the dispatch, which learns this frame's) + return here == s.pre_key && s.pre_candidate == here; +} + +Texture* temporal_pre_tonemap(VkCommandBuffer cmd) { + const int mode = temporal_mode(); + if (!pre_wanted(mode)) return nullptr; + State& s = st(); + std::lock_guard lk(s.mu); + const Camera cam = s.cam; + Texture* scene = const_cast(cam.color); + // (AMD FSR 3.1: not one of the chain's engines, its own inputs and passes: pre_fsr3) + const bool f3 = !ur::is_dlss(mode) && !ur::is_fsr4(mode); + Engine* const engine = f3 ? nullptr : &engine_of(mode); + // (anything unexpected: nothing here, and the upscale's dispatch draws as before, on the tone mapped picture) + if (!cam.valid || !scene || (engine && (!engine->e || engine->failed)) || cam.depth_gen != texture_destroy_generation()) + return nullptr; + const uint32_t rw = cam.width, rh = cam.height; + const VkImageUsageFlags need = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; + // (an RGBA16F scene too (local, RenoDX port): the engines' picture goes back into it through the pass's -DHDR layout. + // AMD FSR 3.1's own output pass has only the plain one) + if (f3 && scene->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return nullptr; + if (scene->width != rw || scene->height != rh || !temporal_scene_format(scene->format) || + (scene->usage & need) != need || scene->samples != VK_SAMPLE_COUNT_1_BIT || scene->layers != 1) { + static bool told; + if (!told) + told = true, logf("vk: upscaler: the scene's colour target cannot be drawn into before the bloom (%ux%u, format %d, " + "usage %#x): the engine draws on the tone mapped picture", scene->width, scene->height, + (int)scene->format, (unsigned)scene->usage); + return nullptr; + } + if (cam.depth->width != rw || cam.depth->height != rh || !(cam.depth->usage & VK_IMAGE_USAGE_SAMPLED_BIT) || + cam.depth->samples != VK_SAMPLE_COUNT_1_BIT || !(cam.depth->aspect & VK_IMAGE_ASPECT_DEPTH_BIT)) + return nullptr; + // (an engine that scales up draws at the upscale's output size, as last seen) + uint32_t ow = rw, oh = rh; + if (!ur::full_scale(mode)) { + ow = s.out_w.load(std::memory_order_relaxed), oh = s.out_h.load(std::memory_order_relaxed); + if (!ow || !oh || !dlss_checks::scene_size_fits(rw, rh, ow, oh)) return nullptr; + } + const VkImageView view = depth_view(scene); // (its colour, sampled by the inputs pass and written by the output pass) + if (!view) return nullptr; + free_dead(false); + s.cam.valid = false; // (each frame's own camera) + struct SkinsDone { + State& s; + ~SkinsDone() { s.skins.clear(); } + } skins_done{s}; + const std::vector captures = take_captures(); + s.asked = texture_frame_no(), s.holding = true; + if (f3) return pre_fsr3(cmd, scene, view, rw, rh, ow, oh) ? scene : nullptr; + if (!chain(cmd, mode, *engine, cam, captures, view, rw, rh, ow, oh, view, scene, scene->format, scene->format)) return nullptr; + return scene; +} + +bool temporal_pre_dispatch(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, + uint32_t out_level, bool learn) { + const int mode = temporal_mode(); + if (!pre_wanted(mode)) return false; + State& s = st(); + std::lock_guard lk(s.mu); + if ((learn || s.pre_pending) && out && temporal_scene_format(out->format) && in && + (out->width >> out_level) >= in->width) + note_output(out, out_level); + return pre_dispatch(cmd, mode, in, in_view, out, out_view, out_level, learn); +} + +bool temporal_pre_composite(const Texture* color0, uint32_t width, uint32_t height, TemporalRetarget* k) { + State& s = st(); + std::lock_guard lk(s.mu); + if (!s.pre_pending || s.pre_final || !s.pre_scene || !color0 || color0 == s.pre_scene) return false; + if (!temporal_scene_format(color0->format) || width != s.pre_scene->width || height != s.pre_scene->height) + return false; + s.pre_final = color0; + // (the engine's picture is larger than the scene: the draw once more, into the upscale's output at its size) + Texture* out = s.pre_out; + const auto& pic = s.pre_picture; + if (!pic.view || (pic.width == width && pic.height == height) || !out || s.pre_out_gen != texture_destroy_generation()) + return false; + if (out->width != pic.width || out->height != pic.height || !temporal_scene_format(out->format) || + !(out->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) || out->samples != VK_SAMPLE_COUNT_1_BIT || out->layers != 1) + return false; + const VkImageView view = depth_view(out); + if (!view) return false; + k->target = out, k->target_view = view, k->width = out->width, k->height = out->height; + k->from = s.pre_scene, k->to_view = pic.view; + return true; +} + +VkImageView temporal_pre_merged(VkCommandBuffer cmd) { + State& s = st(); + std::lock_guard lk(s.mu); + const uint32_t ow = s.pre_picture.width, oh = s.pre_picture.height; + // (nothing drawn into the scene since, or no copy of it: the engine's picture as it is) + if (!s.pre_pending || !s.pre_touched || !s.pre_scene || !s.base.image || s.base.width != s.pre_scene->width || + s.base.height != s.pre_scene->height) + return s.pre_picture.view; + const VkDescriptorType S = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, I = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; + const VkDescriptorType types[4] = {S, S, S, I}; + if (!s.merge && !make_pipeline(DLSS_MERGE_COMP_SPV, sizeof DLSS_MERGE_COMP_SPV, types, 4, 8, s.merge_set, s.merge_layout, s.merge)) + return s.pre_picture.view; + const VkImageView scene = depth_view(const_cast(s.pre_scene)); + if (!scene || !make_image(cmd, s.merged, VK_FORMAT_R16G16B16A16_SFLOAT, ow, oh)) return s.pre_picture.view; + const int32_t pc[2] = {(int32_t)ow, (int32_t)oh}; + const VkDescriptorImageInfo info[4] = {{s.linear, scene, VK_IMAGE_LAYOUT_GENERAL}, + {s.linear, s.base.view, VK_IMAGE_LAYOUT_GENERAL}, + {s.point, s.pre_picture.view, VK_IMAGE_LAYOUT_GENERAL}, + {VK_NULL_HANDLE, s.merged.view, VK_IMAGE_LAYOUT_GENERAL}}; + VkWriteDescriptorSet w[4]{}; + for (uint32_t i = 0; i < 4; i++) { + w[i] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + w[i].dstBinding = i, w[i].descriptorCount = 1, w[i].pImageInfo = &info[i]; + w[i].descriptorType = i < 3 ? S : I; + } + full_barrier(cmd); // (the scene, drawn into just before) + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.merge); + vkCmdPushDescriptorSetKHR(cmd, VK_PIPELINE_BIND_POINT_COMPUTE, s.merge_layout, 0, 4, w); + vkCmdPushConstants(cmd, s.merge_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, pc); + vkCmdDispatch(cmd, (ow + 7) / 8, (oh + 7) / 8, 1); + full_barrier(cmd); + descriptors_disturbed(); + static bool told; + if (!told) told = true, logf("vk: upscaler: what the game draws into the scene after the engine's pass (the lens flare) is " + "added to the engine's picture (frame %llu)", (unsigned long long)texture_frame_no()); + return s.merged.view; +} + +void temporal_pre_composited(bool drawn) { + State& s = st(); + std::lock_guard lk(s.mu); + s.pre_direct = drawn; + static bool told; + if (drawn && !told) + told = true, logf("vk: upscaler: the game's tone mapping draws at the output's size from the engine's picture (%ux%u), " + "into the upscale's output", s.pre_picture.width, s.pre_picture.height); +} + } // namespace mkwvk diff --git a/gpu/vk/vk_temporal.h b/gpu/vk/vk_temporal.h index d95b400..96499e9 100644 --- a/gpu/vk/vk_temporal.h +++ b/gpu/vk/vk_temporal.h @@ -46,9 +46,41 @@ struct SkinnedDraw { int itype = 0, count = 0, base_vertex = 0; uint64_t bones = 0, bones_size = 0; // (the palette: 3 x 4 row-major matrices, model space to the camera's world) uint64_t object = 0, object_size = 0; // (the object's buffer: its origin at 0x40) + uint64_t camera = 0, camera_size = 0; // (the camera it was drawn with, the vertex stage's buffer 3: its view at 0, projection + // at 0x70. Characters need not be drawn with the scene's: theirs is used for them) uint64_t program = 0; }; -void temporal_note_skinned_draw(const SkinnedDraw& k); +/// nullptr: taken; else why not (vk_draw.cpp's RX_VK_DLSS_TRACE says it) +const char* temporal_note_skinned_draw(const SkinnedDraw& k); + +/// A draw into a scene-sized target whose vertex stage stores its positions (vk_shader.cpp's capture_position): what the +/// motion needs to draw it again from the positions it stored this frame and the frame before (vk_temporal.cpp +/// capture_motion: everything the game moves in its vertex shaders, bones or not) +struct CaptureDraw { + const Texture* depth = nullptr; // (its depth target: only the scene's are drawn again) + uint64_t vbuf = 0; // (vertex stream 0's address: the draw's name across frames, with the rest) + uint64_t ibuf = 0; // (its indices; itype dlss_actor::kNoIndices: none, vertex i is base_vertex + i) + int itype = 0, count = 0, base_vertex = 0; + uint64_t program = 0; + uint64_t camera = 0, camera_size = 0; // (the vertex stage's uniform buffer 3: the camera it is drawn with, its jitter) + VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + bool restart = false; // (primitive restart, as the draw has it) +}; +/// Where such a draw's vertex stage stores its positions: CAPTURE_PUSH_OFFSET's push constants (address 0: nowhere) +struct CaptureSlot { + uint64_t address = 0; + uint32_t first = 0, count = 0; // (the vertex index of the first slot, the slots) +}; +/// The slot for a draw about to be recorded, when the chain wants its positions (*out left zero when not); the draw must be +/// recorded after it, as it is described +void temporal_capture_draw(const CaptureDraw& k, CaptureSlot* out); +/// Whether draws are to store their positions at all now (an engine wanted, RX_VK_DLSS_ACTORS not 0 or bones): a draw +/// that is not asks nothing more +bool temporal_capture_wanted(); + +/// (local, RenoDX port) Whether f is the scene's colour format: the game's B10G11R11, or the RGBA16F the host chose for the +/// run once an upscale's input was RGBA16F +bool temporal_scene_format(VkFormat f); /// A gameplay upscale's dispatch (program `key`; vk_draw.cpp's temporal_stand_in finds them: the 4/3 network fd029a317a9a4b94 /// at the game's usual 3/4, the same-size pass 9dc98871eb7fc101 at full size, and one network of its own for each other @@ -59,6 +91,43 @@ void temporal_note_skinned_draw(const SkinnedDraw& k); bool temporal_upscale(VkCommandBuffer cmd, uint64_t key, bool known, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, uint32_t out_level); +/// NVIDIA DLAA before the game's bloom and tone mapping (RX_VK_DLSS_PRE=0: not). OoT's frame after the scene's last draw: +/// the bloom's first pass samples the scene's colour target, the bloom's pyramid, one draw that adds the bloom and tone +/// maps into another target, and the upscale's dispatch. Each draw (vk_draw.cpp) is asked here with its colour target 0 +/// and its program: true at the first draw after the scene's last (found by its program, as the frame before had it), +/// where temporal_pre_tonemap is then to run, outside a pass. *late: a draw into the scene after the engine drew there, in +/// a frame worth a dump (the first few such frames) +bool temporal_pre_point(const Texture* color0, uint64_t program, bool* late = nullptr); +/// The engine's frame there: the scene's linear HDR colour, the camera's depth and motion in, its picture back into the +/// scene's colour target (returned: it was written), so the bloom and the tone mapping work from the anti-aliased scene. +/// The upscale's dispatch of that frame then only copies (temporal_upscale). nullptr: nothing drawn, the dispatch draws +Texture* temporal_pre_tonemap(VkCommandBuffer cmd); +/// After it, each draw with one colour target (its size): true at the game's tone mapping draw (the first into a target +/// of the scene's size and format that is not the scene: it samples the scene and the bloom) when the engine scaled up. +/// The draw is then to be recorded once more before its own: into k's target at its size, sampling k->to_view (the +/// engine's picture) wherever it samples k->from (the scene), so the tone mapped picture is made at the output's size. +/// Its own recording still follows, for what the game reads of its target (its edge anti-aliasing, its light meter). +/// false: nothing more to do (DLAA: the draw's own target is the picture, taken by the upscale's dispatch) +struct TemporalRetarget { + Texture* target = nullptr; + VkImageView target_view = VK_NULL_HANDLE; + uint32_t width = 0, height = 0; + const Texture* from = nullptr; + VkImageView to_view = VK_NULL_HANDLE; +}; +bool temporal_pre_composite(const Texture* color0, uint32_t width, uint32_t height, TemporalRetarget* k); +/// The upscale's dispatch as AMD FSR 3.1 has it (vk_fsr3.cpp fsr3_upscale; the chain's own engines are asked inside +/// temporal_upscale): true when the output is written, because the picture was drawn before the bloom this frame. In a +/// frame it was not, the point is learnt for the next (learn: this dispatch is known to be the scene's upscale), and false +bool temporal_pre_dispatch(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Texture* out, VkImageView out_view, + uint32_t out_level, bool learn); +/// Before that recording, outside a pass: the view it is to sample in place of k->to_view. The engine's picture, or that +/// with what the game drew into the scene after the engine's pass added (OoT's lens flare is drawn there after the +/// bloom's passes: shaders/dlss_merge.comp), which this records +VkImageView temporal_pre_merged(VkCommandBuffer cmd); +/// Whether that recording drew (not when its pipeline was not ready): the upscale's dispatch then has nothing to copy +void temporal_pre_composited(bool drawn); + /// Once a frame (the game's present): after 120 frames without an upscale by an engine (off, or the upscale not taken) the /// engine's own state, the chain's images and deferred frees are let go, so their video memory comes back. Nothing to do /// costs one atomic load @@ -101,9 +170,10 @@ struct TemporalEngine { bool (*start)(); /// Ready to scale rw x rh into ow x oh, made again when its sizes or settings changed (cmd: what that records). in_w and /// in_h: how large the inputs are to be (the most the render size can be for what it made). 1 ready, 2 ready and made - /// just now (a new history), 0 not this frame (*why: the reason), -1 failed for good (*why too) - int (*prepare)(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, uint32_t* in_w, uint32_t* in_h, - const char** why); + /// just now (a new history), 0 not this frame (*why: the reason), -1 failed for good (*why too). hdr: the colour holds + /// linear HDR values (an RGBA16F scene), not the LDR of TemporalFrame's color + int (*prepare)(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t oh, bool hdr, uint32_t* in_w, + uint32_t* in_h, const char** why); /// Records the frame: false when it failed (for good: the game's upscale from then on) bool (*evaluate)(VkCommandBuffer cmd, const TemporalFrame& f); /// What it made, let go (its feature or context): the chain unused for a while, or another engine chosen. Work in flight diff --git a/gpu/vk/vk_vendor.h b/gpu/vk/vk_vendor.h new file mode 100644 index 0000000..0f676fa --- /dev/null +++ b/gpu/vk/vk_vendor.h @@ -0,0 +1,73 @@ +// (hookshot) Workarounds for one GPU vendor's or driver's behaviour, chosen from the device's properties alone: who made it +// (vendorID), whose driver it runs (driverID, and driverInfo where a driver names its compiler) and what kind of GPU it is. +// vendor_fixes() is plain code with no Vulkan calls, so tests/test_vendor_fixes.py runs it on made-up devices: each fix on +// the GPUs it is for and on no other, and NVIDIA's driver with none of them (the GPU every row of the game was checked on). +// Each one has an RX_VK_ switch to force it on (1) or off (0) on any GPU, to test it where it is not needed. +#pragma once + +#include +#include +#include + +#include + +namespace mkwvk { + +struct VendorFacts { + uint32_t vendor_id = 0; + VkDriverId driver_id{}; + VkPhysicalDeviceType device_type = VK_PHYSICAL_DEVICE_TYPE_OTHER; + const char* driver_info = ""; // (VkPhysicalDeviceDriverProperties::driverInfo) +}; + +struct VendorFixes { + // Out-of-bounds texel fetches answered with zero in the shader (emit_spirv_image.cpp EmitImageFetch). Vulkan leaves such a + // fetch undefined without robustImageAccess, which Hookshot does not turn on; NVIDIA's GPUs (the Switch 2's among them) + // return zero (measured on an RTX 3090: every texture type, past each edge, the last level and the last sample). The ground fog's shader reads depth at points projected off screen near the edges, and on AMD (RX 9070) those + // pixels took the other branch: a pale stepped box at the left, right and top edges. Every GPU but NVIDIA's. RX_VK_FETCH_BOUNDS + bool fetch_bounds = false; + // isnan(x) as a test of x's bits, not OpIsNan (emit_spirv_floating_point.cpp IsNan), for AMD's older Windows shader compiler + // (the driver branch for RDNA 1 and 2, RX 5000 and RX 6000: its driverInfo names the "AMD proprietary shader compiler" where + // the RDNA 3 and 4 driver names LLPC; the test of driverInfo is totk-pc-recomp's vk_caps.c, MIT). Players of OoT ports on + // those cards saw black and white blocks where a NaN test did not hold. The colour outputs' NaN guard is such a test too. + // RX_VK_NAN_BITS + bool nan_bits = false; + // Gathers nudged by 1/512 of a texel, so that the four texels a gather picks match Maxwell's at texel edges + // (emit_spirv_image.cpp ImageGatherSubpixelOffset, Eden's, which Hookshot had never turned on). Eden and Lichii turn it on + // for these drivers (the AMD and Intel ones, and the mobile ones Eden runs on): shadow edges drawn as dashed lines without it. + // RX_VK_GATHER_OFFSET + bool gather_offset = false; +}; + +/// Which of the fixes the device needs (before the RX_VK_ switches: vendor_fixes_env) +inline VendorFixes vendor_fixes(const VendorFacts& f) { + VendorFixes x; + x.fetch_bounds = f.vendor_id != 0x10DE; + x.nan_bits = f.driver_id == VK_DRIVER_ID_AMD_PROPRIETARY && f.driver_info && std::strstr(f.driver_info, "proprietary shader compiler"); + switch (f.driver_id) { + case VK_DRIVER_ID_AMD_PROPRIETARY: + case VK_DRIVER_ID_AMD_OPEN_SOURCE: + case VK_DRIVER_ID_MESA_RADV: + case VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS: + case VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA: + case VK_DRIVER_ID_QUALCOMM_PROPRIETARY: + case VK_DRIVER_ID_MESA_TURNIP: + x.gather_offset = true; + break; + default: + break; + } + return x; +} + +/// The RX_VK_ switches over them: 0 off, anything else on, unset as the device has it. get: getenv, or a test's own +template void vendor_fixes_env(VendorFixes& x, Get get) { + const auto over = [&](const char* name, bool& v) { + if (const char* e = get(name); e && *e) v = std::atoi(e) != 0; + }; + over("RX_VK_FETCH_BOUNDS", x.fetch_bounds); + over("RX_VK_NAN_BITS", x.nan_bits); + over("RX_VK_GATHER_OFFSET", x.gather_offset); +} + +} // namespace mkwvk diff --git a/host/hos_main.c b/host/hos_main.c index d473045..76ca130 100644 --- a/host/hos_main.c +++ b/host/hos_main.c @@ -440,39 +440,6 @@ int hos_oot_is_player(Ctx *c, uint64_t actor) { } #if defined(_WIN32) || defined(__linux__) /* (the debug tools: host/posix has what they call) */ -/* OneShotAddOrRemovePouchContent (f_828d4a70) for one pouch content by actor name: delta > 0 adds, < 0 removes. - Returns the event status (top bits of the result word), or -1 when the pouch is not ready. */ -static int oot_pouch_change(Ctx *c, const char *name, int delta) { - const uint64_t pouch_singleton = recomp_load64(c, 0x84c9e0d0ULL); - const uint64_t state_singleton = recomp_load64(c, 0x84c9e2a8ULL); - const uint64_t actor_db = recomp_load64(c, 0x84eb6888ULL); - const uint64_t actor_info = recomp_load64(c, 0x84e8c060ULL); - A64Fn edit = a64_lookup(0x828d4a70ULL); - if (!edit || !pouch_singleton || !recomp_load64(c, pouch_singleton) || - !state_singleton || !recomp_load64(c, state_singleton) || !actor_db || !actor_info || !delta || - strlen(name) >= 0x60) return -1; - - // OneShotAddOrRemovePouchContent reads the event parameters through pointers. - const Ctx saved = *c; - const uint64_t event = (c->x[31] - 0xe0) & ~0xfULL; - memset(A64_PTR(event), 0, 0xe0); - memcpy(A64_PTR(event + 0x80), name, strlen(name) + 1); - recomp_store64_sp(c, event + 0x20, event + 0x60); - recomp_store64_sp(c, event + 0x30, event + 0x70); - recomp_store64_sp(c, event + 0x38, event + 0x68); - recomp_store64_sp(c, event + 0x48, event + 0x74); - recomp_store64_sp(c, event + 0x50, event + 0x74); - recomp_store64_sp(c, event + 0x60, event + 0x80); - recomp_store64_sp(c, event + 0x68, 0x83f0a6d8ULL); // Script - recomp_store32_sp(c, event + 0x70, (uint32_t)delta); - c->x[31] = event; - c->x[0] = event; - edit(c); - const int result = (int)(recomp_load32(c, event + 0x18) >> 30); - *c = saved; - return result; -} - /* QueryGetPouchContentNumByActorName (f_82a3c260): f_805b63e0(pouch manager, &name, 0, 0) counts one content. */ static int oot_pouch_count(Ctx *c, const char *name) { const uint64_t manager = recomp_load64(c, 0x84e98e28ULL); @@ -490,6 +457,9 @@ static int oot_pouch_count(Ctx *c, const char *name) { return n; } +static int oot_item_get(Ctx *c, const char *name); +static int oot_item_give(Ctx *c, const char *name, int count); + static void oot_edit_pouch(Ctx *c, int action) { static const char *const items[] = { "Item_DekuSeed", "Item_DekuNut", "Item_DekuStick", "Item_Bomb", "Item_Arrow_Normal" @@ -497,8 +467,11 @@ static void oot_edit_pouch(Ctx *c, int action) { const unsigned item = (unsigned)(action - 200) / 32; const int delta = (action - 200) % 32 - 10; if (item >= sizeof items / sizeof items[0] || !delta || delta < -10 || delta > 10) return; - const int result = oot_pouch_change(c, items[item], delta); - if (result >= 0) hos_log("cheats: pouch %s %+d (event status %d)", items[item], delta, result); + const int have = oot_item_get(c, items[item]); + if (have < 0) return; + const int want = have + delta < 0 ? 0 : have + delta > 999 ? 999 : have + delta; + oot_item_give(c, items[item], want); + hos_log("cheats: inventory %s: %d -> %d", items[item], have, want); } /* The Inventory page (gpu/vk/oot_cheat_items.h): counts go to the menu twice a second, edits come back as actions. */ @@ -509,88 +482,39 @@ static const char *const oot_item_names[] = {OOT_CHEAT_ITEMS(OOT_NO_SECTION, OOT static const unsigned char oot_item_kinds[] = {OOT_CHEAT_ITEMS(OOT_NO_SECTION, OOT_ITEM_KIND)}; #define OOT_ITEM_COUNT (sizeof oot_item_names / sizeof oot_item_names[0]) -static int oot_item_count(Ctx *c, const char *name); static int oot_gamedata_bool(Ctx *c, uint32_t hash, int *value); static void oot_inventory_refresh(Ctx *c, int64_t now) { void rx_option_set(int id, int value); static int64_t next; - static int probed; if (now < next) return; next = now + 500000000LL; - int loaded = 0; /* (a save's counts read: the first item's is not -1) */ - for (unsigned i = 0; i < OOT_ITEM_COUNT; i++) { - const int count = oot_item_count(c, oot_item_names[i]); - if (!i) loaded = count >= 0; - rx_option_set(OOT_CHEAT_ITEM_BASE + (int)i, count); - } + /* (a save is loaded once the pouch answers: before that GameData holds a new game's values, shown as unknown) */ + const int loaded = oot_pouch_count(c, oot_item_names[0]) >= 0; + for (unsigned i = 0; i < OOT_ITEM_COUNT; i++) + rx_option_set(OOT_CHEAT_ITEM_BASE + (int)i, loaded ? oot_item_get(c, oot_item_names[i]) : -1); { /* Link's age for the Debug tab's Switch age row: 0 child, 1 adult, -1 no save loaded (Sequence_IsChildhood) */ int child = 1; rx_option_set(OOT_CHEAT_AGE_ID, loaded && oot_gamedata_bool(c, 0xcea220d3u, &child) ? (child ? 0 : 1) : -1); } - if (!probed && oot_pouch_count(c, "Item_DekuSeed") >= 0) { - probed = 1; /* (one line naming every count, both spellings: which names the pouch knows) */ - static const char *const probes[] = {OOT_CHEAT_ITEM_PROBES}; - const unsigned total = (unsigned)(OOT_ITEM_COUNT + sizeof probes / sizeof probes[0]); - char line[512]; - size_t used = 0; - for (unsigned i = 0; i < total; i++) { /* (several short lines: the log cuts long ones) */ - const char *name = i < OOT_ITEM_COUNT ? oot_item_names[i] : probes[i - OOT_ITEM_COUNT]; - used += (size_t)snprintf(line + used, sizeof line - used, " %s=%d", name, oot_pouch_count(c, name)); - if (used > 300 || i + 1 == total) hos_log("cheats: inventory probe:%s", line), used = 0; - } - } -} - -/* Masks share one slot (the Happy Mask Shop lends one at a time). The game takes "Item_Mask_X" when adding one and - may keep it as "Armor_Child_Mask_X", so both spellings count and a new mask first returns the one held. */ -static int oot_mask_alias(const char *name, char *alias, size_t size) { - if (!strncmp(name, "Armor_Child_Mask_", 17)) return snprintf(alias, size, "Item_Mask_%s", name + 17), 1; - return 0; -} - -static int oot_item_count(Ctx *c, const char *name) { - char alias[64]; - const int n = oot_pouch_count(c, name); - if (!oot_mask_alias(name, alias, sizeof alias)) return n; - const int m = oot_pouch_count(c, alias); - return n > m ? n : m; } static void oot_inventory_edit(Ctx *c, int action) { const unsigned item = (unsigned)(action - OOT_CHEAT_ITEM_ACTION) / 256, op = (unsigned)(action - OOT_CHEAT_ITEM_ACTION) % 256; if (item >= OOT_ITEM_COUNT) return; const char *name = oot_item_names[item]; - char alias[64]; - const int is_mask = oot_mask_alias(name, alias, sizeof alias); - const int have = oot_item_count(c, name); - int delta = 0; - if (op == 200) delta = have > 0 ? -have : 1; /* unlock / relock */ - else if (op < 128) delta = (int)op - 64; - if (!delta || have < 0) return; - if (is_mask && delta > 0) { /* return whichever mask is in the slot first */ - for (unsigned i = 0; i < OOT_ITEM_COUNT; i++) { - char other_alias[64]; - if (i == item || !oot_mask_alias(oot_item_names[i], other_alias, sizeof other_alias)) continue; - const char *spellings[2] = {oot_item_names[i], other_alias}; - for (unsigned k = 0; k < 2; k++) { - const int held = oot_pouch_count(c, spellings[k]); - if (held > 0) hos_log("cheats: inventory returned %s (status %d)", spellings[k], oot_pouch_change(c, spellings[k], -held)); - } - } - delta = 1; + const int have = oot_item_get(c, name); + if (have < 0) { + hos_log("cheats: inventory %s: the game's save data has no such item", name); + return; } - int result = -1; - if (is_mask && delta < 0) { /* remove under whichever spelling holds it */ - const char *spellings[2] = {name, alias}; - for (unsigned k = 0; k < 2; k++) { - const int held = oot_pouch_count(c, spellings[k]); - if (held > 0) result = oot_pouch_change(c, spellings[k], -held); - } - } else { - result = oot_pouch_change(c, is_mask ? alias : name, delta); /* (masks are added as Item_Mask_X, as the shop does) */ - } - hos_log("cheats: inventory %s %+d (had %d, now %d, event status %d)", name, delta, have, oot_item_count(c, name), result); + int want = have; + if (op == 200) want = have > 0 ? 0 : 1; /* unlock / relock */ + else if (op < 128) want = have + (int)op - 64; + want = want < 0 ? 0 : want > 999 ? 999 : want; + if (want == have) return; + oot_item_give(c, name, want); + hos_log("cheats: inventory %s: %d -> %d", name, have, want); } static void oot_set_time(Ctx *c, unsigned hour) { @@ -758,8 +682,50 @@ static struct { unsigned destination; } teleport; +/* (Triforce, lab) The pipeline crawl's commands, from the live input file (host/nn_hid.c). "!banc + [child|adult]" asks for a map change to any map by its names, as the game's own entrance actors do (the names are in the + maps' files: Banc/GameBancParam, the StartPos actors, the entrance actors' NextEventName); "!pos " puts Link + there with his controller's ChangePosition, and holds him there after "!hold 1" (no falling between two places); + "!where" says the map, whether it loads, whether an event plays and where Link is. D:\src\lab\hookshot\crawl drives + them to draw every map's actors once, for the pipeline list; nothing sends them in play. */ +static struct { + SRWLOCK lock; + char banc[96], start[96], boot[128], go[96]; /* (go: the leaving event, "" the usual Dm_SY_BancChangeGo) */ + int banc_pending, age; /* (age: -1 as it is, 0 adult, 1 child) */ + float pos[3]; + int pos_pending, hold, where; + int64_t retry_at; + char give[96]; /* ("!give ": the Inventory page's edit by name, for the lab) */ + int give_delta, give_pending; +} crawl = {SRWLOCK_INIT}; +static const char *crawl_banc, *crawl_start, *crawl_boot, *crawl_go; /* (set while oot_teleport serves a "!banc") */ +void hos_oot_live_crawl(const char *line) { + AcquireSRWLockExclusive(&crawl.lock); + char age[16] = ""; + float x, y, z; + int on; + if (!strncmp(line, "!banc ", 6)) { + crawl.go[0] = 0; /* ("!banc [child|adult|keep []]") */ + if (sscanf(line + 6, "%95s %95s %127s %15s %95s", crawl.banc, crawl.start, crawl.boot, age, crawl.go) >= 3) { + crawl.age = !strcmp(age, "child") ? 1 : !strcmp(age, "adult") ? 0 : -1; + crawl.banc_pending = 1, crawl.retry_at = 0; + } + } else if (!strncmp(line, "!pos ", 5)) { + if (sscanf(line + 5, "%f %f %f", &x, &y, &z) == 3) crawl.pos[0] = x, crawl.pos[1] = y, crawl.pos[2] = z, crawl.pos_pending = 1; + } else if (!strncmp(line, "!hold ", 6)) { + if (sscanf(line + 6, "%d", &on) == 1) crawl.hold = on != 0; + } else if (!strncmp(line, "!where", 6)) { + crawl.where = 1; + } else if (!strncmp(line, "!give ", 6)) { + if (sscanf(line + 6, "%95s %d", crawl.give, &crawl.give_delta) == 2) crawl.give_pending = 1; + } else if (!strncmp(line, "!items", 6)) { + crawl.give_pending = 2; + } + ReleaseSRWLockExclusive(&crawl.lock); +} + static int oot_teleport(Ctx *c, uint64_t actor, unsigned index) { - if (index >= sizeof oot_destinations / sizeof oot_destinations[0]) return 0; + if (!crawl_banc && index >= sizeof oot_destinations / sizeof oot_destinations[0]) return 0; const int64_t now = hos_now_ns(); if (teleport.requested_at && now - teleport.requested_at < 8000000000LL) { hos_log("cheats: teleport ignored, a request is still in progress"); @@ -782,10 +748,11 @@ static int oot_teleport(Ctx *c, uint64_t actor, unsigned index) { return 0; } if (!oot_gamedata_bool(c, 0xcea220d3u, &child)) hos_log("cheats: Sequence_IsChildhood not found, using child maps"); - const OotDestination *d = &oot_destinations[index]; + const OotDestination *d = &oot_destinations[crawl_banc ? 0 : index]; const char *banc = child ? d->child_banc : d->adult_banc; const char *start = child ? d->child_start : d->adult_start; const char *boot = child ? d->child_boot : d->adult_boot; + if (crawl_banc) banc = crawl_banc, start = crawl_start, boot = crawl_boot; /* (the crawl's "!banc": any map) */ if (!banc) { hos_log("cheats: teleport %u has no %s map", index, child ? "child" : "adult"); return 0; @@ -802,6 +769,7 @@ static int oot_teleport(Ctx *c, uint64_t actor, unsigned index) { const char *event_env = getenv("HOS_OOT_TELEPORT_EVENT"); const char *event = event_env && *event_env ? event_env : "Dm_SY_BancChangeGo"; + if (crawl_banc && crawl_go && *crawl_go) event = crawl_go; /* (the crawl: the leaving event some maps' own exits use) */ const char *starter_env = getenv("HOS_OOT_TELEPORT_STARTER"); const int with_starter = !(starter_env && !strcmp(starter_env, "0")); @@ -842,12 +810,14 @@ static int oot_teleport(Ctx *c, uint64_t actor, unsigned index) { release_link(c); } *c = saved; - teleport.requested_at = now; - teleport.check_at = now + 1500000000LL; + const int refused = crawl_banc && (!ok || !result); /* (the crawl: asked again soon, not after the 8 s of a request under way) */ + teleport.requested_at = refused ? 0 : now; + teleport.check_at = refused ? 0 : now + 1500000000LL; teleport.destination = index; hos_log("cheats: teleport %s to %s at %s (boot %s, event %s, starter %d): request %s, result %#llx", child ? "child" : "adult", banc, start, boot, event, with_starter, ok ? "sent" : "not built", (unsigned long long)result); + if (crawl_banc) return ok && result != 0; /* (the crawl asks again until the event manager takes the request) */ return ok; /* (sent; the request's own result is only logged) */ } @@ -871,6 +841,180 @@ static int oot_gamedata_set_bool(Ctx *c, uint32_t hash, int value) { return 0; } +/* ---- (Triforce, 11-13) The inventory in GameData ---- + The items are GameData: struct "Pouch" (0x3da094e3) has a struct for each item, whose member "Stock" (0x22344481) is an + Int, the item's count; struct 0xade0ef78 has a Bool for each item, "got it once". The names' hashes are MurmurHash3 + (seed 0), as the game's getters take them. Layout and setters as tangerineturtle1/NX2navi's co-op reads and writes + them (runtime/coop_game.c, MIT): the Int container at GameDataMgr+0xc8 (count +8, entries +0x10, the (hash, index) + table +0x18, its size +0x24; 40-byte entries, the current value at +0x1c), the structs' table at +0xc10 (count, + +8 entries of 32 bytes, +0x10 table, +0x1c size; an entry's members: +8 a table of (member hash, value hash) pairs, + +0x14 its size). Writes go through the game's own SetInt (0x80183b70) and SetBool (0x806a2b20; NX2navi names them from main, which is at 0x80020000 here): x0 the manager, x1 the + value, x2 the hash. They queue the change, and the game's per-frame drain writes the current and the saved value and + does its own bookkeeping, as for a change the game made. The event the Inventory page called before + (OneShotAddOrRemovePouchContent) answered "done" and added nothing, outside an event of the game's own. */ +static uint32_t oot_murmur3(const char *text) { + const size_t n = strlen(text); + uint32_t h = 0; + size_t i = 0; + for (; i + 4 <= n; i += 4) { + uint32_t k; + memcpy(&k, text + i, 4); + k *= 0xcc9e2d51u, k = k << 15 | k >> 17, k *= 0x1b873593u; + h ^= k, h = h << 13 | h >> 19, h = h * 5 + 0xe6546b64u; + } + uint32_t k = 0; + switch (n & 3) { + case 3: k ^= (uint32_t)(uint8_t)text[i + 2] << 16; /* fall through */ + case 2: k ^= (uint32_t)(uint8_t)text[i + 1] << 8; /* fall through */ + case 1: k ^= (uint8_t)text[i], k *= 0xcc9e2d51u, k = k << 15 | k >> 17, k *= 0x1b873593u, h ^= k; + } + h ^= (uint32_t)n; + h ^= h >> 16, h *= 0x85ebca6bu, h ^= h >> 13, h *= 0xc2b2ae35u, h ^= h >> 16; + return h; +} + +/* the index a (hash, index) table of size cells gives for hash, -1 none (open addressing from hash % size) */ +static int64_t oot_gd_lookup(Ctx *c, uint64_t table, uint32_t size, uint32_t hash) { + if (!table || !size || size > (1u << 22) || !hash) return -1; + for (uint32_t probe = 0, slot = hash % size; probe < size; probe++, slot = slot + 1 == size ? 0 : slot + 1) { + const uint32_t key = recomp_load32(c, table + slot * 8ULL); + if (!key) return -1; + if (key == hash) return recomp_load32(c, table + slot * 8ULL + 4); + } + return -1; +} + +/* a struct's entry by its hash, 0 none */ +static uint64_t oot_gd_struct(Ctx *c, uint64_t mgr, uint32_t hash) { + const int64_t i = oot_gd_lookup(c, recomp_load64(c, mgr + 0xc20), recomp_load32(c, mgr + 0xc2c), hash); + const uint64_t entries = recomp_load64(c, mgr + 0xc18); + return i < 0 || !entries || (uint64_t)i >= recomp_load32(c, mgr + 0xc10) ? 0 : entries + (uint64_t)i * 0x20; +} + +/* the value hash of a struct's member, 0 none (the members' table is searched whole: a few dozen pairs) */ +static uint32_t oot_gd_member(Ctx *c, uint64_t entry, uint32_t member) { + const uint64_t table = entry ? recomp_load64(c, entry + 8) : 0; + const uint32_t size = entry ? recomp_load32(c, entry + 0x14) : 0; + if (!table || !size || size > 65536) return 0; + for (uint32_t i = 0; i < size; i++) + if (recomp_load32(c, table + 8ULL * i) == member) return recomp_load32(c, table + 8ULL * i + 4); + return 0; +} + +/* an Int's entry by its hash, 0 none */ +static uint64_t oot_gd_int(Ctx *c, uint64_t mgr, uint32_t hash) { + const int64_t i = oot_gd_lookup(c, recomp_load64(c, mgr + 0xc8 + 0x18), recomp_load32(c, mgr + 0xc8 + 0x24), hash); + const uint64_t entries = recomp_load64(c, mgr + 0xc8 + 0x10); + return i < 0 || !entries || (uint64_t)i >= recomp_load32(c, mgr + 0xc8 + 8) ? 0 : entries + (uint64_t)i * 0x28; +} + +/* the hash of an item's count (its Pouch struct's Stock), 0 when the Pouch has no such item */ +static uint32_t oot_item_stock_hash(Ctx *c, uint64_t mgr, const char *name) { + const uint32_t item = oot_gd_member(c, oot_gd_struct(c, mgr, 0x3da094e3u), oot_murmur3(name)); + return item ? oot_gd_member(c, oot_gd_struct(c, mgr, item), 0x22344481u) : 0; +} + +/* the game's own SetInt / SetBool: 1 when called */ +static int oot_gd_set(Ctx *c, uint64_t mgr, uint32_t hash, uint32_t value, int is_bool) { + A64Fn set = a64_lookup(is_bool ? 0x806a2b20ULL : 0x80183b70ULL); + if (!set || !mgr || !hash) return 0; + const Ctx saved = *c; + c->x[31] = (c->x[31] - 0x100) & ~0xfULL; + c->x[0] = mgr, c->x[1] = value, c->x[2] = hash; + set(c); + *c = saved; + return 1; +} + +/* a Bool's entry by its hash, 0 none (24-byte entries, the current value at +22, as oot_gamedata_set_bool has them) */ +static uint64_t oot_gd_bool(Ctx *c, uint64_t mgr, uint32_t hash) { + const int64_t i = oot_gd_lookup(c, recomp_load64(c, mgr + 32), recomp_load32(c, mgr + 44), hash); + const uint64_t entries = recomp_load64(c, mgr + 24); + return i < 0 || !entries || (uint64_t)i >= recomp_load32(c, mgr + 16) ? 0 : entries + (uint64_t)i * 24; +} + +/* An item's count as GameData has it: its Pouch struct's Stock, or 1 / 0 of its "got it once" flag where it has only + that (the songs). -1: the save data has no such item */ +static int oot_item_get(Ctx *c, const char *name) { + const uint64_t mgr = oot_singleton(c, OOT_GAMEDATA_SLOT); + if (!mgr) return -1; + const uint32_t stock = oot_item_stock_hash(c, mgr, name); + uint64_t entry = stock ? oot_gd_int(c, mgr, stock) : 0; + if (entry) return (int)recomp_load32(c, entry + 0x1c); + const uint32_t first = oot_gd_member(c, oot_gd_struct(c, mgr, 0xade0ef78u), oot_murmur3(name)); + entry = first ? oot_gd_bool(c, mgr, first) : 0; + return entry ? recomp_load8(c, entry + 22) & 1 : -1; +} + +/* What the bags hold, as the game's files have it (each bag's GameParameter/ExpansionMaxNumActor: "GameData" the name of + the size in the capacity struct 0xf80f8077, "MaxNum" the size). The game raises the size when it gives a bag; a bag or + ammunition set from here does the same, so that what is given can be carried and used. */ +static const struct { const char *bag, *what; int max; } oot_bags[] = { + {"Item_BombBag_Small", "Bomb", 20}, {"Item_BombBag_Medium", "Bomb", 30}, {"Item_BombBag_Large", "Bomb", 40}, + {"Item_Quiver_Small", "Arrow", 30}, {"Item_Quiver_Medium", "Arrow", 40}, {"Item_Quiver_Large", "Arrow", 50}, + {"Item_BulletBag_Small", "DekuSeed", 30}, {"Item_BulletBag_Medium", "DekuSeed", 40}, {"Item_BulletBag_Large", "DekuSeed", 50}, + {"Item_NutBag_Small", "DekuNut", 20}, {"Item_NutBag_Medium", "DekuNut", 30}, {"Item_NutBag_Large", "DekuNut", 40}, + {"Item_StickBag_Small", "DekuStick", 10}, {"Item_StickBag_Medium", "DekuStick", 20}, {"Item_StickBag_Large", "DekuStick", 30}, + {"Item_Wallet_Medium", "Rupee", 500}, {"Item_Wallet_Large", "Rupee", 1000}, +}; +static const struct { const char *item, *what; } oot_ammo[] = { + {"Item_Bomb", "Bomb"}, {"Item_Bombchu", "Bomb"}, {"Item_Arrow_Normal", "Arrow"}, {"Item_DekuSeed", "DekuSeed"}, + {"Item_DekuNut", "DekuNut"}, {"Item_DekuStick", "DekuStick"}, +}; +#define OOT_BAGS (sizeof oot_bags / sizeof oot_bags[0]) + +/* a size of the capacity struct: its Int's hash (0 none), and its value now through *value */ +static uint32_t oot_capacity(Ctx *c, uint64_t mgr, const char *what, int *value) { + const uint32_t hash = oot_gd_member(c, oot_gd_struct(c, mgr, 0xf80f8077u), oot_murmur3(what)); + const uint64_t entry = hash ? oot_gd_int(c, mgr, hash) : 0; + if (value) *value = entry ? (int)recomp_load32(c, entry + 0x1c) : 0; + return entry ? hash : 0; +} + +/* a count of the Pouch set (and the item marked as got once), 1 when the Pouch has the item */ +static int oot_pouch_set(Ctx *c, uint64_t mgr, const char *name, int count) { + const uint32_t stock = oot_item_stock_hash(c, mgr, name); + if (!stock || !oot_gd_int(c, mgr, stock)) return 0; + oot_gd_set(c, mgr, stock, (uint32_t)(count < 0 ? 0 : count), 0); + const uint32_t first = oot_gd_member(c, oot_gd_struct(c, mgr, 0xade0ef78u), oot_murmur3(name)); + if (count > 0 && first) oot_gd_set(c, mgr, first, 1, 1); /* ("got it once": as the game marks what was got) */ + return 1; +} + +/* An item's count set, through the game's own setters: 1 done, 0 the save data has no such item */ +static int oot_item_give(Ctx *c, const char *name, int count) { + const uint64_t mgr = oot_singleton(c, OOT_GAMEDATA_SLOT); + if (!mgr) return 0; + for (unsigned i = 0; i < OOT_BAGS; i++) { /* a bag: the size it gives, or without it the largest bag left */ + if (strcmp(name, oot_bags[i].bag)) continue; + int size = 0, best = count > 0 ? oot_bags[i].max : !strcmp(oot_bags[i].what, "Rupee") ? 200 : 0; + const uint32_t hash = oot_capacity(c, mgr, oot_bags[i].what, &size); + for (unsigned k = 0; k < OOT_BAGS; k++) + if (k != i && !strcmp(oot_bags[k].what, oot_bags[i].what) && oot_bags[k].max > best && oot_item_get(c, oot_bags[k].bag) > 0) + best = oot_bags[k].max; + if (hash && best != size) oot_gd_set(c, mgr, hash, (uint32_t)best, 0); + } + for (unsigned i = 0; count > 0 && i < sizeof oot_ammo / sizeof oot_ammo[0]; i++) { /* ammunition: a bag that holds it */ + if (strcmp(name, oot_ammo[i].item)) continue; + int size = 0, fits = -1, largest = -1; + const uint32_t hash = oot_capacity(c, mgr, oot_ammo[i].what, &size); + for (unsigned k = 0; k < OOT_BAGS; k++) { + if (strcmp(oot_bags[k].what, oot_ammo[i].what)) continue; + if (largest < 0 || oot_bags[k].max > oot_bags[largest].max) largest = (int)k; + if (oot_bags[k].max >= count && (fits < 0 || oot_bags[k].max < oot_bags[fits].max)) fits = (int)k; + } + if (largest >= 0 && count > oot_bags[largest].max) count = oot_bags[largest].max, fits = largest; + if (hash && fits >= 0 && count > size) { + oot_pouch_set(c, mgr, oot_bags[fits].bag, 1); + oot_gd_set(c, mgr, hash, (uint32_t)oot_bags[fits].max, 0); + } + } + if (oot_pouch_set(c, mgr, name, count)) return 1; + const uint32_t first = oot_gd_member(c, oot_gd_struct(c, mgr, 0xade0ef78u), oot_murmur3(name)); + if (first && oot_gd_bool(c, mgr, first)) return oot_gd_set(c, mgr, first, count > 0, 1); /* (a song: its flag) */ + return 0; +} + /* Age toggle: flips Sequence_IsChildhood (what the Temple of Time event sets) and reloads the current map, or the Market when this map is not in oot_destinations, through the teleport so the other age's map and Link load. */ static void oot_toggle_age(Ctx *c, uint64_t actor) { @@ -959,7 +1103,94 @@ static void oot_update_player_cheats(Ctx *c, uint64_t actor, uint64_t components } else if (action >= 100 && action < 124) { oot_set_time(c, action - 100); } - if (!flying && action != 2 && action != 3) return; + /* (Triforce, lab) the crawl's commands: see crawl above */ + static float crawl_target[3]; + static int crawl_holding; + static uint64_t crawl_actor; + int crawl_goto = 0; + { + char b[96], s[96], e[128], g[96]; + int try_banc = 0, age = -1, where = 0, hold; + AcquireSRWLockExclusive(&crawl.lock); + if (crawl.banc_pending && now >= crawl.retry_at) { + memcpy(b, crawl.banc, sizeof b), memcpy(s, crawl.start, sizeof s), memcpy(e, crawl.boot, sizeof e); + memcpy(g, crawl.go, sizeof g); + age = crawl.age, try_banc = 1; + } + if (crawl.pos_pending) crawl.pos_pending = 0, memcpy(crawl_target, crawl.pos, sizeof crawl_target), crawl_goto = 1; + where = crawl.where, crawl.where = 0; + hold = crawl.hold; + char give[96] = ""; + int give_delta = 0; +const int give_pending = crawl.give_pending; + if (give_pending) crawl.give_pending = 0, memcpy(give, crawl.give, sizeof give), give_delta = crawl.give_delta; + ReleaseSRWLockExclusive(&crawl.lock); + if (give_pending == 1 && give[0]) { + const int had = oot_item_get(c, give); + const int done = had >= 0 && oot_item_give(c, give, had + give_delta); + hos_log("cheats: crawl: give %s %+d: GameData had %d (-1: no such item), the pouch %d: %s", give, give_delta, had, + oot_pouch_count(c, give), done ? "set" : "not set"); + } + if (give_pending == 2) { /* ("!items": every item of the Inventory page as the pouch and GameData have it) */ + const uint64_t mgr = oot_singleton(c, OOT_GAMEDATA_SLOT); + const uint64_t pouch = mgr ? oot_gd_struct(c, mgr, 0x3da094e3u) : 0; + hos_log("cheats: crawl: items: manager %#llx (the other holder: %#llx), Pouch struct %#llx with %u member cells, %u Ints", + (unsigned long long)mgr, (unsigned long long)recomp_load64(c, 0x84ea42a8ULL), (unsigned long long)pouch, + pouch ? recomp_load32(c, pouch + 0x14) : 0, mgr ? recomp_load32(c, mgr + 0xc8 + 8) : 0); + char line[400], num[16]; + size_t used = 0; + for (unsigned i = 0; mgr && i < OOT_ITEM_COUNT; i++) { + snprintf(num, sizeof num, "%d", oot_item_get(c, oot_item_names[i])); + used += (size_t)snprintf(line + used, sizeof line - used, " %s=%d/%s", oot_item_names[i], + oot_pouch_count(c, oot_item_names[i]), num); + if (used > 280 || i + 1 == OOT_ITEM_COUNT) hos_log("cheats: crawl: items (pouch/GameData):%s", line), used = 0; + } + /* (the member hashes of the Pouch and of the "got it once" struct: which names the game has, by MurmurHash3) */ + static const uint32_t dumps[3] = {0x3da094e3u, 0xade0ef78u, 0xf80f8077u}; + for (unsigned d = 0; mgr && d < 3; d++) { + const uint64_t e = oot_gd_struct(c, mgr, dumps[d]); + const uint64_t table = e ? recomp_load64(c, e + 8) : 0; + const uint32_t size = e ? recomp_load32(c, e + 0x14) : 0; + used = 0; + for (uint32_t i = 0; table && size <= 65536 && i < size; i++) { + const uint32_t m = recomp_load32(c, table + 8ULL * i); + const uint64_t cap = m && d == 2 ? oot_gd_int(c, mgr, recomp_load32(c, table + 8ULL * i + 4)) : 0; + if (m && d == 2) used += (size_t)snprintf(line + used, sizeof line - used, " %08x=%d", m, cap ? (int)recomp_load32(c, cap + 0x1c) : -1); + else if (m) used += (size_t)snprintf(line + used, sizeof line - used, " %08x", m); + if (used > 280 || (i + 1 == size && used)) hos_log("cheats: crawl: members %08x:%s", dumps[d], line), used = 0; + } + } + } + if (try_banc) { + int child = 1; + const int known = oot_gamedata_bool(c, 0xcea220d3u, &child); /* Sequence_IsChildhood */ + const int flip = known && age >= 0 && age != child; + if (flip) oot_gamedata_set_bool(c, 0xcea220d3u, age); + crawl_banc = b, crawl_start = s, crawl_boot = e, crawl_go = g; + const int ok = oot_teleport(c, actor, 0); + crawl_banc = NULL; + if (!ok && flip) oot_gamedata_set_bool(c, 0xcea220d3u, child); + AcquireSRWLockExclusive(&crawl.lock); + if (ok) crawl.banc_pending = 0; + else crawl.retry_at = now + 2000000000LL; + ReleaseSRWLockExclusive(&crawl.lock); + if (ok) crawl_holding = 0, crawl_goto = 0; + } + if (where) { + char current[80]; + int loading = 0, child = 1; + oot_gamedata_string(c, 0x1d6189dau, current, sizeof current); /* Sequence_CurrentBanc */ + oot_gamedata_bool(c, 0xef2b60c2u, &loading); /* Sequence_IsLoadingBanc */ + oot_gamedata_bool(c, 0xcea220d3u, &child); + const uint64_t events = oot_singleton(c, OOT_EVENTMGR_SLOT); + hos_log("cheats: crawl: where: map \"%s\" loading %d event %d child %d pos %.1f %.1f %.1f", current, loading, + events && recomp_load64(c, events + 104) ? 1 : 0, child, oot_load_float(c, actor + 796), + oot_load_float(c, actor + 800), oot_load_float(c, actor + 804)); + } + if (crawl_goto) crawl_holding = hold, crawl_actor = actor; + if (!hold || crawl_actor != actor) crawl_holding = 0; /* (another Link: another map) */ + } + if (!flying && action != 2 && action != 3 && !crawl_goto && !crawl_holding) return; // Follow OneShotPhysicsCctChangePosition to Link's controller. const unsigned offsets[] = {80, 32, 16, 8}; @@ -982,6 +1213,25 @@ static void oot_update_player_cheats(Ctx *c, uint64_t actor, uint64_t components marked_controller = controller; hos_log("cheats: marked position %.2f %.2f %.2f", mark[0], mark[1], mark[2]); } + if (crawl_goto || (crawl_holding && !flying)) { /* (the crawl: Link put at its place, and kept there while held) */ + const Ctx saved = *c; + const uint64_t arg = c->x[31] - 16; + for (unsigned i = 0; i < 3; i++) { + uint32_t bits; + memcpy(&bits, &crawl_target[i], sizeof bits); + recomp_store32_sp(c, arg + i * 4, bits); + } + recomp_store32_sp(c, arg + 12, 0); + c->x[31] = arg; + c->x[0] = controller; + c->x[1] = arg; + change_position(c); + *c = saved; + if (crawl_goto) + hos_log("cheats: crawl: Link put at %.1f %.1f %.1f%s", crawl_target[0], crawl_target[1], crawl_target[2], + crawl_holding ? ", held" : ""); + if (!flying && action != 2 && action != 3) return; + } const int returning = action == 3 && marked_controller == controller; if (action == 3 && !returning) hos_log("cheats: no mark for this player controller"); if (!flying && !returning) return; diff --git a/host/hos_update.c b/host/hos_update.c index f51ee91..a791ee5 100644 --- a/host/hos_update.c +++ b/host/hos_update.c @@ -27,9 +27,12 @@ static int safe_tag(const char *s) { #include #include -#define UPDATE_HOST L"api.github.com" -#define UPDATE_PATH L"/repos/ruckus7382sfgsgdf/CBeta0.2/releases?per_page=1" /* (the newest, pre-releases too: /latest skips them) */ -#define RELEASES_PAGE L"https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases" +/* (11-13: Triforce's own home, as setup/Setup.cs Program.ReleaseApi: the release list of triforce/downloads on its Forgejo, + asked on the main domain. Up to v0.3.5: api.github.com, /repos/ruckus7382sfgsgdf/CBeta0.2/releases?per_page=1. The Linux + lines below ask the same list) */ +#define UPDATE_HOST L"triforceproject.com" +#define UPDATE_PATH L"/api/v1/repos/triforce/downloads/releases?limit=1" /* (the newest, pre-releases too) */ +#define RELEASES_PAGE L"https://triforceproject.com" /* (a line "name=value" of a small text file, in UTF-8: its value, trimmed) */ static int read_value(const wchar_t *path, const char *name, char *out, size_t cap) { @@ -54,7 +57,7 @@ static int read_value(const wchar_t *path, const char *name, char *out, size_t c return found; } -/* (the latest release's tag, from GitHub's API: "tag_name":"...") */ +/* (the latest release's tag, from the release list (Forgejo's, GitHub's before): "tag_name":"...") */ static int latest_tag(char *tag, size_t cap) { int ok = 0; HINTERNET s = WinHttpOpen(L"Triforce-update-check", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); @@ -228,12 +231,15 @@ static int pipe_tag(const char *cmd, char *tag, size_t cap) { } static int latest_tag(char *tag, size_t cap) { - if (pipe_tag("curl -fsSL --max-time 4 --retry 2 -A Triforce-update-check " - "-H \"Accept: application/vnd.github+json\" " - "https://api.github.com/repos/ruckus7382sfgsgdf/CBeta0.2/releases/latest 2>/dev/null", tag, cap)) + /* (11-13: Triforce's own home, as on Windows above: the newest release of triforce/downloads, pre-releases too. The list + of one release starts {"id":..,"tag_name":"..": pipe_tag finds the tag in its first bytes. The second address is the + same list asked of the Forgejo itself, should the main domain not pass it on. Up to v0.3.5 this asked GitHub's + /releases/latest, which skips pre-releases, and every Triforce release is one: no Linux game was ever told of an update) */ + if (pipe_tag("curl -fsSL --max-time 4 --retry 2 -A Triforce-update-check -H \"Accept: application/json\" " + "\"https://triforceproject.com/api/v1/repos/triforce/downloads/releases?limit=1\" 2>/dev/null", tag, cap)) return 1; - return pipe_tag("curl -fsSL --max-time 8 --retry 2 -A Triforce-update-check " - "https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases/latest/download/triforce-linux.txt 2>/dev/null", tag, cap); + return pipe_tag("curl -fsSL --max-time 8 --retry 2 -A Triforce-update-check -H \"Accept: application/json\" " + "\"https://git.triforceproject.com/api/v1/repos/triforce/downloads/releases?limit=1\" 2>/dev/null", tag, cap); } /* the builder an update installed (builder/linux/linux_update.py): /triforce/builder/versions//AppRun. The @@ -305,7 +311,7 @@ void hos_update_check(void) { if (strncmp(answer, "Update", 6)) return; if (!has_builder) { if (fork() == 0) { - execlp("xdg-open", "xdg-open", "https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases", (char *)0); + execlp("xdg-open", "xdg-open", "https://triforceproject.com", (char *)0); _exit(127); } return; diff --git a/host/mkw_glue.c b/host/mkw_glue.c index ad8d00a..51657bd 100644 --- a/host/mkw_glue.c +++ b/host/mkw_glue.c @@ -43,7 +43,7 @@ DWORD WINAPI hos_out_of_memory_box(LPVOID unused) { "Windows has run out of memory (RAM plus the page file), so Triforce may close.\n\n" "Close other programs, and in Windows' System > About > Advanced system settings > Performance > Advanced > Virtual " "memory, choose \"Automatically manage paging file size\" (or give it at least 16 GB). A lower Quality preset in the " - "Insert menu also uses less memory.", + "game's Options (the Graphics tab) also uses less memory.", "Triforce: out of memory", MB_OK | MB_ICONWARNING | MB_TOPMOST); return 0; } diff --git a/host/nn_applet.c b/host/nn_applet.c index 7e582ff..4d98ecf 100644 --- a/host/nn_applet.c +++ b/host/nn_applet.c @@ -147,7 +147,10 @@ uint64_t hos_rt_pool_size(uint64_t game) { const uint64_t scaled = px > 2560 * 1440 ? (game * px / (2560 * 1440) + 0xfffff) & ~0xfffffULL : game; const uint64_t minimum = 512ULL << 20, five_k = 900ULL << 20; const int is_five_k = hos_output_size(0) == 5120 && hos_output_size(1) == 2880; - const uint64_t v = e ? strtoull(e, NULL, 0) << 20 : scaled < minimum ? minimum : is_five_k && scaled > five_k ? five_k : scaled; + extern int hos_scene_rgba16f(void); + /* (local, RenoDX port) the scene's colour target at 8 bytes a pixel in place of 4: room for it and its copies, at 3840 x 2160 33 MB each */ + const uint64_t rgba16f = hos_scene_rgba16f() ? 128ULL << 20 : 0; + const uint64_t v = (e ? strtoull(e, NULL, 0) << 20 : scaled < minimum ? minimum : is_five_k && scaled > five_k ? five_k : scaled) + (e ? 0 : rgba16f); static int logged; if (!logged++) hos_log("applet: render target pool %llu MB (the game's %llu MB)", (unsigned long long)(v >> 20), (unsigned long long)(game >> 20)); return v; diff --git a/host/nn_audio_in.c b/host/nn_audio_in.c index de2172a..5e1eddb 100644 --- a/host/nn_audio_in.c +++ b/host/nn_audio_in.c @@ -25,6 +25,7 @@ #include #define WIN32_LEAN_AND_MEAN #include +#include #define MIC_MAGIC 0x4D494349u /* "MICI": the high word of our handle in the game's InputStreamType */ #define MAX_STREAMS 4 @@ -184,7 +185,9 @@ static void lost(Source *src, int64_t now, const char *why) { missed(src, now, why); } /* the wanted microphone opened; a named one that cannot be: the default stands in */ +static const char *mic_test_file(void); static void connect(Source *src) { + if (mic_test_file()) return; /* (lab, HOS_MIC_TEST: no device, the test sound below) */ const int64_t now = hos_now_ns(); if (src->mode <= 0) { close_mic(src, now); @@ -231,10 +234,64 @@ static void choose(Source *src) { if (mode <= 0) hos_log("audio in: the microphone is off in the menu: silence"); connect(src); } +/* (lab, 11-13) HOS_MIC_TEST=: no microphone is opened; what the game hears is what that file says, read again + every half second, so a run can go from silence to sound and back: "0" (or no file) silence, "noise " white + noise, "tone " a hummed note with a little noise on it (amp 0..1 of full scale; 16-bit streams only). + For the report of fps falling "as soon as the mic picks up noise": measured in the lab without a microphone */ +static const char *mic_test_file(void) { + static const char *f; + static int read_it; + if (!read_it) f = getenv("HOS_MIC_TEST"), read_it = 1; + return f && *f ? f : NULL; +} +static void test_push(Source *src, int frames) { + static int kind; /* 0 silence, 1 noise, 2 tone */ + static double hz, amp, phase; + static uint32_t seed = 0x1234567u; + static int64_t next_read; + const int64_t now = hos_now_ns(); + if (now >= next_read) { + char line[64] = ""; + next_read = now + 500000000LL; + FILE *f = fopen(mic_test_file(), "r"); + if (f) { + if (!fgets(line, sizeof line, f)) line[0] = 0; + fclose(f); + } + int k = 0; + double a = 0, h = 0; + if (sscanf(line, "noise %lf", &a) == 1) k = 1; + else if (sscanf(line, "tone %lf %lf", &h, &a) == 2) k = 2; + if (k != kind || a != amp || h != hz) hos_log("audio in: test microphone: %s", k ? line : "silence"); + kind = k, amp = a, hz = h; + } + if (!kind || src->format != FMT_PCM16) { + push_all(src, NULL, frames * src->frame_bytes); + return; + } + int16_t buf[1024]; + const int ch = src->channels > 0 ? src->channels : 1; + while (frames > 0) { + const int n = frames < 1024 / ch ? frames : 1024 / ch; + for (int i = 0; i < n; i++) { + seed = seed * 1664525u + 1013904223u; + const double noise = ((int32_t)(seed >> 8) % 20001 - 10000) / 10000.0; /* (-1..1) */ + double v = kind == 1 ? noise * amp : (sin(phase) + noise * 0.02) * amp; + phase += 6.283185307179586 * hz / (double)src->rate; + if (phase > 6.283185307179586) phase -= 6.283185307179586; + if (v > 1) v = 1; + if (v < -1) v = -1; + for (int c = 0; c < ch; c++) buf[i * ch + c] = (int16_t)(v * 32767.0); + } + push_all(src, (const uint8_t *)buf, n * src->frame_bytes); + frames -= n; + } +} + /* what the source has recorded since, into its streams: the microphone's, or silence at the rate when there is none */ static void pump(Source *src) { const int64_t now = hos_now_ns(); - if (src->mode > 0 && (!src->mic || src->standin) && now >= src->retry_ns) connect(src); /* (the wanted one again) */ + if (!mic_test_file() && src->mode > 0 && (!src->mic || src->standin) && now >= src->retry_ns) connect(src); /* (the wanted one again) */ if (src->mode == 2 && src->mic && !src->standin && now >= src->check_ns) { /* (still plugged in?) */ uint32_t id; src->check_ns = now + CHECK_NS; @@ -281,7 +338,10 @@ static void pump(Source *src) { src->silence_from_ns += secs * 1000000000LL, src->silence_made -= secs * src->rate; } if (due > src->rate) due = src->rate; /* (more than a second is past every stream's capacity anyway) */ - if (due > 0) push_all(src, NULL, (int)due * src->frame_bytes); + if (due > 0) { + if (mic_test_file()) test_push(src, (int)due); + else push_all(src, NULL, (int)due * src->frame_bytes); + } } static void pump_all(void) { for (int i = 0; i < MAX_STREAMS; i++) diff --git a/host/nn_hid.c b/host/nn_hid.c index dc3f3b8..621bdc1 100644 --- a/host/nn_hid.c +++ b/host/nn_hid.c @@ -361,6 +361,10 @@ static void live_input(void) { if (!strncmp(line, "!flasharm", 9)) rx_flash_dark_arm(); extern volatile int hos_oot_live_action; /* host/hos_main.c: "!cheat ", as the Cheats page sends */ if (!strncmp(line, "!cheat ", 7)) __atomic_store_n(&hos_oot_live_action, atoi(line + 7), __ATOMIC_RELAXED); + void hos_oot_live_crawl(const char *line); /* host/hos_main.c: "!banc", "!pos", "!hold", "!where" (the pipeline crawl) */ + if (!strncmp(line, "!banc ", 6) || !strncmp(line, "!give ", 6) || !strncmp(line, "!items", 6) || !strncmp(line, "!pos ", 5) || !strncmp(line, "!hold ", 6) || + !strncmp(line, "!where", 6)) + hos_oot_live_crawl(line); hos_log("hid: live command at %.1f s: %.*s", at / 1000.0, (int)(n > 1 ? n - 1 : 0), line); continue; } diff --git a/host/nn_vi.c b/host/nn_vi.c index a1d2b37..8ebfe70 100644 --- a/host/nn_vi.c +++ b/host/nn_vi.c @@ -211,6 +211,30 @@ static void scan_dt(long long presents) { 1/15 s, as TotK Recomp's frame_rate.c (slower frames slow the game down, as on the console), at least 1/60 s (the game's own limit holds it at 60). HOS_REALTIME_STEP=0: the shipping whole steps. */ extern volatile uint64_t hos_gfx_module; +/* (local, RenoDX port) The scene's colour target as RGBA16F in place of the game's R11G11B10F (nx2/oot_patches.py: the format's + choice at main+0x65234c asks here; host/nn_applet.c gives the render targets' pool room for it): with the Insert menu's HDR + Native at the start, where RenoDX's shaders map the scene (gpu/vk/vk_renodx.cpp; RX_VK_RENODX=0 turns them off, and this with + them). Decided once, at the first ask, so the pool and the target agree. HOS_SCENE_RGBA16F=0 or 1 over it. */ +int hos_scene_rgba16f(void) { + static volatile LONG known = -1; + if (known < 0) { + const char *e = getenv("HOS_SCENE_RGBA16F"), *r = getenv("RX_VK_RENODX"); + /* (the menu's saved choice, hdr=2: the first ask comes before the renderer has its swapchain, so it cannot be asked + whether the display took HDR10. On a display that did not, the game stays in SDR with the wider target) */ + extern int hos_ini_option(const char *key, int otherwise); +#ifdef HOOKSHOT_RENODX + /* (Triforce, 11-13: and the menu's RenoDX HDR row on, renodx_hdr=1, which is off unless chosen; RX_VK_RENODX=0 or 1 + over the row, as in gpu/vk/vk_menu.cpp renodx_chosen) */ + const LONG v = e ? atoi(e) != 0 : hos_ini_option("hdr", 0) == 2 && (r && *r ? atoi(r) != 0 : hos_ini_option("renodx_hdr", 0) == 1); +#else /* (a build without RenoDX's shaders, nx2/build.py HOOKSHOT_RENODX: nothing asks for the wider target) */ + const LONG v = e ? atoi(e) != 0 : 0; + (void)r; +#endif + if (InterlockedCompareExchange(&known, v, -1) == -1) + hos_log("vi: the scene's colour target: %s", v ? "RGBA16F (HDR Native at the start: for RenoDX's tone mapping)" : "the game's R11G11B10F"); + } + return (int)known; +} volatile int hos_fixed_resolution = 0; /* (the lifted code reads these: nx2/oot_patches.py) */ volatile uint32_t hos_fixed_scale_bits = 0x3f800000; /* (HOS_RES_SCALE: the fixed path's scale) */ volatile int hos_dynres_runs = 0; /* (the dynamic path's frames: it fills fields the 3D reads, +8 +16 +168) */ diff --git a/host/posix/win32_posix.c b/host/posix/win32_posix.c index 6110071..be6210e 100644 --- a/host/posix/win32_posix.c +++ b/host/posix/win32_posix.c @@ -405,9 +405,11 @@ void ExitThread(DWORD code) { pthread_exit(NULL); } void ExitProcess(UINT code) { - /* (at once, as Windows ends the other threads first: exit() would run static destructors under running threads) */ + /* (at once, as Windows ends the other threads first: exit() would run static destructors under running threads. + quick_exit, not _exit: it runs what was registered with at_quick_exit and nothing else, and the renderer's + library registers its orderly-end marks there, as a DLL's atexit runs at Windows' ExitProcess) */ fflush(NULL); - _exit((int)code); + quick_exit((int)code); } BOOL TerminateProcess(HANDLE p, UINT code) { (void)p; ExitProcess(code); } diff --git a/host/prompts.c b/host/prompts.c index 7671d24..523d57b 100644 --- a/host/prompts.c +++ b/host/prompts.c @@ -225,6 +225,10 @@ static int setup(char *dir, size_t cap, int *face) { ok = GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES; } if (ok) f = choose_face(d); + /* (v0.3.5 shipped tools whose Python lacked nx2/prompt_requirements.txt: no folder was made, the Button prompts + setting did nothing, and the log said nothing of it) */ + else hos_log("prompts: no prompts folder beside the game: the game's own icons, whatever Button prompts is set to " + "(Setup's Update makes them)"); InterlockedExchange(&setup_state, ok ? 2 : 3); } while (setup_state == 1) Sleep(1); diff --git a/nx2/build.py b/nx2/build.py index 1e24485..9d741d8 100644 --- a/nx2/build.py +++ b/nx2/build.py @@ -206,6 +206,21 @@ NGX_MSVC_RT = "vk_ngx_msvc_rt.cpp" FSR = os.environ.get("HOOKSHOT_FSR", "") == "1" +def renodx_folder(folder): + """HOOKSHOT_RENODX as the build takes it: the folder when it has the compiled shaders, else "" (and why, said)""" + if folder and not os.path.isfile(os.path.join(folder, "renodx_spv.h")): + print("build: HOOKSHOT_RENODX=%s has no renodx_spv.h (scripts/renodx_shaders.py makes it): built without RenoDX" + % folder, flush=True) + return "" + return folder + + +# HOOKSHOT_RENODX=: the Vulkan back end with RenoDX's HDR for OoT (gpu/vk/vk_renodx.cpp), from RenoDX's shaders fetched +# and compiled into that folder's renodx_spv.h by scripts/renodx_shaders.py (never committed: they are worked from the game's +# own shaders). Off without it (make_game.py --renodx does both); the host then keeps the game's own scene format (nn_vi.c) +RENODX = renodx_folder(os.environ.get("HOOKSHOT_RENODX", "")) + + def ngx_link(sdk, mingw): """What triforce_vk.dll's link adds for NVIDIA DLSS on Windows: NVIDIA's library and the registry calls it makes; with llvm-mingw, not Microsoft's C++ runtime it names (libcpmt: vk_ngx_msvc_rt.cpp has what it needs of it, and the other @@ -823,7 +838,9 @@ def main(): host_fl + ["-I" + os.path.join(OPUS, "include")] + (["-I" + os.path.join(FFMPEG, "include")] if FFMPEG else []) + (FFMPEG_LX[0] if LINUX and FFMPEG_LX else []) + - ([stamp_def] if os.path.basename(s) == "hos_main.c" else []), host_deps) for s in host_srcs] + ([stamp_def] if os.path.basename(s) == "hos_main.c" else []) + + # (RenoDX's HDR in this build: the scene's colour target is RGBA16F with HDR Native, hos_scene_rgba16f) + (["-DHOOKSHOT_RENODX"] if RENODX and os.path.basename(s) == "nn_vi.c" else []), host_deps) for s in host_srcs] # libopus 1.5.2 (third_party/opus, from TOTKPort): nn::codec's hardware Opus decoder (host/nn_codec.c) # (hookshot: built for the same CPU target as the rest (CPU), so its float code can be vectorized where the target has # AVX2: the vendored copy has no x86 intrinsics files of its own) @@ -913,6 +930,12 @@ def main(): fsr_flags = ["-DHOOKSHOT_FSR", "-I" + os.path.join(kit.HERE, "..", "third_party", "fidelityfx")] if FSR else [] if FSR: print("the Vulkan back end: with AMD FSR 4 (AMD's FSR API headers, third_party/fidelityfx)", flush=True) + # (RenoDX's HDR, a build's option too: only vk_renodx.cpp sees its compiled shaders; without them it is the stubs + # that replace nothing) + renodx_flags = ["-DHOOKSHOT_RENODX", "-I" + RENODX] if RENODX else [] + renodx_deps = open(os.path.join(RENODX, "renodx_spv.h"), "rb").read() if RENODX else b"" + if RENODX: + print("the Vulkan back end: with RenoDX's HDR (its shaders compiled in %s)" % RENODX, flush=True) # (Eden's recompiler and sirit see only their own headers: a change to the back end's vk_*.h does not # rebuild their ~500 files; the back end itself depends on everything, suyu's texture decoders included) vk_lib_deps = tree_headers(os.path.join(vk, "eden"), os.path.join(vk, "sirit"), os.path.join(vk, "compat"), @@ -952,8 +975,10 @@ def main(): ([stamp_def] if os.path.basename(src) == "vk_menu.cpp" else []) + (ngx_flags if os.path.basename(src) == "vk_dlss.cpp" else []) + (imgui_flags if os.path.basename(src) in imgui_users else []) + - (fsr_flags if os.path.basename(src) == "vk_fsr4.cpp" else []), + (fsr_flags if os.path.basename(src) == "vk_fsr4.cpp" else []) + + (renodx_flags if os.path.basename(src) == "vk_renodx.cpp" else []), vk_lib_deps if lib else vdeps + (logo_text if os.path.basename(src) == "vk_imgui.cpp" else b"") + + (renodx_deps if os.path.basename(src) == "vk_renodx.cpp" else b"") + (ngx_deps if os.path.basename(src) == "vk_dlss.cpp" else b"") + (imgui_deps if os.path.basename(src) in imgui_users else b""))) if NGX_SDK and not LINUX and toolchain.mingw(): diff --git a/nx2/make_game.py b/nx2/make_game.py index 8fe0635..e4109cc 100644 --- a/nx2/make_game.py +++ b/nx2/make_game.py @@ -1272,6 +1272,40 @@ def fsr_wanted(a, out): return bool(getattr(a, "fsr", False)) or bool(a.update and os.path.isfile(os.path.join(out, FSR_MARK))) +RENODX_MARK = ".hookshot_renodx" # (in a game folder built with RenoDX's HDR: --update builds it with RenoDX again) + + +def renodx_wanted(a, out): + """RenoDX's HDR in this build. (Triforce, 11-13: every build has it, not only one that asks with --renodx; --no-renodx + builds without. It acts only with the Insert menu's HDR set to Native.)""" + return not getattr(a, "no_renodx", False) + + +def prepare_renodx(work): + """--renodx: RenoDX's shaders fetched and compiled before the build (scripts/renodx_shaders.py), into HOOKSHOT_RENODX when + set, else a renodx folder beside the work folder. Only what is missing or not the file expected is downloaded, and the + shaders are compiled again only when the script's pinned sources or compiler changed. Returns the folder""" + import importlib.util + path = os.path.join(ROOT, "scripts", "renodx_shaders.py") + if not os.path.isfile(path): # (the AppImage carries no scripts/: its Vulkan back end comes built, without RenoDX) + print("RenoDX's HDR: this builder does not carry %s: built without RenoDX" % path, flush=True) + return None + spec = importlib.util.spec_from_file_location("renodx_shaders", path) + renodx = importlib.util.module_from_spec(spec) + spec.loader.exec_module(renodx) + folder = os.environ.get("HOOKSHOT_RENODX") or os.path.join(os.path.dirname(work), "renodx") + print(renodx.NOTICE, flush=True) + try: + renodx.prepare(folder, "linux" if LINUX else "windows", say=lambda line: print(line, flush=True)) + except (OSError, ValueError) as e: + # (Triforce, 11-13: RenoDX is in every build now, so a PC without a connection, or a download that is not the file + # expected, must not stop the game's build: this one is made without RenoDX and says so; the next build tries again) + print("RenoDX's shaders could not be fetched or compiled (%s): this build is made without RenoDX's HDR. The next " + "build tries again." % e, flush=True) + return None + return folder + + def place_ngx_runtime(out): """(NVIDIA DLSS) a game built with NVIDIA's SDK (HOOKSHOT_NGX_SDK, as nx2/build.py takes it) gets DLSS's runtime in its ngx folder, where gpu/vk/vk_dlss.cpp looks first: nvngx_dlss.dll on Windows, libnvidia-ngx-dlss.so. on Linux. Never @@ -1318,6 +1352,11 @@ def parse_args(): # (AMD FSR 4, off unless asked: nothing is downloaded. gpu/vk/vk_fsr4.cpp) p.add_argument("--fsr", action="store_true", help="build with AMD FSR 4 (AMD's DLLs are not included: see the readme)") p.add_argument("--no-fsr", action="store_true", help="with --update: build without AMD FSR 4 even if the folder had it") + # (RenoDX's HDR, in every build since 11-13: its shaders and the Slang compiler are downloaded and compiled here. + # scripts/renodx_shaders.py, gpu/vk/vk_renodx.cpp) + p.add_argument("--renodx", action="store_true", + help="kept for old command lines: every build has RenoDX's HDR now (its shaders and the Slang compiler are downloaded, about 60 MB)") + p.add_argument("--no-renodx", action="store_true", help="build without RenoDX's HDR: nothing of it is downloaded") a = p.parse_args() if a.prepare: # (first: a bad --game below is said as RecompLauncher's "error" line) global PREPARE @@ -1395,6 +1434,26 @@ def main(a=None): os.environ.pop("HOOKSHOT_FSR", None) if os.path.isfile(os.path.join(out, FSR_MARK)): os.remove(os.path.join(out, FSR_MARK)) + # (RenoDX's HDR: its shaders made first, then the build's switch for nx2/build.py and the folder's mark for the next + # --update) + if renodx_wanted(a, out): + if os.environ.get("HOOKSHOT_VK_PREBUILT"): # (the AppImage's back end, built without RenoDX) + print("RenoDX's HDR: this build uses the prebuilt Vulkan back end (HOOKSHOT_VK_PREBUILT), which has no RenoDX: built " + "without it", flush=True) + os.environ.pop("HOOKSHOT_RENODX", None) + else: + renodx_folder = prepare_renodx(work) + if renodx_folder: + os.environ["HOOKSHOT_RENODX"] = renodx_folder + open(os.path.join(out, RENODX_MARK), "w").close() + else: + os.environ.pop("HOOKSHOT_RENODX", None) + if os.path.isfile(os.path.join(out, RENODX_MARK)): + os.remove(os.path.join(out, RENODX_MARK)) + else: + os.environ.pop("HOOKSHOT_RENODX", None) + if os.path.isfile(os.path.join(out, RENODX_MARK)): + os.remove(os.path.join(out, RENODX_MARK)) exefs = os.path.join(work, "exefs") romfs = os.path.join(out, "romfs") diff --git a/nx2/oot_patches.py b/nx2/oot_patches.py index 59623e7..115c49f 100644 --- a/nx2/oot_patches.py +++ b/nx2/oot_patches.py @@ -442,6 +442,22 @@ def patch_text_speed(s): return s.replace('#include "a64.h"\n', '#include "a64.h"\n' + TEXT_DECL, 1) +# (local, RenoDX port) The scene's colour target, "agl::RenderDisplay(color)": the game picks engine format 26 (R11G11B10F) or 44 +# (RGBA16F) at main+0x65234c (0x8067234c; RenoDX's addon.cpp names the place for build e0f3ccfa). RenoDX's tone mapping wants +# RGBA16F, whose values may be negative, with HDR Native: host/nn_vi.c hos_scene_rgba16f says when. The other choice of that +# csel is 44 already, so both become 44 then; the UNORM branch at main+0x6525b0 is left alone. +RGBA16F_DECL = "int hos_scene_rgba16f(void);\n" +RGBA16F_OLD = (" c->x[9] = 0x1aULL;\n c->x[9] &= 0xFFFFFFFFULL;\n" + " { uint64_t _r = (!c->z) ? c->x[10] : c->x[9]; _r &= 0xFFFFFFFFULL; c->x[9] = _r; }\nL_80672354:;") +RGBA16F_NEW = RGBA16F_OLD.replace("c->x[9] = 0x1aULL;", "c->x[9] = hos_scene_rgba16f() ? 0x2cULL : 0x1aULL;", 1) + + +def patch_scene_format(s): + if RGBA16F_OLD not in s: + return None + return s.replace(RGBA16F_OLD, RGBA16F_NEW, 1).replace('#include "a64.h"\n', '#include "a64.h"\n' + RGBA16F_DECL, 1) + + def apply(gen, *, protect_hearts=False, required=False): """required: the lift of the supported build (LIFE_BUILD_ID), whole: a missing output-size edit stops it (apply_output_size). The other patches only warn when their place is not found once.""" @@ -456,6 +472,7 @@ def apply(gen, *, protect_hearts=False, required=False): done["player flight rotation"] = 0 done["free camera"] = 0 done["mouse camera"] = 0 + done["scene colour target format"] = 0 # (local, RenoDX port) step_sites, step_files = 0, [] # (the divides with the hook, and the files that have it) whole_sites = 0 # (the counters of WHOLE_SITES with the whole frames: patch_whole_frames) sound_jobs = solver_sites = 0 # (patch_sound_job, patch_solver_steps: the places found with their hooks) @@ -494,6 +511,11 @@ def apply(gen, *, protect_hearts=False, required=False): if n: done["fixed path's scale"] += 1 print("oot_patches: the fixed path's scale in", os.path.basename(path)) + fmt = patch_scene_format(out) if protect_hearts else None + if fmt is not None: + out = fmt + done["scene colour target format"] += 1 + print("oot_patches: the scene's colour target format in", os.path.basename(path)) life = patch_life(out) if protect_hearts else None if life is not None: out = life diff --git a/readme.md b/readme.md index a068c54..fc41733 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@

- Download Triforce Setup + Download Triforce Setup Windows 10 | 11 Vulkan 1.3 No emulator @@ -80,7 +80,7 @@ itself is assembled on your PC, from your copy, in one guided build. ### Four steps to Hyrule -**1 · Download.** Get **`TriforceSetup.exe`** from the [newest release](https://github.com/ruckus7382sfgsgdf/CBeta0.2/releases) +**1 · Download.** Get **`TriforceSetup.exe`** from the [newest release](https://triforceproject.com) and run it. **2 · Install.** Choose where Triforce goes (your own user folder by default, so no administrator prompt) and whether @@ -261,6 +261,8 @@ style and what a good pull request looks like. - **sostenesfreitas (ocarina-recomp):** an early README layout, and notes that confirmed the mesh stage's control section. - **MythosOfs (Orchid):** the original fog and exposure workaround for Ocarina of Time. +- **Carlos Lopez (clshortfuse) and [RenoDX](https://github.com/clshortfuse/renodx):** the HDR tone mapping, eye + adaptation and colour grading of the optional RenoDX HDR build, from RenoDX's mod for Ocarina of Time. - **Mesa (NAK):** the map of Ampere's instruction encoding. - **Everyone who sent fixes:** SkippySteve (a great many of them), klimovich008, d3zessete, chrispository, vzeol, monsterlag, leonidasmark, Segmentree, Zorkats, ShyVortex, hiKareeem, gab9281, i900gaming and more. @@ -278,5 +280,9 @@ GPL. Bundled components with their own GPL-compatible licenses (Sirit, Vulkan Me and the a64-kit tools) keep their notices in their own folders. Triforce Setup's tools package also carries Python and llvm-mingw, under their own licenses. +The optional RenoDX HDR support is worked from RenoDX, which is under the MIT license: its notice is in +[third_party/renodx/LICENSE.md](third_party/renodx/LICENSE.md). RenoDX's own shaders are never part of Triforce: a +build that asks for them downloads and compiles them on the builder's PC. + Triforce is a fan-made project with no connection to Nintendo, and Nintendo hasn't endorsed it. The Legend of Zelda and Ocarina of Time are Nintendo's trademarks. diff --git a/scripts/renodx_shaders.py b/scripts/renodx_shaders.py new file mode 100644 index 0000000..843729b --- /dev/null +++ b/scripts/renodx_shaders.py @@ -0,0 +1,295 @@ +"""RenoDX's Zelda OoT shaders for a build with RenoDX's HDR (HOOKSHOT_RENODX, gpu/vk/vk_renodx.cpp): renodx_spv.h. + +RenoDX's shaders (src/games/zelda-oot-oz, MIT, Carlos Lopez) are not part of Hookshot and are never committed or bundled, nor is +what is compiled from them: they are worked from the game's own shaders. A build that asks for RenoDX fetches the sources from +RenoDX's repository at one pinned commit and the Slang compiler they are written for at one pinned release, each file checked +against its SHA-256, into , and compiles the four shaders into /renodx_spv.h: + - renodx/: RenoDX's LICENSE and the sources the four shaders read (64 files, 0.7 MB); + - slang/: the Slang compiler (57 MB, Apache 2.0 with LLVM exception), from its release archive. + +RenoDX names the shaders it replaces by the CRC-32 of the SPIR-V another runner's Eden recompiler emits. Hookshot's own emitter +gives the same programs other bytes (its fragment NaN guard, its execution modes), so each replacement is listed here under the +CRC-32 of the module Hookshot makes (RX_VK_DUMP_ALL_SPV= writes them, named by it). A change to Hookshot's emitter +changes those: dump again and match by what the shader reads. + +Usage: python -I scripts/renodx_shaders.py [--platform linux|windows] [] + : default work/renodx. Then build with HOOKSHOT_RENODX= (nx2/make_game.py --renodx does both). + python -I scripts/renodx_shaders.py --from [] + a checkout and a compiler already on the PC: nothing is downloaded +""" +import argparse +import hashlib +import os +import shutil +import struct +import subprocess +import sys +import tempfile +import urllib.request +import zipfile + +COMMIT = "59bd6f606a5d105bc6de52627332703c840443be" +BASE = "https://raw.githubusercontent.com/clshortfuse/renodx/" + COMMIT +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +GAME = "src/games/zelda-oot-oz" +HEADER = "renodx_spv.h" + +# (Hookshot's module CRC-32, RenoDX's source, its part in the eye adaptation (0 none, 1 the fog: it records the field of view, +# 2 the scene: it meters), what it is) +# (Triforce, 11-13: matched again for this translator, on an NVIDIA card. The patch's four (C749AC23, D2EDEE38, 0D00542E, +# 9E0C0C3A) were v0.3.3's, and none of them is made any more: RenoDX replaced nothing. Found by interface: of the 6,503 +# fragment modules a run in HDR Native made (RX_VK_DUMP_ALL_SPV), those with the same set 0 bindings, inputs and outputs as +# RenoDX's shader: one each for the fog and the local exposure's scene, 8 for the encoder and 6 for the scene, of which one +# each is drawn in play (RX_VK_RENODX_TRACE=1: the frame's last draw, and the draw after the bloom's pyramid). Another card's +# make can give these programs other bytes (the AMD and Intel translation fixes): there RenoDX replaces nothing until its +# four are matched the same way, and the log says so half a minute in ("none of its four shaders has replaced")) +SHADERS = [ + (0x4AE77AB6, "output_0x92D6F81D.frag.slang", 0, "the native HDR output encoder"), + (0x66644A1B, "scene_mapping_hdr_0xED732BB7.frag.slang", 2, "the scene's tone mapping, native HDR (what play draws)"), + (0xD08E7AD8, "scene_mapping_hdr_0x09EB4538.frag.slang", 2, "the scene's tone mapping, native HDR, with local exposure"), + (0xCCB24C45, "fov_capture_0x0258153C.frag.slang", 1, "the fog, which records the camera's field of view"), +] +FLAGS = ["-stage", "fragment", "-O3", "-g0", "-entry", "main", "-Wno-30056", "-Wno-15205", "-Wno-30081", "-Wno-41035", + "-DNDEBUG", "-target", "spirv"] + +# (path in RenoDX's repository, its SHA-256): its license, and what the four shaders read (slangc -depfile lists them) +FILES = [ + ("LICENSE", "e9e2da3991a48d9c09b710c9ddbf5673275b6d569c976bcffab3111d0c509d51"), + ("src/games/zelda-oot-oz/aa_controls.slangi", "aece31045cedc6b25a7995052c4fa6915afb23b3e9f47c7703f55562aa34c646"), + ("src/games/zelda-oot-oz/adaptation.slangi", "6964a8809c86fb426de776a30fa39f0f960311b1628d80304e11da6d674e6f27"), + ("src/games/zelda-oot-oz/fov_capture_0x0258153C.frag.slang", "05eda5c10f28d7d7bc469766f9488be313ad5e9ddba81f926c1a009c7555c76c"), + ("src/games/zelda-oot-oz/output_0x92D6F81D.frag.slang", "8fa2f3b6e10b61212e1f29891487522ecd617cead3ab3dc3e463ed163c1dd15d"), + ("src/games/zelda-oot-oz/scene_mapping_hdr_0x09EB4538.frag.slang", "f4b7a1aef605aa3842e804110d7ade1b2362505195a94673a90bb3c6c50a8856"), + ("src/games/zelda-oot-oz/scene_mapping_hdr_0xED732BB7.frag.slang", "bb1e12b20fed3cf5d5a2d23952557bcf1ab55f4833e1774975a2373e0c6f15ce"), + ("src/games/zelda-oot-oz/scene_tonemap.slangi", "41d94e7c8cab28c7c966fda36f43167fb5eeb411b2265cd717631d22642dbf7c"), + ("src/games/zelda-oot-oz/shared.h", "9e3d9748d37dc98f244af56ae3005f61535cca2ccd67d5c42d3f7a852e4197a3"), + ("src/shaders/canvas.hlsl", "7c721ee6ac76177223194345d1229fa8a09a36f0d92f437960ccfbeeef568be5"), + ("src/shaders/color.hlsl", "bf277992a11f1c3ab3f74d86fd67f47326ef10f57b868bd701f5446de7033ae1"), + ("src/shaders/color/acescc.hlsl", "293fd2c95666c73938e6a69cfd61020f6d4dfc55f1269fc92263a179e0d70ea8"), + ("src/shaders/color/acescct.hlsl", "1502d905d75eee1a548ca594ded3e8a261d8227c469639c4aac06c7cf515e74f"), + ("src/shaders/color/arri.hlsl", "07c0383c7d9289d98dde2431f03d8d50747ba9985f5f0b865df6db968e23013c"), + ("src/shaders/color/castlecsf.hlsl", "4a4373ecc66b933ef0b3f5d9c92b1b00f983a6ffffb90ed8a72567403dfdd90f"), + ("src/shaders/color/clamp.hlsl", "1c1165062f6a2a1d37db59285fd39ceff041d85e6b710ea41628e7af06b6dcc0"), + ("src/shaders/color/colorvideovdp.hlsl", "1784d60bb2d89925f9b1c5ace038c1423b196f49d1f2c40a2cc7b825a4ee4873"), + ("src/shaders/color/convert.hlsl", "79f60e7501b6454a7f78e88442b5f74c9a17b676ff2f0f44fae13edd56b642c9"), + ("src/shaders/color/dtucs.hlsl", "ea4e914c78d73200ace2a8295e7c0afadb236b47da4492742e7f2cdb1f1e2d98"), + ("src/shaders/color/gamma.hlsl", "1c24fb8a3032fbd730f44fa5d2f7d8cdd5857646c4f9c9ceedbd055879544122"), + ("src/shaders/color/gamut.hlsl", "4030044bf73e6e46cc927248f7e5b76e3f3d92336318b72adb5ed2875bc204ae"), + ("src/shaders/color/ictcp.hlsl", "7c88d88a1eddc0985cb391c396cc68dedb1c581958bc65b0637e6d40fa2fe759"), + ("src/shaders/color/ipt.hlsl", "598874398019c930c847c0ada9d2825c5ea2621d104f48b9a1b2c54e375bd53a"), + ("src/shaders/color/macleod_boynton.hlsl", "c1b89facaa91ff6662746b0a12f1403f961ce116ee94279604a27e35a61c49e0"), + ("src/shaders/color/oklab.hlsl", "a97b6115f7aa728c5bbf45c25361ae1a15d5777c21b393c30adea73502d2b787"), + ("src/shaders/color/pq.hlsl", "06b13cb8b9c2fa37817c20ca41977e005cd3ee53ea0c5fd54f3fd44824b934b9"), + ("src/shaders/color/rgb.hlsl", "babbb614ede608d8250f15b1444e4e617a46fe7d048d7711f7a406f51e29d83c"), + ("src/shaders/color/srgb.hlsl", "8ea6d0b188a2802f137bc9b1a9fdb00913323da3225f313d96ec8ef2f32e1a7e"), + ("src/shaders/color/stockman.hlsl", "bcaeba9be68abbb66dc11b0f6018c76e7ede2832fe9ee96364a49ec02c953011"), + ("src/shaders/color/ycbcr.hlsl", "3e0f395276b91c79be0feb8723d20e200cab7418dda00c2d8d9de96c7130054c"), + ("src/shaders/color_convert.hlsl", "6d1655efe39f80f3bb96eef6dba4a03565678575e7bf7aaabe748cb876982dc4"), + ("src/shaders/colorcorrect.hlsl", "18c63e8aeede808a83c60c8d03fb96eef05e68c8a966af6c8e08d6ee67c3528d"), + ("src/shaders/colorgrade.hlsl", "d2acff2015f912ee981f511482d6199e849c96db4a18bfc888659c1f32c8f98f"), + ("src/shaders/debug.hlsl", "4b364d342c4bf1b1b858ce473f5aa9b880e5b2908432e63cb3508172f9f17e7b"), + ("src/shaders/deprecated.hlsl", "5a974b3e481f38ff2278fee2afa248eb07163066e3907ebc4bbb9d003b4eafe1"), + ("src/shaders/draw.hlsl", "0f873ee298929b48999c5bb36037dcc8e13bd4b76e38124cc0ebba38c752aac9"), + ("src/shaders/effects.hlsl", "412d95b9248b9a9b7e374cf8acad994cea687510788cbc9a69ce46d7d26ca9bf"), + ("src/shaders/inverse_tonemap.hlsl", "69653d5cde82f3dbd0d97645afeebaec01c1ba42149435521134861910c99151"), + ("src/shaders/lut.hlsl", "d7ed65ebcc1979a6c3b490a0ed3acf608d4daa8d2fc4bbd696cd9f6336f71dc8"), + ("src/shaders/math.hlsl", "fb4c282c2baf8bf75c5de895c1a6fb7f5798b978cb537cc5032a7a764680e673"), + ("src/shaders/math/constants.hlsl", "96ff24c68515fcda1e95c203f7b9be06ec8057179bb145a4d0f03c7619820fe2"), + ("src/shaders/math/cross.hlsl", "b81755c7964cb8447283d2ac33376333062b4d39d635296b4272f5198fd8e08d"), + ("src/shaders/math/select.hlsl", "c1f28149a9708fa06ce137c7634221a7a2ce3f6ebcc46a1f386408eea2a3d6c2"), + ("src/shaders/math/sign.hlsl", "54841f0f2efe9a818ca32d2462e03139a7fcc86a398350559271e15523d60e92"), + ("src/shaders/random.hlsl", "a1d560bfffe016c00661f29b749101b94350ea3cde911b46063e1d9f0ac16f0f"), + ("src/shaders/renodx.hlsl", "4e8a033c989f79fc64b175e7ef8b122c8a5c57609e5a1f56786b1bbb32108bcf"), + ("src/shaders/tonemap.hlsl", "221c3588c855cbf636abecda4c66d6824e32a260505cb7490dcac1847cbcf94f"), + ("src/shaders/tonemap/aces.hlsl", "54c64cbeab4b6fabdb916d4eb92768258facb5de420a32112e2d336bd90cc5bc"), + ("src/shaders/tonemap/agx.hlsl", "0b58d91deed404d1b0af094e61bc663dc6c8c0979b20c9d7a8d4e00db42c1a23"), + ("src/shaders/tonemap/allenwp.hlsl", "55572ee3b24d20a70793cf8b9461a2a06656e2e8e6a13747880e57735406c534"), + ("src/shaders/tonemap/c_infinity_rolloff.hlsl", "dd16c280bc7a0a773d000bbd40e9d9e154ed7de4d39c7caeb6c376b28ffa5d45"), + ("src/shaders/tonemap/daniele.hlsl", "3919f5675668e6c5e0eb3843b09b1a20ce530904fc31014a358bbbc8fd7fc52d"), + ("src/shaders/tonemap/DICE.hlsl", "21dc120417df088226ced464d4921136a4134d1bfa24104a2569f40a9a07c11e"), + ("src/shaders/tonemap/frostbite.hlsl", "a962696ec9246376cf4811eb2ca72f3a7997fc0c63b630886f4551618194844b"), + ("src/shaders/tonemap/hermite_spline.hlsl", "b70a83c88f4a9ec3dd669fb3ef574cb94010e17804ed403dcd6d3e94a0af2cb5"), + ("src/shaders/tonemap/naka_rushton.hlsl", "e3151899bf3f7bb7407176c93c00dbddf2a0437c4056156d4fe2492d79e1ed16"), + ("src/shaders/tonemap/neutwo.hlsl", "49982526e49be628f94290f021e96bd404b1ddee54475984a3807cc54ff118bd"), + ("src/shaders/tonemap/psychov.hlsl", "521b4a6772da427369f4a34122cf91357758ad46a2ff535d9b27793547ecf574"), + ("src/shaders/tonemap/psychov/test17.hlsl", "363aae484a157e2cf5c8feea23373315058891f51ae731df7ba72267417aec89"), + ("src/shaders/tonemap/psychov/test22.hlsl", "52b9468ace1973dfbdf2afbeb2f4e7b3294237ab8411d903ab22a7a86310eb07"), + ("src/shaders/tonemap/psychov/test30.hlsl", "edf8366a568771f0e66f5ead24b8aca93f5f0b7f93b922621e0900eb7dcce185"), + ("src/shaders/tonemap/psychov/test35.hlsl", "a420abc34dc690cc761d97803a9697a862c5c3a43712bac3dde029e8342d1216"), + ("src/shaders/tonemap/reinhard.hlsl", "7b4e78632482895e43544969c19bdd412165f57c5edf3049b2bd8f2edd169eac"), + ("src/shaders/tonemap/reno_drt.hlsl", "54c940b810e0e7c2bdc62a6a3071d1c57c9de5403b0a260cc9a7defc17ff4dba"), + ("src/shaders/tonemap/rushton_henry.hlsl", "b8fae1e57684c2060ce65a4184af6f6f303a12a3908448fcee42fa7c6dd6df2d"), +] + +# (the Slang compiler's release archive for a platform: its URL, its SHA-256, the compiler in it) +SLANG_VERSION = "2026.14.1" +SLANG_BASE = "https://github.com/shader-slang/slang/releases/download/v%s/slang-%s-" % (SLANG_VERSION, SLANG_VERSION) +SLANG = { + "windows": (SLANG_BASE + "windows-x86_64.zip", "5ed0a59d650a0af0aca45d5db4e083b3d8fb5cea05748747dd95dfbe9c580658", + "bin/slangc.exe"), + "linux": (SLANG_BASE + "linux-x86_64.zip", "d7c02e044b5f2f4ceb8e220a2cf8f7d053418db1877da2656fb59e1ce545f8dd", + "bin/slangc"), +} + +NOTICE = """\ +RenoDX's HDR is built from RenoDX's Zelda OoT shaders (github.com/clshortfuse/renodx, MIT, Carlos Lopez), compiled on this PC +with the Slang compiler (github.com/shader-slang/slang). Neither they nor what is compiled from them is part of Hookshot: +never share a game folder or a build made with them.""" + + +def host_platform(): + return "linux" if sys.platform.startswith("linux") else "windows" + + +def header(folder): + """The compiled shaders in a HOOKSHOT_RENODX folder: what nx2/build.py's renderer includes""" + return os.path.join(folder, HEADER) + + +def sha256(path): + h = hashlib.sha256() + with open(path, "rb") as f: + for block in iter(lambda: f.read(1 << 20), b""): + h.update(block) + return h.hexdigest() + + +TIMEOUT = 60 # (seconds without an answer, or between two reads, before a download gives up: a stalled one ends the build) + + +def fetch_one(url, digest, dst, opener=urllib.request.urlopen): + """One file into dst, unless it is there already with that SHA-256. The download goes to dst.part and is moved in only + when its SHA-256 is the expected one; otherwise it is deleted and ValueError says which""" + if os.path.isfile(dst) and sha256(dst) == digest: + return False + os.makedirs(os.path.dirname(dst) or ".", exist_ok=True) + tmp = dst + ".part" + try: + with opener(url, timeout=TIMEOUT) as r, open(tmp, "wb") as f: + shutil.copyfileobj(r, f, 1 << 20) + if sha256(tmp) != digest: + raise ValueError("renodx: %s is not the file expected (SHA-256): not used" % url) + os.replace(tmp, dst) + finally: + if os.path.exists(tmp): + os.remove(tmp) + return True + + +def slangc(folder, platform): + return os.path.join(folder, "slang", *SLANG[platform][2].split("/")) + + +def fetch(folder, platform, opener=urllib.request.urlopen, say=print): + """RenoDX's sources and the Slang compiler into the folder: only what is missing or not the file expected is downloaded. + The compiler's archive is unpacked again when it is another one than the folder's (slang/archive.sha256 says which)""" + for path, digest in FILES: + if fetch_one(BASE + "/" + path, digest, os.path.join(folder, "renodx", *path.split("/")), opener): + say("renodx: %s" % path) + url, digest, _ = SLANG[platform] + slang = os.path.join(folder, "slang") + mark = os.path.join(slang, "archive.sha256") + if os.path.isfile(slangc(folder, platform)) and os.path.isfile(mark) and open(mark).read().strip() == digest: + return + archive = os.path.join(folder, "slang.zip") + say("renodx: the Slang compiler %s (57 MB on Windows, 80 MB on Linux)" % SLANG_VERSION) + fetch_one(url, digest, archive, opener) + shutil.rmtree(slang, ignore_errors=True) + with zipfile.ZipFile(archive) as z: + root = os.path.realpath(slang) + # (the compiler and its libraries and licenses alone: the archive's documentation has paths past Windows' 260 + # characters in a deep folder. Nothing outside the folder, whatever the archive names) + wanted = [i for i in z.infolist() if not i.is_dir() and i.filename.split("/")[0] in ("bin", "lib", "LICENSE", "LICENSES")] + for info in wanted: + if not os.path.realpath(os.path.join(slang, info.filename)).startswith(root + os.sep): + raise ValueError("renodx: the Slang archive names a file outside its folder: not used") + z.extractall(slang, wanted) + if platform == "linux": # (a zip keeps no modes) + for name in os.listdir(os.path.dirname(slangc(folder, platform))): + os.chmod(os.path.join(os.path.dirname(slangc(folder, platform)), name), 0o755) + with open(mark, "w") as f: + f.write(digest + "\n") + os.remove(archive) + + +def stamp(): + """What a compiled header is made from: the commit, the compiler, the shaders and their flags. In the header's first line, + so one made from something else is made again""" + h = hashlib.sha256(repr((COMMIT, SLANG_VERSION, SHADERS, FLAGS, FILES)).encode()) + return "// renodx_shaders.py %s" % h.hexdigest()[:16] + + +def current(folder): + """The folder's header is this script's: compiled from the pinned sources with the pinned compiler""" + path = header(folder) + if not os.path.isfile(path): + return False + with open(path, encoding="utf-8") as f: + return f.readline().rstrip("\n") == stamp() + + +def compile_header(renodx, compiler, out_path, say=print, first_line=None): + """renodx_spv.h from a RenoDX checkout (or the folder's renodx/) with slangc""" + src = os.path.join(renodx, *GAME.split("/")) + lines = ([first_line] if first_line else []) + [ + "// Generated by scripts/renodx_shaders.py from RenoDX (MIT, Carlos Lopez): do not edit, never commit.", + "// Each array replaces the module of Hookshot's whose CRC-32 names it (vk_renodx.cpp).", "#pragma once", + "#include ", ""] + with tempfile.TemporaryDirectory() as tmp: + for crc, name, kind, what in SHADERS: + spv = os.path.join(tmp, "%08X.spv" % crc) + r = subprocess.run([compiler, name] + FLAGS + ["-o", spv], cwd=src, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + if r.returncode or not os.path.isfile(spv): + raise ValueError("renodx: %s did not compile (%s)" % (name, r.stdout.decode("utf-8", "replace").strip()[-400:])) + data = open(spv, "rb").read() + words = struct.unpack("<%dI" % (len(data) // 4), data) + lines.append("// %s: %s" % (name, what)) + lines.append("static const uint32_t RENODX_%08X[] = {" % crc) + for i in range(0, len(words), 12): + lines.append(" " + ", ".join("0x%08x" % w for w in words[i:i + 12]) + ",") + lines.append("};") + say("renodx: %08X <- %s (%d words)" % (crc, name, len(words))) + lines.append("") + lines.append("static const struct { uint32_t crc; const uint32_t* words; uint32_t count; int kind; } RENODX_SHADERS[] = {") + for crc, name, kind, what in SHADERS: + lines.append(" {0x%08Xu, RENODX_%08X, sizeof RENODX_%08X / 4, %d}," % (crc, crc, crc, kind)) + lines.append("};") + os.makedirs(os.path.dirname(out_path) or ".", exist_ok=True) + with open(out_path + ".part", "w", newline="\n", encoding="utf-8") as f: + f.write("\n".join(lines) + "\n") + os.replace(out_path + ".part", out_path) + + +def prepare(folder, platform=None, opener=urllib.request.urlopen, say=print): + """The folder ready for a build with HOOKSHOT_RENODX=: fetched, and its header compiled when it is not this + script's already. Returns the header""" + platform = platform or host_platform() + if current(folder): + return header(folder) + fetch(folder, platform, opener, say) + compile_header(os.path.join(folder, "renodx"), slangc(folder, platform), header(folder), say, stamp()) + return header(folder) + + +def main(argv=None): + p = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + p.add_argument("--platform", choices=sorted(SLANG), default=host_platform()) + p.add_argument("--from", dest="local", nargs=2, metavar=("CHECKOUT", "SLANGC"), + help="a RenoDX checkout and a slangc already on the PC: nothing is downloaded") + p.add_argument("folder", nargs="?", default=os.path.join(ROOT, "work", "renodx")) + a = p.parse_args(argv) + print(NOTICE, flush=True) + try: + if a.local: + compile_header(a.local[0], a.local[1], header(a.folder)) + else: + prepare(a.folder, a.platform) + except (OSError, ValueError) as e: + print(e, file=sys.stderr) + return 1 + print("renodx: %s (build with HOOKSHOT_RENODX=%s)" % (header(a.folder), a.folder)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/setup/Main.xaml b/setup/Main.xaml index 4d66cdc..f2bac68 100644 --- a/setup/Main.xaml +++ b/setup/Main.xaml @@ -775,12 +775,17 @@