I think it may be useful for shaders to contain addtional usage information in form of application 'promises'.
I'll give a brief snippet with first draft syntax
This would then signal to the compile step that this shader will only be used with an active alpha test. It would also signal that tex coordinate set 0 will always be of the form (s,t,0,1). To extend upon the idea, I've added a constraint on texture coord set 1 also, concatenated by comma.Code ://constants and stuff goes here promise //typeless? perhaps, as it should be a keyword { //usual block notation to compound multiple things alpha_test(greater,0.0); //relational expressions of type bool, promised to be true 0 == (tex_coord0.p); 1 == (tex_coord0.q , tex_coord1.q); } void main() { <...> }
This one could be extended to full relational expressions, all of which should by virtue of 'promise' evaluate to true. I'm not quite sure how to make a nice syntax for that. These should be applicable to uniforms as well.
If one specifies conflicting promises, or links shader code with conflicting promises, this would have to be detected and reported as an error I think.
The promise concept could be extended ad infinitum, once it's in place
Now, what's the use?
Promising the alpha test condition as above would allow hardware that doesn't natively support 'discard', but does support conditional moves to compile and execute corresponding fragment shaders. 'discard' could then be implemented as a conditional move to the output's alpha channel.
If the application's promise is broken, results would be undefined, of course.
Likewise, hardware that doesn't have hardwired zero/one constants and no other way to generate them on the fly could make utility of the 'promised' input conditions. Or, to make it a little harder, hardwired 0.5 constants ...
All of this would have no other purpose than allowing compilation of more complex shaders to a broader range of targets, by providing compile-time usage hints that can't be elegantly expressed otherwise. I believe maximum target support would be a good thing for a high level language to tackle.
Thoughts?
[This message has been edited by zeckensack (edited 06-20-2003).]




