WIP: refactor(vk): the draw code's pure predicates move to draw_key.h, and their checks include it #1340
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1340
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:refactor/draw-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: refactor · Risk: low · Tested on: Linux, RTX 3090 · Needs: the checks' first run
Why
vk_draw.cppis 11,000 lines doing four jobs, and nothing in it links alone, so 124 checks cut functions out of it by their text and compile them with stubs. A rename far away breaks them, and the per-draw path cannot be reworked safely. Track D of the renderer rework plan, step 1 of nine: the part that is already pure gets a header of its own. Stacked on #1309, #1325 and #1326: review the last commit only.What changed
gpu/vk/draw_key.h(new): 15 functions moved verbatim fromvk_draw.cpp(pipe_same,dyn_same,vertex_set_same,vertex_bind_range,vertex_bind_reuse,index_bind_same,writes_sampled_target,words_append,words_same_store,desc_counts_pack,desc_counts_unpack,table_track_open,compare_op,stencil_op,topology_class). They take scalars and arrays only, call no Vulkan function and read no state. The header compiles with the Vulkan headers and the standard library alone.vk_draw.cppincludes it and loses the definitions. No call site changed.test_push_state.py,test_vertex_bind_range.py) now use the real Vulkan types where they had stand-ins.topology(logs), the blend and vertex format maps (need the NVN constants),mix(nx2/bake.pymirrors it).Measurements
Nothing to measure: the same code in another file. One session as a check: Kokiri Forest 67.2 fps standing, Hyrule Field 93.1, main's draw counts and GPU times.
Testing
Tested: Linux, RTX 3090: built; one session through Kokiri Forest and Hyrule Field, both drew as main does, no error line.
Not tested:
tests/run_all.py: not run on this PC. The 12 edited checks were changed by reading alone, and this is the part most likely to be wrong: nine of them now need Vulkan headers to compile, andrun_all.pyskips them where it finds none.Must be tested:
Risks
What could break: a check that no longer compiles or silently skips. The game's code is unchanged in behaviour.
Turning it off: revert the commit.
Compatibility: none: no cache is rebuilt,
MKWVK_API_VERSIONstays, no setting changes.Issues
See #1300
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). Not run on this PC; left to the forge's checks.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
Tested in game: Linux, RTX 3090, NVIDIA 620.70: one session through Kokiri Forest and Hyrule Field at 2560x1440; both drew with main's draw counts and GPU times.
A second commit is on this branch: the next two steps of the split. No behaviour change is intended.
draw_key.hgainsblend_factor,blend_op,vertex_format, a puretopology(its log-once stays at the call),mix, andpipeline_key(const KeyInputs&);vk_draw.cppfillsKeyInputsfrom the program, state, targets and device and calls it. The terms and their order are the same, so every persisted key is the same.cur_program, a thread-local standing in for an argument, is an argument ofdyn_packanddynamic_state.CmdBoundwithreset()andreset_keeping_index(): the four sites were not alike (the masked clear never forgot the index buffer), and each resets exactly what it did.tests/test_pipeline_key_values.py(new) pins four keys and 160 seeded cases against a restatement of the old arithmetic, and holdsnx2/bake.py's copy to the same values. Eleven existing checks follow the moved text.Run in the game (RTX 3090, NVIDIA 620.70, Linux, 2560x1440), against the commit before:
A changed key would have built the pipelines again at the second start; they came from the caches. Screenshots differ from the commit before by 0.021 / 0.009 / 0.009 (mean absolute error of 1), as two sessions of this commit do from each other (0.017 / 0.009 / 0.010).
Not tested:
tests/run_all.py(the pinned keys come from a restatement of the old code, not from running it, so the new check's first run is the real test), Windows, and any GPU that takesvertex_format's or the blend maps' other branches. The split's next step reshapesdraw()itself and waits for these edits to pass the checks.Folded into #1354, which is now the one pull request for frame pipeline and the draw split. The commits are unchanged apart from being rebased into one stack and carrying the fixes the check suite asked for; nothing was dropped.
Pull request closed