Skip to contentSkip to conversation

1/1 fix detection of GL_ARB_draw_buffers in test_framebuffer_object

PATCH In review Mark Carey 1 participant 2 messages Oct 25, 2007 1 message not in the archive

lore
Share & tools
lore

Mark Carey

author
#0 lore raw

PATCH 1/1 1/1 fix detection of GL_ARB_draw_buffers in test_framebuffer_object

Further to comments in
http://people.freedesktop.org/~marcheu/irclogs/nouveau-2007-10-20
between 11:30 and 13:51, chowmeined confirmation in
http://people.freedesktop.org/~marcheu/irclogs/nouveau-2007-10-21 at 10:16 of the same behaviour on a second 0322.

It appears that 10de0322 supports GL_EXT_framebuffer_object but does not support ARB_draw_buffers, accordingly the current fragment program in renouveau test.c::test_ext_framebuffer_object() causes OpenGL error 1282, 502, INVALID_OPERATION at call to ProgramStringARB on line 4595,
http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_program.txt
section 3.11.1 suggests this is due to the illegal token in the fragment program (fp).

The example code in
http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_program.txt
between lines 417 and 429 suggest a method for determining which character in the fragment program caused the error;

	GLint errorPos;
	regl.GetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);

Error appears to be firstly OPTION ARB_draw_buffers; and secondly the use of MOV result.color[%d], fragment.color; when without GL_ARB_draw_buffers a syntactically correct line woudl read MOV result.color, fragment.color;.

Furthermore due to incorrect detection of nr_bufs line 4614 or 4615 causes a similar error when the draw buffers test attempts to use a draw buffer which does not exist on the hardware.

Perusing http://oss.sgi.com/projects/ogl-sample/registry/ARB/draw_buffers.txt
when querying the number of supported draw buffers one should call GetIntegerv specifying MAX_DRAW_BUFFERS_ARB (0x8824) not GL_MAX_COLOR_ATTACHMENTS_EXT as currently performed on line 4566.

Attached patch;

1. Defines the constant MAX_DRAW_BUFFERS_ARB (in test.c, which header should this go into? does it really matter for renouveau?)
2. Correctly uses MAX_DRAW_BUFFERS_ARB to determine the number of draw buffers present
(http://oss.sgi.com/projects/ogl-sample/registry/ARB/draw_buffers.txt
suggests that OpenGL 1.5 MAX_DRAW_BUFFERS_ARB will always return a minimum value of 1, will renouveau ever be run on OpenGL<1.5?)
3. Adds a line to card_10de-xxxx_test_ext_framebuffer_object.txt when GL_ARB_draw_buffers is not supported
4. Modifies the fp in the case when MAX_DRAW_BUFFERS_ARB == 1 and GL_ARB_draw_buffers is not supported
5. Draw buffer test now runs without error (due to 2)

Patch applied to a fresh checkout of renouveau on both 0322 (GL_EXT_framebuffer_object) and 0393 (GL_EXT_framebuffer_object + GL_ARB_draw_buffers) compiled and tested without error.

Please review and consider applying the attached patch.

Regards,

Mark Carey

tests.c renamed from tests.c.orig +28 -13
@@ -4563,8 +4563,12 @@
 
 	TEST_PROLOGUE;
 
-	regl.GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &nr_bufs);
+/* defined as per http://oss.sgi.com/projects/ogl-sample/registry/ARB/draw_buffers.txt */
+#define MAX_DRAW_BUFFERS_ARB 0x8824 
+	regl.GetIntegerv(MAX_DRAW_BUFFERS_ARB, &nr_bufs);
 	printf("# %d draw buffers supported\n", nr_bufs);
+	if (nr_bufs == 1 && !strstr(extensions, "GL_ARB_draw_buffers"))
+		printf("# No GL_ARB_draw_buffers extension\n");
 	if (nr_bufs > RENOUVEAU_MAX_DRAW_BUFFERS)
 		nr_bufs = RENOUVEAU_MAX_DRAW_BUFFERS;
 
@@ -4578,23 +4582,34 @@
 	    regl.RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, 32, 32);
 	}
 	regl.GenProgramsARB(RENOUVEAU_MAX_DRAW_BUFFERS, fp_obj);
-	for (i=0; i<nr_bufs; i++) {
-		int buf;
-
+	if (nr_bufs == 1 && !strstr(extensions, "GL_ARB_draw_buffers")) {
+		/* cards with GL_EXT_framebuffer_object and no GL_ARB_draw_buffers 0322 */
 		fp[0] = '\0';
-		strcat(fp, "!!ARBfp1.0\nOPTION ARB_draw_buffers;\n");
-		for (buf=0; buf<=i; buf++) {
-			char l[100];
-			sprintf(l, "MOV result.color[%d], fragment.color;\n", buf);
-			strcat(fp, l);
-		
-		}
-		strcat(fp, "END\n");
+		strcat(fp, "!!ARBfp1.0\nMOV result.color, fragment.color;\nEND\n");
 		printf("# Fragprog is:\n%s\n", fp);
-		regl.BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp_obj[i]);
+		regl.BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp_obj[0]);
 		regl.ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
 				      GL_PROGRAM_FORMAT_ASCII_ARB,
 				      strlen(fp), fp);
+	} else {
+		for (i=0; i<nr_bufs; i++) {
+			int buf;
+
+			fp[0] = '\0';
+			strcat(fp, "!!ARBfp1.0\nOPTION ARB_draw_buffers;\n");
+			for (buf=0; buf<=i; buf++) {
+				char l[100];
+				sprintf(l, "MOV result.color[%d], fragment.color;\n", buf);
+				strcat(fp, l);
+		
+			}
+			strcat(fp, "END\n");
+			printf("# Fragprog is:\n%s\n", fp);
+			regl.BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp_obj[i]);
+			regl.ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
+					      GL_PROGRAM_FORMAT_ASCII_ARB,
+					      strlen(fp), fp);
+		}
 	}
 	regl.Finish();
 

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 34576580710250235i43117e4g793cf4e6eeb7529c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author Applied
#2 lore raw
Quoted 3 lines · Mark Carey

Please review and consider applying the attached patch.

applied