RI::DeviceLimits¶
What it is¶
The limits field on a Device (device.limits) reports the limits and
optional capabilities that RI's own functions depend on. RI::createDevice
fills it in once and it never changes. To query any other GPU property or feature, use the
native API.
| Field | Meaning | Vulkan | D3D12 |
|---|---|---|---|
maxResourceDescriptors |
Maximum number of resource view slots in a descriptor heap | Smallest update-after-bind descriptor limit of the GPU (also checked with vkGetDescriptorSetLayoutSupport), capped at 1,000,000 |
1,000,000 (D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2) |
maxSamplerDescriptors |
Maximum number of sampler slots in a descriptor heap | GPU's update-after-bind sampler limit, capped at 2048 | 2048 (D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE) |
maxRootDataSize |
Maximum bytes of root data a pipeline's shaders may declare | maxPushConstantsSize (at least 128), capped at 256 (kMaxRootDataSize) |
256 (64 32-bit root constants) |
maxBufferViewSize |
Maximum bytes one read or read-write buffer view may cover, in addition to the kMaxBufferViewElements (2^27) element limit |
maxStorageBufferRange |
No byte limit beyond the element limit: kMaxBufferViewElements × 2048 (the largest structure stride) |
maxConstantViewSize |
Maximum bytes one constant buffer view may cover | maxUniformBufferRange, capped at 65,536 |
65,536 (4096 × 16 bytes) |
gpuUploadMemory |
Whether MemoryKind::eGPUUpload can be allocated on this device |
True when all of the largest device-local heap is host-visible (ReBAR) | D3D12_FEATURE_DATA_D3D12_OPTIONS16::GPUUploadHeapSupported |
timestampFrequency |
Number of timestamp ticks per second | 1e9 / timestampPeriod (where timestampPeriod is in nanoseconds per tick) |
ID3D12CommandQueue::GetTimestampFrequency of the graphics queue |
meshShaders |
Whether task and mesh shaders (cmdDrawMesh) are supported |
VK_EXT_mesh_shader with taskShader and meshShader |
D3D12_OPTIONS7::MeshShaderTier at least tier 1 |
geometryShaders |
Whether geometry shaders are supported | geometryShader |
Always supported |
tessellation |
Whether hull and domain shaders (Topology::ePatchList) are supported |
tessellationShader |
Always supported |
indirectRootData |
Whether indirect Level 2 (cmdExecuteIndirectWithRootData) is supported |
VK_EXT_device_generated_commands (Vulkan 1.4 devices) |
Always supported |
rayTracing, accelerationStructureScratchAlignment |
Whether inline ray tracing is supported, and the required byte alignment for acceleration structure scratch buffer offsets | VK_KHR_acceleration_structure + VK_KHR_ray_query, with acceleration structures accepted as a mutable descriptor type; minAccelerationStructureScratchOffsetAlignment (0 when unsupported) |
Raytracing tier 1.1; 256 bytes |
samplerMinMax |
Whether Reduction::eMin and Reduction::eMax samplers are supported |
samplerFilterMinmax (Vulkan 1.2) |
D3D12_OPTIONS::TiledResourcesTier at least 2 |
int64BufferAtomics |
Whether 64-bit integer atomics (InterlockedAdd, InterlockedMin, … on uint64_t/int64_t) are supported on buffers reached through the descriptor heap |
shaderBufferInt64Atomics and shaderInt64 |
D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported and D3D12_OPTIONS1::Int64ShaderOps |
int64SharedAtomics |
Whether 64-bit integer atomics are supported on groupshared memory |
shaderSharedInt64Atomics and shaderInt64 |
D3D12_OPTIONS9::AtomicInt64OnGroupSharedSupported and Int64ShaderOps |
workGraphs |
Whether work graphs are supported | Never (D3D12 only) | D3D12_OPTIONS21::WorkGraphsTier at least 1.0 |
depthResolveModes, stencilResolveModes |
Bitmask of supported depth and stencil resolve modes, with one bit per mode via resolveModeBit(mode) |
VkPhysicalDeviceDepthStencilResolveProperties |
Programmable sample positions tier 2: depth average/min/max, stencil min/max |
If a shader uses 64-bit integer atomics when int64BufferAtomics or int64SharedAtomics is
false, pipeline creation fails with a programmer error in validation builds. On D3D12,
RI reads the atomic usage from the DXIL bytecode and names the offending shader stage; on
Vulkan, the Vulkan validation layer reports the violation.
Signature¶
// <RI/RI.hpp>, namespace RI
struct DeviceLimits {
uint32 maxResourceDescriptors = 0; // per descriptor heap
uint32 maxSamplerDescriptors = 0; // per descriptor heap
uint32 maxRootDataSize = 0; // bytes of root data a pipeline may declare, at most kMaxRootDataSize (P107)
// Bytes of one buffer view (P106), besides kMaxBufferViewElements. Read and
// read-write views: Vulkan maxStorageBufferRange; D3D12 has only the element
// limit. Constant views: at most 64 KiB (D3D12), lower where Vulkan's
// maxUniformBufferRange is.
uint64 maxBufferViewSize = 0;
uint32 maxConstantViewSize = 0;
bool gpuUploadMemory = false; // MemoryKind::eGPUUpload is available (P32)
uint64 timestampFrequency = 0; // timestamp ticks per second (P71 (3))
bool meshShaders = false; // task and mesh shaders, cmdDrawMesh (P39)
bool geometryShaders = false; // GraphicsPipelineDesc::geometry (P102)
bool tessellation = false; // GraphicsPipelineDesc::hull and domain (P102)
bool indirectRootData = false; // indirect Level 2: cmdExecuteIndirectWithRootData (P48)
bool rayTracing = false; // acceleration structures and RayQuery (P49)
bool workGraphs = false; // work graphs, D3D12 only (P50)
bool samplerMinMax = false; // Reduction::eMin and eMax samplers
bool int64BufferAtomics = false; // 64-bit integer atomics on buffers reached through the heap (P105)
bool int64SharedAtomics = false; // 64-bit integer atomics on groupshared memory (P105)
uint32 accelerationStructureScratchAlignment = 0; // scratch buffer offsets (P49)
// Depth and stencil resolve modes (P76): resolveModeBit(mode) per mode.
uint32 depthResolveModes = 0;
uint32 stencilResolveModes = 0;
};
From the header: Limits RI reports for the device (P59, P44).
| Field | Type | Default | Description |
|---|---|---|---|
maxResourceDescriptors |
uint32 |
0 |
per descriptor heap |
maxSamplerDescriptors |
uint32 |
0 |
per descriptor heap |
maxRootDataSize |
uint32 |
0 |
bytes of root data a pipeline may declare, at most kMaxRootDataSize (P107) |
maxBufferViewSize |
uint64 |
0 |
Bytes of one buffer view (P106), besides kMaxBufferViewElements. Read and read-write views: Vulkan maxStorageBufferRange; D3D12 has only the element limit. Constant views: at most 64 KiB (D3D12), lower where Vulkan's maxUniformBufferRange is. |
maxConstantViewSize |
uint32 |
0 |
|
gpuUploadMemory |
bool |
false |
MemoryKind::eGPUUpload is available (P32) |
timestampFrequency |
uint64 |
0 |
timestamp ticks per second (P71 (3)) |
meshShaders |
bool |
false |
task and mesh shaders, cmdDrawMesh (P39) |
geometryShaders |
bool |
false |
GraphicsPipelineDesc::geometry (P102) |
tessellation |
bool |
false |
GraphicsPipelineDesc::hull and domain (P102) |
indirectRootData |
bool |
false |
indirect Level 2: cmdExecuteIndirectWithRootData (P48) |
rayTracing |
bool |
false |
acceleration structures and RayQuery (P49) |
workGraphs |
bool |
false |
work graphs, D3D12 only (P50) |
samplerMinMax |
bool |
false |
Reduction::eMin and eMax samplers |
int64BufferAtomics |
bool |
false |
64-bit integer atomics on buffers reached through the heap (P105) |
int64SharedAtomics |
bool |
false |
64-bit integer atomics on groupshared memory (P105) |
accelerationStructureScratchAlignment |
uint32 |
0 |
scratch buffer offsets (P49) |
depthResolveModes |
uint32 |
0 |
Depth and stencil resolve modes (P76): resolveModeBit(mode) per mode. |
stencilResolveModes |
uint32 |
0 |
Example¶
const RI::DeviceLimits &limits = device.limits;
std::printf("heap: up to %u resource and %u sampler slots; root data: up to %u bytes; eGPUUpload: %s\n",
limits.maxResourceDescriptors, limits.maxSamplerDescriptors, limits.maxRootDataSize,
limits.gpuUploadMemory ? "yes" : "no");
The same in native code¶
The limits come from VkPhysicalDeviceLimits and VkPhysicalDeviceVulkan12Properties
(maxDescriptorSetUpdateAfterBind*, maxPerStageDescriptorUpdateAfterBind*), and from
the memory heaps and types for gpuUploadMemory. RI also checks with
vkGetDescriptorSetLayoutSupport that a heap of the maximum size can be created.
The timestamp period is VkPhysicalDeviceLimits::timestampPeriod.
The descriptor heap limits are fixed by resource binding tier 3
(D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2,
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE). A root signature holds up to 64 32-bit
values (256 bytes). gpuUploadMemory comes from
D3D12_FEATURE_DATA_D3D12_OPTIONS16::GPUUploadHeapSupported. Because timestamp frequency
belongs to a command queue in D3D12, RI queries its graphics queue.
Rules and errors¶
- Requesting a descriptor heap with more resource or sampler slots than
maxResourceDescriptorsormaxSamplerDescriptorsis a programmer error increateDescriptorHeap. - A pipeline or work graph whose shaders declare more root data than
maxRootDataSizefailscreateComputePipeline,createGraphicsPipeline, orcreateWorkGraphwith an unsupported error. - Allocating
MemoryKind::eGPUUploadwhengpuUploadMemoryisfalsefailsallocateMemorywith an unsupported error. - Writing a buffer view larger than
maxBufferViewSize(for read or read-write views) ormaxConstantViewSize(for constant buffer views) is a programmer error inwriteDescriptorsin validation builds. timestampFrequencyis stored onDeviceLimitswhile RI has only a single queue; it will move to the queue type when multiple queues are added. Only differences between timestamps are meaningful.