"""(Triforce, 11-26) The game's gameplay upscale with RenoDX's RGBA16F scene and the game's own upscaler (gpu/vk/vk_draw.cpp wide_upscale). On the lab's RX 7900 XT with the owner's settings, Render resolution 75% and Auto (the 3/4 network, fd029a317a9a4b94) drew a black 3D, and 67% and 50% (their networks left out on that card, 6676619641320ba7 and 72ba090c70fe2614) a 3D veiled in white: upscale_stub's plain blit copied the network's input, the square root of the scene colour, as it is. The same at a fresh start. Now the stand-in's own pass (shaders/taau_upscale.comp, which squares it back) draws them into an R11G11B10F scratch image, blitted into the RGBA16F picture. What it checks: wide_upscale is for a run whose scene is RGBA16F alone, with RX_VK_WIDE_UPSCALE=0 over it; it squares through typed_upscale into an R11G11B10F image at the output's size and blits that into the output's level; taau_stand_in gives it the 3/4 network when that network's output is RGBA16F (not with the upscaler Off or N64 Classic, whose own stand-ins go first); and upscale_stub gives it an RGBA16F network's pass before the plain blit, under the lock it holds. The shader squares its input. No game, no GPU. python -I -B tests/test_wide_upscale.py """ from pathlib import Path ROOT = Path(__file__).resolve().parents[1] VK = ROOT / "gpu" / "vk" def check(ok, why): if not ok: raise SystemExit("FAIL: " + why) def function(src, head): at = src.find(head) check(at >= 0, head + " is missing") body = src[at:] return body[:body.index("\n}\n")] def main(): draw = (VK / "vk_draw.cpp").read_text(encoding="utf-8") wide = function(draw, "static bool wide_upscale(VkCommandBuffer cmd, VkImageView input_view, Texture* out, uint32_t level, " "uint64_t key, const char* keys,\n bool temporal) {") check("!temporal_scene_format(VK_FORMAT_R16G16B16A16_SFLOAT)" in wide and 'getenv("RX_VK_WIDE_UPSCALE")' in wide and "out->format != VK_FORMAT_R16G16B16A16_SFLOAT" in wide, "wide_upscale is not for an RGBA16F scene's picture alone") check("ic.format = VK_FORMAT_B10G11R11_UFLOAT_PACK32;" in wide and "VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT" in wide, "the scratch image is not R11G11B10F, stored and blitted from") order = [wide.index(p) for p in ("typed_upscale(cmd, input_view, scratch.view, nullptr, 0, key, keys, temporal, w, h)", "full_barrier(cmd);", "vkCmdBlitImage(cmd, scratch.image, VK_IMAGE_LAYOUT_GENERAL, out->image", "texture_written(out);")] check(order == sorted(order), "wide_upscale does not square into the scratch image, then blit it into the picture") check("bl.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, level, 0, 1};" in wide, "the blit is not into the output's level") check("texture_frame_no() - old[i].frame < 120" in wide, "a scratch image of another size is given back before work in flight is done") typed = function(draw, "static bool typed_upscale(VkCommandBuffer cmd, VkImageView input_view, VkImageView output_view,\n" " Texture* out, uint32_t level, uint64_t key, const char* keys, bool temporal, uint32_t out_w, uint32_t out_h) {") check("out_w ? out_w : std::max(1u, out->width >> level)" in typed and "if (temporal && out) probe_image(" in typed, "typed_upscale does not take a size of its own for a scratch image") stand = function(draw, "bool taau_stand_in(VkCommandBuffer cmd, const NvnState& s, const Program& p) {") check("const bool wide = p.key == 0xfd029a317a9a4b94ull && !off && !n64;" in stand and "if (!ch.stand_in && !wide) return false;" in stand and "if (wide && out && out->format == VK_FORMAT_R16G16B16A16_SFLOAT) {" in stand and 'wide_upscale(cmd, dw().imgs[0].imageView, out, level, p.key, "fd029a317a9a4b94, RGBA16F", true)' in stand, "taau_stand_in does not give the 3/4 network's RGBA16F picture to wide_upscale") check(stand.index("wide_upscale(") < stand.index("if (!ch.stand_in || !out || out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return false;"), "the RGBA16F stand-in comes after the SDR one's refusal") stub = function(draw, "bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) {") check('wide_upscale(cmd, input_view, dst, 0, key, "a network left out, RGBA16F", false)' in stub and stub.index("ParLock lk;\n VkFormatProperties fs{}, fd{};") < stub.index("wide_upscale(") < stub.index("vkCmdBlitImage(cmd, src->image"), "upscale_stub does not give an RGBA16F network's pass to wide_upscale before the plain blit, under its lock") shader = (VK / "shaders" / "taau_upscale.comp").read_text(encoding="utf-8") check("vec3 c = s * s;" in shader, "the stand-in's pass no longer squares the network's input back") check("| `RX_VK_WIDE_UPSCALE=0` |" in (ROOT / "docs" / "development.md").read_text(encoding="utf-8"), "docs/development.md has no row for RX_VK_WIDE_UPSCALE") print("PASS: the RGBA16F scene's gameplay upscale, squared back") if __name__ == "__main__": main()