mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
Triforce v0.4.0
What was merged from NX2navi (DLSS frame generation, AMD FSR 4 in Setup builds, texture detail by video memory, sprint, volume, frame caps, safer saves, the above-60 fixes), the ultrawide HUD at the screen edges, camera speed, movies without the AV1 Video Extension, the 5120x2880 + RenoDX HDR start fix, the renderer work of 11-14 and the first float changes of the lift.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// projection (nx2/oot_jitter.py: P[0][2] and P[1][2]) is read back from it, given to FSR in render pixels and taken off the
|
||||
// motion, with dlss_math.h's functions: the same jitter, read the same way, as DLSS's.
|
||||
#include "vk_fsr3_inputs.h"
|
||||
#include "vk_dlssg.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
@@ -46,10 +47,15 @@ struct Image {
|
||||
struct Camera {
|
||||
float current[16]{}; // (its view-projection, jittered)
|
||||
float projection[16]{}; // (its projection, jittered: the near plane and the field of view come from it)
|
||||
float view[12]{}; // (its view matrix's three rows, at the buffer's start: NVIDIA DLSS frame generation's camera)
|
||||
float jitter[2]{}; // (the projection's offset of the picture's centre, in clip space: nx2/oot_jitter.py)
|
||||
uint32_t width = 0, height = 0;
|
||||
Texture* depth = nullptr;
|
||||
uint64_t depth_gen = 0; // (texture_destroy_generation when taken: a depth texture destroyed since is not used)
|
||||
// (the depth texture's creation number and texture_destroyed_count when taken: destroyed since, it is not used. It was
|
||||
// texture_destroy_generation, which any texture's end changes: with the video memory full the cache lets textures go
|
||||
// in most frames, and each of those frames was left to the game's own upscale)
|
||||
uint32_t depth_id = 0;
|
||||
uint64_t noted = 0;
|
||||
uint64_t frame = 0; // (texture_frame_no when taken)
|
||||
bool valid = false;
|
||||
};
|
||||
@@ -207,7 +213,8 @@ VkImageView depth_view(Texture* t) {
|
||||
|
||||
} // namespace
|
||||
|
||||
bool wanted() { return fsr3_wanted() || fsr3fi::frames_wanted() != 0; }
|
||||
// (Triforce: or NVIDIA DLSS frame generation, which takes the same depth and motion: vk_dlssg.cpp)
|
||||
bool wanted() { return fsr3_wanted() || fsr3fi::frames_wanted() != 0 || dlssg::active(); }
|
||||
|
||||
void note_scene_draw(const Texture* color0, uint32_t width, uint32_t height, Texture* depth, uint64_t camera,
|
||||
uint64_t camera_size) {
|
||||
@@ -227,9 +234,10 @@ void note_scene_draw(const Texture* color0, uint32_t width, uint32_t height, Tex
|
||||
Camera& k = s.cam;
|
||||
std::memcpy(k.current, c + 0x30 / 4, sizeof k.current);
|
||||
std::memcpy(k.projection, c + 0x70 / 4, sizeof k.projection);
|
||||
std::memcpy(k.view, c, sizeof k.view);
|
||||
// (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];
|
||||
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.depth = depth, k.depth_id = depth->id, k.noted = texture_destroyed_count(), k.frame = now;
|
||||
k.valid = true;
|
||||
}
|
||||
|
||||
@@ -249,7 +257,7 @@ bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out,
|
||||
if (!in || !in_view) return fail("no input view");
|
||||
const uint64_t now = texture_frame_no();
|
||||
if (!cam.valid || now - cam.frame > 1) return fail("no scene camera this frame");
|
||||
if (cam.depth_gen != texture_destroy_generation()) return fail("the scene depth may be gone");
|
||||
if (texture_destroyed_since(cam.depth_id, cam.noted)) return fail("the scene depth is gone");
|
||||
const uint32_t rw = in->width, rh = in->height;
|
||||
if (rw != cam.width || rh != cam.height) return fail("the input is not the scene's size");
|
||||
if (cam.depth->width != rw || cam.depth->height != rh || !(cam.depth->usage & VK_IMAGE_USAGE_SAMPLED_BIT) ||
|
||||
@@ -316,6 +324,16 @@ bool prepare(VkCommandBuffer cmd, Texture* in, VkImageView in_view, Frame& out,
|
||||
dlss_math::jitter_to_pixels(cam.jitter, rw, rh, f.jitter); // (in render pixels, x right and y down: FSR's, as DLSS's)
|
||||
f.camera = camera;
|
||||
f.reset = reset;
|
||||
{ // (Triforce, NVIDIA DLSS frame generation's: the images, and the matrices with no jitter in them on either side)
|
||||
f.depth_image = s.depth.image, f.motion_image = s.motion.image;
|
||||
std::memcpy(f.projection, projection, sizeof f.projection);
|
||||
std::memcpy(f.view, cam.view, sizeof f.view);
|
||||
float current[16];
|
||||
std::memcpy(current, cam.current, sizeof current);
|
||||
dlss_math::unjitter(current, cam.jitter);
|
||||
if (!motion || !dlss_math::reprojection(current, previous, f.clip_to_prev))
|
||||
for (int i = 0; i < 16; i++) f.clip_to_prev[i] = i % 5 == 0 ? 1.0f : 0.0f;
|
||||
}
|
||||
f.frame_ms = s.last_time.time_since_epoch().count() && !reset
|
||||
? (float)std::min(250.0, std::chrono::duration<double, std::milli>(t - s.last_time).count())
|
||||
: 16.667f;
|
||||
|
||||
Reference in New Issue
Block a user