HLSL: matrix swizzle (_12, _m23) syntax, partial semantics.

This partially addressess issue #670, for when the matrix swizzle
degenerates to a component or column: m[c], m[c][r] (where HLSL
swaps rows and columns for user's view).

An error message is given for the arbitrary cases not covered.

These cases will work for arbitrary use of l-values.

Future work will handle more arbitrary swizzles, which might
not work as arbitrary l-values.
This commit is contained in:
John Kessenich 2017-01-12 16:51:18 -07:00
parent 913e3b686a
commit 001dfa1c5c
6 changed files with 367 additions and 62 deletions

View file

@ -62,6 +62,32 @@ struct TVectorFields {
int num;
};
class TMatrixComponents {
public:
static const int maxMatrixComponents = 4;
struct tMatrixComponent {
int coord1; // stay agnostic about column/row; this is parse order
int coord2;
};
TMatrixComponents() : size_(0) { }
void push_back(tMatrixComponent comp)
{
if (size_ < maxMatrixComponents)
components[size_++] = comp;
}
int size() const { return size_; }
tMatrixComponent get(int i) const
{
assert(i < maxMatrixComponents);
return components[i];
}
private:
int size_;
tMatrixComponent components[4];
};
//
// Some helper structures for TIntermediate. Their contents are encapsulated
// by TIntermediate.