Repository navigation
MetalFX: the inputs DLSS gives, and NGX's render sizes and statistics - #342
Merged
Merged
Conversation
…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.
This was referenced Nov 22, 2026
# Conflicts: # src/d3d12/d3d12_command_list.cpp # tests/d3d11/d3d11_metalfx.cpp
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.
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
d3d12_ngx_statsis new.supportedInputContentMin/MaxScaleForDevice:). This also fixes the dynamic minimum render size, which was a scale of 3.012 for a 512-wide output.Subrect.Baseoffsets become MetalFX's content offsets (macOS 27).outputResolutionMotionVectorsEnabled). The downscale pass stays as the fallback, andmetalfx.outputResolutionMotionVectors = Falseforces it.d3d12_metalfx_downscaledis new and runs the fallback.d3d12_metalfxthat no longer applied is refreshed.Each change was seen failing in
d3d12_metalfx,d3d11_metalfxord3d12_metalfx_downscaledwithout it. The bias-mask commit is rebased ontoTemporalUpscale'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.tests/run.py --family nativewithd3d12_metalfx d3d11_metalfx d3d12_ngx_stats d3d12_presented: 7 passed, 0 failed.d3d dxgi nvapi) had the same failures, with the same wrong-result digests, asmain, and the touched tests passed on every default family with--validate --repeat 2.Not run