I'm just starting to dabble in graphics programming on the Mac (having been doing it on other platforms for quite a while, I might add...) - I've run into a bit of a problem.
As soon as I put a discard statement into the fragment shader, everything disappears. If I replace it with a more benign operation, such as altering the pixel colour, everything is fine - the pixels I'd expect to be culled change and everything else looks normal. With the discard statement in the shader, nothing is visible at all.
There are no errors being reported, and compiling the shader by hand outputs a correct looking listing (and it's identical to that generated under Windows).
This is on a shiny new MBP with the 8600 in it. AFAIK I can't update video drivers on a Mac, so I was hoping the ones that ship would be reasonably stable, at least as far as basic shaders - so hopefully I'm just missing something obvious.
Here's a very simple shader that doesn't work - all I feed it is a single triangle with pure red, green, and blue at the 3 vertices... with discard in, it won't display anything, but substituting with a change of colour shows what I'd expect (an inscribed circle).
Any ideas?
As soon as I put a discard statement into the fragment shader, everything disappears. If I replace it with a more benign operation, such as altering the pixel colour, everything is fine - the pixels I'd expect to be culled change and everything else looks normal. With the discard statement in the shader, nothing is visible at all.
There are no errors being reported, and compiling the shader by hand outputs a correct looking listing (and it's identical to that generated under Windows).
This is on a shiny new MBP with the 8600 in it. AFAIK I can't update video drivers on a Mac, so I was hoping the ones that ship would be reasonably stable, at least as far as basic shaders - so hopefully I'm just missing something obvious.
Here's a very simple shader that doesn't work - all I feed it is a single triangle with pure red, green, and blue at the 3 vertices... with discard in, it won't display anything, but substituting with a change of colour shows what I'd expect (an inscribed circle).
Code:
struct input
{
float4 position : POSITION;
float4 color : COLOR0;
};
float4 main(input IN) : COLOR
{
float m = IN.color.x * IN.color.x + IN.color.y * IN.color.y +
IN.color.z * IN.color.z;
if(m > 0.5)
{
// m = 0; // This line works!
discard; // This line doesn't!
}
return float4(m,m,m,1);
}
Any ideas?