Repository navigation
shader: categorise refusals and isolate translation failures per request - #3799
Conversation
40aab7e to
c8cdc10
Compare
|
Rebased onto |
R0Y00
left a comment
There was a problem hiding this comment.
Confirmed the rebase keeps the reason_code constructor spelling required by the Windows build. At c8cdc10a I built compile_dxil, native_compute_pack_check and native_compute_pack_refusal_check in Windows Debug. ctest --preset dev --no-tests=error -j 2 -R '^(native_compile_dxil_refusals|native_compute_pack(_parts|_refusals)?|startup_triage_run)$' --output-on-failure passed 5/5, including refusal isolation and the injected pack failure control.
Problem
The shader translator reports an input it cannot handle by throwing
UnsupportedComputeShader, optionally with a reason code. Three paths did not follow that contract:std::runtime_errorfor a truncated, misaligned or malformed instruction, and returned an instruction with an empty mnemonic for an unknown opcode. Callers then had to treat an empty name as a special case, and one of them (name.substr(name.size()-4)in the SDWA compare path) indexed before the start of an empty name.std::logic_error. While a compute pack was being prepared, the per-record handler caught onlystd::runtime_error, so such an exception was not confined to its record.This PR is part of making the translator base more solid: every refusal has a category, and one failing request does not affect the others.
Change
Refusal categories:
UnsupportedComputeShadermoves to its own header,src/shader_translation_error.h, sogfx1013_isaandgfx1013_compute_ircan throw it without including the native translator header.invalid_isa.gfx1013::instruction()now refuses an unknown opcode with codeunknown_isa_opcodeand the messageunknown gfx1013 opcode <n> at byte <pc>. The newgfx1013::probe_instruction()keeps the previous structural decode (form, opcode, size, empty mnemonic) for the two mesh lookahead sites that only inspect the next instruction.Failure isolation:
translate_compute,translate_compute_container,translate_graphics_container,translate_mesh_program,translate_mesh_container,translate_mesh_pixel_program,translate_graphics_pair,translate_reflected_graphics) convert astd::logic_errorinto a refusal with codeinternaland the message prefixinternal:.build_compute_frontend_packtracks each record as prepared, unsupported or internal, and catchesstd::exceptionper record. An internal failure is written to the pack as a refusal record like any other, the remaining records are published unchanged, andComputePackCountsgains aninternalcount.compile_dxil --prepare-compute-packprintsinternal=<n>aftererrors=<n>and returns a failing status wheninternalis non-zero. Scripts that parse this line need to accept the extra field.tools/startup/triage_run.pygroups the new unknown-opcode message with the existingunsupported opcodereason and reportsinternal:messages asinternal translator error.Tests and documentation:
gfx1013_isa:valid_vop3_empty_namebecomesrefuse_unknown_vop3, andrefuse_unknown_vopc_sdwais added (VOPC opcode0x40with an SDWA extension word). Refusal cases now check the reason code as well as the diagnostic, and the two unknown-opcode cases also check the probe result. The case count goes from 80 to 81; the Python model, the CMake fragment anddocs/experiments/gfx1013-isa.mdare updated to match.native_compute_pack_refusals(tests/cmake/native_compute_pack_refusals.cmake). It builds a second copy of the pack check from sources with two injected faults, one in the translator and one in the per-record pack code, each selected by a distincts_nopprefix. It checks the reported refusal codes, the counts and exit status, that the record with the forced invariant failure carriesinternal: forced translation failure, that the unaffected records are byte-identical to those from the unmodified build, and that the pack is identical with 1 and 3 preparation threads.startup_triage_runcovers the two new report groups and checks that the text of an internal error is not echoed.The third commit is a build fix: MSVC rejected a qualified local enumerator used as a default member initializer of a local struct (
RecordStatus status = RecordStatus::prepared, error C2653). The member is now value-initialized withstatus{}, which selects the first enumerator,prepared.Validation
Built on Windows with MSVC and run on the exact head
40aab7ea6:Result: PASS.
The first attempt, on the second commit, failed to build with MSVC (C2653, described above). The third commit fixes it, and the result above is from the head that includes it.
Not covered by this run: hardware GPU tests, and a comparison of generated DXIL or IR against the base commit for inputs that translate successfully.
Related PRs
CMakeLists.txt: both PRs add an entry to the same native shader source list line. The other shared files merge cleanly.src/gfx1013_compute_native.h, where build: raise MSVC warnings for the shader compiler #3794 renames a constructor parameter ofUnsupportedComputeShaderand this PR moves that class tosrc/shader_translation_error.h. The resolution is to apply the rename in the new header.tools/startup/compile_dxil.cppand merges cleanly.None of these must land first. I will rebase this branch onto whichever of them is merged before it.