Sign in to follow this  

HLSL Functions

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this