Skip to content

startup: four runtime diagnostics missing in a long run (direct-draw refusal census, snapshot pool totals, clear census, memory SRV shape table) #3477

Backlog

Description

@Leyukaka

Part of #870.

One local run of the application (about 1,430 s, runtime at 36914379) left four questions the logs could not answer. Line numbers are on main c4b8a41b. Counts only.

  • Direct draws not drawn, per (pipeline key, reason).
    • Code: note_draw_refusal returns at once unless X2W_PIPELINE_COLOUR is on (src/startup_stubs/d3d12_draw.inl:2968-2974). The counters untranslated_draws and translation_missing (:240, :3793, :3966) carry no key and no reason.
    • Run: 2,311,629 direct draws not drawn, 573 pipelines missing. The only per-key output is 12 capped no translation for pipeline lines.
    • Change: note (key, fixed reason code) in a PerReasonRefusalCensus at the not-drawn increment, independent of the debug switch, and report it with the other censuses.
  • Snapshot pool totals and refusals.
    • Code: in reserve_upload_ring, note_reserved skips the snapshot pool (src/startup_stubs/d3d12_xs_device.cpp:2778-2779), the refusal counter is ring-only (:2866), and the refusal line is logged 8 times (:2867-2870).
    • Run: 8 refusal lines, the first at about 132 s, then none for the rest of the run; the compute census then shows 10,930 dispatches refused because an input could not be copied.
    • Change: count pool reservations, bytes and refusals, and print them on the upload ring totals line.
  • Clear colour and target census.
    • Code: list_clear_target logs the first 4 calls only (src/startup_stubs/d3d12_xs_device.cpp:4285-4288).
    • Run: 284,826 clears, 4 logged.
    • Change: a bounded table of distinct (colour, target format) pairs with counts, reported with the render totals.
  • Memory SRV census: shape table full.
    • Code: max_shapes = 128 (src/startup_stubs/memory_srv_census.h:91); later shapes only add to the "calls past the shape table" count (:111, :142).
    • Run: 128 shapes; 5,455,551 of 8,985,300 refusals (61%) fall past the table. The buffer shapes that fill it differ only by size.
    • Change: key buffer shapes by size class, or keep the past-the-table count per reason.

Each item will come as its own small PR with a test.

Not covered here: ExecuteIndirect refusal causes (#3405 / #3411) and the refused-SRV cache (#2782).

I'm working on this.

Activity

  1. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Adding a fifth item, line numbers on main 26df1826:

    • Sampled colour of the presented surface, logged when it changes.
      • Code: present_signature (src/startup_stubs/d3d12_xs_device.cpp:7540-7580) already samples the presented surface, but the sample only goes to the shared block (publish, src/startup_stubs/present_signature.h:121-129). The sampled RGBA is logged only under the red-producer diagnostic (:7560-7570).
      • Run: in one long local run of the application the picture went from a uniform fill to black, and no log line says so.
      • Change: one bounded log line when the sampled colour changes (present number, RGBA), independent of the red-producer switch.
  2. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Adding a sixth item, line numbers on main 26df1826:

    • Native shader compiles: count, time, and refusals past the logged ones.
      • Code: the first Dispatch of a compute key translates it under draw_lock (src/startup_stubs/d3d12_compute_dispatch.inl:796, :812), DXC compile included (:584-587); native graphics does the same from draw_translated (src/startup_stubs/d3d12_draw.inl:3116-3118, try_native_graphics at :1296 and :1314). Neither path records a duration. refuse_native logs the first 16 compute refusals only (d3d12_compute_dispatch.inl:486-488); later ones are counted nowhere by reason.
      • Run: in one long local run of the application with native shaders enabled, 84 compute programs were translated natively and about 270 were refused, 16 of them logged; frames stopped about 42 s before the run ended, and the log cannot say whether compiles held the lock.
      • Change: one totals line with native compiles (count, total and max ms, compute and graphics apart), time spent on native work under draw_lock, and native compute refusals per reason beyond the 16 logged lines.
      • Overlap: startup: translate native compute programs on a worker thread (#3451) #3467 moves the compute translation to a worker thread without draw_lock and adds no timing or counters. This item changes no locking; if startup: translate native compute programs on a worker thread (#3451) #3467 merges first, the compute lock time is dropped and the compile times are taken on the worker.
  3. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Adding a seventh item, line numbers on main 1b8e2fee:

    • Native graphics: name the stage interface lookup that failed.
      • Code: prepare_direct_graphics (src/direct_compute_cache.cpp:594) looks up one companion per stage, first as a pinned container (:626-627), then in the reviewed interface catalog (:632-634), keyed by exact code digest and then by embedded ID (:279-281). The lookup is skipped when there is no cache directory or a stage is DXBC (:624). With nothing pinned, a catalog hit for one stage only is discarded (:636). A fixed pixel entry without companions then throws fixed graphics entry requires matching stage interfaces (:700-702), the same text for every cause.
      • Run: in one long local run of the application with native shaders enabled, all 46 native graphics attempts were refused with that message and none became ready; the log cannot say which lookup failed.
      • Change: name the cause in the refusal (lookup skipped, no catalog loaded, vertex stage not found, pixel stage not found, one stage found and discarded because its partner was missing), and add a per-cause count to the totals. A catalog tie already has its own message (:283). No change to what is accepted.
  4. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Adding an eighth item, line numbers on main 77d63db8:

    • Debugger trace: thread id on traced-call and exception lines.
      • Code: a --trace-calls 1 call is described at entry (tools/startup/debug_launch.py:711-712 for the runtime module, :529 for the movie player) and written when it returns (:763-765) with the time since launch and the result only; the thread id is known there (returns.add(ret, tid, ...), :761) but not printed. The exception line (:1055-1056) and the debugger stop line (:1085) omit it too, while LOG_AT (:659) and thread creation (:988) print it. The one time on a call line is taken at return, so the gap between two calls on a thread cannot be read from the log.
      • Run: in one long local run of the application that ended with the same fault as startup: with X2W_NATIVE_SHADERS on, a save-load run faults in the title at the end of the load #3451, the trace could not say which thread stopped issuing work.
      • Change: add tid= to traced-call, exception and stop lines, and on traced-call lines the time since the previous traced call on the same thread. No change to what is traced or to the hit limits (:524-525).
      • Overlap: tools: skip the step window for ntdll stub hooks and last returns #3463 edits the same return-logging block of debug_launch.py; this item will be based on it once it merges.
  5. Leyukaka commented on Nov 29, 2026

    @Leyukaka
    CollaboratorAuthor

    Adding a ninth item, line numbers on main ff9dcef0:

    • Native compute outcome per key, written at shutdown.
      • Code: refuse_native logs the first 16 refusals of the process only (src/startup_stubs/d3d12_compute_dispatch.inl:486-488). The compute census (log_compute_census, :1381-1410) runs only on frames divisible by 300 (src/startup_stubs/d3d12_xs_device.cpp:8032-8039), lists only keys that reached the Dispatch recorder, and carries the first Dispatch refusal, not the native compile outcome. Nothing is written at exit.
      • Run: in one long local run of the application with native shaders enabled, most compute keys had no native outcome line by the stop.
      • Change: one uncapped row per compute key with its publication state and native state (not attempted, unavailable, refused with reason, ready), written at controlled shutdown and recoverable on the launcher's forced-stop path (tools/startup/launch.py:314, tools/startup/debug_launch.py:1228), without taking draw_lock at DLL detach. No change to what is translated.
      • Overlap: startup: totals for native shader compiles and refusals #3494 adds totals per reason, not per key; this item is based on it.

    I'm working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions