[Mesa-dev] [PATCH] mesa: Add support for the ARB_fragment_program part of ARB_draw_buffers.

Eric Anholt eric at anholt.net
Wed Apr 13 11:11:05 PDT 2011


Fixes fbo-drawbuffers-arbfp.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34321
---
 src/mesa/program/program_parse.y  |   15 +++++++++++++++
 src/mesa/program/program_parser.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index 19aa8cc..c725a8b 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -2064,6 +2064,20 @@ optResultFaceType:
 	      ? VERT_RESULT_COL0
 	      : FRAG_RESULT_COLOR;
 	}
+	| '[' INTEGER ']'
+	{
+	   if (state->mode == ARB_vertex) {
+	      yyerror(& @1, state, "invalid program result name");
+	      YYERROR;
+	   } else {
+	      if ($2 >= state->MaxDrawBuffers) {
+		 yyerror(& @1, state,
+			 "result.color[] exceeds MAX_DRAW_BUFFERS_ARB");
+		 YYERROR;
+	      }
+	      $$ = FRAG_RESULT_DATA0 + $2;
+	   }
+	}
 	| FRONT
 	{
 	   if (state->mode == ARB_vertex) {
@@ -2681,6 +2695,7 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st
    state->MaxClipPlanes = ctx->Const.MaxClipPlanes;
    state->MaxLights = ctx->Const.MaxLights;
    state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices;
+   state->MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
 
    state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB)
       ? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM;
diff --git a/src/mesa/program/program_parser.h b/src/mesa/program/program_parser.h
index d689eef..8e5aaee 100644
--- a/src/mesa/program/program_parser.h
+++ b/src/mesa/program/program_parser.h
@@ -173,6 +173,7 @@ struct asm_parser_state {
    unsigned MaxClipPlanes;
    unsigned MaxLights;
    unsigned MaxProgramMatrices;
+   unsigned MaxDrawBuffers;
    /*@}*/
 
    /**
-- 
1.7.4.1



More information about the mesa-dev mailing list