Call for contributions: a new shader model

Đang mở
#499 19 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, github

Hướng nghiên cứu

Work on the experimental exp/shader-model branch based on arch/30fps; open a focused PR for one listed task or gate. Start by reading the relevant history linked in the issue, then run the shader tests with ctest -R '^kyty_shim_' and measure using the per-frame profiler (KYTY_FRAME_PROFILE, tools/frame-profile.py). Done means the chosen task meets its phase gate while preserving correctness; the issue does not name implementation files.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: shaders enhancement hard help wanted perf

Call for contributions: a new shader model

We are rebuilding how AnyPS5 handles shaders, from guest binary to running GPU pipeline. The work now lands on AnyKyty, the single main line, which contains all of arch/30fps. Contributions are welcome. Please target AnyKyty with your PRs.

Not in the first switch to one main line, and coming with V1.3 because they change the shader store stamp: R8 atomic OR (#524), mesh layers (#504), padded image tables (#502 and #483) and divergent-atomic barriers (#487), and the ten contributor changes already merged on exp/shader-model (pull requests #678 to #690). exp/shader-model stays until then; do not base new work on it.

Why

On a native PS5 title with ~16,000 shader programs, the current model costs too much in several ways:

  • We put runtime data into the code. The console runs one binary per program, and that binary reads its buffer, image and sampler descriptors (V#, T#, S#) from memory at every run. We instead freeze what the game wrote in memory (formats, strides, dimensions, tables, candidate lists) into each module (ResourceSpecialization).
    • The result is ~14,400 recipes for ~4,600 programs, and variants that only show up while playing.
    • Each fix added a new fallback form or a background specialization. Shaders still compile in game, and some draws bind null images.
  • The emitted code is too heavy for the NVIDIA driver.
    • A memory access through the sparse mirror costs ~82 instructions with atomics.
    • Indirect images become switches over thousands of candidates.
    • The driver inlines everything, so a large compute shader takes ~13 s to compile on NVIDIA (RADV: ~3 s, see #305).
  • Caches follow the translator version, not the game. The shader store stamp hashes 144 source files. Any translator change invalidates the whole precook, which runs for hours on a large title.
Target design

Do what the hardware does.

  1. One module per guest program. The key is the program and its real static state only (wave mode, float mode, export formats). It contains nothing read from memory at dispatch.
  2. Buffers read their V# at run time. Bounds, stride and format come from the descriptor. Formatted access goes through texel views, or a small run-time decode when the host has no matching format. Earlier measurement (#168): reading V# at run time is a GPU gain. Naive per-access helpers are what made it costly.
  3. Images through one fixed bindless heap with a few typed arms: Float, Uint and Sint × dimension. The heap index is data: pushed by the CPU, or translated once per dispatch on the GPU for tables. Format and swizzle live in the view. There is no candidate search and no table capacity in the key.
  4. Memory access as one add (mirror base + address) for the windows admitted at dispatch. Usage tracking moves to the CPU, at dispatch and at coarse grain.
  5. No compile in game, by design.
    • Every program in the title's code store is precooked offline, with no game session needed.
    • Graphics uses one pipeline-library part per stage and program, with states taken from the title's effect data (#338) and linked in milliseconds.
    • A specialization only exists if a GPU measurement justifies it. It is then compiled in the background while the generic module serves.
    • Any compile after startup is reported as a defect.
  6. Three cache layers:
    • guest recipes per title, stable and independent of the translator ;
    • translated SPIR-V, disposable and rebuilt in minutes ;
    • driver binaries (VK_KHR_pipeline_binary) addressed by content and garbage-collected.

Expected outcome, to be measured at each gate: zero compile in game, a full compute precook in ~15–20 min instead of hours, and a cache of ~12 GB instead of ~100 GB.

Phases and tasks
Phase Content Gate
P0 measure and stop the bleeding real driver time per compile in summaries ; a dry-run precook that predicts the cost of a translator change ; a single precook tool built from the repo ; GC of compute binaries ; no dependency on the NVIDIA disk cache ; null images and skipped draws counted as failures dry run under 5 min of CPU, prediction within 10 %
P1 one module per compute program P1a V# read at run time ; P1b images through the fixed heap ; P1c precook every compute program from the code store, remove background specialization and compute fallback forms 1.00 module per compute program ; 0 compute compile in game ; GPU time ≤ +10 %
P2 lighter emitted code one-add memory access ; texel views for formatted loads ; fewer per-lane selects driver time −50 % on the 50 largest compute programs ; GPU time ≤ base
P3 graphics on the same model VS, PS and mesh images through the heap ; one GPL library per stage and program 0 graphics compile in game
P4 three-layer cache canonical SPIR-V ; content-addressed binaries ; incremental precook cold precook ≤ 20 min ; ≤ 5 min after a local change ; ≤ 20 GB on disk

P0 and P1a are in progress. P1b, P1c, P2 (partly started), P3 and P4 are open.

How to contribute
  • Branch from AnyKyty and open PRs against it. Keep each PR to one task or one gate.
  • Measure. For performance claims, give before and after numbers on the same capture or scene, measured in the same session when you can.
    • Driver time per compile, not wall time.
    • GPU time per frame from the per-frame profiler (KYTY_FRAME_PROFILE, tools/frame-profile.py).
    • The number of recipes and modules per program.
  • Keep correctness first. The ordering and shader tests (ctest -R '^kyty_shim_') must pass. A null image or a skipped draw is a bug, not a fallback.
  • The route-based predictive precook in #457 remains the practical path today; the shader model aims to make it unnecessary for compute.
  • Useful history: #33 (one module per program), #109 (heap vs descriptor arrays), #168 (V# at run time), #292 (GPL on RADV), #302, #305 (driver cost vs inlined size), #307, #338 (effect data), #450–#452, #457, #471, #486.

Questions and design discussion are welcome in this issue.

Ngôn ngữ chính
C++
Star
214
Fork
7
Merge trung bình
7 giờ 53 phút
Pull request đã merge (30 ngày)
280

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của simnJS/AnyPS5

Tất cả issue của simnJS/AnyPS5

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.