AGC: a geometry shader on a triangle strip or fan only draws the first input primitive (XPSemu PPSA97358 GPU probe) #23642

Open
opened 2026-11-19 11:31:40 +00:00 by LeandroLP23 · 0 comments
LeandroLP23 commented 2026-11-19 11:31:40 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-19T11:31:40Z.


What happens

On the mesh path, a draw whose NGG geometry program reads a triangle strip or fan only rasterizes the output of the first input primitive. XPSemu's start-up GPU probe reads black where the second triangle of each strip and fan should be: Could not determine triangle strip1 rotation, got color: R=0, G=0, B=0.

Title, test or build step

XPSemu (PPSA97358, catalog Alpha-2.1), an xemu port. The probe is render_geom_shader_triangles in xemu's hw/xbox/nv2a/pgraph/vk/gpuprops.c. It runs one pass-through geometry shader (layout(triangles) in; layout(triangle_strip, max_vertices = 3) out;, three EmitVertex calls and one EndPrimitive per input triangle) over three draws into a 640x480 target: a triangle list of 3 vertices, a triangle strip of 4 and a triangle fan of 4. Then it reads one pixel inside each of the 5 triangles.

AnyPS5 commit

main 74f685158e, no PRs on top.

System

Windows 11 (10.0.26300), AMD Radeon 860M (AMD 26.10.2, LLPC), WinLibs GCC 15.2.0 r7, Release.

Host report

AnyPS5 host report (format 1)
commit: 74f685158e10
[system]
os: Windows 10.0.26300
cpu: AMD Ryzen AI 7 350 w/ Radeon 860M
cpu_threads: 16
memory_mib: 31866
cpu_gate: passed
[sdl]
linked: 2.33.0
compiled: 2.33.0
[gpu]
device: AMD Radeon(TM) 860M Graphics
type: integrated
vendor_id: 0x1002
device_id: 0x1114
vulkan_api: 1.4.359
driver: AMD proprietary driver
driver_info: 26.10.2 (LLPC)
driver_version: 2.0.416
driver_version_raw: 0x008001a0
subgroup_size: 64
device_local_mib: 10963
candidates: AMD Radeon(TM) 860M Graphics
present_modes: unknown
present_mode_requested: default
[vulkan]
VK_KHR_8bit_storage: extension required present
VK_KHR_buffer_device_address: extension required present
VK_KHR_shader_float_controls: extension required present
bufferDeviceAddress: feature required present
fragmentStoresAndAtomics: feature required present
samplerAnisotropy: feature required present
shaderInt64: feature required present
shaderSignedZeroInfNanPreserveFloat32: feature required present
storageBuffer8BitAccess: feature required present
textureCompressionBC: feature required present
vertexPipelineStoresAndAtomics: feature required present
VK_EXT_external_memory_host: extension optional present
VK_EXT_fragment_shader_interlock: extension optional present
VK_EXT_hdr_metadata: extension optional present
VK_EXT_memory_budget: extension optional present
VK_EXT_mesh_shader: extension optional present
VK_EXT_present_mode_fifo_latest_ready: extension optional present
VK_EXT_provoking_vertex: extension optional present
VK_EXT_sample_locations: extension optional present
VK_EXT_sampler_filter_minmax: extension optional present
VK_EXT_shader_demote_to_helper_invocation: extension optional present
VK_EXT_shader_image_atomic_int64: extension optional present
VK_KHR_draw_indirect_count: extension optional present
VK_KHR_driver_properties: extension optional present
VK_KHR_fragment_shader_barycentric: extension optional present
VK_KHR_maintenance5: extension optional present
VK_KHR_present_mode_fifo_latest_ready: extension optional present
VK_KHR_shader_atomic_int64: extension optional present
VK_KHR_shader_clock: extension optional present
VK_KHR_shader_terminate_invocation: extension optional present
VK_KHR_spirv_1_4: extension optional present
[shader_cache]
state: absent
[environment]
ANYPS5_HOST_REPORT: 1

Steps to reproduce

python tools/title_run.py PPSA97358 --games <games> --build build --out <out> --runs 1 --seconds 60. The probe's lines are in data/xemu/xemu.log in the work folder, within the first 4 s.

Log

