RI::cmdResolve, resolveTo¶
What it does¶
A resolve turns a multisampled texture view into a single-sampled one, combining each pixel's samples into a single value. RI provides two ways to record a resolve:
- At the end of a rendering section: set
resolveTo(a single-sampledTextureView) andresolveModeon aColorAttachmentor theDepthAttachmentpassed tocmdBeginRendering.cmdEndRenderingthen performs the resolve. - As a standalone command: call
RI::cmdResolve(cmd, src, dst, mode)outside any rendering section.
The ResolveMode enum selects how the samples of a pixel are combined: eAverage, eMin,
eMax, or eSampleZero.
- Color resolves only support
eAverage, and only for non-integer formats. - Depth and stencil resolves use the modes the GPU reports in
device.limits.depthResolveModesanddevice.limits.stencilResolveModes. Each bitmask containsRI::resolveModeBit(mode)for every supported mode. A format with both depth and stencil resolves both aspects with the same mode, soRI::resolveModeBit(mode)must be present in both masks.eMinandeMaxare the portable depth modes on desktop GPUs; D3D12 does not supporteSampleZero. RI does not emulate missing modes: if you need an unsupported mode, resolve in your own shader instead.
Signature¶
// <RI/RI.hpp>, namespace RI
void cmdResolve(CommandList &cmd, const TextureView &src, const TextureView &dst, ResolveMode mode);
From the header: Resolves a multisampled view into a single-sampled one (P52, P76), outside rendering sections. Counts as Stage::eRenderTarget (color) or Stage::eDepthStencil (depth) for barriers.
From the header: MSAA resolve (P52, P76): how the samples of a pixel become one value. Color resolves average; depth and stencil take the modes the device reports in DeviceLimits::depthResolveModes / stencilResolveModes. No emulation.
| Value | Meaning |
|---|---|
eAverage |
|
eMin |
|
eMax |
|
eSampleZero |
From the header: The bit of mode in DeviceLimits::depthResolveModes and stencilResolveModes.
How RI does it¶
- Vulkan:
cmdBeginRenderingbinds eachresolveTotarget as a dynamic rendering resolve attachment (resolveImageViewandresolveModeonVkRenderingAttachmentInfo), andcmdEndRenderingtransitions it back to its resting layout.cmdResolverecords an empty rendering section that loads the source and resolves it, becausevkCmdResolveImageonly averages color. Supported depth and stencil modes are read fromVkPhysicalDeviceDepthStencilResolveProperties. - D3D12: RI records
ResolveSubresourceRegionfor each layer and plane, either after the rendering section incmdEndRenderingor directly incmdResolve. Before and after the resolve, RI transitions the views intoD3D12_BARRIER_LAYOUT_RESOLVE_SOURCEandD3D12_BARRIER_LAYOUT_RESOLVE_DESTand back to their resting layouts. Depth and stencil resolves require programmable sample positions tier 2 (which provideseAverage,eMin, andeMaxfor depth, andeMinandeMaxfor stencil).
Rules and errors¶
- The source view must be multisampled and the destination view single-sampled, with the same
dimensions, layer count, and format. The destination texture must have
TextureUsage::eRenderTarget(color) orTextureUsage::eDepthStencil(depth). - In validation builds, violating the view requirements, resolving an integer color format,
using a color mode other than
eAverage, using a depth or stencil mode the GPU does not support, or callingcmdResolveinside a rendering section reports a programmer error. - For barriers, resolves count as
Stage::eRenderTarget(color) orStage::eDepthStencil(depth) writes; their results are visible after the layout switch back to rest that RI records, like attachment writes. - A destination placed over memory that another resource previously used must be
discarded with
cmdDiscardbefore the resolve. Validation builds report a missing discard atcmdResolve, or atcmdBeginRenderingfor aresolveTotarget.