mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
Triforce v0.5.0
In-game mods (GameBanana browser, search and installs, with the Mask Salesman), code-patch and cheat mods, the devs' test18 to test45 work (full performance overlay, frame pacing on, steady frame rate, save export and import, bug capture, new options rows, Setup's Mods page and Add to Steam), occlusion queries and new defaults, Auto resolution that scales, replay helper threads and robust buffers off by default, the options in sections.
This commit is contained in:
@@ -33,10 +33,12 @@ enum VkFormat { VK_FORMAT_R8G8B8A8_UNORM = 37, VK_FORMAT_BC1_RGB_UNORM_BLOCK = 1
|
||||
VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, VK_FORMAT_D32_SFLOAT = 126 };
|
||||
struct Texture { bool uploaded = false, astc = false, bc = false; VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
uint64_t gpu = 0x1000, guest_size = 0x4000; uint32_t id = 1, width = 64, height = 64, layers = 1; int nvn_format = 0; };
|
||||
#include "write_gen.h" /* (gpu/vk: a page write generation, 64 bits) */
|
||||
using mkwvk::WriteGen;
|
||||
static int logs;
|
||||
static void logf(const char *, ...) { logs++; }
|
||||
static uint32_t gpu_owned_since(uint64_t, uint64_t) { return 7; } /* (render targets took this storage) */
|
||||
static uint32_t decide(Texture *tex) {
|
||||
static WriteGen gpu_owned_since(uint64_t, uint64_t) { return WriteGen{7}; } /* (render targets took this storage) */
|
||||
static WriteGen decide(Texture *tex) {
|
||||
static const bool upload_all = false;
|
||||
DECISION
|
||||
return owned;
|
||||
@@ -51,11 +53,11 @@ int main(int argc, char **) {
|
||||
astc_raw.format = VK_FORMAT_ASTC_12x12_SRGB_BLOCK;
|
||||
etc2.format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
||||
depth.format = VK_FORMAT_D32_SFLOAT;
|
||||
CHECK(decide(&rgba) == 7 && decide(&depth) == 7); /* (formats the GPU renders: skipped as before) */
|
||||
for (Texture *t : {&bc, &bc_kept, &astc_decoded, &astc_raw, &etc2}) CHECK(decide(t) == (old_rule ? 7u : 0u));
|
||||
CHECK(decide(&rgba) == WriteGen{7} && decide(&depth) == WriteGen{7}); /* (formats the GPU renders: skipped as before) */
|
||||
for (Texture *t : {&bc, &bc_kept, &astc_decoded, &astc_raw, &etc2}) CHECK(decide(t) == (old_rule ? WriteGen{7} : WriteGen{}));
|
||||
Texture done = bc;
|
||||
done.uploaded = true;
|
||||
CHECK(decide(&done) == 0);
|
||||
CHECK(!decide(&done));
|
||||
CHECK(old_rule ? logs == 0 : logs > 0);
|
||||
std::printf("PASS: %s\n", old_rule ? "RX_VK_SKIP_COMPRESSED_OVER_RT=1: compressed textures skipped as before"
|
||||
: "compressed textures over render targets' storage uploaded, others skipped as before");
|
||||
@@ -69,24 +71,34 @@ OWNED = r'''#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
static std::map<uint64_t, std::pair<uint64_t, uint32_t>> gpu_owned;
|
||||
#include "write_gen.h" /* (gpu/vk: a page write generation, 64 bits) */
|
||||
using mkwvk::WriteGen;
|
||||
static std::map<uint64_t, std::pair<uint64_t, WriteGen>> gpu_owned;
|
||||
FUNCTION
|
||||
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL:%d %s\n", __LINE__, #x); return 1; } } while (0)
|
||||
static void set(std::initializer_list<std::pair<uint64_t, uint64_t>> r) {
|
||||
gpu_owned.clear();
|
||||
for (auto& x : r) gpu_owned[x.first] = {x.second, 5};
|
||||
for (auto& x : r) gpu_owned[x.first] = {x.second, WriteGen{5}};
|
||||
}
|
||||
int main() {
|
||||
const WriteGen none, five{5};
|
||||
set({{0x0, 0x3000}, {0x2000, 0x4000}}); /* (overlapping, with [0x4000, 0x5000) never drawn) */
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == 0);
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == none);
|
||||
set({{0x0, 0x3000}, {0x2000, 0x6000}}); /* (overlapping, covering it) */
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == 5);
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == five);
|
||||
set({{0x1000, 0x5000}});
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == 5);
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == five);
|
||||
set({{0x1000, 0x2000}, {0x3000, 0x5000}}); /* (a gap) */
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == 0);
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == none);
|
||||
set({});
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == 0);
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == none);
|
||||
/* (Triforce: generations past 2^32: the oldest of the ranges' is told, whole, not its low 32 bits) */
|
||||
const WriteGen late{(1ull << 32) + 5}, later{(1ull << 32) + 9};
|
||||
gpu_owned.clear();
|
||||
gpu_owned[0x1000] = {0x3000, later}, gpu_owned[0x3000] = {0x5000, late};
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == late);
|
||||
gpu_owned[0x3000] = {0x5000, WriteGen{0xFFFFFFF0ull}}; /* (one from before 2^32 is the older) */
|
||||
CHECK(gpu_owned_since(0x1000, 0x4000) == WriteGen{0xFFFFFFF0ull});
|
||||
std::printf("PASS: gpu_owned_since counts overlapping render-target ranges once: a gap never drawn is not the GPU's\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -100,7 +112,7 @@ def main():
|
||||
src = (ROOT / "gpu" / "vk" / "vk_texture.cpp").read_text(encoding="utf-8")
|
||||
body = src[src.index("Texture* texture_touch(Texture* tex, bool for_sampling) {"):]
|
||||
start = body.index(" static const bool skip_compressed")
|
||||
end = body.index("\n", body.index(" uint32_t owned = ", start))
|
||||
end = body.index("\n", body.index(" WriteGen owned = ", start))
|
||||
decision = body[start:end]
|
||||
assert "gpu_owned_since(tex->gpu, tex->guest_size)" in decision, decision
|
||||
# (the log after it is in the block: up to its closing brace)
|
||||
@@ -118,14 +130,16 @@ def main():
|
||||
# -Werror made that an error with clang on Windows)
|
||||
# (Triforce: this tree has no hookshot_env.h; the switch is read with getenv and atoi here, so <cstdlib> stands in)
|
||||
inc = ["-include", str(ENV_ON_H)] if ENV_ON_H.exists() else ["-include", "cstdlib"]
|
||||
subprocess.run([cxx, "-std=c++17", "-D_CRT_SECURE_NO_WARNINGS", *inc, "-Wall",
|
||||
# (Triforce: C++20 and gpu/vk on the include path, for write_gen.h: the cut code holds generations as WriteGen)
|
||||
vk = ["-I", str(ROOT / "gpu" / "vk")]
|
||||
subprocess.run([cxx, "-std=c++20", "-D_CRT_SECURE_NO_WARNINGS", *inc, *vk, "-Wall",
|
||||
"-Wno-unused-function", "-Werror", str(tmp / "f.cpp"), "-o", str(exe)],
|
||||
check=True)
|
||||
fn = src[src.index("uint32_t gpu_owned_since(uint64_t gpu, uint64_t n) {"):]
|
||||
fn = src[src.index("WriteGen gpu_owned_since(uint64_t gpu, uint64_t n) {"):]
|
||||
fn = fn[:fn.index("\n}\n") + 3]
|
||||
(tmp / "owned.cpp").write_text(OWNED.replace("FUNCTION", fn), encoding="utf-8")
|
||||
owned = tmp / ("owned.exe" if os.name == "nt" else "owned")
|
||||
subprocess.run([cxx, "-std=c++17", "-Wall", "-Werror", str(tmp / "owned.cpp"), "-o", str(owned)], check=True)
|
||||
subprocess.run([cxx, "-std=c++20", *vk, "-Wall", "-Werror", str(tmp / "owned.cpp"), "-o", str(owned)], check=True)
|
||||
r = subprocess.run([str(owned)], capture_output=True, text=True)
|
||||
print(r.stdout.strip())
|
||||
if r.returncode:
|
||||
|
||||
Reference in New Issue
Block a user