HLSL: implement [unroll] and [loop] attributes

This adds infrastructure suitable for any front end to create SPIR-V loop
control flags.  The only current front end doing so is HLSL.

[unroll] turns into spv::LoopControlUnrollMask
[loop] turns into spv::LoopControlDontUnrollMask
no specification means spv::LoopControlMaskNone
This commit is contained in:
steve-lunarg 2017-05-02 20:14:50 -06:00
parent de1cc06c1d
commit f1709e7146
17 changed files with 334 additions and 17 deletions

View file

@ -758,6 +758,15 @@ protected:
TType type;
};
//
// Loop control hints
//
enum TLoopControl {
ELoopControlNone,
ELoopControlUnroll,
ELoopControlDontUnroll,
};
//
// Handle for, do-while, and while loops.
//
@ -767,17 +776,25 @@ public:
body(aBody),
test(aTest),
terminal(aTerminal),
first(testFirst) { }
first(testFirst),
control(ELoopControlNone)
{ }
virtual void traverse(TIntermTraverser*);
TIntermNode* getBody() const { return body; }
TIntermTyped* getTest() const { return test; }
TIntermTyped* getTerminal() const { return terminal; }
bool testFirst() const { return first; }
void setLoopControl(TLoopControl c) { control = c; }
TLoopControl getLoopControl() const { return control; }
protected:
TIntermNode* body; // code to loop over
TIntermTyped* test; // exit condition associated with loop, could be 0 for 'for' loops
TIntermTyped* terminal; // exists for for-loops
bool first; // true for while and for, not for do-while
TLoopControl control; // loop control hint
};
//