Skip to content

d3d11, d3d12, airconv: a D3D11 barrier fix, Metal's tessellator for D3D11, shader model 6.8, and MetalFX, NVAPI and converter changes - #341

Closed
aaf2tbz wants to merge 21 commits into
dttdrv:mainfrom
aaf2tbz:metal-features
Closed

aaf2tbz wants to merge 21 commits into
dttdrv:mainfrom
aaf2tbz:metal-features

Conversation

@aaf2tbz

@aaf2tbz aaf2tbz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

This branch is a set of changes where Mullion did less than Direct3D, NVIDIA's interfaces or Metal allow: one correctness fix that games hit (D3D11 dropped a barrier), D3D11 on Metal's own tessellator, shader model 6.8, MetalFX inputs DLSS gives that were dropped, NVAPI's ray tracing entry points, and converter changes. Each commit is one change with its test, seen failing without it and passing with it (CONTRIBUTING 3.1). Changes that could not be shown to help were left out; the end of this description lists those and why.

The first commit is #334's, so that tests/d3d12/d3d12_metalfx.cpp builds on main; it drops out when #334 is merged. The changes are independent and can be split into separate pull requests if that is preferred (CONTRIBUTING 2.3): the D3D11 barrier, split barriers, the pipeline option, NVAPI, DXGI, the sampler bias, MetalFX, D3D11 tessellation, and the converter.

What changes

Correctness

  • d3d11: a draw whose vertex stages use what the pass's pixel shaders wrote starts the next render pass (9748324). A draw sees what earlier draws wrote through UAVs (D3D11.3 5.3.5.1), but a tile-based GPU shades a pass's vertices before its fragments and Metal has no fragment-to-vertex barrier inside a pass, so the encoder dropped it (A fragment-vertex barrier is omitted) and the vertex shader read stale data. The context now tracks what the pass's pixel shaders read and wrote and ends the pass before a draw whose VS/HS/DS/GS, vertex/index buffers, indirect arguments or stream output conflict with it. d3d11_fragment_vertex_order: without it all four cases (SRV and vertex buffer, immediate and deferred) read 0 instead of 7.
  • airconv: a shader model 6.8 wave size range is refused without the GPU's size (e76bee0). The converter read only the 6.6 wave size tag; a 6.8 [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.
  • airconv: a DXIL part is refused when its headers do not fit it (99c4395): DXC's IsValidDxilProgramHeader checks before the first read. host_dxil_header: SIGBUS on the first of 9 malformed parts before.

