Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/source-regressions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: python -m pip install --disable-pip-version-check --no-deps zstandard==0.25.0
- name: Compilers and the SPIR-V validator
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y g++ clang spirv-tools
run: sudo apt-get update && sudo apt-get install -y g++ clang spirv-tools glslang-tools

# (the steps below all run when one before them failed, so one run shows every failure)
- name: Check Windows native source regressions
Expand Down
16 changes: 16 additions & 0 deletions gpu/PROVENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,19 @@ mkw-recomp's changes, for the Switch 2:
`mkw_gpu.cpp` / `mkw_gpu.h` / `build-gpu.bat` are the earlier Vulkan stand-in (a window and a swapchain; no longer
loaded). `shadertool.cpp` runs dumped NVN2 programs through Eglantine's recompiler offline (SPIR-V; it prints what
each program reads from the constant banks).

Hookshot's NVIDIA DLSS (`vk/vk_dlss.cpp`, the DLSS part of `vk/vk_draw.cpp`, `vk/shaders/dlss_*.comp`) is ported from Lichii
(zortos293/Lichii: `vulkan_common/streamline.cpp`, `renderer_vulkan/vk_streamline_dlss.cpp`, `vk_ocarina_camera_motion.cpp`,
`host_shaders/ocarina_*.comp`; Eden Emulator Project, GPL-3.0-or-later; Lichii credits Duck912's Eglantine work).
`third_party/streamline/` is NVIDIA Streamline v2.14.16's headers (MIT, `license.txt`); its DLLs and NVIDIA's DLSS are
loaded from the user's PC at run time and are not vendored.

Hookshot's AMD FSR 4.1 (`vk/vk_fsr4.cpp`, the FSR and jitter parts of `vk/vk_draw.cpp`, the `fsr` paths of
`vk/shaders/dlss_*.comp`) is ported from madebyjordan's FSR 4.1 work on Lichii's OoT branch (`renderer_vulkan/vk_fsr4_upscaler.cpp`,
`vk_rasterizer.cpp`'s Ocarina jitter, `host_shaders/ocarina_*.comp`; GPL-3.0-or-later). `third_party/fidelityfx/` is AMD's
FSR API headers from FidelityFX SDK v2.4.0 (MIT, `LICENSE.md`); AMD's signed DLLs are loaded from the user's PC at run time
and are not vendored.

Hookshot's AMD FSR 3.1 (`vk/vk_fsr3.cpp`, `vk/shaders/fsr3_*`) comes from notquiteog's FSR 3.1
pull request on NotRexed/Hookshot (#822, GPL-3.0-or-later); the shaders are compiled from `third_party/fidelityfx-sdk/` (AMD FidelityFX SDK
v1.1.4, MIT).
25 changes: 25 additions & 0 deletions gpu/vk/shaders/dlss_color.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#version 450
// (hookshot) ported from Lichii (Eden lineage; Duck912's Eglantine work), GPL-3.0-or-later: vk_dlss.cpp

layout(local_size_x = 8, local_size_y = 8) in;
layout(binding = 0) uniform sampler2D guest_color;
layout(binding = 1, rgba16f) uniform writeonly image2D dlss_color;
layout(push_constant) uniform P { int encode; int fsr; } pc;

void main() {
ivec2 pixel = ivec2(gl_GlobalInvocationID.xy);
if (any(greaterThanEqual(pixel, imageSize(dlss_color)))) {
return;
}
// The guest has already tonemapped this square-root-encoded color for LDR (the network's input, RGB9E5). (hookshot) encode = 1:
// the tonemapped scene, the network's first passes left out (vk_draw.cpp), square-root encoded here the same way.
// dlss_output.comp squares it back
// (hookshot-amd) fsr = 1, AMD FSR 4.1: its LDR mode keeps history, where a NaN, infinite or out-of-range value would build up;
// and under its jitter moved up or left, the AMD driver draws nothing into the scene's last column or row (a stale near-white
// value, a flickering line on the right and bottom edges): they repeat the ones before them (vk_draw.cpp FsrJitter)
const ivec2 source = pc.fsr != 0 ? min(pixel, max(imageSize(dlss_color) - 2, ivec2(0))) : pixel;
vec3 c = max(texelFetch(guest_color, source, 0).rgb, vec3(0.0));
if (pc.fsr != 0 && (any(isnan(c)) || any(isinf(c)))) c = vec3(0.0);
c = pc.encode != 0 ? sqrt(c) : c;
imageStore(dlss_color, pixel, vec4(pc.fsr != 0 ? min(c, vec3(1.0)) : c, 1.0));
}
97 changes: 97 additions & 0 deletions gpu/vk/shaders/dlss_color_comp_spv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// 1116.2.0
#pragma once
const uint32_t DLSS_COLOR_COMP_SPV[] = {
0x07230203,0x00010600,0x0008000b,0x0000007d,0x00000000,0x00020011,0x00000001,0x00020011,
0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,
0x00000000,0x00000001,0x0009000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,
0x00000016,0x00000023,0x0000003f,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,
0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00040005,0x00000009,0x65786970,0x0000006c,0x00080005,0x0000000d,0x475f6c67,0x61626f6c,
0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00050005,0x00000016,0x73736c64,0x6c6f635f,
0x0000726f,0x00040005,0x00000020,0x72756f73,0x00006563,0x00030005,0x00000021,0x00000050,
0x00050006,0x00000021,0x00000000,0x6f636e65,0x00006564,0x00040006,0x00000021,0x00000001,
0x00727366,0x00030005,0x00000023,0x00006370,0x00030005,0x0000003b,0x00000063,0x00050005,
0x0000003f,0x73657567,0x6f635f74,0x00726f6c,0x00040047,0x0000000d,0x0000000b,0x0000001c,
0x00030047,0x00000016,0x00000019,0x00040047,0x00000016,0x00000021,0x00000001,0x00040047,
0x00000016,0x00000022,0x00000000,0x00030047,0x00000021,0x00000002,0x00050048,0x00000021,
0x00000000,0x00000023,0x00000000,0x00050048,0x00000021,0x00000001,0x00000023,0x00000004,
0x00040047,0x0000003f,0x00000021,0x00000000,0x00040047,0x0000003f,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,
0x00090019,0x00000014,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,
0x00000002,0x00040020,0x00000015,0x00000000,0x00000014,0x0004003b,0x00000015,0x00000016,
0x00000000,0x00020014,0x00000019,0x00040017,0x0000001a,0x00000019,0x00000002,0x0004001e,
0x00000021,0x00000006,0x00000006,0x00040020,0x00000022,0x00000009,0x00000021,0x0004003b,
0x00000022,0x00000023,0x00000009,0x0004002b,0x00000006,0x00000024,0x00000001,0x00040020,
0x00000025,0x00000009,0x00000006,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,
0x00000006,0x00000030,0x00000002,0x0005002c,0x00000007,0x00000033,0x00000028,0x00000028,
0x00040017,0x00000039,0x00000013,0x00000003,0x00040020,0x0000003a,0x00000007,0x00000039,
0x00090019,0x0000003c,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,
0x00000000,0x0003001b,0x0000003d,0x0000003c,0x00040020,0x0000003e,0x00000000,0x0000003d,
0x0004003b,0x0000003e,0x0000003f,0x00000000,0x00040017,0x00000043,0x00000013,0x00000004,
0x0004002b,0x00000013,0x00000046,0x00000000,0x0006002c,0x00000039,0x00000047,0x00000046,
0x00000046,0x00000046,0x00040017,0x0000004f,0x00000019,0x00000003,0x0004002b,0x00000013,
0x00000070,0x3f800000,0x0006002c,0x00000039,0x00000071,0x00000070,0x00000070,0x00000070,
0x0004002b,0x0000000a,0x0000007a,0x00000008,0x0004002b,0x0000000a,0x0000007b,0x00000001,
0x0006002c,0x0000000b,0x0000007c,0x0000007a,0x0000007a,0x0000007b,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,
0x00000007,0x0004003b,0x00000008,0x00000020,0x00000007,0x0004003b,0x00000008,0x0000002a,
0x00000007,0x0004003b,0x0000003a,0x0000003b,0x00000007,0x0004003b,0x0000003a,0x0000005f,
0x00000007,0x0004003b,0x0000003a,0x0000006c,0x00000007,0x0004003d,0x0000000b,0x0000000f,
0x0000000d,0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,
0x0004007c,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d,
0x00000007,0x00000012,0x00000009,0x0004003d,0x00000014,0x00000017,0x00000016,0x00040068,
0x00000007,0x00000018,0x00000017,0x000500af,0x0000001a,0x0000001b,0x00000012,0x00000018,
0x0004009a,0x00000019,0x0000001c,0x0000001b,0x000300f7,0x0000001e,0x00000000,0x000400fa,
0x0000001c,0x0000001d,0x0000001e,0x000200f8,0x0000001d,0x000100fd,0x000200f8,0x0000001e,
0x00050041,0x00000025,0x00000026,0x00000023,0x00000024,0x0004003d,0x00000006,0x00000027,
0x00000026,0x000500ab,0x00000019,0x00000029,0x00000027,0x00000028,0x000300f7,0x0000002c,
0x00000000,0x000400fa,0x00000029,0x0000002b,0x00000036,0x000200f8,0x0000002b,0x0004003d,
0x00000007,0x0000002d,0x00000009,0x0004003d,0x00000014,0x0000002e,0x00000016,0x00040068,
0x00000007,0x0000002f,0x0000002e,0x00050050,0x00000007,0x00000031,0x00000030,0x00000030,
0x00050082,0x00000007,0x00000032,0x0000002f,0x00000031,0x0007000c,0x00000007,0x00000034,
0x00000001,0x0000002a,0x00000032,0x00000033,0x0007000c,0x00000007,0x00000035,0x00000001,
0x00000027,0x0000002d,0x00000034,0x0003003e,0x0000002a,0x00000035,0x000200f9,0x0000002c,
0x000200f8,0x00000036,0x0004003d,0x00000007,0x00000037,0x00000009,0x0003003e,0x0000002a,
0x00000037,0x000200f9,0x0000002c,0x000200f8,0x0000002c,0x0004003d,0x00000007,0x00000038,
0x0000002a,0x0003003e,0x00000020,0x00000038,0x0004003d,0x0000003d,0x00000040,0x0000003f,
0x0004003d,0x00000007,0x00000041,0x00000020,0x00040064,0x0000003c,0x00000042,0x00000040,
0x0007005f,0x00000043,0x00000044,0x00000042,0x00000041,0x00000002,0x00000028,0x0008004f,
0x00000039,0x00000045,0x00000044,0x00000044,0x00000000,0x00000001,0x00000002,0x0007000c,
0x00000039,0x00000048,0x00000001,0x00000028,0x00000045,0x00000047,0x0003003e,0x0000003b,
0x00000048,0x00050041,0x00000025,0x00000049,0x00000023,0x00000024,0x0004003d,0x00000006,
0x0000004a,0x00000049,0x000500ab,0x00000019,0x0000004b,0x0000004a,0x00000028,0x000300f7,
0x0000004d,0x00000000,0x000400fa,0x0000004b,0x0000004c,0x0000004d,0x000200f8,0x0000004c,
0x0004003d,0x00000039,0x0000004e,0x0000003b,0x0004009c,0x0000004f,0x00000050,0x0000004e,
0x0004009a,0x00000019,0x00000051,0x00000050,0x000400a8,0x00000019,0x00000052,0x00000051,
0x000300f7,0x00000054,0x00000000,0x000400fa,0x00000052,0x00000053,0x00000054,0x000200f8,
0x00000053,0x0004003d,0x00000039,0x00000055,0x0000003b,0x0004009d,0x0000004f,0x00000056,
0x00000055,0x0004009a,0x00000019,0x00000057,0x00000056,0x000200f9,0x00000054,0x000200f8,
0x00000054,0x000700f5,0x00000019,0x00000058,0x00000051,0x0000004c,0x00000057,0x00000053,
0x000200f9,0x0000004d,0x000200f8,0x0000004d,0x000700f5,0x00000019,0x00000059,0x0000004b,
0x0000002c,0x00000058,0x00000054,0x000300f7,0x0000005b,0x00000000,0x000400fa,0x00000059,
0x0000005a,0x0000005b,0x000200f8,0x0000005a,0x0003003e,0x0000003b,0x00000047,0x000200f9,
0x0000005b,0x000200f8,0x0000005b,0x00050041,0x00000025,0x0000005c,0x00000023,0x00000028,
0x0004003d,0x00000006,0x0000005d,0x0000005c,0x000500ab,0x00000019,0x0000005e,0x0000005d,
0x00000028,0x000300f7,0x00000061,0x00000000,0x000400fa,0x0000005e,0x00000060,0x00000064,
0x000200f8,0x00000060,0x0004003d,0x00000039,0x00000062,0x0000003b,0x0006000c,0x00000039,
0x00000063,0x00000001,0x0000001f,0x00000062,0x0003003e,0x0000005f,0x00000063,0x000200f9,
0x00000061,0x000200f8,0x00000064,0x0004003d,0x00000039,0x00000065,0x0000003b,0x0003003e,
0x0000005f,0x00000065,0x000200f9,0x00000061,0x000200f8,0x00000061,0x0004003d,0x00000039,
0x00000066,0x0000005f,0x0003003e,0x0000003b,0x00000066,0x0004003d,0x00000014,0x00000067,
0x00000016,0x0004003d,0x00000007,0x00000068,0x00000009,0x00050041,0x00000025,0x00000069,
0x00000023,0x00000024,0x0004003d,0x00000006,0x0000006a,0x00000069,0x000500ab,0x00000019,
0x0000006b,0x0000006a,0x00000028,0x000300f7,0x0000006e,0x00000000,0x000400fa,0x0000006b,
0x0000006d,0x00000073,0x000200f8,0x0000006d,0x0004003d,0x00000039,0x0000006f,0x0000003b,
0x0007000c,0x00000039,0x00000072,0x00000001,0x00000025,0x0000006f,0x00000071,0x0003003e,
0x0000006c,0x00000072,0x000200f9,0x0000006e,0x000200f8,0x00000073,0x0004003d,0x00000039,
0x00000074,0x0000003b,0x0003003e,0x0000006c,0x00000074,0x000200f9,0x0000006e,0x000200f8,
0x0000006e,0x0004003d,0x00000039,0x00000075,0x0000006c,0x00050051,0x00000013,0x00000076,
0x00000075,0x00000000,0x00050051,0x00000013,0x00000077,0x00000075,0x00000001,0x00050051,
0x00000013,0x00000078,0x00000075,0x00000002,0x00070050,0x00000043,0x00000079,0x00000076,
0x00000077,0x00000078,0x00000070,0x00040063,0x00000067,0x00000068,0x00000079,0x000100fd,
0x00010038
};
33 changes: 33 additions & 0 deletions gpu/vk/shaders/dlss_debug.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#version 450
// (hookshot) RX_DLSS_DEBUG=1..4: DLSS's inputs drawn into the network's target in place of DLSS's output (vk_draw.cpp).
// 1: motion, 0.5 grey = still, R/G = 0.5 + x/y render pixels / 64 (toward the previous frame); 2: depth^64;
// 3: |last frame's colour fetched along the motion - this frame's colour| x4; 4: the same without the motion (the baseline)

layout(local_size_x = 8, local_size_y = 8) in;
layout(binding = 0) uniform sampler2D cur_color;
layout(binding = 1) uniform sampler2D motion;
layout(binding = 2) uniform sampler2D scene_depth;
layout(binding = 3) uniform sampler2D prev_color;
layout(binding = 4, r11f_g11f_b10f) uniform writeonly image2D target;
layout(push_constant) uniform P { int mode; } pc;

void main() {
ivec2 pixel = ivec2(gl_GlobalInvocationID.xy);
ivec2 extent = imageSize(target);
if (any(greaterThanEqual(pixel, extent))) {
return;
}
vec2 uv = (vec2(pixel) + 0.5) / vec2(extent);
vec2 mv = textureLod(motion, uv, 0).xy;
vec3 c;
if (pc.mode == 1) {
c = vec3(clamp(0.5 + mv / 64.0, 0.0, 1.0), 0.5);
} else if (pc.mode == 2) {
c = vec3(pow(textureLod(scene_depth, uv, 0).r, 64.0));
} else {
vec2 from = uv + (pc.mode == 3 ? mv / vec2(textureSize(cur_color, 0)) : vec2(0));
vec3 d = abs(textureLod(prev_color, from, 0).rgb - textureLod(cur_color, uv, 0).rgb);
c = vec3(min((d.r + d.g + d.b) * (4.0 / 3.0), 1.0));
}
imageStore(target, pixel, vec4(c, 1.0));
}
Loading