Commit Graph

9 Commits

Author SHA1 Message Date
Adrià Franch 14f2092c9e build(agc): link the graphics and BDA device tests against libSceAgcDriver
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-13 13:53:51 +02:00
Adrià Franch f20a32bec3 build(agc): link agc_driver_mesh_tests against libSceAgcDriver
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-13 13:46:45 +02:00
Felipe Arce 4dfe0526b8 fix(agc): link the texture mip layout into the BDA device tests 2026-10-12 03:26:02 -03:00
Dean Galvin 33f9109999 feat(shader): translate NGG geometry programs to mesh shaders
The geometry path's merged ES/GS programs (VGT_SHADER_STAGES_EN.GS_EN)
were compiled as mesh-stage programs whose input metadata was never
filled in, so every such draw failed with "mesh shader translation
configuration is not supported".

Recompiler:
- BuildShaderStageInputInfo takes the draw's MeshConfiguration; the mesh
  input helpers (primitive size, step and counts) are implemented.
- The prologue emulates one NGG subgroup per workgroup: s2 GS_TG_INFO,
  s3 the merged wave info per wave, the GS vertex offsets (ES thread
  index times VGT_ESGS_RING_ITEMSIZE, odd strip triangles swapped), the
  primitive id, and the ES vertex and instance ids. An indexed draw's
  vertex id is read from the index buffer through a raw V# the driver
  puts in hidden user words 4..7.
- s_sendmsg GS_ALLOC_REQ becomes MeshAllocate. The epilogue zeroes the
  allocation first, clamps it to the output limits, culls primitives no
  thread exported and decodes the 9-bit vertex indices.
- The draw parameters live in the last six push dwords. A BDA fault in
  a mesh program no longer stops the invocation (as for other programs
  with barriers, the fault is recorded and the read returns zero), so
  every invocation reaches the subgroup barriers and the epilogue.
- The cache keys cover the mesh configuration; requests serialize its
  new esgsItemSize field (version 4).

Driver:
- DecodeShaderStages reads VGT_ESGS_RING_ITEMSIZE (now in the draw key)
  and sizes the subgroup for its ES vertices, GS primitives and outputs.
- Stages compile below the mesh draw parameters, which every mesh draw
  pushes; the mesh stage always takes part in the push range.
- The index-buffer V# is set per draw (per record on the CPU-resolved
  indirect path); the index-buffer alias check spares read-only
  elements.
- The workgroup and LocalSize checks count two guest lanes per
  invocation on 32-wide subgroups; mesh draws may carry a first vertex
  or instance.

agc_driver_mesh_tests (EXCLUDE_FROM_ALL, needs VK_EXT_mesh_shader)
recompiles a hand-assembled merged ES/GS program in the PS5 compiler's
layout and draws indexed and non-indexed triangle lists in one- and
two-wave subgroups and a triangle strip across odd-starting subgroups,
reading the pixels back. agc_shader_replay prints a request's draw and
mesh configuration.
2026-09-30 23:57:47 +13:00
devilismyfriend 8a69fefe13 perf(agc): batch GPU work in a recorder with host-imported guest memory
Replaces the synchronous per-command execution model, and with it the
upstream render-target, pipeline-cache, tile-buffer, batched-draw and
memory-ownership commits (5a280ce, 7ed5a0b, 46c799d, 598caac, 40df528),
whose files are removed.

- Recorder: one open command buffer per device; dispatches, resident
  draws, uploads, write-backs, labels, fills and copies record into it;
  timeline-semaphore serials let drains wait without the GPU mutex;
  completions run in order at reap.
- one worker thread per PM4 queue; labels and stores written by the GPU
  into the host import; GPU-side DISPATCH_INDIRECT; the buffer-fill
  kernel replaced by vkCmdFillBuffer; a dispatch cache validated by
  write watch; filler packets tolerated; rejected submissions dumped.
- guest memory: page-state cache, 64 KiB write generations, host imports
  with VK_EXT_external_memory_host, persistent mirrors of the executable
  image, GPU copies of misaligned sub-ranges.
- textures: shader-written images stay resident with deferred
  write-back (adjacent-generation rule for packed video planes), sampled
  views of storage images, DCC key handling, addrlib swizzle equations,
  bidirectional detiler.
- draws: MRT, more formats, dynamic viewport/scissor, cached pipelines,
  resident 64 KiB targets, draws recorded into the recorder.
- ShaderResources: two-stage build, descriptor and sampler caches, a
  content-keyed resource cache; presentation from the resident image.
- a label deferred behind a completion is no longer re-stored by the
  CPU at reap time unless a write-back overwrote it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
boykopovar 40df5282e6 perf(agc): track guest memory ownership + optimize gpu synchronization 2026-09-25 19:47:18 +03:00
boykopovar 598caac0ce perf(agc): batch draws and cache descriptors, samplers, and buffers 2026-09-25 11:40:03 +03:00
boykopovar 2778c1e86e perf(agc): keep render targets on gpu across draws 2026-09-24 21:30:00 +03:00
boykopovar 7ed9ef1e9b perf(agc): move color transfers to + gpu resources cache 2026-09-23 22:32:42 +03:00