Repository navigation
D3D12.X: rect lists drawn whole through a generated geometry shader - #199
Conversation
…stream rect lists From the review of ivall#199: - translated_graphics_pso: when the driver refuses a pipeline with the generated rect list GS, it is made once more without it (retry_without_rect_gs) and a note is logged, so each rect is drawn as its first triangle, as before, rather than by the dummy shaders. - A stream pipeline of type 19 that is not translated (HS/DS, a translation error) gets the PC's topology type before the driver sees it (untranslated_stream_desc), as at 956a476, where the stream path mapped it. dev_create_graphics_pso's body is now graphics_pso, with a flag for descs from a stream; a direct CreateGraphicsPipelineState is unchanged. - rect_list_gs compares clip-space x and y directly: w is one already. Tests (CPU): a_refused_rect_list_gs_is_retried_without_it (injected refusal), untranslated_stream_rect_lists_get_the_pcs_topology_type. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The review's two follow-ups are in 4bbcf98. A pipeline the driver refuses with the generated GS is now retried once without it and logs a note, so each rect is drawn as its first triangle again instead of by the dummy shaders. Untranslated type-19 stream pipelines get TRIANGLE before they reach the driver, as on main. The corner test now compares clip-space x and y directly. |
|
Main now draws rect lists through the CPU expansion from #195 ( |
…stream rect lists From the review of ivall#199: - translated_graphics_pso: when the driver refuses a pipeline with the generated rect list GS, it is made once more without it (retry_without_rect_gs) and a note is logged, so each rect is drawn as its first triangle, as before, rather than by the dummy shaders. - A stream pipeline of type 19 that is not translated (HS/DS, a translation error) gets the PC's topology type before the driver sees it (untranslated_stream_desc), as at 956a476, where the stream path mapped it. dev_create_graphics_pso's body is now graphics_pso, with a flag for descs from a stream; a direct CreateGraphicsPipelineState is unchanged. - rect_list_gs compares clip-space x and y directly: w is one already. Tests (CPU): a_refused_rect_list_gs_is_retried_without_it (injected refusal), untranslated_stream_rect_lists_get_the_pcs_topology_type. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fbc855c to
287d67a
Compare
|
Rebased on main eaa36b6 and force-pushed: head 287d67a, the five earlier commits plus one new one. What main changed: 38b05b7 brought #195's CPU rect expansion ( Overlaps: #195's On the corner rule (#189): the GS does not assume v0 + v2 − v1.
Tests:
|
|
Full run on the RTX 5070 Ti (NVIDIA 610.74), AI use: Claude Code, Claude Opus 5.5. |
The console's rect lists (IASetPrimitiveTopology 17, AMD's DI_PT_RECTLIST; pipeline topology type 19) were drawn as triangle lists: each rect as the triangle of its three vertices, half of it. A translated VS+PS pipeline of topology type 19 now gets a pass-through GS (emit::rect_list_gs, declared from the VS's own output struct) that adds the fourth corner. The three vertices are corners of a screen-aligned rectangle (AMD PAL palCmdBuffer.h: "Each rect is three 2D axis-aligned rectangle vertices"), and the corner between the other two is not always v0: Mesa radeonsi's blits send (x1,y1), (x1,y2), (x2,y1), xf86-video-ati's r600 EXA (x1,y1), (x1,y2), (x2,y2). The corner is the vertex sharing x with one of the others and y with the other; the fourth vertex is a + b - corner, its outputs likewise (both drivers' texture coordinates rely on that). Bounded to what is established: three vertices with one positive w (then clip and screen space agree and so do the interpolation modes); others stay one triangle. Refused, keeping the old triangle form: integer VS outputs, a PS that reads flat (an integer input or v_interp_mov_f32), a PC PS - which vertex gives a rect's flat values is not established. The stream path keeps type 19 for the translated pipeline; the graphics stand-in maps it. Tests: rect_list_gs_outputs, rect_list_ps_reads_flat (CPU); gpu_rect_list_corners: corners at v0, v1, v2 cover the rect with the attribute linear everywhere, part stays clear without the GS, and a non-rectangle or unequal-w triangle draws the same with and without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gpu_rect_list_fullscreen_order draws the three corners a downstream build (theaustinayers/xcl build 5, linked in ivall#189) reports from a retail title's full-screen passes: positions (-1,1) (-1,-1) (1,-1), texture coordinates (0,0) (0,1) (1,1), so the shared corner is v1 and the implied one is (1,1) with (1,0). Plain HLSL VS/PS around emit::rect_list_gs on a 16x16 target: every pixel must carry its texture coordinate, for w 1 and 2; without the GS (the negative control) only about half the pixels are drawn. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ted too gpu_rect_list_fullscreen_order also draws the other half of the full-screen rect as a triangle: v0, v2 and the implied corner, what a draw expanded to two triangles a rect on the CPU sends next (ivall#195). Those are three corners of the same rect, so the GS completes it to the whole rect as well. A draw expanded on the CPU must therefore not also get this GS, or each rect is drawn twice (the same image when opaque, wrong with blending). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…stream rect lists From the review of ivall#199: - translated_graphics_pso: when the driver refuses a pipeline with the generated rect list GS, it is made once more without it (retry_without_rect_gs) and a note is logged, so each rect is drawn as its first triangle, as before, rather than by the dummy shaders. - A stream pipeline of type 19 that is not translated (HS/DS, a translation error) gets the PC's topology type before the driver sees it (untranslated_stream_desc), as at 956a476, where the stream path mapped it. dev_create_graphics_pso's body is now graphics_pso, with a flag for descs from a stream; a direct CreateGraphicsPipelineState is unchanged. - rect_list_gs compares clip-space x and y directly: w is one already. Tests (CPU): a_refused_rect_list_gs_is_retried_without_it (injected refusal), untranslated_stream_rect_lists_get_the_pcs_topology_type. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
For ivall#195, which expands rect lists to two triangles a rect on the CPU: a draw on a pipeline that has the GS must not be expanded too, since each half is three corners of the rect and the GS would complete both. has_rect_list_gs(pso) answers that, for a pipeline as is_translated_graphics takes it. A pipeline made again without the GS (retry_without_rect_gs) is not noted, and forget_pso drops the entry with the pipeline's address. Test (CPU): pipelines_with_the_rect_list_gs_are_known_until_forgotten. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Main expands a DrawInstanced of a rect list on the CPU (bind::draw_rects, from ivall#195): v0 v1 v2, then v0 v2 v3. On a pipeline with the rect list GS each of those halves is three corners of the rect, so the GS completed both and every rect was drawn twice (gpu_rect_list_fullscreen_order shows the second half completed). draw_rects now leaves a pipeline with the GS alone (cpu_rect_expansion: real::has_rect_list_gs of the resolved pipeline); it still expands rect lists on the pipelines the GS refuses. Test (CPU): rect_lists_with_the_rect_list_gs_are_not_expanded_on_the_cpu. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Rebased on main 6da33fa: head 7ac4048. The On 7ac4048, RTX 5070 Ti (NVIDIA 610.74), AI use: Claude Code, Claude Opus 5.5. |
287d67a to
7ac4048
Compare
|
Merged (main d4f17ca). Checked on an RX 9070 (RDNA4) with 11 PRs merged together on main af20b4b: |
Closes #189. Based on main 956a476. Commits 9bd8908 (the change), ae8145d and 9ec1bfe (tests).
Problem
The console's rect lists (
IASetPrimitiveTopology(17), AMD'sDI_PT_RECTLIST; pipeline topology type 19) are drawn as triangle lists (list_x.rs,real.rs::pc_topology_type). Each rect is drawn as the triangle of its three vertices, so only half of it appears. HANDOFF lists this as open.What a rect list is (sources)
inc/core/palCmdBuffer.h:RectList = 0x5, ///< Each rect is three 2D axis-aligned rectangle vertices.The bounding box of an arbitrary triangle is a separate, optional topology,TwoDRectList.330203b), the driver for current AMD GPUs:si_draw_rectangledraws 3 vertices asSI_PRIM_RECTANGLE_LIST→V_008958_DI_PT_RECTLIST.gfx/si_nir_lower_vs_inputs.c(load_vs_input_from_blit_sgpr) gives vertex 0 = (x1,y1), 1 = (x1,y2), 2 = (x2,y1), so the shared corner is v0. Texture coordinates use the same selectors.r600_exa.c(R600Solid,R600AppendCopyVertex;DI_PT_RECTLISTinr6xx_accel.c) is older-generation (R600) evidence: v0 = (x1,y1), v1 = (x1,y2), v2 = (x2,y2), so the corner is v1. The copy's source coordinates at the implied corner are v0 + v2 − v1.So the corner between the other two is not a fixed vertex. The fourth vertex completes the axis-aligned rectangle, and the drivers rely on attributes continuing linearly to it. These semantics come from how AMD's drivers (PAL, Mesa, R600) use the topology. They were not measured on RDNA2 hardware.
Change
emit::rect_list_gs(outputs)generates a pass-through GS that declares the VS's own output struct (out_struct). It appends v0..v2 unchanged. When the three vertices have one equal positive clip w and one vertex shares x with one neighbour and y with the other (exact compare), it also emits a second triangle with d = a + b − corner for the position and every output, keeping the first triangle's winding. Any other three vertices stay the one triangle they make, as before. With equal w, clip and screen space agree, so every interpolation mode agrees too.pso::rect_list_gs(vs)builds it from the console VS's output signature, the list the translated VS's struct is declared from.real.rs::translated_graphics_psoadds it to a translated VS+PS pipeline of topology type 19 that has no GS. The GS sees the VS's outputs, so indexed draws and rects made from the vertex index alone are covered too. The stream path keeps type 19 for console-VS pipelines so that the translated path sees it.Refused, keeping today's triangle form plus a translation note:
v_interp_mov_f32,pso::ps_reads_flat);Which vertex gives a rect's flat values is not established.
Overlap with #162:
standin_graphicsnow callspc_topology_type, the same one-line change #162 makes. Whichever lands second drops its copy.Relation to #195
#195 expands non-indexed
DrawInstancedrect lists on the CPU (bind::draw_rects: v0 v1 v2, then v0 v2 v3). If both land as they are, two things go wrong:gpu_rect_list_fullscreen_orderchecks this). Each rect would then be drawn twice: the same picture when opaque, wrong with blending.pc_stream_typesrewrites the stream's type 19 to 3 beforestream_pipelinereads it, so stream pipelines would never get the GS.Proposed split: the GS where a pipeline has one. The CPU expansion only for rect-list draws on pipelines without it, the refused cases. Type 19 left in the stream for
translated_graphics_pso. The two branches merge without textual conflicts, and the four rect tests below pass on the merge (bf26412 + this branch). I'll rebase on whichever lands first.Tests
rect_list_gs_outputs(CPU): integer outputs are refused; the HLSL compiles with DXC as gs_6_6.rect_list_ps_reads_flat(CPU):v_interp_mov_f32is detected;v_interp_p1/p2is not flagged.gpu_rect_list_corners(GPU), with a translated VS+PS through the GS on a 16×16 target, per pixel within 1e-5:gpu_rect_list_fullscreen_order(GPU), plain HLSL VS/PS around the GS:On an RTX 5070 Ti (NVIDIA 610.74, Windows 11), the GPU tests and both CPU tests pass. Two mutations fail
gpu_rect_list_corners: the GS without the fourth corner, and the fourth corner without attribute extrapolation.The expected images are the rectangles and triangles defined above. They are not a hardware measurement, and nothing was run on AMD.
Workspace suite (
cargo test --workspace --no-fail-fast -- --test-threads=2, RTX 5070 Ti):One earlier run on this branch failed
hle::d3d12x::frame::tests::statistics_name_each_frames_origin_and_rescheduled_handles_outlive_the_clock_tick, with "each frame its own origin": the third frame's origin came 93 ticks before the second's. That is a timing test in a file this branch doesn't touch, and it passed in the other five runs here. It didn't fail on main in three suite runs or 25 runs of its own, so I couldn't show it fails there.Not covered
TwoDRectList.Open points from an independent review (follow-up commit coming)
translated_graphics_pso). I'll add one retry withGScleared.Credit
The full-screen corner order and the uvs come from theaustinayers' downstream build 5 (theaustinayers/xcl 73bd45a, "rect lists drawn as two triangles", now part of #195). YeetSkillet linked it in #189 and checked that order with a native D3D12 probe. No code was taken from it: the approaches differ (a CPU expansion of the vertex buffer there, a GS behind the translated VS here).
AI-assisted (Claude Code). No game data.
🤖 Generated with Claude Code