mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-29 04:18:49 -04:00
Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
118
tests/test_ui_hdr_renodx.py
Normal file
118
tests/test_ui_hdr_renodx.py
Normal file
@@ -0,0 +1,118 @@
|
||||
"""The overlays on an HDR10 window coded as RenoDX's encoder codes the game's own menus (gpu/vk/vk_imgui.cpp UiHdr,
|
||||
ui_hdr_now, hdr10_of; no game).
|
||||
|
||||
(2026-11-26) The owner, of our options beside the game's own with HDR Native and RenoDX (PsychoV35, Color space DCI-P3):
|
||||
"washed out ... correct the shading to be exactly the same color and shading of the vanilla options". RenoDX's encoder
|
||||
(its zelda-oot-oz output shader) codes the finished picture, the game's menus in it, at the UI brightness row's nits, its
|
||||
colours as the Color space row says (Display P3: more saturated), after the Gamma correction row's power, unless its tone
|
||||
mapper and colour space are both Vanilla. The overlays were always at Paper white, BT.709, the sRGB curve. This compiles
|
||||
the three, cut out of vk_imgui.cpp as they are, and checks:
|
||||
|
||||
- without RenoDX, or with both its rows Vanilla: Paper white, BT.709, the sRGB curve, as before;
|
||||
- with RenoDX and PsychoV35: the UI brightness row's white;
|
||||
- Color space DCI-P3: an orange's blue lower than BT.709's (more saturated), white the same code;
|
||||
- Gamma correction 2.2: a dark brown's codes lower (darker shadows), white the same code.
|
||||
|
||||
python -I -B tests/test_ui_hdr_renodx.py [--cxx clang++]
|
||||
"""
|
||||
import argparse
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
VK = ROOT / "gpu" / "vk"
|
||||
RUN_ALL_ARGS = ["--cxx", "{cxx}"]
|
||||
|
||||
|
||||
def check(ok, why):
|
||||
if not ok:
|
||||
raise SystemExit("FAIL: " + why)
|
||||
|
||||
|
||||
def function(text, head):
|
||||
start = text.index(head)
|
||||
end = text.index("{", start) + 1
|
||||
depth = 1
|
||||
while depth:
|
||||
depth += (text[end] == "{") - (text[end] == "}")
|
||||
end += 1
|
||||
if text[end:end + 1] == ";":
|
||||
end += 1
|
||||
return text[start:end]
|
||||
|
||||
|
||||
PROGRAM = r"""
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
typedef unsigned int ImU32;
|
||||
#define IM_COL32_R_SHIFT 0
|
||||
#define IM_COL32_G_SHIFT 8
|
||||
#define IM_COL32_B_SHIFT 16
|
||||
#define IM_COL32_A_MASK 0xFF000000u
|
||||
#define IM_COL32_WHITE 0xFFFFFFFFu
|
||||
struct Opts { int hdr_white = 200, hdr = 2, rdx_space = 0, rdx_tonemap = 0, rdx_ui_white = 200, rdx_gamma = 0; } opts;
|
||||
static bool renodx = true;
|
||||
bool renodx_chosen() { return renodx; }
|
||||
%(ui)s
|
||||
static ImU32 rgb(int r, int g, int b) { return 0xFF000000u | (ImU32)b << 16 | (ImU32)g << 8 | (ImU32)r; }
|
||||
static int ch(ImU32 c, int k) { return (int)(c >> (8 * k) & 0xFF); }
|
||||
int main() {
|
||||
int fails = 0;
|
||||
const ImU32 orange = rgb(211, 144, 37), brown = rgb(48, 34, 21), white = rgb(255, 255, 255);
|
||||
// (Vanilla and Vanilla: as before)
|
||||
opts.rdx_tonemap = 0, opts.rdx_space = 0, opts.hdr_white = 300, opts.rdx_ui_white = 100;
|
||||
UiHdr u = ui_hdr_now();
|
||||
if (u.white != 300 || u.p3 || u.gamma != 0) std::puts("FAIL: RenoDX with its Vanilla rows is not as before"), fails++;
|
||||
renodx = false, opts.rdx_tonemap = 1, opts.rdx_space = 2;
|
||||
u = ui_hdr_now();
|
||||
if (u.white != 300 || u.p3 || u.gamma != 0) std::puts("FAIL: without RenoDX the rows count"), fails++;
|
||||
renodx = true, opts.hdr = 1;
|
||||
u = ui_hdr_now();
|
||||
if (u.white != 300 || u.p3) std::puts("FAIL: the SDR picture made HDR takes RenoDX's rows"), fails++;
|
||||
opts.hdr = 2, opts.hdr_white = 200, opts.rdx_ui_white = 200, opts.rdx_space = 1;
|
||||
u = ui_hdr_now();
|
||||
if (u.white != 200 || u.p3) std::puts("FAIL: PsychoV35, BT.709: not the UI brightness, BT.709"), fails++;
|
||||
const ImU32 o709 = hdr10_of(orange, u), w709 = hdr10_of(white, u), b709 = hdr10_of(brown, u);
|
||||
opts.rdx_space = 2;
|
||||
u = ui_hdr_now();
|
||||
if (!u.p3) std::puts("FAIL: Color space DCI-P3 not taken"), fails++;
|
||||
const ImU32 op3 = hdr10_of(orange, u), wp3 = hdr10_of(white, u);
|
||||
if (!(ch(op3, 2) < ch(o709, 2) && ch(op3, 0) > ch(o709, 0)))
|
||||
std::printf("FAIL: P3's orange not more saturated: %d,%d,%d against %d,%d,%d\n", ch(op3, 0), ch(op3, 1), ch(op3, 2), ch(o709, 0), ch(o709, 1), ch(o709, 2)), fails++;
|
||||
for (int k = 0; k < 3; k++)
|
||||
if (std::abs(ch(wp3, k) - ch(w709, k)) > 1) std::puts("FAIL: white is not white in P3"), fails++;
|
||||
opts.rdx_space = 1, opts.rdx_gamma = 1;
|
||||
u = ui_hdr_now();
|
||||
const ImU32 b22 = hdr10_of(brown, u), w22 = hdr10_of(white, u);
|
||||
if (u.gamma != 2.2f || !(ch(b22, 0) < ch(b709, 0))) std::puts("FAIL: gamma 2.2 does not darken the shadows"), fails++;
|
||||
if (ch(w22, 0) != ch(w709, 0)) std::puts("FAIL: gamma 2.2 moved white"), fails++;
|
||||
opts.rdx_ui_white = 400, opts.rdx_gamma = 0;
|
||||
u = ui_hdr_now();
|
||||
if (!(ch(hdr10_of(white, u), 0) > ch(w709, 0))) std::puts("FAIL: the UI brightness does not raise white"), fails++;
|
||||
return fails;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--cxx", default="clang++")
|
||||
args = parser.parse_args()
|
||||
imgui = (VK / "vk_imgui.cpp").read_text(encoding="utf-8")
|
||||
ui = "\n".join([function(imgui, "struct UiHdr {"), function(imgui, "UiHdr ui_hdr_now() {"), function(imgui, "ImU32 hdr10_of(ImU32 c, const UiHdr& u) {")])
|
||||
check("static const float kP3[9] = {0.753833f, 0.198597f, 0.047570f" in ui, "hdr10_of has no Display P3 to Rec. 2020 matrix")
|
||||
check("const UiHdr u = ui_hdr_now();" in function(imgui, "void hdr10(ImDrawData* dd) {"), "the draw lists are not coded by ui_hdr_now")
|
||||
check(imgui.count("hdr10_texel(c, u)") == 1, "the textures are not coded by ui_hdr_now")
|
||||
with tempfile.TemporaryDirectory(prefix="ui-hdr-") as tmp:
|
||||
src, exe = Path(tmp) / "ui.cpp", Path(tmp) / "ui.exe"
|
||||
src.write_text(PROGRAM.replace("%(ui)s", ui), encoding="utf-8")
|
||||
subprocess.run([args.cxx, "-std=c++20", "-O1", "-w", str(src), "-o", str(exe)], check=True)
|
||||
r = subprocess.run([str(exe)], capture_output=True, text=True)
|
||||
check(r.returncode == 0, "the overlays' HDR coding:\n" + r.stdout)
|
||||
print("PASS: the overlays on an HDR10 window coded as RenoDX codes the game's menus")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user