Skip to content

MetalFX: the inputs DLSS gives, and NGX's render sizes and statistics - #342

Merged
dttdrv merged 7 commits into
dttdrv:mainfrom
aaf2tbz:split/metalfx-dlss
Nov 26, 2026
Merged

dttdrv merged 7 commits into
dttdrv:mainfrom
aaf2tbz:split/metalfx-dlss

Conversation

@aaf2tbz

@aaf2tbz aaf2tbz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

MetalFX was given less than DLSS hands it. This takes the inputs DLSS gives that Mullion dropped, and fixes the render sizes and statistics NGX reports. Split out of #341, with the same commits.

What changes

  • nvngx: DLSS's statistics give the memory MetalFX's scaler of a feature's sizes takes. It reported 0. The estimate is about 23 bytes per render pixel and 30 per output pixel, measured against real scalers at five sizes (within 1%). d3d12_ngx_stats is new.
  • nvngx: DLSS's render sizes are within the scales MetalFX takes on the device (supportedInputContentMin/MaxScaleForDevice:). This also fixes the dynamic minimum render size, which was a scale of 3.012 for a 512-wide output.
  • d3d12: MetalFX reads DLSS's inputs where their content starts in their textures. Subrect.Base offsets become MetalFX's content offsets (macOS 27).
  • d3d12: DLSS's bias mask is MetalFX's reactive mask.
  • d3d12: MetalFX reads DLSS's output-resolution motion vectors where it can (outputResolutionMotionVectorsEnabled). The downscale pass stays as the fallback, and metalfx.outputResolutionMotionVectors = False forces it. d3d12_metalfx_downscaled is new and runs the fallback.
  • tests: a fault patch of d3d12_metalfx that no longer applied is refreshed.

Each change was seen failing in d3d12_metalfx, d3d11_metalfx or d3d12_metalfx_downscaled without it. The bias-mask commit is rebased onto TemporalUpscale's once-logged input checks (#335) and keeps them.

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.

Not run

  • D3D11 gets none of these changes, and the output subrect's base is not read.
  • x86_64 was not built.

…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.
# Conflicts:
#	src/d3d12/d3d12_command_list.cpp
#	tests/d3d11/d3d11_metalfx.cpp
@dttdrv
dttdrv merged commit c23cc96 into dttdrv:main Nov 26, 2026
20 checks passed
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.

2 participants