Give frame generation and FSR the scene's own near and far planes, field of view and units.

DLSS frame generation (Streamline and the NGX path) and FSR 3.1 and 4 upscaling and frame generation were told the depth came from a camera with near 0.1 and no far plane. Ocarina's projection has a finite far plane that changes with the camera: in Hyrule Field its z row is (-1.00001, -0.200001), near 0.1 and far about 25,000; the camera before it had far about 1,000. With the far plane taken as missing, a surface 10,000 units away was read as 16,650. The planes, and whether the depth is inverted, now come from the frame's projection and the device's depth mode every frame (vk_dlaa.c proj_planes), with one log line when they change. The stored depth is already 0 near and 1 far: the -w..w clip depth the pipelines keep maps to exactly what a 0..w projection with the same planes stores, and a frame dump's scene depth spans 0.975 to 1.0.

FSR's contexts lose their infinite-depth flag and take the far plane from each dispatch. FSR frame generation now gets the camera's field of view instead of a fixed 1 radian, and the upscaler gets it too (its caller passed 0). The view's units are metres, not the centimetres FSR was told: the camera orbits Link about 4 units behind him at about 3 units a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tangerineturtle1
2026-11-11 13:19:31 -05:00
parent 6a011d2adf
commit e1cb6301ab
7 changed files with 116 additions and 31 deletions

View File

@@ -27,10 +27,16 @@ int vk_dlaa_needs_restart(void); // the menu's upscaler cannot start in this r
int vk_dlaa_fg_inputs(VkFfxImage *depth, VkFfxImage *mv, float *jx, float *jy, int *reset);
// ... their views, and this frame's camera for DLSS Frame Generation (vk_dlssg.c): matrices for row vectors (v * M, the
// rows stored in order), as Streamline takes them; 0 without a camera that frame.
// znear and zfar: the view distances the depth buffer holds as 0 and 1 (1 and 0 when inverted), from the frame's own
// projection and the device's depth mode (vk_dlaa.c proj_planes); with an infinite far plane (infinite) zfar is
// VK_DLAA_FAR_INFINITE, a distance no surface reaches.
#define VK_DLAA_FAR_INFINITE 1e8f
typedef struct {
float view_to_clip[16], clip_to_view[16], clip_to_prev_clip[16], prev_clip_to_clip[16];
float pos[3], up[3], right[3], fwd[3];
float fov_y, aspect;
float znear, zfar;
int infinite, inverted;
} VkDlaaCamera;
int vk_dlaa_fg_views(VkImageView *depth, VkImageView *mv);
// The picture without the HUD at the size of the game's picture, in *fmt: RGBA8 UNORM bytes like it (sRGB-encoded), or
@@ -39,6 +45,7 @@ int vk_dlaa_fg_views(VkImageView *depth, VkImageView *mv);
extern int vk_dlaa_hudless_wanted;
int vk_dlaa_fg_hudless(VkImage *img, VkImageView *view, uint32_t *w, uint32_t *h, VkFormat *fmt);
int vk_dlaa_fg_camera(VkDlaaCamera *c); // ... and its temporal upscaler is AMD FSR 3.1 (NX2NAVI_TAA = fsr3) instead of DLSS
int vk_dlaa_ffx_camera(VkFfxCamera *c); // the same camera as FSR takes it (vk_ffx.h); 0 without one that frame
// vk_device.c: NGX's instance and device extensions join the lists (room for max names); vk_dlaa_init after the
// device exists brings NGX up and checks that DLSS is available.
void vk_dlaa_instance_exts(const char **ext, uint32_t *n, uint32_t max);