Capabilities is a pure-virtual interface with three full implementations (StandardCapabilities, CapabilitiesGLES, CapabilitiesVK), a builder, and a gmock. Adding one capability flag currently touches around six files, and every backend's accessors are trivial reads of precomputed values, so the polymorphism buys little for the cross-backend data.
The interface conflates two different concerns.
- Cross-backend capability data (bools, default formats, sizes) is exposed through trivial accessors, identical in shape across backends, that just read precomputed values. This needs no polymorphism.
- Backend-specific behavior and state (Vulkan extensions, features, and workarounds; GLES limits and ANGLE/ES detection) legitimately differs per backend and is already reached via
BackendCast downcasts (1 site for GLES, ~5 for Vulkan).
Proposal
Split the cross-backend capability data from backend-specific state.
- Make the shared capability surface a concrete data-holding type (fields plus a builder/setters, no virtuals), and delete
MockCapabilities.
- Have
CapabilitiesGLES and CapabilitiesVK own a data object and expose their backend-specific methods separately. Context::GetCapabilities() returns the data object.
- Route the existing
BackendCast<CapabilitiesVK>/BackendCast<CapabilitiesGLES> sites through the backend context instead.
- Fold Vulkan's post-construction mutation (
SetPhysicalDevice, ApplyWorkarounds, SetOffscreenFormat) into plain setters, removing the const + mutable workaround.
After this, adding a capability is "add a field, set it where it is computed."
Pure cleanup, no behavior change.
Capabilitiesis a pure-virtual interface with three full implementations (StandardCapabilities,CapabilitiesGLES,CapabilitiesVK), a builder, and a gmock. Adding one capability flag currently touches around six files, and every backend's accessors are trivial reads of precomputed values, so the polymorphism buys little for the cross-backend data.The interface conflates two different concerns.
BackendCastdowncasts (1 site for GLES, ~5 for Vulkan).Proposal
Split the cross-backend capability data from backend-specific state.
MockCapabilities.CapabilitiesGLESandCapabilitiesVKown a data object and expose their backend-specific methods separately.Context::GetCapabilities()returns the data object.BackendCast<CapabilitiesVK>/BackendCast<CapabilitiesGLES>sites through the backend context instead.SetPhysicalDevice,ApplyWorkarounds,SetOffscreenFormat) into plain setters, removing theconst+mutableworkaround.After this, adding a capability is "add a field, set it where it is computed."
Pure cleanup, no behavior change.