Features

  • d3d11: tessellate through Metal's tessellator where it tessellates as Direct3D does (18d1b3b). D3D12 already did (d3d12: Tessellate through Metal's tessellator on Metal 3 and in compute on Metal 4 #173); D3D11 always used the mesh emulation. Draws meeting D3D12's conditions (tri/quad domain to triangles, integer/pow2, no GS, stream output, tested clip or cull distances, VS/HS UAVs or statistics; direct draws) run the converter's existing hull kernel in a compute pass before the render pass and drawPatches; the rest keep the mesh path. d3d11.nativeTessellation = False forces the mesh path. At factor 64 a draw takes 4.3 ms instead of 8.8 ms (M6, medians of 15 samples, 3 alternating runs per build; at factor 8 the difference is within noise). d3d11_tessellation_native checks every pixel on both paths and that 24 draws are native: 0 draws ran hull kernels, want 24 before; d3d11_tessellator's 256 native draws match the reference tessellator.
  • d3d12: the device reports shader model 6.8, its comparison sampling and its start locations (282e399): with the fix above every 6.8 feature works (wave size ranges, SampleCmpBias/Grad, SV_StartVertexLocation/SV_StartInstanceLocation directly and through ExecuteIndirect, Barrier of memory and semantics), so 6.8 and OPTIONS21's two flags are reported. d3d12_sm68 checks they are reported when, and only when, they work: 3 wrong before.
  • nvapi: NVIDIA's ray tracing caps and extended acceleration structure builds are answered (7b2a9c0): NvAPI_D3D12_GetRaytracingCaps (nothing beyond D3D12's), NvAPI_D3D12_BuildRaytracingAccelerationStructureEx and ..._GetRaytracingAccelerationStructurePrebuildInfoEx forward plain builds to D3D12's and refuse micromaps, spheres and their flags with NVAPI_NOT_SUPPORTED. nvapi_raytracing: the entry points were missing.
  • MetalFX inputs DLSS gives, D3D12 (065c6ec, e8d0888, c724dac, 6dbc857): render sizes within the scales MetalFX takes on the device (supportedInputContentMin/MaxScaleForDevice:, also fixing the dynamic minimum render size, which was a scale of 3.012 for a 512-wide output); Subrect.Base offsets as MetalFX's content offsets (macOS 27); DLSS's bias mask as MetalFX's reactive mask; display-resolution motion vectors read natively where MetalFX can (outputResolutionMotionVectorsEnabled), the downscale pass kept as the fallback (metalfx.outputResolutionMotionVectors = False forces it). Each was seen failing in d3d12_metalfx, d3d11_metalfx or the new d3d12_metalfx_downscaled; c1ea639 refreshes an existing fault patch that no longer applied.
  • dxgi: an adapter has a device of its vendor's, and a configurable subsystem and revision (af2142e). This changes a default: with no device configured, AMD (the default vendor) reports 744c, NVIDIA 2704, Intel 56a0, instead of 0000; dxgi.customSubSysId and dxgi.customRevision are new. dxgi_adapter_identity: 8 of 10 configurations wrong before.
  • d3d11.samplerLodBias and d3d12.samplerLodBias (a24fbf2), as DXVK's options of the name: added to every sampler's own bias, within −16 to 15.99. d3d11_sampler_lod_bias, d3d12_sampler_lod_bias: the biased runs read mips 5 and 5.5 instead of the expected ones before.
  • d3d12.ignoreFailedPipelines (bb38b1a), off by default (CODE.md 2.5): a pipeline the converter or Metal cannot make is given to the application as one whose draws and dispatches are dropped instead of failing creation; running out of memory still fails. d3d12_ignore_failed_pipelines: both creations refused (E_INVALIDARG) before.
  • nvngx: DLSS's statistics give the memory MetalFX's scaler takes (e04166a), about 23 bytes per render pixel and 30 per output pixel, measured against real scalers at five sizes (within 1%); it reported 0. d3d12_ngx_stats.

Less work

  • d3d12: the first half of a split barrier orders nothing (46b5659). Both halves were ordering points, so work recorded between them waited for the work before them, which is what a split barrier exists to avoid; the second half still orders. d3d12_split_barrier passes before and after, and fails (32 of 32 pixels) with the second half also skipped, so it shows the ordering kept; with MULLION_TRACE_PASS=heavy the draw between the halves now shares the first draw's pass instead of following it.
  • airconv: a geometry pipeline's payload is what its object threadgroup stores (bb90f2b): it was the 16256-byte maximum for every geometry and stream output pipeline; it is now sized from the vertex shader's outputs (576 to 15936 bytes). 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: no speed change is shown.
  • airconv: a stage before the rasterizer contracts what its position does not depend on (a9856b3). Contraction was off in every pre-raster stage (the TODO(invariance-analysis)), so depth prepasses match. It now stays off only for what feeds the position, clip and cull distances, non-register outputs and branch conditions, and everything else may contract; a function whose position depends on memory it also writes stays strict. MULLION_AIRCONV_SKIP=position-contraction gives the old output. host_position_invariance: 4 wrong before, and 6 with the position deliberately relaxed. AIRCONV_VERSION is 126.
  • airconv: a converted library's header names the macOS of its module's triple (4b3325e): 14.0, 15.0 or 26.0, as Apple's metallib writes, where it was 14.4 for every target. host_metallib_header: 4 wrong before.

Evidence

Mac mini, Apple M6, macOS 27.3 (26C5047e). MetalSharp Wine 8.0 (wine-11.20), arm64 with FEX, copied with --clone. Build: --cross-file build-arm64ec.txt --buildtype debugoptimized -Denable_nvngx=true -Denable_nvapi=true -Denable_tests=true, LLVM 15.

  • Every commit builds on its own (ARM64EC).
  • Each new test was run failing on the code without its change (or with the change deliberately broken), as given above, then passing.
  • The suite on the final revision against main + tests: d3d12_metalfx compiles again #334 (386d2db), both tests/run.py --family native --jobs 4 d3d dxgi nvapi:
Revision Passed Failed Skipped
main + #334 754 30 3
this branch 773, and 2 more after the last amend (below) 31, then 29 3

