KIL Instruction?

I’ve been playing with ARB_fragment_program, but I’ve had problems getting KIL to actually work.

For example, even this:
MOV temp, 1.0;
KIL temp;
appears to cause the fragment to be killed. The only thing that seems to not kill the fragment is KIL 1.0; (or KIL x for any non-negative x constant).

Is there any trick to getting KIL to work?

This is on a G5 with a Radion 9600.

KIL kills if any component isn’t positive. Thus, you may be testing a variable which has some negative component.

Try declaring a param that initializes all four components to 1, and run a KIL on that, as an experiment. It could be a driver bug (make sure you use the freshest available drivers) but experimenting more makes for better bug reports.

OK. I added the following two lines to the top of the program:

PARAM testParam = { 1.0, 1.0, 1.0, 1.0 };
KIL testParam;

If I understand correctly, that should be a No-Op, but as before it kills all fragments. Well, not exactly. The first frame it draws is drawn as though the fragment program weren’t running at all, but thereafter it discards all fragments. I’ll update my driver.

As best I can tell, I already have the latest driver (ATIRadeon9700 1.3.4 12/11/03).

I did what I should have tried a while ago and find that KIL works just fine in Apple’s Shader Builder. That at leat gives me a baseline that it’s not a fundamental OS/driver/hardware issue. Now to see what’s going on…

Problem solved.

The issue was that KIL pushed me over the texture indirection limit (since KIL is considered a texture instruction). It would be nice if the documentation mentioned this more explicity.

I am not sure, though, why this didn’t produce an error. I was using this to catch fragment program errors, which I found in documentation somewhere:

if(GL_INVALID_OPERATION == glGetError()) {
	// find error position
	GLint theErrPos;
	glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &theErrPos);
	
	// print error
	const unsigned char * theErrString = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
	fprintf(stderr, "error at position %d
%s
",
			theErrPos, theErrString);
	mFragID = 0;
}

For reference, this discussion was helpful in tracking things down: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/009721.html

You can remove this line because it prevents error detection.

if(GL_INVALID_OPERATION == glGetError())

and do error checking after calling

glProgramString(…);

As for KIL counting towards tex indirection, that’s an implementation detail, so it doesn’t appear in the spec.

//CODE from ARB_fragment_program

GLint errorPos, isNative;
glProgramStringARB(target, format, len, string);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative);
if ((errorPos == -1) && (isNative == 1))
return GL_TRUE;
else
return GL_FALSE;

[This message has been edited by V-man (edited 01-27-2004).]