Skip to content

d3d12: guard mesh PSO conservative-raster and f16-halves paths; run non-mesh stream tests before mesh skip - #8200

Open
auswhalen999-debug wants to merge 1 commit into
ItsNotRexed:mainfrom
auswhalen999-debug:pr/d3d12-mesh-pso-pascal-fixes
Open

auswhalen999-debug wants to merge 1 commit into
ItsNotRexed:mainfrom
auswhalen999-debug:pr/d3d12-mesh-pso-pascal-fixes

Conversation

@auswhalen999-debug

Copy link
Copy Markdown

Claimed in the coordination issue as: #8047 (comment)

What and why

Fixes two mesh-PSO bugs in PipelineState::create_graphics() (runtime/shims/d3d12_vulkan_device.cpp) introduced with pipeline state streams (#2359) and expands runtime/test/d3d12_mesh_test.cpp so non-mesh ID3D12Device2::CreatePipelineState stream coverage runs on non-mesh GPUs (e.g. Pascal) before skipping the VK_EXT_mesh_shader draws:

  1. Conservative rasterization on mesh PSOs (runtime/shims/d3d12_vulkan_device.cpp, runtime/src/conservative_raster.h):
    • PipelineState::create_graphics() checked desc.PrimitiveTopologyType != D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE even when mesh == true, contradicting the input-assembly switch right above (mesh ? D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE : desc.PrimitiveTopologyType). Any mesh PSO enabling ConservativeRaster = ON without a redundant PRIMITIVE_TOPOLOGY subobject was rejected with E_INVALIDARG.
    • Factored the check into leonida::conservative_raster::graphics_state_allowed(solid_fill, triangle_topology, mesh) (solid_fill && (mesh || triangle_topology)) and added pure-CPU unit checks in runtime/test/conservative_raster_test.cpp and runtime/test/d3d12_mesh_test.cpp (plus an end-to-end mesh-PSO check when VK_EXT_mesh_shader and VK_EXT_conservative_rasterization are both available).
  2. link_f16_halves() aliasing stages[0] (MS) as vs_stage (runtime/shims/d3d12_vulkan_device.cpp):
    • When mesh == true, stages[0] holds the mesh shader (VK_SHADER_STAGE_MESH_BIT_EXT), not a vertex shader. Pairing a mesh shader with a pixel shader declaring f16_halves erroneously called leonida::link_f16_halves() on the mesh SPIR-V module and failed with E_FAIL (f16_halves: VS has no Vertex entry point).
    • Guarded link_f16_halves() with !mesh and added a log_once notice when mesh && ps_stage.entry && !ps_stage.entry->f16_halves.empty(), matching the existing geometry-shader branch.
  3. Non-mesh CreatePipelineState stream regression coverage before the VK_EXT_mesh_shader skip (runtime/test/d3d12_mesh_test.cpp):
    • Previously d3d12_mesh_test exited 77 immediately after checking MeshShaderTier and the single mesh-PSO E_NOTIMPL refusal, leaving all stream validation and VS+PS stream PSO draw/readback untested on non-mesh GPUs.
    • Moved the 9 E_INVALIDARG stream validation cases, 4 versioned depth-stencil/rasterizer subobject checks, 2 E_NOTIMPL subobject checks (AS, DepthBoundsTestEnable), conservative-raster stream checks, and a full 64x64 VS+PS stream PSO draw/readback (4096 pixels) ahead of if (!d.mesh_shader) return 77;. Added mesh-path checks for conservative rasterization without a topology subobject and mesh+f16_halves PSO creation inside the d.mesh_shader block.

Tested

Built on Windows 11 with clang-cl 23.1.6 + lld-link 23.1.6 + Windows SDK 10.0.26100 (-DCMAKE_CXX_SCAN_FOR_MODULES=OFF -DLEONIDA_SDL3=OFF) and run on NVIDIA GeForce GTX 1070 (Pascal, driver 581.80, Vulkan 1.3, no VK_EXT_mesh_shader):

  • conservative_raster_test.exe: PASS (exit 0) — all tier/inner-coverage and mesh/non-mesh graphics_state_allowed checks pass.
  • spirv_f16_halves_test.exe: PASS (exit 0).
  • d3d12_mesh_test.exe: all non-mesh checks PASS (mesh PSO E_NOTIMPL, 9 invalid / 2 not-implemented / 4 versioned stream subobjects, conservative-raster unit + stream checks, VS+PS stream PSO draw/readback matched 4096/4096 pixels, clean COM refcount), then exits 77 to skip the VK_EXT_mesh_shader draw section as expected on Pascal.
  • d3d12_draw_test.exe: PASS (exit 0, all 4096-pixel readbacks matched).
  • d3d12_f16_halves_test.exe: PASS (exit 0, ps_packed and ps_reloc rendered (64,191,127,255)).
  • d3d12_conservative_raster_test.exe (LEONIDA_HOST_ADAPTER=warp): PASS (exit 0, 48 Vulkan and 24 WARP scenario pairs).

Note: the VK_EXT_mesh_shader draw/PSO block (make_device(true, ...)) was compiled and inspected, not executed on mesh-capable hardware on this Pascal GPU.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — runtime/test change only.)

