mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-21 00:59:59 -04:00
Triforce v0.6.0 "Sage Of Power"
Faster frames (the replay's memory work, held submits, helper threads, collection and capture cuts), the game letting old areas go (QueryMemoryInfo), the 0.5.2 stutter fixed, AMD RX 5000/6000 and integrated-GPU fixes, the GPU device chosen by name, the in-game menus and launcher reworked, controller, Linux and benchmark fixes.
This commit is contained in:
@@ -1,25 +1,30 @@
|
||||
// (Triforce) Foliage in the sun's far shadow cascades drawn with one face culled (vk_draw.cpp draw_cull, for dynamic_state;
|
||||
// RX_VK_FOLIAGE_SHADOW_CULL, off unless set), apart from Vulkan so that tests/test_foliage_shadow.py can run its rule.
|
||||
// (Triforce) The foliage in the sun's far shadow cascades, made cheaper (vk_draw.cpp draw_cull, for dynamic_state; and
|
||||
// foliage_rate, for the mesh draws), apart from Vulkan so that tests/test_foliage_shadow.py can run its rules. After NX2navi's
|
||||
// 754ded9 (epicmeme546's): 18 to 43 fps at Kokiri Forest's entrance on an RX 7900 XT there, the two halves together.
|
||||
//
|
||||
// The game draws its foliage cards (grass, ferns, leaves) double-sided with mesh programs, into the shadow cascades too: the
|
||||
// sun's three cascades are the layers of one depth array, 1600 x 1600 in the owner's logs. Seen from the sun the stacked,
|
||||
// alpha-tested cards cover the same texels many times over: NX2navi counted about 1,000 million fragments in one such draw of
|
||||
// the far cascade. With the switch, a draw of a mesh program (native, or through the compute fallback) into a cascade from the
|
||||
// given layer on, that culls neither face, is drawn with its back faces culled (its front ones with an "f"): half the cards'
|
||||
// fragments there. Cull mode is dynamic state, so no other pipeline is made. A cascade here is Triforce's own test for one,
|
||||
// as for the cascades' depth bias in dynamic_state: depth only, square, wider than 768 (the characters' own shadow maps, 768
|
||||
// and less, are never touched).
|
||||
// the far cascade. A cascade here is Triforce's own test for one, as for the cascades' depth bias in dynamic_state: depth only,
|
||||
// square, wider than 768 (the characters' own shadow maps, 768 and less, are never touched).
|
||||
//
|
||||
// The behaviour of NX2navi's NX2NAVI_FOLIAGE_SHADOW_CULL (epicmeme546's, on there from layer 1), written anew. It is not the same
|
||||
// picture: a card that faces away from the sun no longer casts its shadow in those cascades. Where cards stand in crossed pairs
|
||||
// or clumps others cover the same texels, but a lone card's shadow can go, so it is off here: a switch to compare, at
|
||||
// RX_VK_FOLIAGE_SHADOW_CULL=1 as NX2navi has it.
|
||||
// 1. The cull (RX_VK_FOLIAGE_SHADOW_CULL, on from layer 1 as NX2navi has it). A draw of a mesh program (native, or through the
|
||||
// compute fallback) into a cascade from the given layer on, that culls neither face, is drawn with its back faces culled (its
|
||||
// front ones with an "f"): half the cards' fragments there. Cull mode is dynamic state, so no other pipeline is made. It is not
|
||||
// quite the same picture: a card that faces away from the sun no longer casts its shadow in those cascades. Where cards stand in
|
||||
// crossed pairs or clumps (the game's foliage almost everywhere) the others cover the same texels; a lone card's shadow can go,
|
||||
// in the middle and far cascades only, where a texel is tens of centimetres to metres of ground and such a card is a fraction of
|
||||
// one. NX2navi kept it so (nothing done for a lone card), and so does this; the near cascade (layer 0) is drawn as the game asks.
|
||||
// RX_VK_FOLIAGE_SHADOW_CULL=off: as the game asks everywhere.
|
||||
//
|
||||
// Not done: NX2navi's second half, NX2NAVI_FOLIAGE_SHADOW_VRS (one fragment shaded per 2 x 2 pixels in those cascades, so the
|
||||
// leaves' alpha test runs a quarter as often). It needs VK_KHR_fragment_shading_rate enabled on the device, the shading rate as
|
||||
// dynamic state in every mesh pipeline and its libraries (a change to every mesh pipeline's creation, which the driver's cache
|
||||
// then misses) and vkCmdSetFragmentShadingRateKHR, which takes pointers, carried by the recorder (vk_recorder.h, vk_work.h);
|
||||
// none of that can be checked without the game, and its picture is not the same either (a coarser cut-out of the leaves).
|
||||
// 2. The shading rate (RX_VK_FOLIAGE_SHADOW_VRS, from layer 2 as NX2navi has it). The same draws, of native mesh programs, from
|
||||
// that layer on shade one fragment per 2 x 2 pixels (VK_KHR_fragment_shading_rate, pipelineFragmentShadingRate): the leaves'
|
||||
// alpha test runs a quarter as often. Depth is still tested and written for each texel; what is coarser is the alpha cut-out, in
|
||||
// 2 x 2 texels of the far cascade, metres of ground each. The rate is dynamic state in the pipelines that can draw such a draw and
|
||||
// in no other: native mesh programs with no colour target and a depth one (pipeline_rate), whose key that already names; they
|
||||
// set it at each draw (1 x 1 into any other target), their stage libraries are keyed apart. Where the device has no
|
||||
// pipelineFragmentShadingRate (older Intel, some APUs), without native mesh shaders, or RX_VK_FOLIAGE_SHADOW_VRS=off, the
|
||||
// extension is not enabled and no pipeline changes.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
@@ -30,30 +35,59 @@ namespace mkwvk::foliage_shadow {
|
||||
|
||||
constexpr int kNone = 0, kFront = 1, kBack = 2; // (NVN's faces: NVN_FACE_NONE, _FRONT, _BACK)
|
||||
constexpr uint32_t kCascadeMin = 769; // (a cascade is wider than 768: vk_draw.cpp dynamic_state's test)
|
||||
constexpr int kCullFrom = 1, kRateFrom = 2; // (NX2navi's layers: the cull from the middle cascade, the rate in the far one)
|
||||
|
||||
struct Rule {
|
||||
int from = -1; // (the first cascade layer it applies to; -1: off)
|
||||
bool front = false; // (the front faces culled, not the back ones)
|
||||
};
|
||||
|
||||
/// RX_VK_FOLIAGE_SHADOW_CULL=<layer>[f]: from that layer of the cascades on (the game has three, 0 to 2; 1 is NX2navi's), the back
|
||||
/// faces culled, the front ones with an "f" after the number. Unset, empty or not starting with a digit: off
|
||||
/// RX_VK_FOLIAGE_SHADOW_CULL=<layer>[f]: from that layer of the cascades on (the game has three, 0 to 2), the back faces culled,
|
||||
/// the front ones with an "f" after the number. Unset or empty: from layer 1, the back faces (NX2navi's). Anything not starting
|
||||
/// with a digit ("off", "-1"): off
|
||||
inline Rule parse(const char* e) {
|
||||
Rule r;
|
||||
if (!e || *e < '0' || *e > '9') return r;
|
||||
if (!e || !*e) return r.from = kCullFrom, r;
|
||||
if (*e < '0' || *e > '9') return r;
|
||||
r.from = std::atoi(e);
|
||||
r.front = std::strchr(e, 'f') != nullptr;
|
||||
return r;
|
||||
}
|
||||
|
||||
/// The face a draw culls: the game's (cull, NVN's face), or under the rule the one it names, for a draw of a mesh program into a
|
||||
/// cascade (no colour target, a depth target width x height, square and wider than 768, the depth view's first layer at
|
||||
/// rule.from or past it) that culls neither face
|
||||
/// RX_VK_FOLIAGE_SHADOW_VRS=<layer>: from that layer of the cascades on, one fragment per 2 x 2 pixels. Unset or empty: from
|
||||
/// layer 2 (NX2navi's). Anything not starting with a digit ("off", "-1"): off, and the device's extension is not asked for.
|
||||
/// Returns the first layer, -1 off
|
||||
inline int parse_rate(const char* e) {
|
||||
if (!e || !*e) return kRateFrom;
|
||||
if (*e < '0' || *e > '9') return -1;
|
||||
return std::atoi(e);
|
||||
}
|
||||
|
||||
/// A draw into a cascade from layer `from` on (no colour target, a depth target width x height, square and wider than 768, the
|
||||
/// depth view's first layer at from or past it), of a mesh program, that culls neither face as the game draws it
|
||||
inline bool far_foliage(int from, int game, bool mesh_program, int colour_targets, bool depth, uint32_t width, uint32_t height,
|
||||
uint32_t layer) {
|
||||
if (from < 0 || game != kNone || !mesh_program || colour_targets != 0 || !depth) return false;
|
||||
return width == height && width >= kCascadeMin && layer >= (uint32_t)from;
|
||||
}
|
||||
|
||||
/// The face a draw culls: the game's (cull, NVN's face), or under the rule the one it names, for far_foliage's draws
|
||||
inline int cull(const Rule& rule, int game, bool mesh_program, int colour_targets, bool depth, uint32_t width, uint32_t height,
|
||||
uint32_t layer) {
|
||||
if (rule.from < 0 || game != kNone || !mesh_program || colour_targets != 0 || !depth) return game;
|
||||
if (width != height || width < kCascadeMin || layer < (uint32_t)rule.from) return game;
|
||||
if (!far_foliage(rule.from, game, mesh_program, colour_targets, depth, width, height, layer)) return game;
|
||||
return rule.front ? kFront : kBack;
|
||||
}
|
||||
|
||||
/// Whether a pipeline has the shading rate as dynamic state: the rate is on (on), the program a native mesh one, no colour
|
||||
/// target and a depth one. Only what its key names (vk_draw.cpp pipeline_key): every pipeline of a key is made alike
|
||||
inline bool pipeline_rate(bool on, bool native_mesh, int colour_targets, bool depth_format) {
|
||||
return on && native_mesh && colour_targets == 0 && depth_format;
|
||||
}
|
||||
|
||||
/// The fragment size (1 or 2, both ways) a draw through such a pipeline sets: 2 for far_foliage's draws from layer `from` on
|
||||
inline uint32_t rate(int from, int game, bool native_mesh, int colour_targets, bool depth, uint32_t width, uint32_t height,
|
||||
uint32_t layer) {
|
||||
return far_foliage(from, game, native_mesh, colour_targets, depth, width, height, layer) ? 2u : 1u;
|
||||
}
|
||||
|
||||
} // namespace mkwvk::foliage_shadow
|
||||
|
||||
Reference in New Issue
Block a user