summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-10-04 14:40:05 +0000
committerBrian Paul <[email protected]>2004-10-04 14:40:05 +0000
commitbe76b7fe1e09ae52204f6225331355414c05f91d (patch)
tree61aea1c988cb214a1ada8534c59ec09eb9845628 /src/mesa/shader
parent00fb3a054a7499a9db6f87088356bee5c4e8f135 (diff)
ARB_fp support for GL_ARB_draw_buffers (Karl Rasche)
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c33
-rw-r--r--src/mesa/shader/arbprogram.c4
-rw-r--r--src/mesa/shader/arbprogram.syn26
-rw-r--r--src/mesa/shader/arbprogram_syn.h15
4 files changed, 69 insertions, 9 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 5b5924c739c..ae85a93ecf9 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -146,7 +146,7 @@ __extension__ static char arb_grammar_text[] =
- changed and merged V_* and F_* opcode values to OP_*.
- added GL_ARB_fragment_program_shadow specific tokens (michal)
*/
-#define REVISION 0x07
+#define REVISION 0x08
/* program type */
#define FRAGMENT_PROGRAM 0x01
@@ -826,6 +826,28 @@ parse_generic_attrib_num(GLcontext *ctx, GLubyte ** inst,
/**
+ * \param color The index of the color buffer to write into
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_output_color_num (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLuint * color)
+{
+ GLint i = parse_integer (inst, Program);
+
+ if ((i < 0) || (i >= (int)ctx->Const.MaxDrawBuffers)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid draw buffer index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid draw buffer index");
+ return 1;
+ }
+
+ *color = (GLuint) i;
+ return 0;
+}
+
+
+/**
* \param coord The texture unit index
* \return 0 on sucess, 1 on error
*/
@@ -1558,13 +1580,20 @@ static GLuint
parse_result_binding (GLcontext * ctx, GLubyte ** inst, GLuint * binding,
GLuint * binding_idx, struct arb_program *Program)
{
- GLuint b;
+ GLuint b, out_color;
switch (*(*inst)++) {
case FRAGMENT_RESULT_COLOR:
/* for frag programs, this is FRAGMENT_RESULT_COLOR */
if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* This gets result of the color buffer we're supposed to
+ * draw into
+ */
+ parse_output_color_num(ctx, inst, Program, &out_color);
+
*binding = FRAG_OUTPUT_COLR;
+
+ /* XXX: We're ignoring the color buffer for now. */
*binding_idx = 0;
}
/* for vtx programs, this is VERTEX_RESULT_POSITION */
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index f6d16b5547f..85235586181 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -107,7 +107,7 @@ _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index == 0 || index >= VERT_ATTRIB_MAX) {
+ if (index == 0 || index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribfvARB(index)");
return;
}
@@ -130,7 +130,7 @@ _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
break;
case GL_CURRENT_VERTEX_ATTRIB_ARB:
FLUSH_CURRENT(ctx, 0);
- COPY_4V(params, ctx->Current.Attrib[index]);
+ COPY_4V(params, ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]);
break;
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
if (!ctx->Extensions.ARB_vertex_buffer_object) {
diff --git a/src/mesa/shader/arbprogram.syn b/src/mesa/shader/arbprogram.syn
index e6249abd30b..a4e3a20222e 100644
--- a/src/mesa/shader/arbprogram.syn
+++ b/src/mesa/shader/arbprogram.syn
@@ -6,7 +6,7 @@
compares the value with its REVISION value. If they do not match, the loader is not up
to date.
*/
-.emtcode REVISION 0x07
+.emtcode REVISION 0x08
/* program type */
.emtcode FRAGMENT_PROGRAM 0x01
@@ -2064,6 +2064,23 @@ stateModMatNum
integer;
/*
+ From ARB_draw_buffers:
+ <optOutputColorNum> ::= ""
+ | "[" <OutputColorNum> "]"
+*/
+optOutputColorNum
+ optOutputColorNum_1 .or .true .emit 0x00;
+optOutputColorNum_1
+ lbracket_ne .and outputColorNum .and rbracket;
+
+/*
+ From ARB_draw_buffers:
+ <outputColorNum> ::= <integer> from 0 to MAX_DRAW_BUFFERS_ARB-1
+*/
+outputColorNum
+ integer;
+
+/*
<optTexCoordNum> ::= ""
| "[" <texCoordNum> "]"
*/
@@ -2305,8 +2322,9 @@ vp_OUTPUT_statement
vp_resultBinding .error RESULT_EXPECTED;
/*
+ From ARB_draw_buffers:
fragment program
- <resultBinding> ::= "result" "." "color"
+ <resultBinding> ::= "result" "." "color" <optOutputColorNum>
| "result" "." "depth"
vertex program
@@ -2321,8 +2339,10 @@ fp_resultBinding
vp_resultBinding
"result" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
fp_resultBinding_1
- "color" .emit FRAGMENT_RESULT_COLOR .or
+ fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or
"depth" .emit FRAGMENT_RESULT_DEPTH;
+fp_resultBinding_2
+ "color" .and optOutputColorNum;
vp_resultBinding_1
.if (ARB_position_invariant == 0x00) "position" .emit VERTEX_RESULT_POSITION .or
resultColBinding .emit VERTEX_RESULT_COLOR .or
diff --git a/src/mesa/shader/arbprogram_syn.h b/src/mesa/shader/arbprogram_syn.h
index 71ccd204d12..f7bc69e9939 100644
--- a/src/mesa/shader/arbprogram_syn.h
+++ b/src/mesa/shader/arbprogram_syn.h
@@ -28,8 +28,9 @@
* \author Michal Krol
*/
+
".syntax program;\n"
-".emtcode REVISION 0x07\n"
+".emtcode REVISION 0x08\n"
".emtcode FRAGMENT_PROGRAM 0x01\n"
".emtcode VERTEX_PROGRAM 0x02\n"
".emtcode OPTION 0x01\n"
@@ -1007,6 +1008,13 @@
" lbracket_ne .and stateModMatNum .and rbracket;\n"
"stateModMatNum\n"
" integer;\n"
+"optOutputColorNum\n"
+" optOutputColorNum_1 .or .true .emit 0x00;\n"
+"optOutputColorNum_1\n"
+" lbracket_ne .and outputColorNum .and rbracket;\n"
+" \n"
+"outputColorNum\n"
+" integer;\n"
"optTexCoordNum\n"
" optTexCoordNum_1 .or .true .emit 0x00;\n"
"optTexCoordNum_1\n"
@@ -1101,8 +1109,10 @@
"vp_resultBinding\n"
" \"result\" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;\n"
"fp_resultBinding_1\n"
-" \"color\" .emit FRAGMENT_RESULT_COLOR .or\n"
+" fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or\n"
" \"depth\" .emit FRAGMENT_RESULT_DEPTH;\n"
+"fp_resultBinding_2\n"
+" \"color\" .and optOutputColorNum;\n"
"vp_resultBinding_1\n"
" .if (ARB_position_invariant == 0x00) \"position\" .emit VERTEX_RESULT_POSITION .or\n"
" resultColBinding .emit VERTEX_RESULT_COLOR .or\n"
@@ -1342,3 +1352,4 @@
"e_charordigit\n"
" 'A'-'Z' .or 'a'-'z' .or '0'-'9';\n"
""
+