x


[SOLVED] Cg Error: profile does not support "for" statements

Hey everyone,

If in a shader I have a fragment program that has a for loop in it such as:

... int number_of_runs = 5; for(int i; i < number_of_runs; i++) { ... } ...

I get this as an error:

C5013: profile does not support "for" stantements and "for" could not be unrolled.

If however I change the loop to:

... for(int i; i < 5; i++) { ... } ...

the shader compiles. Is this an issue with Shaderlab not supporting dynamic for loops or is it something to do with my graphics card (dual 8800GTX) or something else entirely?

Thanks in advance, Ryan

Note: Heavily edited because I wasn't really asking what I meant to ask in the original post.

more ▼

asked May 21 '10 at 03:48 AM

Random Indie gravatar image

Random Indie
481 3 8 21

Not sure if this is relevant but I just mucked with the render emulation and when I set it back to No Emulation I get a console error saying no subshaders can be run on this graphics card.

May 21 '10 at 03:53 AM Random Indie
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Try using a higher shader profile

e.g.

#pragma target 3.0

documented here:

http://unity3d.com/support/documentation/Components/SL-ShaderPrograms.html#target

more ▼

answered May 22 '10 at 10:48 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 252

that got rid of error C5013, now it's telling me I need a vertex program too. I think I need to spend more time reading the docs.

Aren't 8800's SM3 cards though?

May 22 '10 at 11:29 PM Random Indie

Gah, missed the part where it says they get compiled into 1.1 by default. Thanks Mike!

May 22 '10 at 11:46 PM Random Indie
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1937
x1649
x56
x18
x3

asked: May 21 '10 at 03:48 AM

Seen: 2519 times

Last Updated: May 22 '10 at 11:47 PM