Closed bjornbytes closed 11 months ago
It might not be possible to properly validate this due to texture binding aliasing. It's possible to use a shader that declares a texture2DMS
variable that aliases the ColorTexture
of the Material and uses that to do a custom resolve via pass:fill(multisampledTexture)
.
It's not really possible to statically validate this since the exact texture type accessed by the shader could be impacted by dynamic control flow, specialization constants, etc.
Multisampled/non-2D textures could be banned from Materials but this cuts off some use cases. For example cubemap skyboxes are currently using texture aliasing.
I guess the SPIR-V parser could use a bitmask to track the union of all the types of texture binding aliases for a slot, and then lovr could at least validate that your texture is compatible with at least one of the aliases declared in the shader. That would reliably solve the common case where you accidentally pass a non-2D or MSAA texture to a regular non-aliased 2D texture variable. If someone decides to use aliased texture bindings and uses them improperly then they're subjected to the UB.
Merging this with #718 since I think their solution is the same now
e.g.