HLSL Functions

Started by
0 comments, last by sirob 15 years, 10 months ago
I have an array of booleans that I would like to set all to being false. I know how to do this, however, how can I call that function from outside of the effect file? The only way I could have thought of doing it was doing this,however, I get a syntax error what I do it. technique TheTechnique { pass pass0 { CallFunction(); VS = .. PS = .. } } [Edited by - Hurp on June 23, 2008 1:03:11 PM]
Advertisement
You can't call code directly outside the one of the shaders (VS, PS, etc.). If you place the code at the start of the VS, and it is unaffected by the input values, the HLSL compiler will probably optimize it correctly and run it in a preshader.

From the sound of it, you're mis-using this array. Constants cannot be modified, and if you have an array that only contains false boolean values, it will always contain false, so you'll be better off replacing the array access with the keyword false.

If you plan on modifiying the contents of the array from one of the shaders, remember that modifying a global variable does not modify the global, but creates a local copy with the modified data, which is discarded as soon as the shader exits. You cannot pass data between shader invokations. You can just as well use a local array instead.

If you want to set this array from the C++ side of your application, simply leave it uninitialized, and set the value from your C++ application.

Finally, I'm pretty sure the contents of the array are preinitialized to 0, though I can't find the exact reference in the docs. This might all be unnecessary.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement