Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QRhiShadingRateMap Class Reference

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h More...

#include <qrhi.h>

Inheritance diagram for QRhiShadingRateMap:
Collaboration diagram for QRhiShadingRateMap:

Classes

struct  NativeShadingRateMap
 \inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h More...

Public Member Functions

QRhiResource::Type resourceType () const override
virtual bool createFrom (NativeShadingRateMap src)
 Sets up the shading rate map to use a native 3D API shading rate object src.
virtual bool createFrom (QRhiTexture *src)
 Sets up the shading rate map to use the texture src as the image containing the per-tile shading rates.
virtual QSize logicalSize () const
Public Member Functions inherited from QRhiResource
virtual ~QRhiResource ()
 Destructor.
virtual void destroy ()=0
 Releases (or requests deferred releasing of) the underlying native graphics resources.
void deleteLater ()
 When called without a frame being recorded, this function is equivalent to deleting the object.
QByteArray name () const
void setName (const QByteArray &name)
 Sets a name for the object.
quint64 globalResourceId () const
QRhi * rhi () const

Protected Member Functions

 QRhiShadingRateMap (QRhiImplementation *rhi)
 \variable QRhiShadingRateMap::NativeShadingRateMap::object
Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)

Additional Inherited Members

Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer ,
  ShadingRateMap , IndirectCommandBuffer
}
 Specifies type of the resource. More...
Protected Attributes inherited from QRhiResource
QRhiImplementation * m_rhi = nullptr
quint64 m_id
QByteArray m_objectName

Detailed Description

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h

Since
6.9

An object that wraps a texture or another kind of native 3D API object.

Note
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.

For an introduction to Variable Rate Shading (VRS), see \l{https://learn.microsoft.com/en-us/windows/win32/direct3d12/vrs}. Qt supports a subset of the VRS features offered by Direct 3D 12 and Vulkan. In addition, Metal's somewhat different mechanism is supported by making it possible to set up a QRhiShadingRateMap with an existing MTLRasterizationRateMap object.

Definition at line 1194 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiShadingRateMap()

QRhiShadingRateMap::QRhiShadingRateMap ( QRhiImplementation * rhi)
protected

\variable QRhiShadingRateMap::NativeShadingRateMap::object

64-bit integer containing the native object handle.

Used with QRhiShadingRateMap::createFrom(). For example, with Metal, object is expected to be an id<MTLRasterizationRateMap>.

Definition at line 5373 of file qrhi.cpp.

Member Function Documentation

◆ createFrom() [1/2]

bool QRhiShadingRateMap::createFrom ( NativeShadingRateMap src)
virtual

Sets up the shading rate map to use a native 3D API shading rate object src.

Returns
true when successful, false when not supported.
Note
This is functional only when the QRhi::VariableRateShadingMap feature is reported as supported, while QRhi::VariableRateShadingMapWithTexture feature is not. Currently this is true for Metal, assuming variable rate shading is supported by the GPU.
With Metal, the object field of src is expected to contain an id<MTLRasterizationRateMap>. Qt passes the MTLRasterizationRateMap on to the MTLRenderPassDescriptor, and, because Metal then interprets viewports and scissor rectangles in the map's screen space coordinate system, sizes the default scissor and converts viewports and scissors specified via QRhiCommandBuffer accordingly. The size of that coordinate system is reported by logicalSize(). Anything else, such as scaling when sampling the rendered result, is up to the application (or the XR compositor).

Reimplemented in QMetalShadingRateMap.

Definition at line 5406 of file qrhi.cpp.

◆ createFrom() [2/2]

bool QRhiShadingRateMap::createFrom ( QRhiTexture * src)
virtual

Sets up the shading rate map to use the texture src as the image containing the per-tile shading rates.

Returns
true when successful, false when not supported.

The QRhiShadingRateMap does not take ownership of src.

Note
This is functional only when the QRhi::VariableRateShadingMapWithTexture feature is reported as supported. In practice may be supported on Vulkan and Direct 3D 12 when using modern graphics cards. It will never be supported on OpenGL or Metal, for example.
src must have a format of QRhiTexture::R8UI.
src must have a width of {ceil(render_target_pixel_width / (float)tile_width)} and a height of {ceil(render_target_pixel_height / (float)tile_height)}. It is up to the application to ensure the size of the texture is as expected, using the above formula, at all times. The tile size can be queried via \l QRhi::resourceLimit() and QRhi::ShadingRateImageTileSize.

Each byte (texel) in the texture corresponds to the shading rate value for one tile. 0 indicates 1x1, while a value of 10 indicates 4x4. See \l{https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_shading_rate}{D3D12_SHADING_RATE} for other possible values.

Reimplemented in QVkShadingRateMap.

Definition at line 5439 of file qrhi.cpp.

◆ logicalSize()

QSize QRhiShadingRateMap::logicalSize ( ) const
virtual
Since
6.13
Returns
the size of the logical coordinate space the shading rate map defines, or an invalid QSize when the map does not define one.

Some implementations, Metal in particular, describe a shading rate map in terms of a logical (screen space) size that is mapped onto the physical pixels of the render target. When such a map is attached to a render target, viewports and scissor rectangles are interpreted in the logical coordinate system, and the logical size is typically larger than QRhiRenderTarget::pixelSize(). Applications that derive viewports, scissors, or projection setup from the render target size should use this size instead whenever it is valid.

For implementations where the shading rate map is a tile image covering the render target, such as Vulkan and Direct 3D 12, there is no separate logical coordinate space, and an invalid QSize is returned. The render target's pixel size applies as usual in that case.

See also
QRhiRenderTarget::pixelSize()

Reimplemented in QMetalShadingRateMap.

Definition at line 5467 of file qrhi.cpp.

◆ resourceType()

QRhiResource::Type QRhiShadingRateMap::resourceType ( ) const
overridevirtual
Returns
the resource type.

Implements QRhiResource.

Definition at line 5381 of file qrhi.cpp.


The documentation for this class was generated from the following files: