Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorShaders::Bindings Namespace Reference

The ONE descriptor-binding layout every Qt-RHI shader family speaks (overlay, animation, surface, pointer) and the daemon's ShaderNodeRhi populates. More...

Functions

int expectedSamplerBinding (QStringView name)
 The binding a canonical contract sampler must declare, or -1 when name is not a contract sampler (a consumer-declared one, which the validator then checks against the consumer range instead).
constexpr bool isConsumerBinding (int binding) noexcept
 Whether binding is one a consumer may claim through setExtraBinding: the single gap slot, or anything above the reserved range.

Variables

constexpr int kUniformBlock = 0
constexpr int kConsumer = 1
constexpr int kChannelBase = 2
constexpr int kChannelCount = kMaxBufferPasses
constexpr int kAudioSpectrum = kChannelBase + kChannelCount
constexpr int kUserTextureBase = kAudioSpectrum + 1
constexpr int kUserTextureCount = 4
constexpr int kWallpaper = kUserTextureBase + kUserTextureCount
constexpr int kDepth = kWallpaper + 1
constexpr int kReservedEnd = kDepth
 Last binding the library manages; everything above is a consumer slot.
constexpr int kExtraBase = kReservedEnd + 1
constexpr int kMaxBinding = 31
 Highest binding a consumer may claim.
constexpr int kChannelResolutionSlots = 4
 How many channel sizes the uniform block carries (iChannelResolution[4]).

Detailed Description

The ONE descriptor-binding layout every Qt-RHI shader family speaks (overlay, animation, surface, pointer) and the daemon's ShaderNodeRhi populates.

Each family's shared GLSL header declares its samplers with layout(binding = N) from this table, the node builds its SRB from the same constants, and plasmazones-shader-validate reflects every baked stage back against it (expectedSamplerBinding), so a header that drifts from the table fails the pack gate instead of the pipeline.

The table is CONTIGUOUS and declared in this order:

0 the family's std140 uniform block 1 consumer slot (the overlay zone-labels texture, uZoneLabels) 2 .. 9 iChannel0 .. iChannel7, the multipass buffer outputs 10 uAudioSpectrum 11 .. 14 uTexture0 .. uTexture3 (the pointer family's uCursorSprite takes slot 11, the one it has no uTexture0 for) 15 uWallpaper / uBackdrop (one slot, two family names) 16 uDepthBuffer 17 .. 31 free for consumers via ShaderNodeRhi::setExtraBinding

The uniform block carries iChannelResolution[4] for the FIRST four channels only, so it keeps its 672-byte base layout across the channel growth; a pass that reads iChannel4 .. iChannel7 sizes them with textureSize(), which is what the builtin Kawase passes do.

Function Documentation

◆ expectedSamplerBinding()

int PhosphorShaders::Bindings::expectedSamplerBinding ( QStringView name)
inline

The binding a canonical contract sampler must declare, or -1 when name is not a contract sampler (a consumer-declared one, which the validator then checks against the consumer range instead).

◆ isConsumerBinding()

bool PhosphorShaders::Bindings::isConsumerBinding ( int binding)
inlineconstexprnoexcept

Whether binding is one a consumer may claim through setExtraBinding: the single gap slot, or anything above the reserved range.

Variable Documentation

◆ kAudioSpectrum

int PhosphorShaders::Bindings::kAudioSpectrum = kChannelBase + kChannelCount
inlineconstexpr

◆ kChannelBase

int PhosphorShaders::Bindings::kChannelBase = 2
inlineconstexpr

◆ kChannelCount

int PhosphorShaders::Bindings::kChannelCount = kMaxBufferPasses
inlineconstexpr

◆ kChannelResolutionSlots

int PhosphorShaders::Bindings::kChannelResolutionSlots = 4
inlineconstexpr

How many channel sizes the uniform block carries (iChannelResolution[4]).

◆ kConsumer

int PhosphorShaders::Bindings::kConsumer = 1
inlineconstexpr

◆ kDepth

int PhosphorShaders::Bindings::kDepth = kWallpaper + 1
inlineconstexpr

◆ kExtraBase

int PhosphorShaders::Bindings::kExtraBase = kReservedEnd + 1
inlineconstexpr

◆ kMaxBinding

int PhosphorShaders::Bindings::kMaxBinding = 31
inlineconstexpr

Highest binding a consumer may claim.

This is a PROJECT ceiling, not a Qt one. QRhi exposes no resource limit for binding count, and neither QRhiShaderResourceBindings nor QRhiShaderResourceBinding documents a portable maximum binding INDEX, so 31 is a convention this library enforces rather than a guarantee it inherits. ShaderNodeRhi.h says the same of kMaxConsumerBinding, which is this constant.

What Qt does document is a different quantity, and a smaller one: a per-shader SAMPLER COUNT. QRhiShaderResourceBinding states, of sampledTexture(), texture() and sampler() alike, that a shader may not be able to consume more than 16 textures or samplers depending on the underlying graphics API. The reserved range above claims bindings 1 to 16, which is exactly that many, so the contract sits AT the documented ceiling and every consumer slot in 17..31 is the seventeenth sampler onward in any stage that reaches it.

That became live rather than theoretical when the channel budget went from four to eight: createImageSrbMulti binds all kChannelCount channel slots unconditionally, dummy-filled for a pack that declares fewer, and the user textures, wallpaper and depth bindings are unconditional too, so a multipass pack already carries 14 fragment-stage samplers, 15 with audio and 16 with one consumer extra. Nothing has failed on the target: desktop Mesa and NVIDIA report far above the Vulkan minimum of 16 per-stage sampled images, and GL_MAX_TEXTURE_IMAGE_UNITS is 32 on Mesa. A conservative backend is where it would show, and adding a reserved slot is what would push it there.

◆ kReservedEnd

int PhosphorShaders::Bindings::kReservedEnd = kDepth
inlineconstexpr

Last binding the library manages; everything above is a consumer slot.

◆ kUniformBlock

int PhosphorShaders::Bindings::kUniformBlock = 0
inlineconstexpr

◆ kUserTextureBase

int PhosphorShaders::Bindings::kUserTextureBase = kAudioSpectrum + 1
inlineconstexpr

◆ kUserTextureCount

int PhosphorShaders::Bindings::kUserTextureCount = 4
inlineconstexpr

◆ kWallpaper

int PhosphorShaders::Bindings::kWallpaper = kUserTextureBase + kUserTextureCount
inlineconstexpr