diff --git a/README.md b/README.md index 168e94fc25..2316b490f2 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ builds into `Documents\Leonida`; `python -I make_game.py --help` lists every opt of work space (the asset export alone about 370 GB), Python 3.12+, the .NET 8 SDK, the Vulkan SDK, LLVM 21+ with the AMDGPU target for `llvm-mc` (`scripts\build_llvm_mc.ps1` builds one on Windows) and, for the runtime stage, Visual Studio 2022 with the Windows SDK 10.0.26100 or newer; `--stages check,shaders,runtime` needs about 30 GB. Clone with -`--recursive` for the `third_party/rpf9-explorer` submodule. [docs/design.md](docs/design.md) has the formats and the +`git clone --recursive https://github.com/ProjectLeonida/mandy` for the `third_party/rpf9-explorer` submodule. [docs/design.md](docs/design.md) has the formats and the translator's contract, [docs/linux.md](docs/linux.md) the Linux steps. | Piece | Where it stands | diff --git a/d3d12/README.md b/d3d12/README.md index f759768e0d..41ebb21be3 100644 --- a/d3d12/README.md +++ b/d3d12/README.md @@ -17,7 +17,7 @@ On a Ryzen 5 7600X with a GeForce RTX 4060 Ti 16 GB, the Series X profile render frames a second is not reached yet. On RTX 40 and 50 cards, DLSS frame generation is on by default when NVIDIA's files are there (`Get-NVIDIA-DLSS.cmd`): it shows twice the frames, held to 28 a second by Reflex (`LEONIDA_FG_LIMIT_FPS`) with presents paced evenly (`LEONIDA_PRESENT_SMOOTH`); `-NoFrameGen` turns it off. The -measurements and what is still wrong in the picture are in the [top-level README](../README.md#project-status). +measurements and what is still wrong in the picture are in the [top-level README](../README.md#where-it-stands). ## Leonida's picture fixes diff --git a/docs/i18n/ar/quickstart.md b/docs/i18n/ar/quickstart.md index d28d5fc700..970da67c22 100644 --- a/docs/i18n/ar/quickstart.md +++ b/docs/i18n/ar/quickstart.md @@ -3,7 +3,7 @@ # دليل البدء السريع لمشروع Leonida الوثائق الإنجليزية هي المرجع المعتمد. يستند هذا الدليل إلى المراجعة `561b65a` ويغطي خطوات البدء الأساسية. -راجع [ملف README بالإنجليزية](../../../README.md#project-status) لمعرفة حالة المشروع الحالية، و[فهرس الوثائق](../../README.md) للمزيد من التفاصيل. +راجع [ملف README بالإنجليزية](../../../README.md#where-it-stands) لمعرفة حالة المشروع الحالية، و[فهرس الوثائق](../../README.md) للمزيد من التفاصيل. ## ما هو Leonida؟ @@ -72,7 +72,7 @@ python -I make_game.py --game "D:\path\to\package" --out "D:\Games\Leonida" --wo يعمل `make_game.py` على Linux، ويجد `llvm-mc` تلقائيًا إذا كان ضمن `PATH`. تأكد من أن نسخته تدعم AMDGPU. يعمل محمّل اللعبة، وهو برنامج Windows، عبر Wine أو Proton. إذا كان لديك بناء Windows جاهز للمحمّل، -فمرّر مجلده باستخدام `--runtime-build`. راجع [تعليمات البناء والتشغيل على Linux](../../../README.md#running-the-loader-on-linux). +فمرّر مجلده باستخدام `--runtime-build`. راجع [تعليمات البناء والتشغيل على Linux](../../linux.md). ## حل المشاكل الشائعة diff --git a/make_game.py b/make_game.py index a7a38ca60f..a01f980600 100644 --- a/make_game.py +++ b/make_game.py @@ -1324,7 +1324,7 @@ def read_translation_index(index: str) -> dict: with open(index, encoding="utf-8-sig") as f: shaders = json.load(f) if not isinstance(shaders, dict): - raise ValueError("expected a JSON object keyed by shader name") + raise ValueError("must contain a JSON object keyed by shader name") return shaders @@ -2980,8 +2980,6 @@ def require_translated_shaders(work: str) -> str: except (OSError, ValueError) as e: fail(f"The translated shader index {index} is unreadable ({getattr(e, 'strerror', None) or e}): " "run the shaders stage again.") - if not isinstance(translated, dict): - fail(f"The translated shader index {index} must contain a JSON object. Run the shaders stage again.") if not translated: # A build from before the shaders stage refused an empty merge can carry this marker. fail(f"The translated shader index {index} is empty, so there is nothing to check. Run the shaders stage again.") diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 411a52b6ca..5a53557195 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -275,7 +275,8 @@ if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME) # /MAP writes gta6rt.map next to the exe (link.exe and lld-link): gta6rt_no_tls_callbacks names each TLS callback from # it, to tell the C++ runtime's __dyn_tls_init (tlsdyn.obj) and __dyn_tls_dtor (tlsdtor.obj) from Rust std's own # callback. It does not change the exe. - target_link_options(gta6rt PRIVATE /OPT:NOREF ${GTA6RT_HOST_BASE} /STACK:${GTA6RT_STACK} /MAP) + # /STACK goes last: tests/test_build_runtime_fallback.py reads the reserve at the end of this line. + target_link_options(gta6rt PRIVATE /OPT:NOREF ${GTA6RT_HOST_BASE} /MAP /STACK:${GTA6RT_STACK}) target_link_libraries(gta6rt PRIVATE gta6rt_bcpack gta6rt_d3d12_xs_rootsig gta6rt_xtaskqueue psapi) # Root-signature forwarding test: needs a real PC d3d12.lib to serialize the synthetic descriptors. diff --git a/runtime/test/pipeline_workers_test.cpp b/runtime/test/pipeline_workers_test.cpp index b830dc5fa7..3b09083e06 100644 --- a/runtime/test/pipeline_workers_test.cpp +++ b/runtime/test/pipeline_workers_test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -336,6 +337,19 @@ void oom_during_start_and_enqueue() { PipelineWorkers pool(4); std::vector> calls(6); const std::function job = [&calls](std::size_t i) { calls[i].fetch_add(1); }; + // Whether run()'s queue_.push_back can succeed here, asked of a fresh deque of the same element type under + // the same OOM rather than read back from the counters under test. + bool pushed = true; + { + std::deque probe; + OomScope oom(OomScope::FailAll{}); + try { + probe.push_back(nullptr); + } catch (const std::bad_alloc&) { + pushed = false; + } + } + const auto before = pool.stats(); bool threw = false; try { OomScope oom(OomScope::FailAll{}); @@ -345,14 +359,18 @@ void oom_during_start_and_enqueue() { } check(!threw, "hard oom on first batch threw instead of running inline"); for (auto& c : calls) check(c == 1, "hard oom inline fallback lost or repeated a job"); + // libstdc++'s deque owns its first node from construction, so the one push_back may succeed; the batch is + // then counted and the caller runs it. When the push does fail, the inline fallback counts nothing. const auto during = pool.stats(); - check(during.started == 0 && during.batches == 0 && during.jobs == 0 && during.running == 0, + check(during.started == 0 && during.running == 0, "hard oom started no worker"); + check(pushed ? during.batches == before.batches + 1 && during.jobs == before.jobs + 6 + : during.batches == before.batches && during.jobs == before.jobs, "hard oom inline fallback kept stats clean"); std::vector> after(5); pool.run(after.size(), [&](std::size_t i) { after[i].fetch_add(1); }); for (auto& c : after) check(c == 1, "batch after hard oom lost or repeated a job"); - check(pool.stats().started == 4 && pool.stats().batches == 1 && pool.stats().running == 0, + check(pool.stats().started == 4 && pool.stats().batches == during.batches + 1 && pool.stats().running == 0, "pool works normally once memory is available again"); } } diff --git a/runtime/test/shaders/cs_imgatomic_ext.asm b/runtime/test/shaders/cs_imgatomic_ext.asm index e58ecbcb60..84fba49ce4 100644 --- a/runtime/test/shaders/cs_imgatomic_ext.asm +++ b/runtime/test/shaders/cs_imgatomic_ext.asm @@ -56,10 +56,10 @@ s_mov_b32 s8, 0x5000 s_mov_b32 s9, 0x1400000 s_mov_b32 s10, 0x55 s_mov_b32 s11, 0x55 -s_mov_b32 s12, 0x55 +s_mov_b32 s12, 0x80000055 s_mov_b32 s13, 0x55 s_mov_b32 s14, 0x55 -s_mov_b32 s15, 0x55 +s_mov_b32 s15, 0xd7801800 s_mov_b32 s16, 0x2000 s_mov_b32 s17, 0x1400000 s_mov_b32 s18, 0x22 diff --git a/runtime/test/vk_bindless_dimensions_test.cpp b/runtime/test/vk_bindless_dimensions_test.cpp index 3da8370d66..c3da54a036 100644 --- a/runtime/test/vk_bindless_dimensions_test.cpp +++ b/runtime/test/vk_bindless_dimensions_test.cpp @@ -404,6 +404,50 @@ int main() { return 77; } + // The limits above are only the sampled-image ones; the sizing also answers to the resource and set limits (an + // Apple Paravirtual device under MoltenVK stops at the 256 defaults). Whether the device holds live_images + 1 of + // each of the three beside what the sizing gave the rest is asked of those limits and of + // vkGetDescriptorSetLayoutSupport, as size_bindings' fits() does, not read back from the counts under test. + const auto& limits = properties.properties.limits; + BindlessFeatures wanted = features; + const std::uint32_t storage = wanted.counts[bindless::storage_binding(ImageDimension::dim_2d, 0)]; + for (const ImageDimension dimension : + {ImageDimension::dim_1d, ImageDimension::dim_2d_array, ImageDimension::dim_3d}) { + auto& sampled = wanted.counts[bindless::sampled_binding(dimension)]; + sampled = std::max(sampled, live_images + 1); + // A storage array holds the 2D storage count up to its dimension's images, as size_bindings' apply(true). + const std::uint32_t held = std::min(storage, sampled); + for (std::uint32_t c = 0; c < 3; ++c) wanted.counts[bindless::storage_binding(dimension, c)] = held; + if (bindless::r32ui_binding(dimension) != bindless::no_binding) + wanted.counts[bindless::r32ui_binding(dimension)] = held; + } + std::uint64_t sampled = 0, stored = 0, resources = 0, all = 0; + for (std::uint32_t b = 0; b < bindless::binding_count; ++b) { + if (!bindless::binding_enabled(b, wanted)) continue; + const VkDescriptorType type = bindless::bindings[b].type; + all += wanted.counts[b]; + if (type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) sampled += wanted.counts[b]; + if (type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) stored += wanted.counts[b]; + if (type != VK_DESCRIPTOR_TYPE_SAMPLER) resources += wanted.counts[b]; + } + const std::uint32_t storage_limit = std::min(v12.maxPerStageDescriptorUpdateAfterBindStorageImages, + v12.maxDescriptorSetUpdateAfterBindStorageImages); + const std::uint32_t resource_limit = + v12.maxPerStageUpdateAfterBindResources - + std::min(v12.maxPerStageUpdateAfterBindResources, std::min(limits.maxColorAttachments, 8u)); + const auto within = [](std::uint64_t n, std::uint32_t limit) { return n + bindless::growth_headroom <= limit; }; + if (!within(sampled, sampled_limit) || !within(stored, storage_limit) || !within(resources, resource_limit) || + all > v12.maxUpdateAfterBindDescriptorsInAllPools || + (all > v11.maxPerSetDescriptors && !layout_supported(wanted))) { + std::printf("unsupported: the device's resource and set limits hold fewer than %u images of each dimension\n", + live_images + 1); + return 77; + } + // The device holds them, so the sizing must have given them (the 4096 1D and 3D cap this test is for). + for (const ImageDimension dimension : + {ImageDimension::dim_1d, ImageDimension::dim_2d_array, ImageDimension::dim_3d}) + EXPECT(features.counts[bindless::sampled_binding(dimension)] > live_images); + const std::vector code = load_spirv(LEONIDA_TEST_BINDLESS_DIMENSIONS_SPV); EXPECT(!code.empty()); const std::uint32_t max_layers = properties.properties.limits.maxImageArrayLayers; diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 95edd30654..203f081b61 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -4295,10 +4295,12 @@ int check_list_values() { raw(lv, 14, 1, 1, 1); EXPECT(hr_of(raw(lv, 9)) == S_OK); g_queue_call_count = 0; - const ULONGLONG started = GetTickCount64(); + // steady_clock, not GetTickCount64: its 15.6 ms steps can report 15 ms for a 30 ms wait + const auto started = std::chrono::steady_clock::now(); EXPECT(submit(qb, lv) == 0); EXPECT(g_queue_call_count == 2 && queue_call_is(0, qb_mock, 15, word(b_gate), 2)); - EXPECT(xs::list_values_idle(3000) && fence_completed(b_gate) == 2 && GetTickCount64() - started >= 20); + EXPECT(xs::list_values_idle(3000) && fence_completed(b_gate) == 2 && + std::chrono::steady_clock::now() - started >= std::chrono::milliseconds(20)); stats = xs::list_value_stats(); EXPECT(stats.gates_timed_out == 1 && stats.waits_met_at_submit >= 1); xs::set_list_value_wait_timeout_ms(5000); diff --git a/scripts/run_game_wine.sh b/scripts/run_game_wine.sh index 9d8f19a37b..cc60d67670 100755 --- a/scripts/run_game_wine.sh +++ b/scripts/run_game_wine.sh @@ -228,13 +228,14 @@ DRM_SYSFS=${LEONIDA_DRM_SYSFS_DIR:-/sys/class/drm} if [ -n "$DEVICE" ]; then export MESA_VK_DEVICE_SELECT="$DEVICE!" # kwin and Xwayland's glamor on the card that renders, so the present path stays on one device. - dev_lc=${DEVICE,,} + lc() { printf '%s' "$1" | tr '[:upper:]' '[:lower:]'; } # not ${x,,}: macOS's bash 3.2 lacks it + dev_lc=$(lc "$DEVICE") for n in "$DRM_SYSFS"/renderD*; do [ -e "$n" ] || continue ven=$(cat "$n/device/vendor" 2>/dev/null || true) did=$(cat "$n/device/device" 2>/dev/null || true) ven=${ven//$'\r'/}; did=${did//$'\r'/} - [ "${ven,,}:${did,,}" = "0x${dev_lc%%:*}:0x${dev_lc#*:}" ] \ + [ "$(lc "$ven"):$(lc "$did")" = "0x${dev_lc%%:*}:0x${dev_lc#*:}" ] \ && export KWIN_DRM_DEVICES=/dev/dri/${n##*/} done else diff --git a/tests/semantic/test_valu_cvt_f16_int16_mods.py b/tests/semantic/test_valu_cvt_f16_int16_mods.py index 7141fbf195..995da602b5 100644 --- a/tests/semantic/test_valu_cvt_f16_int16_mods.py +++ b/tests/semantic/test_valu_cvt_f16_int16_mods.py @@ -70,10 +70,30 @@ def test_sdwa_clamp(self): self.assertEqual(words[0], 0x0000FFFE) # -2 clamped to +0.0 in WORD_1, WORD_0 preserved self.assertEqual(words[1], 0x00003C00) # 2 clamped to 1.0 in WORD_0, WORD_1 padded with 0 - def test_f16_to_int16_output_modifiers_still_rejected(self): + def test_f16_to_int16_output_modifiers_are_hardware_noops(self): + # Measured on RDNA2: clamp and mul:/div: change nothing on an integer destination (rdna2spirv.py, v_cvt_*_f16). + words = run_ps([ + "v_mov_b32 v0, 0xdead4500", + "v_cvt_u16_f16 v0, v0 clamp", + "v_mov_b32 v1, 0xbeefc000", + "v_cvt_i16_f16 v1, v1 mul:4", + "v_mov_b32 v2, 0xcafe4200", + "v_cvt_u16_f16 v2, v2 div:2", + "v_mov_b32 v3, 0x0000c000", + "v_cvt_i16_f16_sdwa v3, v3 clamp dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0", + "exp mrt0 v0, v1, v2, v3 done vm", + "s_endpgm", + ]) + self.assertEqual(words[0], 0xDEAD0005) # 5.0, not clamped to 1 + self.assertEqual(words[1], 0xBEEFFFFE) # -2.0, not scaled + self.assertEqual(words[2], 0xCAFE0003) # 3.0, not halved + self.assertEqual(words[3], 0x0000FFFE) # SDWA clamp ignored too + + def test_f16_to_int16_unknown_modifiers_still_rejected(self): for op in ("v_cvt_u16_f16", "v_cvt_i16_f16"): - with self.subTest(op=op), self.assertRaises(rdna2spirv.Unsupported): - translate_lines("ps_cvt_f16_reject", [f"{op} v0, v0 clamp", "exp mrt0 v0, v0, v0, v0 done vm", "s_endpgm"]) + for form, mod in ((op, "mul:8"), (op + "_e32", "clamp")): + with self.subTest(form=form, mod=mod), self.assertRaises(rdna2spirv.Unsupported): + translate_lines("ps_cvt_f16_reject", [f"{form} v0, v0 {mod}", "exp mrt0 v0, v0, v0, v0 done vm", "s_endpgm"]) if __name__ == "__main__": diff --git a/tests/test_bcpack_history_calib.py b/tests/test_bcpack_history_calib.py index 7c3c065295..8eb7e7460a 100644 --- a/tests/test_bcpack_history_calib.py +++ b/tests/test_bcpack_history_calib.py @@ -1194,7 +1194,9 @@ class PathDeduplicationAndGuardTest(unittest.TestCase): def _darwin(case_sensitive_result): fake_os = mock.Mock(wraps=os, pathconf=mock.Mock(return_value=case_sensitive_result)) fake_os.path.normcase = posixpath.normcase - return mock.patch.multiple(report_paths, sys=mock.Mock(platform="darwin"), os=fake_os) + # The scratch-folder probe asks the real volume, which on a Mac is case-insensitive whatever pathconf says here. + return mock.patch.multiple(report_paths, sys=mock.Mock(platform="darwin"), os=fake_os, + _same_resolved_name=mock.Mock(return_value=False)) def test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive(self): with mock.patch.object(calib._ttpf, "find_pools", side_effect=lambda p: [p]): diff --git a/tests/test_d3d12_guid_tools_errors.py b/tests/test_d3d12_guid_tools_errors.py index db6cc3289f..181e4d9531 100644 --- a/tests/test_d3d12_guid_tools_errors.py +++ b/tests/test_d3d12_guid_tools_errors.py @@ -96,10 +96,18 @@ def test_good_header_and_stub_behave_as_before(self): self.assertIn("imports from d3d12_xs.dll: #50", p.stdout) self.assertIn("WARNING: these d3d12_xs.dll imports may be IID data", p.stdout) - p = self.run_tool("d3d12_guid_sites", image, "--header", header) - self.assertEqual(p.returncode, 0, p.stderr) - self.assertIn("1 known GUIDs from", p.stdout) - self.assertNotIn("Traceback", p.stderr) + # The first line is "{n} known GUIDs from {header}". The tool also adds tools/gdk_runtime_classes.json + # when that file is next to it (PR #487 on main), so the header's one entry is the difference from an + # empty header. + counts = {} + for h in (header, self.write("empty.h", b"")): + p = self.run_tool("d3d12_guid_sites", image, "--header", h) + self.assertEqual(p.returncode, 0, p.stderr) + self.assertNotIn("Traceback", p.stderr) + line = next((row for row in p.stdout.splitlines() if "known GUIDs from" in row), "") + self.assertIn(h, line) + counts[h] = int(line.split()[0]) + self.assertEqual(counts[header] - counts[h], 1) if __name__ == "__main__": diff --git a/tests/test_docs_cli_flags.py b/tests/test_docs_cli_flags.py index 2514ce9aa4..2182eb7b68 100644 --- a/tests/test_docs_cli_flags.py +++ b/tests/test_docs_cli_flags.py @@ -104,7 +104,9 @@ def extract_ps1_params(content): i += 1 param_body = cleaned[start:i - 1 if depth == 0 else i] - parts, cur, nest = [], [], 0 + # Each part is cut at its default, the first "=" outside brackets and quotes: [Parameter(Mandatory = $true)] + # has one inside, and [ValidatePattern('^[(]$')] a quoted bracket. + parts, cur, nest, cut = [], [], 0, None in_sgl = in_dbl = False for ch in param_body: if ch == "'" and not in_dbl: @@ -118,16 +120,17 @@ def extract_ps1_params(content): if nest > 0: nest -= 1 elif ch == "," and nest == 0: - parts.append("".join(cur).strip()) - cur = [] + parts.append("".join(cur[:cut]).strip()) + cur, cut = [], None continue + elif ch == "=" and nest == 0 and cut is None: + cut = len(cur) cur.append(ch) if cur: - parts.append("".join(cur).strip()) + parts.append("".join(cur[:cut]).strip()) params = set() - for part in parts: - decl = part.split("=", 1)[0] + for decl in parts: vars_found = re.findall(r"\$([a-zA-Z_][a-zA-Z0-9_]*)", decl) if vars_found: params.add(vars_found[-1].lower()) @@ -251,8 +254,10 @@ def test_checkers_report_only_the_missing_flag(self): self.assertEqual(tool_flag_mismatches(pages, sources), []) ps1_pages = {"docs/b.md": "```\n.\\scripts\\test.ps1 -ValidParam -BadParam\n```\n"} - ps1_sources = {"scripts/test.ps1": "param([string]$ValidParam)"} + ps1_sources = {"scripts/test.ps1": "param([Parameter(Mandatory = $true)][string]$ValidParam)"} self.assertEqual(ps1_flag_mismatches(ps1_pages, ps1_sources), [("docs/b.md:2", "scripts/test.ps1", "-BadParam")]) + self.assertEqual(extract_ps1_params("param([ValidatePattern('^[(]$')][string]$Name = $Fallback, $Other)"), + {"name", "other"}) rust = '#[arg(long)]\n/// doc\npub one_submit: bool,\n#[arg(short, long)]\nno_merge: bool,\n' self.assertEqual(clap_long_flags(rust), ["--one-submit", "--no-merge"]) diff --git a/tests/test_run_game_wine_safety.py b/tests/test_run_game_wine_safety.py index 9c9de01698..ce2d6a1c51 100644 --- a/tests/test_run_game_wine_safety.py +++ b/tests/test_run_game_wine_safety.py @@ -147,6 +147,8 @@ def test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation(se _write_lf(sbin / "flock", "#!/usr/bin/env bash\nexit 0\n", executable=True) _write_lf(sbin / "pkill", "#!/usr/bin/env bash\nexit 0\n", executable=True) _write_lf(sbin / "timeout", "#!/usr/bin/env bash\nshift 3\n\"$@\"\n", executable=True) + # --visible probes DISPLAY with xdpyinfo when the host has one; the fake :99 must not depend on that. + _write_lf(sbin / "xdpyinfo", "#!/usr/bin/env bash\nexit 0\n", executable=True) _write_lf( sbin / "python3", "#!/usr/bin/env bash\n" diff --git a/tests/test_sampler_source_census.py b/tests/test_sampler_source_census.py index 7e744ec2e6..84faf9941a 100644 --- a/tests/test_sampler_source_census.py +++ b/tests/test_sampler_source_census.py @@ -438,7 +438,7 @@ def test_statistics_bound_what_the_classes_cannot_decide(self): ("s_add_u32 s10, s10, 0x7fff0000", 8), ("s_mov_b32 s11, 0", 4), ("s_load_dwordx8 s[20:27], s[10:11], 0x800", 8), - ("s_lshl3_add_u32 s8, s8, 0x30", 4), + ("s_lshl3_add_u32 s8, 6, s8", 4), ("s_mov_b32 s9, 0", 4), ("s_load_dwordx4 s[28:31], s[8:9], 0x10", 8), SAMPLE, END, diff --git a/tests/test_spirv_metal_set0_cli_errors.py b/tests/test_spirv_metal_set0_cli_errors.py index 18a58e25a1..5a2744b652 100644 --- a/tests/test_spirv_metal_set0_cli_errors.py +++ b/tests/test_spirv_metal_set0_cli_errors.py @@ -74,7 +74,8 @@ def test_spirv_as_that_cannot_be_started(self): def test_spirv_as_that_fails(self): lines = self.assert_failed(self.run_tool(sys.executable, sys.executable)) # spirv-as writes to the terminal itself; the tool's own line comes last. - self.assertEqual(lines[-1], f"ERROR: {sys.executable} failed with exit status 2") + # The first line spirv-as printed to stderr follows the exit status. + self.assertTrue(lines[-1].startswith(f"ERROR: {sys.executable} failed with exit status 2: "), lines) self.assertEqual([line for line in lines if line.startswith("ERROR: ")], lines[-1:]) def test_usage_and_layout_still_work_through_cli(self): diff --git a/tests/test_spirv_metal_set0_extra.py b/tests/test_spirv_metal_set0_extra.py index eb31eb06b2..7dd104f510 100644 --- a/tests/test_spirv_metal_set0_extra.py +++ b/tests/test_spirv_metal_set0_extra.py @@ -343,7 +343,7 @@ def _make_fake_spirv_tools(dis_name="spirv-dis", asm_name="spirv-as"): """Return a subprocess.run replacement backed by the synthetic SPIR-V binary codec.""" calls: list[list[str]] = [] - def fake_run(cmd, check=False, capture_output=False, text=False, input=None, errors=None): + def fake_run(cmd, check=False, capture_output=False, text=False, input=None, errors=None, encoding=None): calls.append(list(cmd)) exe = cmd[0] if exe == dis_name: @@ -699,7 +699,7 @@ def test_out_of_bounds_set0_binding_raises_system_exit(self): self.assertIn("%bad", str(ctx.exception)) self.assertIn(f"binding {b}", str(ctx.exception)) - def test_missing_uint32_type_raises_when_runtime_array_rewritten(self): + def test_missing_uint32_type_is_declared_before_the_array_length(self): base = """\ OpDecorate %images DescriptorSet 0 OpDecorate %images Binding 0 @@ -716,9 +716,9 @@ def test_missing_uint32_type_raises_when_runtime_array_rewritten(self): ("unsigned_64", "%u64 = OpTypeInt 64 0"), ): with self.subTest(case=label): - with self.assertRaises(SystemExit) as ctx: - m.rewrite(base.format(int_decl=int_decl), [4096]) - self.assertIn("no 32-bit uint type", str(ctx.exception)) + out = m.rewrite(base.format(int_decl=int_decl), [4096]) + self.assertEqual(out.count("%msl_uint = OpTypeInt 32 0"), 1) + self.assertLess(out.index("%msl_uint = OpTypeInt 32 0"), out.index("%msl_cap_b0 = OpConstant %msl_uint 4096")) class TestMainAndCli(unittest.TestCase): @@ -904,7 +904,7 @@ def test_target_env_extraction_and_env_var_overrides(self): disasm = header_text + "OpCapability Shader\n" seen_cmds = [] - def run_stub(cmd, check=False, capture_output=False, text=False, input=None, errors=None): + def run_stub(cmd, check=False, capture_output=False, text=False, input=None, errors=None, encoding=None): seen_cmds.append((list(cmd), check, capture_output, text, input)) if len(seen_cmds) == 1: return subprocess.CompletedProcess(cmd, 0, disasm, "") diff --git a/tests/test_windows_boot_journal_seed.py b/tests/test_windows_boot_journal_seed.py index 21d20c4726..7be507d12c 100644 --- a/tests/test_windows_boot_journal_seed.py +++ b/tests/test_windows_boot_journal_seed.py @@ -23,7 +23,7 @@ @unittest.skipUnless(sys.platform == "win32" and POWERSHELL, "boot.ps1 is a Windows PowerShell script") class BootJournalSeedTest(unittest.TestCase): def setUp(self): - self.tmp = Path(tempfile.mkdtemp(prefix="leonida_boot_seed_")) + self.tmp = Path(os.path.realpath(tempfile.mkdtemp(prefix="leonida_boot_seed_"))) # not the RUNNER~1 short name self.addCleanup(shutil.rmtree, self.tmp, ignore_errors=True) self.runtime = self.tmp / "port" self.runtime.mkdir() diff --git a/tools/psin_dialogue.py b/tools/psin_dialogue.py index 9669ae73b8..dd0196bd03 100644 --- a/tools/psin_dialogue.py +++ b/tools/psin_dialogue.py @@ -1,8 +1,13 @@ """Read speaker slots and subtitle labels from typed PSIN conversation records.""" import collections +import os import re import struct +import sys + +# `python -I` implies `-P`, so the script's directory is not on sys.path; the sibling modules are next to it. +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from psin_data import Container diff --git a/tools/rdna2spirv.py b/tools/rdna2spirv.py index 156fdf52f7..f1a402311b 100644 --- a/tools/rdna2spirv.py +++ b/tools/rdna2spirv.py @@ -11377,7 +11377,7 @@ def f64(sv): # 16-bit <-> f16 conversions of the low half (op_sel:[src,dst] picks the high half of the source / of the # destination); the other half of the destination is kept, as for the other 16-bit-result ops. f16 -> int # truncates toward zero, saturates to the 16-bit range (an f16 infinity too) and gives 0 for NaN, as the - # 32-bit conversions do (docs/design.md, "Float-to-int saturation"); output modifiers stay rejected on it. + # 32-bit conversions do (docs/design.md, "Float-to-int saturation"); clamp and omod are accepted as no-ops (below). # int -> f16 applies clamp_mods (mul:/div: then [0, 1] clamp) and rounds like every f16 result (f16_out). sel, dhi = self.opsel_bits(mods, 1) if op in ("v_cvt_f16_u16", "v_cvt_f16_i16"):