WIP: HLSL: add methods to track user structures in texture return type. #1008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP: Incomplete and not yet completely functional. This will turn into support for user structure returns from textures.
Some languages allow a restricted set of user structure types returned from texture sampling operations. The total vector size of all components may not exceed 4, and the basic types of all members must be identical.
This adds underpinnings for that ability. Because storing a whole TType or even a TTypeList in the TSampler would be expensive, the structure definition is packed into a small bitfield, which can represent:
The details of the storage are protected. There are abstraction methods accepting and returning a TType (such as may have been parsed from a grammar). The abstraction methods turn the type into the internal representation, or vice versa, so it is never stored directly.
Currently this is hooked up enough to do what it used to do for vectors and scalars. Places in the code which used to directly set or get the vector size now use the new abstraction. The new abstraction cannot yet handle structures, but that's a matter of fleshing it out, and will be added soon.
NOTE: I believe it's possible to use even fewer bits than are currently being used (currently 12 bits), because not all combinations of vector sizes are valid. E.g., you cannot have 4 vec4s, and the presence of a member 0 restricts the possible vector size of other members, so 12 bits can hold a lot more entropy than is actually required. Maybe it really needs something like 5 bits. That's a detail hidden behind the abstraction. I'll improve that once full functionality is in place.