@LukeOsland1

Copy link
Copy Markdown

Verified the two mesh PSO fixes on mesh-capable Windows hardware. Parent dde82f27e and head 95597e4a72506f0bacaa360b9d7f1be281c8805e, MSVC RelWithDebInfo, Vulkan validation enabled. I selected each adapter with LEONIDA_VK_DEVICE and checked its logged name. The parent run used the head fixture, omitting assertions for the head-only CPU helper and recording both PSO HRESULTs so that the first refusal would not hide the second.

Adapter (Windows driver) Conservative solid mesh PSO, no topology subobject Mesh PSO + pixel shader with f16_halves Unmodified head fixture
RTX 4070 Ti SUPER (32.0.16.1088) E_INVALIDARG → success E_FAIL → success Passed, 4,096/4,096 pixels, zero validation errors
AMD Radeon(TM) Graphics (32.0.21042.62) E_INVALIDARG → success E_FAIL → success Failed later on the mixed pipeline-statistics assertion, also present on the parent

The separate Radeon failure is specific to GSInvocations. A diagnostic run that logged each statistics assertion and continued through readback measured 2 for the mixed query, 0 for mesh only and 2 for vertex only. GSPrimitives, HSInvocations, DSInvocations and CSInvocations were zero in all three. Every other statistics assertion passed, all 4,096 pixels matched and validation reported zero errors. This extends the observation in #7256 to AMD’s Windows driver. The unmodified Radeon test still exits 1. Neither adapter skipped the mesh section. The f16 case checks PSO creation with the fixture’s metadata; the readback uses the ordinary draw shaders.

AI-assisted independent verification. Original claim

@nnonno91

Copy link
Copy Markdown

Independent synthetic Windows mesh testing of #8200 (95597e4) on main 867d922. Windows 11 build 26200, native x64 Release, MSVC 19.51, Vulkan headers 1.4.363, Khronos validation 1.4.357 and LEONIDA_VK_VALIDATION=1. Radeon gfx1036 driver 32.0.21042.62 and RTX 5090 driver 617.42. AI-assisted.

Test tree (3 runs per GPU) Radeon gfx1036 RTX 5090
#8200 alone Mixed GS assertion fails. 3 × VUID-07076 per run. GS assertion completes. 3 × VUID-07076 per run.
#8200 + #7256 (e83aa4e) Mixed and vertex-only GS both 2. Assertions complete. 3 × VUID-07076 per run. Mixed and vertex-only GS both 0. Assertions complete. 3 × VUID-07076 per run.
#8200 + #7256 + #7112 (9e9bb63) 3/3 pass, all 4,096 pixels matched, zero validation errors 3/3 pass, all 4,096 pixels matched, zero validation errors

For the last tree I combined the overlapping test hunks so both the GS comparison from #7256 and the feature-dependent clipping assertions from #7112 run. Radeon reports meshShaderQueries=false and the mesh-only clipping counts are 0/0 in that tree. RTX reports meshShaderQueries=true and the same counters are 8/8.

A temporary log marker confirmed that both adapters actually created the solid conservative mesh PSO without the topology subobject. Both also created the mesh PSO with the f16_halves pixel shader, with the expected linker-skip trace. The marker was used only for that extra run.

The three-PR build passed seven focused CTests three times per GPU: d3d12_mesh, d3d12_pso_validation, d3d12_conservative_raster, conservative_raster, spirv_f16_halves, replay_query_edges and replay_query_predication. WARP was used for host comparisons where applicable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants