mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 18:09:58 -04:00
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:
@@ -24,7 +24,7 @@ extern "C" {
|
||||
extern "C" int vk_ffx4_available(void) { return 0; }
|
||||
extern "C" const char *vk_ffx4_name(void) { return "AMD FSR 4"; }
|
||||
extern "C" int vk_ffx4_upscale(VkCommandBuffer, const VkFfxImage *, const VkFfxImage *, const VkFfxImage *, const VkFfxImage *,
|
||||
float, float, int, float, float) {
|
||||
float, float, int, float, const VkFfxCamera *) {
|
||||
return 0;
|
||||
}
|
||||
extern "C" void vk_ffx4_release(void) {}
|
||||
@@ -232,7 +232,7 @@ Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh) {
|
||||
slot->desc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;
|
||||
slot->desc.header.pNext = &slot->backend.header;
|
||||
slot->desc.flags =
|
||||
FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_DEPTH_INFINITE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE;
|
||||
FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE; // a finite far plane, as FSR 3.1's
|
||||
slot->desc.maxRenderSize = {mw, mh};
|
||||
slot->desc.maxUpscaleSize = {ow, oh};
|
||||
slot->desc.fpMessage = message;
|
||||
@@ -354,7 +354,7 @@ extern "C" void vk_ffx4_trim(uint64_t now_ns) {
|
||||
}
|
||||
|
||||
extern "C" int vk_ffx4_upscale(VkCommandBuffer cb, const VkFfxImage *color, const VkFfxImage *depth, const VkFfxImage *mv,
|
||||
const VkFfxImage *out, float jx, float jy, int reset, float dt_ms, float fov_y) {
|
||||
const VkFfxImage *out, float jx, float jy, int reset, float dt_ms, const VkFfxCamera *cam) {
|
||||
if (!vk_ffx4_available() || g_off.load(std::memory_order_acquire)) return 0;
|
||||
uint64_t now = plat_now_ns();
|
||||
if (g_failures && now < g_retry_ns) return 0; // FSR 3.1 serves until the next try
|
||||
@@ -382,10 +382,11 @@ extern "C" int vk_ffx4_upscale(VkCommandBuffer cb, const VkFfxImage *color, cons
|
||||
d.frameTimeDelta = dt_ms;
|
||||
d.preExposure = 1.0f;
|
||||
d.reset = reset != 0;
|
||||
d.cameraNear = 0.1f; // Ocarina's projection (vk_dlaa.c ocam_vp): near 0.1, far at infinity
|
||||
d.cameraFar = 1e8f;
|
||||
d.cameraFovAngleVertical = fov_y > 0 ? fov_y : 1.0f;
|
||||
d.viewSpaceToMetersFactor = 0.01f; // the game's units are centimetres
|
||||
// the frame's camera (vk_dlaa.c proj_planes), as FSR 3.1 gets it (vk_ffx.cpp)
|
||||
d.cameraNear = cam && cam->znear > 0 ? cam->znear : 0.1f;
|
||||
d.cameraFar = cam && cam->zfar > 0 ? cam->zfar : 1e8f;
|
||||
d.cameraFovAngleVertical = cam && cam->fov_y > 0 ? cam->fov_y : 1.0f;
|
||||
d.viewSpaceToMetersFactor = cam && cam->meters > 0 ? cam->meters : 1.0f;
|
||||
ffxReturnCode_t r = A.dispatch(&u->ctx, &d.header);
|
||||
if (r != FFX_API_RETURN_OK) {
|
||||
static int told;
|
||||
|
||||
Reference in New Issue
Block a user