Skip to content
Closed
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
6 changes: 6 additions & 0 deletions gpu/PROVENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ 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.
19 changes: 19 additions & 0 deletions gpu/vk/shaders/dlss_color.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#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; } 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
const vec3 c = max(texelFetch(guest_color, pixel, 0).rgb, vec3(0.0));
imageStore(dlss_color, pixel, vec4(pc.encode != 0 ? sqrt(c) : c, 1.0));
}
60 changes: 60 additions & 0 deletions gpu/vk/shaders/dlss_color_comp_spv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 1116.6.0
#pragma once
const uint32_t DLSS_COLOR_COMP_SPV[] = {
0x07230203,0x00010600,0x0008000b,0x0000004a,0x00000000,0x00020011,0x00000001,0x00020011,
0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,
0x00000000,0x00000001,0x0009000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,
0x00000016,0x00000026,0x00000035,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,0x00030005,0x00000022,0x00000063,0x00050005,0x00000026,0x73657567,0x6f635f74,
0x00726f6c,0x00030005,0x00000033,0x00000050,0x00050006,0x00000033,0x00000000,0x6f636e65,
0x00006564,0x00030005,0x00000035,0x00006370,0x00040047,0x0000000d,0x0000000b,0x0000001c,
0x00030047,0x00000016,0x00000019,0x00040047,0x00000016,0x00000021,0x00000001,0x00040047,
0x00000016,0x00000022,0x00000000,0x00040047,0x00000026,0x00000021,0x00000000,0x00040047,
0x00000026,0x00000022,0x00000000,0x00030047,0x00000033,0x00000002,0x00050048,0x00000033,
0x00000000,0x00000023,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,0x00040017,0x00000020,0x00000013,0x00000003,0x00040020,0x00000021,
0x00000007,0x00000020,0x00090019,0x00000023,0x00000013,0x00000001,0x00000000,0x00000000,
0x00000000,0x00000001,0x00000000,0x0003001b,0x00000024,0x00000023,0x00040020,0x00000025,
0x00000000,0x00000024,0x0004003b,0x00000025,0x00000026,0x00000000,0x0004002b,0x00000006,
0x00000029,0x00000000,0x00040017,0x0000002b,0x00000013,0x00000004,0x0004002b,0x00000013,
0x0000002e,0x00000000,0x0006002c,0x00000020,0x0000002f,0x0000002e,0x0000002e,0x0000002e,
0x0003001e,0x00000033,0x00000006,0x00040020,0x00000034,0x00000009,0x00000033,0x0004003b,
0x00000034,0x00000035,0x00000009,0x00040020,0x00000036,0x00000009,0x00000006,0x0004002b,
0x00000013,0x00000042,0x3f800000,0x0004002b,0x0000000a,0x00000047,0x00000008,0x0004002b,
0x0000000a,0x00000048,0x00000001,0x0006002c,0x0000000b,0x00000049,0x00000047,0x00000047,
0x00000048,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000021,0x00000022,0x00000007,
0x0004003b,0x00000021,0x0000003a,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,0x0004003d,
0x00000024,0x00000027,0x00000026,0x0004003d,0x00000007,0x00000028,0x00000009,0x00040064,
0x00000023,0x0000002a,0x00000027,0x0007005f,0x0000002b,0x0000002c,0x0000002a,0x00000028,
0x00000002,0x00000029,0x0008004f,0x00000020,0x0000002d,0x0000002c,0x0000002c,0x00000000,
0x00000001,0x00000002,0x0007000c,0x00000020,0x00000030,0x00000001,0x00000028,0x0000002d,
0x0000002f,0x0003003e,0x00000022,0x00000030,0x0004003d,0x00000014,0x00000031,0x00000016,
0x0004003d,0x00000007,0x00000032,0x00000009,0x00050041,0x00000036,0x00000037,0x00000035,
0x00000029,0x0004003d,0x00000006,0x00000038,0x00000037,0x000500ab,0x00000019,0x00000039,
0x00000038,0x00000029,0x000300f7,0x0000003c,0x00000000,0x000400fa,0x00000039,0x0000003b,
0x0000003f,0x000200f8,0x0000003b,0x0004003d,0x00000020,0x0000003d,0x00000022,0x0006000c,
0x00000020,0x0000003e,0x00000001,0x0000001f,0x0000003d,0x0003003e,0x0000003a,0x0000003e,
0x000200f9,0x0000003c,0x000200f8,0x0000003f,0x0004003d,0x00000020,0x00000040,0x00000022,
0x0003003e,0x0000003a,0x00000040,0x000200f9,0x0000003c,0x000200f8,0x0000003c,0x0004003d,
0x00000020,0x00000041,0x0000003a,0x00050051,0x00000013,0x00000043,0x00000041,0x00000000,
0x00050051,0x00000013,0x00000044,0x00000041,0x00000001,0x00050051,0x00000013,0x00000045,
0x00000041,0x00000002,0x00070050,0x0000002b,0x00000046,0x00000043,0x00000044,0x00000045,
0x00000042,0x00040063,0x00000031,0x00000032,0x00000046,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));
}
119 changes: 119 additions & 0 deletions gpu/vk/shaders/dlss_debug_comp_spv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// 1116.5.0
#pragma once
const uint32_t DLSS_DEBUG_COMP_SPV[] = {
0x07230203,0x00010600,0x0008000b,0x0000009b,0x00000000,0x00020011,0x00000001,0x00020011,
0x00000031,0x00020011,0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,
0x00000000,0x0003000e,0x00000000,0x00000001,0x000c000f,0x00000005,0x00000004,0x6e69616d,
0x00000000,0x0000000d,0x00000016,0x00000031,0x0000003a,0x0000005a,0x0000006d,0x00000078,
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,0x00040005,0x00000012,0x65747865,0x0000746e,0x00040005,0x00000016,0x67726174,
0x00007465,0x00030005,0x00000024,0x00007675,0x00030005,0x0000002d,0x0000766d,0x00040005,
0x00000031,0x69746f6d,0x00006e6f,0x00030005,0x00000038,0x00000050,0x00050006,0x00000038,
0x00000000,0x65646f6d,0x00000000,0x00030005,0x0000003a,0x00006370,0x00030005,0x00000045,
0x00000063,0x00050005,0x0000005a,0x6e656373,0x65645f65,0x00687470,0x00040005,0x00000063,
0x6d6f7266,0x00000000,0x00050005,0x0000006d,0x5f727563,0x6f6c6f63,0x00000072,0x00030005,
0x00000077,0x00000064,0x00050005,0x00000078,0x76657270,0x6c6f635f,0x0000726f,0x00040047,
0x0000000d,0x0000000b,0x0000001c,0x00030047,0x00000016,0x00000019,0x00040047,0x00000016,
0x00000021,0x00000004,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000031,
0x00000021,0x00000001,0x00040047,0x00000031,0x00000022,0x00000000,0x00030047,0x00000038,
0x00000002,0x00050048,0x00000038,0x00000000,0x00000023,0x00000000,0x00040047,0x0000005a,
0x00000021,0x00000002,0x00040047,0x0000005a,0x00000022,0x00000000,0x00040047,0x0000006d,
0x00000021,0x00000000,0x00040047,0x0000006d,0x00000022,0x00000000,0x00040047,0x00000078,
0x00000021,0x00000003,0x00040047,0x00000078,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,0x00000008,0x00040020,
0x00000015,0x00000000,0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x00020014,
0x0000001b,0x00040017,0x0000001c,0x0000001b,0x00000002,0x00040017,0x00000022,0x00000013,
0x00000002,0x00040020,0x00000023,0x00000007,0x00000022,0x0004002b,0x00000013,0x00000027,
0x3f000000,0x00090019,0x0000002e,0x00000013,0x00000001,0x00000000,0x00000000,0x00000000,
0x00000001,0x00000000,0x0003001b,0x0000002f,0x0000002e,0x00040020,0x00000030,0x00000000,
0x0000002f,0x0004003b,0x00000030,0x00000031,0x00000000,0x0004002b,0x00000013,0x00000034,
0x00000000,0x00040017,0x00000035,0x00000013,0x00000004,0x0003001e,0x00000038,0x00000006,
0x00040020,0x00000039,0x00000009,0x00000038,0x0004003b,0x00000039,0x0000003a,0x00000009,
0x0004002b,0x00000006,0x0000003b,0x00000000,0x00040020,0x0000003c,0x00000009,0x00000006,
0x0004002b,0x00000006,0x0000003f,0x00000001,0x00040017,0x00000043,0x00000013,0x00000003,
0x00040020,0x00000044,0x00000007,0x00000043,0x0004002b,0x00000013,0x00000047,0x42800000,
0x0004002b,0x00000013,0x0000004c,0x3f800000,0x0004002b,0x00000006,0x00000056,0x00000002,
0x0004003b,0x00000030,0x0000005a,0x00000000,0x0004002b,0x0000000a,0x0000005e,0x00000000,
0x0004002b,0x00000006,0x00000067,0x00000003,0x0004003b,0x00000030,0x0000006d,0x00000000,
0x0005002c,0x00000022,0x00000074,0x00000034,0x00000034,0x0004003b,0x00000030,0x00000078,
0x00000000,0x00040020,0x00000083,0x00000007,0x00000013,0x0004002b,0x0000000a,0x00000086,
0x00000001,0x0004002b,0x0000000a,0x0000008a,0x00000002,0x0004002b,0x00000013,0x0000008e,
0x3faaaaab,0x0004002b,0x0000000a,0x00000099,0x00000008,0x0006002c,0x0000000b,0x0000009a,
0x00000099,0x00000099,0x00000086,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,
0x00000012,0x00000007,0x0004003b,0x00000023,0x00000024,0x00000007,0x0004003b,0x00000023,
0x0000002d,0x00000007,0x0004003b,0x00000044,0x00000045,0x00000007,0x0004003b,0x00000023,
0x00000063,0x00000007,0x0004003b,0x00000023,0x00000069,0x00000007,0x0004003b,0x00000044,
0x00000077,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d,0x0007004f,0x0000000e,
0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,0x0004007c,0x00000007,0x00000011,
0x00000010,0x0003003e,0x00000009,0x00000011,0x0004003d,0x00000014,0x00000017,0x00000016,
0x00040068,0x00000007,0x00000018,0x00000017,0x0003003e,0x00000012,0x00000018,0x0004003d,
0x00000007,0x00000019,0x00000009,0x0004003d,0x00000007,0x0000001a,0x00000012,0x000500af,
0x0000001c,0x0000001d,0x00000019,0x0000001a,0x0004009a,0x0000001b,0x0000001e,0x0000001d,
0x000300f7,0x00000020,0x00000000,0x000400fa,0x0000001e,0x0000001f,0x00000020,0x000200f8,
0x0000001f,0x000100fd,0x000200f8,0x00000020,0x0004003d,0x00000007,0x00000025,0x00000009,
0x0004006f,0x00000022,0x00000026,0x00000025,0x00050050,0x00000022,0x00000028,0x00000027,
0x00000027,0x00050081,0x00000022,0x00000029,0x00000026,0x00000028,0x0004003d,0x00000007,
0x0000002a,0x00000012,0x0004006f,0x00000022,0x0000002b,0x0000002a,0x00050088,0x00000022,
0x0000002c,0x00000029,0x0000002b,0x0003003e,0x00000024,0x0000002c,0x0004003d,0x0000002f,
0x00000032,0x00000031,0x0004003d,0x00000022,0x00000033,0x00000024,0x00070058,0x00000035,
0x00000036,0x00000032,0x00000033,0x00000002,0x00000034,0x0007004f,0x00000022,0x00000037,
0x00000036,0x00000036,0x00000000,0x00000001,0x0003003e,0x0000002d,0x00000037,0x00050041,
0x0000003c,0x0000003d,0x0000003a,0x0000003b,0x0004003d,0x00000006,0x0000003e,0x0000003d,
0x000500aa,0x0000001b,0x00000040,0x0000003e,0x0000003f,0x000300f7,0x00000042,0x00000000,
0x000400fa,0x00000040,0x00000041,0x00000053,0x000200f8,0x00000041,0x0004003d,0x00000022,
0x00000046,0x0000002d,0x00050050,0x00000022,0x00000048,0x00000047,0x00000047,0x00050088,
0x00000022,0x00000049,0x00000046,0x00000048,0x00050050,0x00000022,0x0000004a,0x00000027,
0x00000027,0x00050081,0x00000022,0x0000004b,0x0000004a,0x00000049,0x00050050,0x00000022,
0x0000004d,0x00000034,0x00000034,0x00050050,0x00000022,0x0000004e,0x0000004c,0x0000004c,
0x0008000c,0x00000022,0x0000004f,0x00000001,0x0000002b,0x0000004b,0x0000004d,0x0000004e,
0x00050051,0x00000013,0x00000050,0x0000004f,0x00000000,0x00050051,0x00000013,0x00000051,
0x0000004f,0x00000001,0x00060050,0x00000043,0x00000052,0x00000050,0x00000051,0x00000027,
0x0003003e,0x00000045,0x00000052,0x000200f9,0x00000042,0x000200f8,0x00000053,0x00050041,
0x0000003c,0x00000054,0x0000003a,0x0000003b,0x0004003d,0x00000006,0x00000055,0x00000054,
0x000500aa,0x0000001b,0x00000057,0x00000055,0x00000056,0x000300f7,0x00000059,0x00000000,
0x000400fa,0x00000057,0x00000058,0x00000062,0x000200f8,0x00000058,0x0004003d,0x0000002f,
0x0000005b,0x0000005a,0x0004003d,0x00000022,0x0000005c,0x00000024,0x00070058,0x00000035,
0x0000005d,0x0000005b,0x0000005c,0x00000002,0x00000034,0x00050051,0x00000013,0x0000005f,
0x0000005d,0x00000000,0x0007000c,0x00000013,0x00000060,0x00000001,0x0000001a,0x0000005f,
0x00000047,0x00060050,0x00000043,0x00000061,0x00000060,0x00000060,0x00000060,0x0003003e,
0x00000045,0x00000061,0x000200f9,0x00000059,0x000200f8,0x00000062,0x0004003d,0x00000022,
0x00000064,0x00000024,0x00050041,0x0000003c,0x00000065,0x0000003a,0x0000003b,0x0004003d,
0x00000006,0x00000066,0x00000065,0x000500aa,0x0000001b,0x00000068,0x00000066,0x00000067,
0x000300f7,0x0000006b,0x00000000,0x000400fa,0x00000068,0x0000006a,0x00000073,0x000200f8,
0x0000006a,0x0004003d,0x00000022,0x0000006c,0x0000002d,0x0004003d,0x0000002f,0x0000006e,
0x0000006d,0x00040064,0x0000002e,0x0000006f,0x0000006e,0x00050067,0x00000007,0x00000070,
0x0000006f,0x0000003b,0x0004006f,0x00000022,0x00000071,0x00000070,0x00050088,0x00000022,
0x00000072,0x0000006c,0x00000071,0x0003003e,0x00000069,0x00000072,0x000200f9,0x0000006b,
0x000200f8,0x00000073,0x0003003e,0x00000069,0x00000074,0x000200f9,0x0000006b,0x000200f8,
0x0000006b,0x0004003d,0x00000022,0x00000075,0x00000069,0x00050081,0x00000022,0x00000076,
0x00000064,0x00000075,0x0003003e,0x00000063,0x00000076,0x0004003d,0x0000002f,0x00000079,
0x00000078,0x0004003d,0x00000022,0x0000007a,0x00000063,0x00070058,0x00000035,0x0000007b,
0x00000079,0x0000007a,0x00000002,0x00000034,0x0008004f,0x00000043,0x0000007c,0x0000007b,
0x0000007b,0x00000000,0x00000001,0x00000002,0x0004003d,0x0000002f,0x0000007d,0x0000006d,
0x0004003d,0x00000022,0x0000007e,0x00000024,0x00070058,0x00000035,0x0000007f,0x0000007d,
0x0000007e,0x00000002,0x00000034,0x0008004f,0x00000043,0x00000080,0x0000007f,0x0000007f,
0x00000000,0x00000001,0x00000002,0x00050083,0x00000043,0x00000081,0x0000007c,0x00000080,
0x0006000c,0x00000043,0x00000082,0x00000001,0x00000004,0x00000081,0x0003003e,0x00000077,
0x00000082,0x00050041,0x00000083,0x00000084,0x00000077,0x0000005e,0x0004003d,0x00000013,
0x00000085,0x00000084,0x00050041,0x00000083,0x00000087,0x00000077,0x00000086,0x0004003d,
0x00000013,0x00000088,0x00000087,0x00050081,0x00000013,0x00000089,0x00000085,0x00000088,
0x00050041,0x00000083,0x0000008b,0x00000077,0x0000008a,0x0004003d,0x00000013,0x0000008c,
0x0000008b,0x00050081,0x00000013,0x0000008d,0x00000089,0x0000008c,0x00050085,0x00000013,
0x0000008f,0x0000008d,0x0000008e,0x0007000c,0x00000013,0x00000090,0x00000001,0x00000025,
0x0000008f,0x0000004c,0x00060050,0x00000043,0x00000091,0x00000090,0x00000090,0x00000090,
0x0003003e,0x00000045,0x00000091,0x000200f9,0x00000059,0x000200f8,0x00000059,0x000200f9,
0x00000042,0x000200f8,0x00000042,0x0004003d,0x00000014,0x00000092,0x00000016,0x0004003d,
0x00000007,0x00000093,0x00000009,0x0004003d,0x00000043,0x00000094,0x00000045,0x00050051,
0x00000013,0x00000095,0x00000094,0x00000000,0x00050051,0x00000013,0x00000096,0x00000094,
0x00000001,0x00050051,0x00000013,0x00000097,0x00000094,0x00000002,0x00070050,0x00000035,
0x00000098,0x00000095,0x00000096,0x00000097,0x0000004c,0x00040063,0x00000092,0x00000093,
0x00000098,0x000100fd,0x00010038
};
33 changes: 33 additions & 0 deletions gpu/vk/shaders/dlss_motion.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#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 scene_depth;
layout(binding = 1, rg16f) uniform writeonly image2D motion;

layout(push_constant, row_major) uniform Parameters {
mat4 clip_to_previous_clip;
} params;

void main() {
ivec2 pixel = ivec2(gl_GlobalInvocationID.xy);
ivec2 extent = imageSize(motion);
if (any(greaterThanEqual(pixel, extent))) {
return;
}

vec2 size = vec2(extent);
float depth = texelFetch(scene_depth, pixel, 0).r;
vec2 screen = (vec2(pixel) + 0.5) / size;
// The captured Zelda path is unjittered, with [-1, 1] clip depth and negative viewport height.
vec4 clip = vec4(screen * vec2(2, -2) + vec2(-1, 1), depth * 2 - 1, 1);
vec4 previous = params.clip_to_previous_clip * clip;
vec2 pixels = vec2(0);
if (depth >= 0 && depth <= 1 && previous.w > 1e-6) {
vec2 displacement = (previous.xy / previous.w - clip.xy) * vec2(0.5, -0.5) * size;
if (all(lessThanEqual(abs(displacement), vec2(65504)))) {
pixels = displacement;
}
}
imageStore(motion, pixel, vec4(pixels, 0, 0));
}
Loading
Loading