Could not determine triangle strip1 rotation, got color: R=0, G=0, B=0
Unexpected inconsistency in triangle fan winding, got colors: R=0, G=255, B=0 and R=0, G=0, B=0
VK geometry shader winding: 0, 0, 0, 0

What was checked

  • Which triangles are missing. The single triangle reads a valid color (no message). In the strip, triangle 0 is valid (no strip0 message) and triangle 1 is black. In the fan, triangle 0 is green (colors[8], its first vertex) and triangle 1 is black. So in each draw, only the first primitive through the geometry program reaches the target.
  • Split out of #5437. That issue's two problems are fixed on main; this readback is the part left. babyhuey saw the same three lines on an RTX 3080 on 18 October, so it isn't AMD-specific.
  • Each topology gets its own variant. With APS5_DUMP_PREPARE_INPUTS=1 APS5_DUMP_SHADERS=200240d00,200241600, the geometry program 0x200240d00 (linked with pixel program 0x200241600) is prepared three times. agc_shader_replay reports:
    mesh: input primitive 4, 42 primitives / 126 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1
    mesh: input primitive 6, 85 primitives / 87 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1
    mesh: input primitive 5, 85 primitives / 87 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1
    
    The draw-side count in Draw.cpp gives 2 primitives for 4 strip or fan vertices.
  • The input indices look right on paper. The mesh entry in InstructionTranslator.cpp gives primitive 1 the group-local vertices (1, 3, 2) for the strip and (2, 3, 0) for the fan. Those have the same winding as Vulkan's strip and fan order, so back-face culling (the probe culls back faces, clockwise front) shouldn't drop them, and neither is degenerate.
  • What the existing test doesn't cover. MeshProvokingVertex already checks that strip and fan draw their second triangle on the mesh path, but with a program that outputs one primitive per input primitive. Here the geometry program is radv's NGG lowering of a real geometry shader: each invocation emits its vertices into LDS, and the subgroup's output counts are combined across lanes and declared with GS_ALLOC_REQ.
  • Not established: where the second primitive is lost. One possibility is that the declared output primitive count comes out as 1 rather than 2, from one of the instructions in that cross-lane count. I haven't verified it.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6488601018 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/23642). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-19T11:31:40Z. --- ### What happens On the mesh path, a draw whose NGG geometry program reads a triangle strip or fan only rasterizes the output of the first input primitive. XPSemu's start-up GPU probe reads black where the second triangle of each strip and fan should be: `Could not determine triangle strip1 rotation, got color: R=0, G=0, B=0`. ### Title, test or build step XPSemu (PPSA97358, catalog Alpha-2.1), an xemu port. The probe is `render_geom_shader_triangles` in xemu's [`hw/xbox/nv2a/pgraph/vk/gpuprops.c`](https://github.com/xemu-project/xemu/blob/master/hw/xbox/nv2a/pgraph/vk/gpuprops.c). It runs one pass-through geometry shader (`layout(triangles) in; layout(triangle_strip, max_vertices = 3) out;`, three `EmitVertex` calls and one `EndPrimitive` per input triangle) over three draws into a 640x480 target: a triangle list of 3 vertices, a triangle strip of 4 and a triangle fan of 4. Then it reads one pixel inside each of the 5 triangles. ### AnyPS5 commit `main` `74f685158e`, no PRs on top. ### System Windows 11 (10.0.26300), AMD Radeon 860M (AMD 26.10.2, LLPC), WinLibs GCC 15.2.0 r7, Release. ### Host report ```text AnyPS5 host report (format 1) commit: 74f685158e10 [system] os: Windows 10.0.26300 cpu: AMD Ryzen AI 7 350 w/ Radeon 860M cpu_threads: 16 memory_mib: 31866 cpu_gate: passed [sdl] linked: 2.33.0 compiled: 2.33.0 [gpu] device: AMD Radeon(TM) 860M Graphics type: integrated vendor_id: 0x1002 device_id: 0x1114 vulkan_api: 1.4.359 driver: AMD proprietary driver driver_info: 26.10.2 (LLPC) driver_version: 2.0.416 driver_version_raw: 0x008001a0 subgroup_size: 64 device_local_mib: 10963 candidates: AMD Radeon(TM) 860M Graphics present_modes: unknown present_mode_requested: default [vulkan] VK_KHR_8bit_storage: extension required present VK_KHR_buffer_device_address: extension required present VK_KHR_shader_float_controls: extension required present bufferDeviceAddress: feature required present fragmentStoresAndAtomics: feature required present samplerAnisotropy: feature required present shaderInt64: feature required present shaderSignedZeroInfNanPreserveFloat32: feature required present storageBuffer8BitAccess: feature required present textureCompressionBC: feature required present vertexPipelineStoresAndAtomics: feature required present VK_EXT_external_memory_host: extension optional present VK_EXT_fragment_shader_interlock: extension optional present VK_EXT_hdr_metadata: extension optional present VK_EXT_memory_budget: extension optional present VK_EXT_mesh_shader: extension optional present VK_EXT_present_mode_fifo_latest_ready: extension optional present VK_EXT_provoking_vertex: extension optional present VK_EXT_sample_locations: extension optional present VK_EXT_sampler_filter_minmax: extension optional present VK_EXT_shader_demote_to_helper_invocation: extension optional present VK_EXT_shader_image_atomic_int64: extension optional present VK_KHR_draw_indirect_count: extension optional present VK_KHR_driver_properties: extension optional present VK_KHR_fragment_shader_barycentric: extension optional present VK_KHR_maintenance5: extension optional present VK_KHR_present_mode_fifo_latest_ready: extension optional present VK_KHR_shader_atomic_int64: extension optional present VK_KHR_shader_clock: extension optional present VK_KHR_shader_terminate_invocation: extension optional present VK_KHR_spirv_1_4: extension optional present [shader_cache] state: absent [environment] ANYPS5_HOST_REPORT: 1 ``` ### Steps to reproduce `python tools/title_run.py PPSA97358 --games <games> --build build --out <out> --runs 1 --seconds 60`. The probe's lines are in `data/xemu/xemu.log` in the work folder, within the first 4 s. ### Log ``` Could not determine triangle strip1 rotation, got color: R=0, G=0, B=0 Unexpected inconsistency in triangle fan winding, got colors: R=0, G=255, B=0 and R=0, G=0, B=0 VK geometry shader winding: 0, 0, 0, 0 ``` ### What was checked - **Which triangles are missing.** The single triangle reads a valid color (no message). In the strip, triangle 0 is valid (no `strip0` message) and triangle 1 is black. In the fan, triangle 0 is green (`colors[8]`, its first vertex) and triangle 1 is black. So in each draw, only the first primitive through the geometry program reaches the target. - **Split out of #5437.** That issue's two problems are fixed on `main`; this readback is the part left. babyhuey saw the same three lines on an RTX 3080 on 18 October, so it isn't AMD-specific. - **Each topology gets its own variant.** With `APS5_DUMP_PREPARE_INPUTS=1 APS5_DUMP_SHADERS=200240d00,200241600`, the geometry program `0x200240d00` (linked with pixel program `0x200241600`) is prepared three times. `agc_shader_replay` reports: ``` mesh: input primitive 4, 42 primitives / 126 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1 mesh: input primitive 6, 85 primitives / 87 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1 mesh: input primitive 5, 85 primitives / 87 vertices per group, max 255 vertices / 85 primitives, 256 threads, lds 3072 dwords, provoking 0, ESGS item 1 ``` The draw-side count in `Draw.cpp` gives 2 primitives for 4 strip or fan vertices. - **The input indices look right on paper.** The mesh entry in `InstructionTranslator.cpp` gives primitive 1 the group-local vertices (1, 3, 2) for the strip and (2, 3, 0) for the fan. Those have the same winding as Vulkan's strip and fan order, so back-face culling (the probe culls back faces, clockwise front) shouldn't drop them, and neither is degenerate. - **What the existing test doesn't cover.** `MeshProvokingVertex` already checks that strip and fan draw their second triangle on the mesh path, but with a program that outputs one primitive per input primitive. Here the geometry program is radv's NGG lowering of a real geometry shader: each invocation emits its vertices into LDS, and the subgroup's output counts are combined across lanes and declared with `GS_ALLOC_REQ`. - **Not established:** where the second primitive is lost. One possibility is that the declared output primitive count comes out as 1 rather than 2, from one of the instructions in that cross-lane count. I haven't verified it. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#23642
No description provided.