mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-22 17:19:58 -04:00
Triforce v0.7.0 "Sage Of Courage"
The 0.6 crashes after warps and area changes fixed (no write-back into memory the capture leaves out), invisible objects fixed (occlusion gate), DLSS frame generation flicker fixed, achievements, the renderer built with a play profile, faster translated game code, helper threads judged on settled scenes, memory, shader preparation, audio effects, launcher, controls and Linux fixes.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "predict_types.h" // ((Triforce, 11-22, PIPE-44) the prediction's checks: the vertex inputs' types)
|
||||
#include "vk_draw.h"
|
||||
#include "vk_shader.h"
|
||||
|
||||
@@ -24,6 +25,7 @@ uint64_t fnv(const void* p, size_t n, uint64_t h = 0xcbf29ce484222325ull) {
|
||||
struct Face {
|
||||
uint64_t vs = 0, fs = 0; // the vertex (or mesh) and fragment modules, by their SPIR-V (0: no fragment stage)
|
||||
uint32_t vs_locs = 0, fs_locs = 0; // generic inputs read, colour outputs written
|
||||
predict_types::Locations vs_in; // ((Triforce, 11-22, PIPE-44) the vertex inputs' base types, RX_VK_PREDICT_TYPES=1)
|
||||
};
|
||||
/// The locations of a module's Input (storage 1) or Output (3) variables
|
||||
uint32_t spirv_locations(const std::vector<uint32_t>& w, uint32_t storage) {
|
||||
@@ -78,28 +80,65 @@ struct Seen {
|
||||
it->second.insert(pv);
|
||||
}
|
||||
};
|
||||
/// Every class of an exact module, else the one most program variants of the signature had
|
||||
std::vector<Class> candidates(const Seen* exact, const Seen* sig) {
|
||||
if (exact && !exact->order.empty()) return exact->order;
|
||||
/// Every class of an exact module, else the one most program variants of the signature had. ((Triforce, 11-22, the
|
||||
/// performance audit's PIPE-44, after Source A's) Of those that fit: fits is always true but with RX_VK_PREDICT_TYPES=1,
|
||||
/// where a class whose attributes definitely differ from the program's vertex inputs' types is dropped and counted in
|
||||
/// *misfits, and an exact module whose classes all differ falls back to the signature's)
|
||||
template <class Fits>
|
||||
std::vector<Class> candidates(const Seen* exact, const Seen* sig, Fits fits, size_t* misfits) {
|
||||
if (exact && !exact->order.empty()) {
|
||||
std::vector<Class> kept;
|
||||
for (const Class& c : exact->order)
|
||||
if (fits(c)) kept.push_back(c);
|
||||
else (*misfits)++;
|
||||
if (!kept.empty()) return kept;
|
||||
}
|
||||
if (!sig || sig->order.empty()) return {};
|
||||
const Class* best = nullptr;
|
||||
size_t most = 0;
|
||||
for (const Class& c : sig->order)
|
||||
if (sig->by.at(c).size() > most) most = sig->by.at(c).size(), best = &c;
|
||||
if (sig->by.at(c).size() > most) {
|
||||
if (!fits(c)) {
|
||||
(*misfits)++;
|
||||
continue;
|
||||
}
|
||||
most = sig->by.at(c).size(), best = &c;
|
||||
}
|
||||
if (!best) return {};
|
||||
return {*best};
|
||||
}
|
||||
/// ((Triforce, 11-22, PIPE-44) What a note's vertex layout hands each location: unset (it reads zeros, as in play) or the
|
||||
/// attribute's kind as the translator reads it (attribute_type_of; scaled formats as integers)
|
||||
void layout_kinds(const PipeNote& n, predict_types::Kind out[16]) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
out[i] = predict_types::Kind::Unknown;
|
||||
const uint32_t a = n.s.vattr[i];
|
||||
if (i >= n.s.nvattr || (a >> 27) >= 15) continue;
|
||||
switch (attribute_type_of(a)) {
|
||||
case Shader::AttributeType::Float: out[i] = predict_types::Kind::Float; break;
|
||||
case Shader::AttributeType::UnsignedInt: case Shader::AttributeType::UnsignedScaled: out[i] = predict_types::Kind::Uint; break;
|
||||
case Shader::AttributeType::SignedInt: case Shader::AttributeType::SignedScaled: out[i] = predict_types::Kind::Sint; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/// ((Triforce, 11-21, PIPE-83) into the caller's note: predict_background makes one at a time of the two notes it reads)
|
||||
void predicted_into(PipeNote& n, const PipeNote& V, const PipeNote& O, uint64_t prog, uint64_t variant) {
|
||||
n = O;
|
||||
std::memcpy(n.s.vattr, V.s.vattr, sizeof n.s.vattr);
|
||||
n.s.nvattr = V.s.nvattr;
|
||||
std::memcpy(n.s.vstream, V.s.vstream, sizeof n.s.vstream);
|
||||
n.topo = V.topo;
|
||||
n.prog = prog, n.variant = variant;
|
||||
n.key = 0;
|
||||
}
|
||||
namespace {
|
||||
std::unique_ptr<PipeNote> predicted_note(const PipeNote& V, const PipeNote& O, uint64_t prog, uint64_t variant) {
|
||||
auto n = std::make_unique<PipeNote>(O);
|
||||
std::memcpy(n->s.vattr, V.s.vattr, sizeof n->s.vattr);
|
||||
n->s.nvattr = V.s.nvattr;
|
||||
std::memcpy(n->s.vstream, V.s.vstream, sizeof n->s.vstream);
|
||||
n->topo = V.topo;
|
||||
n->prog = prog, n->variant = variant;
|
||||
n->key = 0;
|
||||
auto n = std::make_unique<PipeNote>();
|
||||
predicted_into(*n, V, O, prog, variant);
|
||||
return n;
|
||||
}
|
||||
} // namespace
|
||||
@@ -118,14 +157,19 @@ std::vector<std::unique_ptr<PipeNote>> predict_rebuild(const std::vector<std::un
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<PipeNote>> predict_pipelines(const std::vector<std::unique_ptr<PipeNote>>& notes, size_t* programs,
|
||||
std::vector<PredictPlan>* plan) {
|
||||
std::vector<PredictPlan>* plan, PredictCounts* counts) {
|
||||
// ((Triforce, 11-22, PIPE-44) RX_VK_PREDICT_TYPES=1: the type check, predict_types.h)
|
||||
static const bool typed = predict_types::typed(predict_types::mode(getenv("RX_VK_PREDICT_TYPES")));
|
||||
PredictCounts tally;
|
||||
std::unordered_map<std::pair<uint64_t, uint64_t>, Face, PairHash> faces;
|
||||
program_cache_each([&](const KeptProgram& k) {
|
||||
Face f;
|
||||
for (const auto& [stage, spirv] : k.stages) {
|
||||
const uint64_t h = fnv(spirv.data(), spirv.size() * 4);
|
||||
if (stage == VK_SHADER_STAGE_VERTEX_BIT) f.vs = h, f.vs_locs = spirv_locations(spirv, 1);
|
||||
else if (stage == VK_SHADER_STAGE_TASK_BIT_EXT || stage == VK_SHADER_STAGE_MESH_BIT_EXT) f.vs = h, f.vs_locs = 0;
|
||||
if (stage == VK_SHADER_STAGE_VERTEX_BIT) {
|
||||
f.vs = h, f.vs_locs = spirv_locations(spirv, 1);
|
||||
if (typed) f.vs_in = predict_types::locations(spirv);
|
||||
} else if (stage == VK_SHADER_STAGE_TASK_BIT_EXT || stage == VK_SHADER_STAGE_MESH_BIT_EXT) f.vs = h, f.vs_locs = 0;
|
||||
else if (stage == VK_SHADER_STAGE_FRAGMENT_BIT) f.fs = h, f.fs_locs = spirv_locations(spirv, 3);
|
||||
}
|
||||
faces[{k.key, k.variant}] = f;
|
||||
@@ -136,7 +180,10 @@ std::vector<std::unique_ptr<PipeNote>> predict_pipelines(const std::vector<std::
|
||||
for (const auto& n : notes) {
|
||||
const std::pair<uint64_t, uint64_t> pv{n->prog, n->variant};
|
||||
const auto it = faces.find(pv);
|
||||
if (it == faces.end()) continue;
|
||||
if (it == faces.end()) { // ((Triforce, 11-22, PIPE-44) counted: a noted variant the programs' file has no face for)
|
||||
tally.no_face++;
|
||||
continue;
|
||||
}
|
||||
const Face& f = it->second;
|
||||
const Class v = vertex_class(*n, f.vs_locs), o = output_class(*n);
|
||||
vh[f.vs].add(v, pv), vsig[f.vs_locs].add(v, pv), fh[f.fs].add(o, pv), fsig[f.fs_locs].add(o, pv);
|
||||
@@ -151,8 +198,15 @@ std::vector<std::unique_ptr<PipeNote>> predict_pipelines(const std::vector<std::
|
||||
*programs = 0;
|
||||
for (const auto& [pv, f] : faces) {
|
||||
if (noted.count(pv)) continue;
|
||||
const std::vector<Class> vc = candidates(find(vh, f.vs), find(vsig, f.vs_locs));
|
||||
const std::vector<Class> oc = candidates(find(fh, f.fs), find(fsig, f.fs_locs));
|
||||
const auto vertex_fits = [&](const Class& c) {
|
||||
if (!typed || !f.vs_in.mask) return true;
|
||||
predict_types::Kind kinds[16];
|
||||
layout_kinds(*vdonor.at(c), kinds);
|
||||
return predict_types::fits(f.vs_in, kinds);
|
||||
};
|
||||
const auto any = [](const Class&) { return true; };
|
||||
const std::vector<Class> vc = candidates(find(vh, f.vs), find(vsig, f.vs_locs), vertex_fits, &tally.misfits);
|
||||
const std::vector<Class> oc = candidates(find(fh, f.fs), find(fsig, f.fs_locs), any, &tally.misfits);
|
||||
if (vc.empty() || oc.empty()) continue;
|
||||
(*programs)++;
|
||||
for (const Class& v : vc)
|
||||
@@ -163,6 +217,7 @@ std::vector<std::unique_ptr<PipeNote>> predict_pipelines(const std::vector<std::
|
||||
out.push_back(predicted_note(V, O, pv.first, pv.second));
|
||||
}
|
||||
}
|
||||
if (counts) *counts = tally;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user