The failures are the same tests with the same wrong-result digests on both, except d3d12_idle_residency_dxil, which ended at memory pressure on main and passed here. (On the final revision before its last amend, d3d12_feature_queries failed in both front ends, expecting OPTIONS21's two flags off; the last commit updates it, and it then passes on every family with --validate. The suite was not run again as a whole after that.) They are not in tests/known.txt, which is keyed to an M5 Pro, so the runner lists all of them as new; they include d3d11_raster*, d3d11_depth_stencil, d3d11_block_values, d3d11_dxbc_arithmetic and d3d11_fullscreen. Host suite: 26 OK, 1 skipped (host_dxbc_hash, which needs MULLION_HASHED).

  • The new and touched tests (d3d11_fragment_vertex_order, d3d12_split_barrier, d3d12_barrier, d3d12_ignore_failed_pipelines, nvapi_raytracing, dxgi_adapter_identity, the two sampler_lod_bias, d3d12_ngx_stats, d3d12_metalfx, d3d11_metalfx, d3d11_tessellation_native, d3d11_tessellator, d3d11_trace_encoders, d3d12_wave_size) on every default family (native, Apple9, 8, 7 and the three Metal 3 ones) with --validate --repeat 2: 189 passed and 7 failed, the seven being nvapi_raytracing_dxil on each family (below). d3d12_sm68 and d3d12_wave_size_range ran validated on all families in their own runs, with the result given below.

Not run, and what remains

  • Under --validate on Metal 4, ExecuteIndirect draws stop (d3d12_indirect_draw and d3d12_indirect_start on main too), so d3d12_sm68 was run validated on the Metal 3 families only, and on all families without validation. nvapi_raytracing fails validated on every family where ray queries do on main (Metal's "Invalid load in 'device' or 'constant' address space"); it passes without validation.
  • win32: src/nvapi/nvapi.cpp does not build on main (an EnumDisplayMonitors lambda); the win32 build was made with -Denable_nvapi=false and no win32 test ran (this Wine runs no i386 programs). x86_64 was not built, and only the M6 ran: other families are MULLION_GPU_FAMILY masks of it.
  • The tests ran on a machine where several builds and test runs were going at once for part of the time, without MULLION_TEST_LOCK; the counts above come from runs alone.
  • tests/faults.py does not work with a build directory inside the worktree (its copy lands in the repository, so the patch changes nothing); the faults were applied by hand instead.
  • D3D11 gets none of the MetalFX changes, and the output subrect's base is not read.

Left out:

  • Several geometry shader primitives per mesh threadgroup. Each GS invocation is a one-thread mesh threadgroup, where Apple's converter packs several. Four emit paths, the conservative and tessellation paths' own use of mesh threads, stream output's per-invocation indexing and the dispatch in D3D11, D3D12 and ExecuteIndirect all assume one; several GS tests stop under validation on main. It needs a design landed in stages, not part of this.
  • No-alias metadata on buffers. Direct3D gives no guarantee to rely on (UAVs alias; DATA_STATIC says nothing about another view in the same draw), and Apple's mechanism is on buffer arguments, which Mullion's argument tables are not.
  • The compute pipeline's threadgroup-multiple hint, and filling a ray tracing candidate's system values only for its shaders: three alternating runs on a quiet machine moved the scenes they touch by −2.2% to +4.1%, signs flipping; no gain is shown.
  • Zeroing new committed resources: Metal returned zeroed memory in every case tried (resources filled, released and made again, four rounds), so there was nothing to fix.
  • Refit options: Mullion's acceleration structures have no per-primitive data, so they change nothing.
  • Static samplers from the root signature's buffer: a copy of a few hundred bytes per bind, and the buffer exists only for local root signatures.
  • air.compile_options: Metal follows the per-instruction flags in every combination tried.
  • D3D11 predication on the GPU (D3D11's occlusion results are summed on the CPU, so the GPU has nothing to read), a UAV barrier inside a D3D12 render pass (a tile-based GPU cannot order fragment before vertex work in a pass, and bindless descriptors hide what a vertex shader reads), Metal 4 texture view pools, per-subresource barrier tracking, a D3D12 vertex fetch through stage_in, tessellation factors that do not grow the mesh payload, double emulation and work graphs: each is a project of its own.
  • Not done: anything through Metal interfaces that are not public, shared fences that go back, and running small indexed ExecuteIndirect calls in place, which would lose indices past the view reading zero.

…nputs check

dttdrv#324 added a lambda named rejected for the invalid temporal MetalFX inputs and
dttdrv#325 a pointer named rejected for the DLSS handles creation refuses, in the same
function: each compiled alone, and together the test does not. The pointer is
the handle its messages already call it.
…rote starts the next render pass

A draw sees what the draws before it wrote through UAVs (D3D11.3 5.3.5.1), in every
stage. A tile-based GPU shades every draw's vertices in a render pass before any of its
fragments, and Metal has no barrier from fragment to vertex work inside a pass, so the
encoder dropped such a barrier ("A fragment-vertex barrier is omitted") and the later
draw's vertex shader read what was there before. The context now records which
resources the pass's pixel shaders read and wrote, and a draw whose vertex, hull, domain
or geometry shader, vertex or index buffers, indirect arguments or stream output read
what one of them wrote, or write what one read, ends the pass first, as a draw that has
no room for its scissors does. The next pass loads what this one stored.

d3d11_fragment_vertex_order reads, in a second draw's vertex shader, a value the first
draw's pixel shader wrote, through a shader resource view and as a vertex buffer, on the
immediate and a deferred context: without this all four read 0.
A split barrier's resource is not used between its two halves, and its second half
orders the work before the first against the work after it ("Split Barriers",
D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY / END_ONLY; Enhanced Barriers, "Split barriers",
D3D12_BARRIER_SYNC_SPLIT). Both halves were ordering points, and the first ended a
render pass whose draws had used UAVs, so work recorded between the halves waited for
the work before them, which is what a split barrier lets it not do. The first half
(BEGIN_ONLY, or SyncAfter SPLIT) now only does the barrier's bookkeeping; the second
orders as a whole barrier does.

d3d12_split_barrier has a pixel shader write a flag, a split transition of its buffer
around a draw that does not use it, and a later vertex shader read the flag, with legacy
and enhanced barriers. It passes before and after; with the second half also skipped it
fails (32 of 32 pixels see the flag unwritten), so it shows the second half still
orders. With MULLION_TRACE_PASS=heavy the draw between the halves now shares the first
draw's render pass instead of opening one after it.
…ke as one whose work is dropped

A pipeline whose shader the converter refuses, or which Metal cannot compile, fails
its creation, which many titles do not expect: they stop or crash. With d3d12.ignoreFailedPipelines
(off by default, CODE.md 2.5) the creation succeeds with a
pipeline whose draws are dropped before they reach a pass and whose dispatches are
dropped, and the log names it. A failure to allocate still fails, as a cached blob of
another build does before the pipeline is made.

d3d12_ignore_failed_pipelines makes a graphics and a compute pipeline of shaders with
a double-precision operation, which the converter refuses: without this both creations
fail with E_INVALIDARG; with it they succeed, their draw and dispatch write nothing, and
an ordinary draw and dispatch around them write what they should (--validate, three
runs).
…builds are answered

NvAPI_D3D12_GetRaytracingCaps, NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx
and NvAPI_D3D12_BuildRaytracingAccelerationStructureEx were not there, and QueryInterface
gave no function for them. Engines that use NVIDIA's ray tracing extensions query the caps
before they choose a build path, and build through the Ex functions with NVAPI's geometry
descriptions.

The caps of every type are its CAP_NONE: no NVIDIA shader extension is lowered, so thread
reordering is the no-op the header gives that value, and there are no opacity or
displacement micromaps, cluster operations, partitioned top-level structures, spheres or
linear swept spheres. A size other than the caps' is INVALID_ARGUMENT, an unknown type too,
and a null pointer INVALID_POINTER (nvapi.h).

The Ex prebuild information and build are "an extension of" ID3D12Device5's and
ID3D12GraphicsCommandList4's: triangle and box geometries, in an array a stride apart or by
pointer, and top-level structures are converted to Direct3D's inputs, whose build flags
have the same values, and go to the device's and list's own calls, post-build information
included. A geometry of micromaps, spheres or linear swept spheres and the build flags of
micromaps and data access are NOT_SUPPORTED, as the caps say none of them is there; a count
of post-build descriptions without them is INVALID_COMBINATION and another structure
version INCOMPATIBLE_STRUCT_VERSION. Instances keep their flags, of which Metal's instances
take the four Direct3D defines.

nvapi_raytracing builds the ray tracing tests' scene (d3d12_rays.hpp) through NVAPI and
traces it with ray queries against the CPU caster, compares the prebuild sizes and the
compacted size with Direct3D's, and checks the caps and the refusals. Without the change it
fails with no function for the three; with it it passes as every family, three times each.
…system and revision

An adapter reported device ID 0 unless dxgi.customDeviceId named one, whatever its vendor:
AMD's by default, NVIDIA's with NVEXT or dxgi.customVendorId. Applications look the vendor
and device up in tables of PC GPUs, where 0 is in none, and MetalSharp's DLSS setup
(src/nvngx/signing/README.md) has to name NVIDIA's RTX 4080, 2704, for a device at all.

The device is now one of the vendor's where the configuration names none: NVIDIA's RTX 4080
(10de:2704), and the other vendors' of its class, AMD's RX 7900 XTX (1002:744c) and Intel's
Arc A770 (8086:56a0); Apple's vendor, which has no PCI devices, keeps 0.
dxgi.customSubSysId (up to eight hex digits) and dxgi.customRevision (up to two) set the
subsystem and revision, which stay 0 without them or when they are not such a number. The
options reach the environment through MULLION_CONFIG, as every option does. mullion.conf
documents both and the defaults.

dxgi_adapter_identity checks GetDesc, GetDesc1 and GetDesc3 in a process for each of ten
configurations: the defaults, NVEXT, each vendor, a named device, a subsystem, revision and
name, and values that are not numbers of their digits. Without the change it fails eight
of the ten cases (device 0 for AMD, NVIDIA and Intel, subsystem and revision 0); with it
it passes as every family under validation, three times each.
…s to every sampler's

There was no way to bias the level of detail samplers pick beyond each sampler's own
MipLODBias. DXVK has d3d11.samplerLodBias for it, which players use to sharpen what a
title's upscaler or a low render resolution blurs.

d3d11.samplerLodBias, for Direct3D 10 and 11, and d3d12.samplerLodBias, for Direct3D 12, are
added to the bias each sampler is made with, held within -16 and 15.99 (D3D11_MIP_LOD_BIAS_MIN
and _MAX, D3D12_MIP_LOD_BIAS_MIN and _MAX). The bias is the sampler metadata's, which
shaders add to the LOD of every sample (D3D11.3 7.18.11, "biasedLOD = output.LOD +
MipLODBias"), so it reaches Direct3D 12's static samplers too, which are the device's samplers
of their descriptions. A Direct3D 11 sampler's GetDesc stays the application's. Without the
options nothing changes. mullion.conf documents both.

d3d11_sampler_lod_bias and d3d12_sampler_lod_bias sample a texture whose mip m holds m at
LOD 5 through samplers of a bias of 0 and 0.5 (in a heap and static, for Direct3D 12), with
no option, a bias of 1.5 and one of -2. Without the change the runs with a bias read mips 5
and 5.5 and fail; with it every run passes as every family under validation, three times
each.
…e's sizes takes

DLSSGetStatsCallback set SizeInBytes, "VRAM allocated" by DLSS (NVSDK_NGX_DLSS_GetStats in
nvsdk_ngx_helpers.h), to 0 always. Engines show it in their memory budgets and leave room
for it.

A feature is MetalFX's temporal scaler, made when a list first records its upscale. The
adapter's local usage (QueryVideoMemoryInfo, the device's currentAllocatedSize) grows by
23 bytes for each render pixel and 30 for each output pixel when one is made, within 1% at
540p to 1080p, 720p to 1440p, 1080p to 2160p, 1440p to 2160p and 1080p unscaled (an M6,
macOS 27.3, RGBA16F color and output). The callback reports that for the sizes on the
parameters it is given: Width, Height, OutWidth and OutHeight, as CreateFeature takes them,
or the other way round as the optimal settings callback leaves them, the smaller being the
render size; without them it reports 0.

d3d12_ngx_stats makes a scaler of each of those sizes through the D3D12 list's MetalFX
extension, measures the usage it adds, and asks NGX's core for the statistics of the same
sizes: they are within a quarter of it. Without the change NGX reports 0 for every size and
the test fails; with it it passes as every family under validation, three times each.
… device

The temporal scalers of D3D11 and D3D12 were made for content scales of 1 to 3 whatever the device took, and DLSS's
optimal settings gave render sizes from that range without asking MetalFX either: its smallest dynamic render size
was the output's divided by 3 in integers, rounded down, so an output of 512 gave 170, a scale of 3.012 that the
scaler's own range leaves out.

The bridge now asks MetalFX for the range (MTLFXTemporalScalerDescriptor supportedInputContentMinScaleForDevice: and
supportedInputContentMaxScaleForDevice:, macOS 14), and both scalers are made with it. The D3D12 command list extension gives it to NGX
(GetTemporalUpscaleScales) and the D3D11 context's as a feature (MTL_FEATURE_METALFX_TEMPORAL_SCALES); NGX takes it
when it starts and keeps each mode's render size within it, its dynamic range's smallest size rounded up from the
largest scale and its largest rounded down from the smallest. On an Apple M6 (macOS 27.3) MetalFX takes 1 to 3, so the scalers and the modes' render sizes
there are the ones they were; the dynamic smallest size of a 512-wide output is now 171.

The NGX part of d3d12_metalfx checks every mode's sizes against the extension's range, and d3d11_metalfx the
feature's answer. d3d12_metalfx's DLSS handle pointer is named handle, as in dttdrv#334, so that the test builds beside
the lambda of the same name.
…r textures

DLSS takes where each input's content starts in its texture (DLSS.Input.Color.Subrect.Base.X and .Y, the depth's and
the motion vectors' as well), and NGX read the content's size alone: MetalFX read the content from each texture's
corner, so a game that renders into part of a larger texture away from its corner was upscaled with what lies
around its content.

MetalFX takes where each input's content starts from macOS 27 (MTLFXTemporalScalerBase colorContentOffsetX,
depthContentOffsetX, motionContentOffsetX and their Y). NGX now reads the bases, the command list extension takes them
(MTL_TEMPORAL_UPSCALE_D3D12_DESC ColorOffsetX...), each kept as far in as its content fits in its texture, and the
bridge gives them to the scaler of either kind of command buffer. Motion vectors at the output resolution, which a
pass brings to the input's, start where the pass puts their start. Without a size the content is the rest of the
color's texture from where it starts. Where MetalFX lacks them, as before macOS 27, the content is read from the
corner as it was, and a warning says so once: no copy of each input is made to bring its content there.

d3d12_metalfx upscales a frame of one color inside textures of another, through the extension and through NGX.
DLSS takes a mask of how much each pixel takes of its current color over its history, from 0 to 1
(DLSS.Input.Bias.Current.Color.Mask), for what its motion vectors miss, such as particles and transparencies. NGX
left it out, so those trailed in the upscaled image as they do without the mask. MetalFX's temporal scaler takes the
same mask (reactiveMaskTextureEnabled and reactiveMaskTextureFormat on its descriptor, reactiveMaskTexture on the
scaler, macOS 14.4: 0 is MetalFX's own blend and 1 ignores the history), with its format in the scaler's key.

NGX now reads the mask and where its content starts (DLSS.Input.Bias.Current.Color.Subrect.Base.X and .Y), the
command list extension takes it (MTL_TEMPORAL_UPSCALE_D3D12_DESC ReactiveMask), its format in the key of the
feature's scaler, and the bridge gives it to the scaler of either kind of command buffer. A typeless mask is read as
the unsigned normalized or float values its bits hold. A mask that does not hold the content, or holds integers, is
left out with a warning once, as DLSS runs without one; the upscale is not refused.

d3d12_metalfx upscales a checkerboard after its inverse, not in reset, with a mask of 1 and without, through the
extension and through NGX: with it the frame shows less of the frame before.
… can

Motion vectors DLSS is given at the output resolution (without NVSDK_NGX_DLSS_Feature_Flags_MVLowRes) were brought
to the input's by a compute pass before each upscale (cs_downscale_dilated_mv), which reads one vector at each input
pixel's place and leaves the rest out. MetalFX reads them at the output resolution itself from macOS 27
(MTLFXTemporalScalerDescriptor outputResolutionMotionVectorsEnabled).

The bridge now says whether the descriptor responds to setOutputResolutionMotionVectorsEnabled:, and a scaler is made
to read the vectors at the output resolution where it does, they are of a format MetalFX takes and their size is the
output's: no pass runs, and MetalFX takes DLSS's scale, which makes them output pixels. Elsewhere the pass runs as it
did, and metalfx.outputResolutionMotionVectors = False keeps it everywhere. The feature's scaler asks what MetalFX
takes once, when it is made, rather than at each scaler.

d3d12_metalfx's frames with motion vectors at the output resolution come out as before, the same image as the same
motion at the input's and another for half of it, and the scaler's log line now says that MetalFX read them where it
reads them; d3d12_metalfx_downscaled runs the test with the pass kept, whose log line says the pass brought them.
tests/breaks/d3d12_metalfx.3.patch broke the reset of the temporal upscale's properties at lines and with names
that had changed (display_motion, which is motion_pass, and the content's size, now worked out before them), so
tests/faults.py could not apply it. It now breaks the same field where it is. With it d3d12_metalfx fails with
121700 channels of the frame in reset showing the frame before.
… Direct3D does

every tessellated draw took the mesh emulation, whose object stage runs the vertex and hull shaders and whose mesh
stage tessellates and runs the domain shader, a patch's workloads to a threadgroup. D3D12 has drawn through Metal's
tessellator on Metal 3 encoders since c951e38, and D3D11's encoders are all Metal 3's.

a pipeline whose tessellator Metal's tessellates as Direct3D's does, a triangle or quad domain to triangles with
integer or pow2 partitioning (D3D11.3 11.7.7.1: the hull kernel rounds pow2's factors), with no geometry shader,
stream output, clip distances the pixel shader tests, cull distances, UAVs in its vertex or hull shader or pipeline
statistics, also has the converter's native functions (SM50_SHADER_PSO_TESSELLATOR_DATA's native, as D3D12's): a hull
kernel and a post-tessellation vertex function running the domain shader. its direct draws run the kernel in a
compute encoder before their pass, which waits for what the pass's vertex stages wait for and makes resident what the
vertex and hull shaders read, and the pass waits for it; drawPatches then draws the patches it wrote. indirect draws,
draws under pipeline statistics and draws after a pre-raster stage has written in the pass, which the kernel would
read before the pass, keep the mesh pipeline, as does a pipeline Metal does not make the tessellator of. the domain
shader's tables are the vertex stage's too, and the vertex and hull shaders' are kept for the kernel, so a pass mixes
the two. d3d11.nativeTessellation = False keeps the mesh emulation for every draw.

the encoder trace names the kernels' encoder "hull", with its draws, and counts drawPatches as tessellation draws:
d3d11_trace_encoders expects it before the pass of the two direct tessellated draws.

d3d11_tessellation_native draws tri and quad patches, integer, pow2 and fractional_odd, clockwise and
counter-clockwise, directly, through 16- and 32-bit indices with a base vertex and a start instance, and indirectly
between, with each stage's constant buffer and the domain shader's buffer: each pixel is checked, with each setting,
and the trace shows 24 native draws with it on and none off. it fails without the change (0 hull kernels).
d3d11_tessellator, whose triangles are the reference tessellator's, draws 256 of its draws natively.

a large draw (8 draws of 128 quad patches x 4 instances, integer; GPU time between timestamp queries, median of 15
per run, three runs, Apple M6, no validation): factor 64 takes 4.28-4.32 ms natively against 8.74-8.86 ms through the
mesh emulation (8.74-8.78 ms before the change), factor 8 0.97-1.20 ms against 1.14-1.33 ms.
… 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.
aaf2tbz added a commit to aaf2tbz/mullion that referenced this pull request Nov 22, 2026
The D3D11 barrier fix, Metal's tessellator for D3D11, shader model 6.8, the MetalFX
inputs DLSS gives, NVAPI's ray tracing entry points and the converter changes
(dttdrv#341), with upstream main up to 574d397.

Kept from metalsharp-2.1-main: TemporalUpscale's inputs DLSS would not be given are
upscaled and logged once (the reactive mask added to them), frame interpolation beside
GetTemporalUpscaleScales, MULLION_D3D12_SHADER_MODEL (now up to 6.8, its default), and
METALSHARP_DLSS_SCALE, whose scale is then held within the scales MetalFX takes.
# Conflicts:
#	src/d3d12/d3d12_command_list.cpp
@aaf2tbz

aaf2tbz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Split by category into five pull requests with the same commits, so each can be reviewed and merged on its own:

Together they make the same tree as this branch. #343 and #345 each add to tests/d3d12/meson.build's one-line test list, so whichever is merged second conflicts on that line only; I'll rebase it. The "left out" geometry shader item follows separately.

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.

1 participant