Repository navigation
Shader model 6.8, and the converter changes with it - #343
Merged
Merged
Conversation
… stores
every geometry and stream output pipeline declared the largest payload, SM50_GEOMETRY_PAYLOAD_SIZE (16256
bytes), in its object and mesh functions and as the pipeline's payloadMemoryLength, whatever its vertex shader
output. an object threadgroup stores four words, the output registers of the vertices it reads and nine words at
the end: SM50GeometryPayloadSize gives that for the most vertices any topology reads with the vertex shader's
output registers (SM50GeometryWarpThreads), rounded up to 16 bytes as Metal Shader Converter pads its payload,
which keeps the 64-bit stream output words at the end aligned. those end words
move with the size, and the object, geometry, pass-through and stream-output-only mesh functions all take it from
the vertex shader's output registers, as Direct3D 11 and 12 take the pipeline's from its reflection
(NumOutputElement), the count the draws size their warps by. a vertex shader of 4 registers now has a payload of
2112 bytes, one of 32 registers 15936. a one-pass stream output pipeline's 16-byte payload is unchanged.
the reserved payload is memory each object threadgroup in flight holds ("payload size can't exceed the limit of 16
kilobytes", WWDC22 10162, 8:50).
measured with tests/perf/perf_probe.py (gs_quads_dxbc, gs_quads_dxil, gs_passthrough, xfb_vs_dxbc, xfb_gs_dxbc,
conservative_t1; 200 frames, best of 3, alternating with origin/main twice, an M6 shared with other GPU work): GPU
medians moved by -16% to +12% in either direction between rounds, no more than the same build's own spread
(up to 18%), so these small scenes show no change.
AIRCONV_VERSION 126.
SM50Initialize read a DXIL part's DxilProgramHeader and DxilBitcodeHeader, and copied the bitcode they point at, with no check against the part's size: a container whose part is shorter than its headers, or whose bitcode offset and size reach past it, read past the container (in the test, into a page the process may not read, which ended it with SIGBUS at the first case, an empty part). a part is now taken only when it holds both headers and the program the program header sizes, the magic is 'DXIL' and the bitcode is nonempty and within it, the checks DirectXShaderCompiler makes (DxilContainer.h, IsValidDxilProgramHeader and IsValidDxilBitcodeHeader) and Metal Shader Converter makes of the magic before it parses. anything else is refused with "Invalid DXIL program header" before the first read of the part, the library check of its kind.
… triple the metallib header named macOS 14.4 for every module, while the module's target triple is macosx14.0 for Metal 3.1's AIR, macosx15.0 for Metal 3.2's and macosx26.0 for Metal 4's (setup_metal_version). Apple's metallib writer takes the OS version from the module's triple (MetalLibObjectWriter::writeHeader, Triple::getOSVersion), and `xcrun metal -mmacosx-version-min=26.0 -std=metal4.0` with `metallib` writes 26.0 (14.0 and 15.0 for the other two): the header now does the same. its file version stays 2.7, the layout this writer produces. air.compile_options stays out: the module states its floating point semantics per instruction, which differ by stage and by operation, and Metal's compiler goes by those. one kernel built as AIR with and without the denorms_disable, denorms_enable, fast_math_enable and fast_math_disable options gave the same results on an M6 (macOS 27.3): x != x of a NaN kept, a denormal kept, a multiply and add fused when they carry contract and not otherwise, under fast_math_enable as well.
…es not depend on both front ends computed every operation of a vertex, hull, domain, geometry or mesh shader as written, no contraction, reassociation or reciprocal, so that two shaders computing a position with the same expression give the same depth, as a depth prepass and the EQUAL-tested pass after it need. that kept Metal from fusing any multiply and add of those stages, also of the varyings, which nothing compares between shaders. once the module is optimized, ContractOutsidePosition takes, in each vertex and mesh function, what the position depends on: every output but a register varying (reg<r>_<c>: the position, clip and cull distances and their varyings, layer, viewport, primitive culling and counts), and every branch condition, followed back through the operands. an operation the front end left free (afn, which every non-precise one has, DXBC's through Converter::UseFastMath and DXIL's from DXC's fast flags) that none of them depends on gets contract, reassoc and arcp, as a pixel shader's have; what they depend on keeps none, so a position computed the same way in two shaders still comes out the same. a function whose position depends on a read of memory it also writes keeps every operation as written, as do object functions and kernels (the vertex and hull stages of geometry and tessellation pipelines), whose outputs a later stage may compute a position from. Metal fuses a multiply and an add that carry contract and does not fuse them without it (an M6, macOS 27.3, one AIR kernel built both ways). MULLION_AIRCONV_SKIP=position-contraction leaves the old output. two versions of one expression in two shaders (mul and add in one, mad in another) still round differently.
…U's size DXC writes a 6.8 shader's [WaveSize] under kDxilRangedWaveSizeTag, the entry property 23, as the least, the most (0 for one size) and the preferred size, and only a 6.6 shader's under kDxilWaveSizeTag (11). the converter read 11 alone, so at cs_6_8 [WaveSize(64,128)], [WaveSize(4,16)] and [WaveSize(64)] made pipelines that ran at 32 lanes, where "the shader is compiled for and will only run with a wave size in this range" (DirectX-Specs, HLSL_SM_6_8_WaveSizeRange) and pipeline creation fails outside the device's sizes, as for a single 6.6 size. the range is now read, and a shader whose range does not hold the GPU's SIMD width is refused as a 6.6 size is; the preferred size is a hint and is not used. the tag's number is confirmed by the result: with 23 read, every range of d3d12_wave_size_range is refused or taken as the spec says, on each GPU family.
…nd its start locations Shader model 6.8 (HLSL_ShaderModel6_8) is wave size ranges, SampleCmpBias and SampleCmpGrad, SV_StartVertexLocation and SV_StartInstanceLocation, and Barrier of separate memory and semantics; work graphs are optional. With the converter reading 6.8's wave size ranges, every one of them works, so the device reports 6.8 and OPTIONS21's SampleCmpGradientAndBiasSupported and ExtendedCommandInfoSupported. Work graphs stay absent, and ExecuteIndirect's tier 1.0. d3d12_sm68 runs each feature, directly and, for the start locations, through ExecuteIndirect, and checks the device reports 6.8 and the two options when, and only when, they work: without this all four work and the three are not reported. It passes on every GPU family, twice. Under --validate it passes on the Metal 3 families and stops in its ExecuteIndirect draws on Metal 4, as d3d12_indirect_draw and d3d12_indirect_start do on main. d3d12_feature_queries expected the two options off, and now expects them on.
This was referenced Nov 22, 2026
# Conflicts: # tests/d3d12/meson.build
# Conflicts: # tests/d3d12/meson.build
# Conflicts: # tests/d3d12/meson.build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shader model 6.8, and the shader converter changes it needs or that came with it. Split out of #341, with the same commits. AIRCONV_VERSION becomes 126, so shader caches are rebuilt once.
What changes
host_geometry_payload: 6 wrong before. Six geometry, stream output and conservative perf scenes, alternated twice, moved between −16% and +12% with the sign flipping, inside one build's own spread, so no speed change is claimed.IsValidDxilProgramHeaderchecks before the first read.host_dxil_header: SIGBUS on the first of 9 malformed parts before.metallibwrites, where it was 14.4 for every target.host_metallib_header: 4 wrong before.TODO(invariance-analysis)), so that depth prepasses match.MULLION_AIRCONV_SKIP=position-contractiongives the old output.host_position_invariance: 4 wrong before, and 6 with the position deliberately relaxed.[WaveSize(64,128)],(4,16)or even(64)was accepted and ran at 32 lanes, where the specification has pipeline creation fail.d3d12_wave_size_range: 5 wrong before.d3d12_sm68checks they are reported when, and only when, they work: 3 wrong before.d3d12_feature_queriesnow expects them.tests/d3d12/meson.build's one-line test list is also extended by #345. Whichever of the two is merged second conflicts on that line only, and keeping both sets of entries resolves it. I'll rebase whichever is left.Evidence
Mac mini, Apple M6, macOS 27.3. MetalSharp Wine 8.0 (arm64 with FEX), copied with
--clone. ARM64EC build with-Denable_nvngx=true -Denable_nvapi=true -Denable_tests=true.meson test --suite host): 26 OK, 1 skipped (host_dxbc_hash, which needsMULLION_HASHED).tests/run.py --family nativewithd3d12_wave_size d3d12_sm6 d3d12_feature_queries d3d11_geometry d3d12_geometry d3d11_gs d3d12_gs d3d11_streamout d3d12_streamout: 36 passed, 0 failed, 2 skipped (the DXBC runs ofd3d12_sm68andd3d12_wave_size_range: shader model 6.8 needs DXC).main.d3d12_sm68andd3d12_wave_size_rangewere also run validated on the Metal 3 families, and on every family without validation.Not run
--validateon Metal 4, ExecuteIndirect draws stop (d3d12_indirect_drawandd3d12_indirect_startonmaintoo). So in d3d11, d3d12, airconv: a D3D11 barrier fix, Metal's tessellator for D3D11, shader model 6.8, and MetalFX, NVAPI and converter changes #341,d3d12_sm68was run validated on the Metal 3 families only, and on every family without validation.