glapi: add GL_EXT_disjoint_timer_query
[mesa.git] / src / mesa / program / program_parse.y
index 41aeb241ffef2af0a289c8e78dc52e2959c6e38d..04ec18d840d1ea1b3a2e4ac848b983bc6d156aeb 100644 (file)
@@ -186,7 +186,6 @@ static struct asm_instruction *asm_instruction_copy_ctor(
 %token TEX_SHADOW1D TEX_SHADOW2D TEX_SHADOWRECT
 %token TEX_ARRAY1D TEX_ARRAY2D TEX_ARRAYSHADOW1D TEX_ARRAYSHADOW2D 
 %token VERTEX VTXATTRIB
-%token WEIGHT
 
 %token <string> IDENTIFIER USED_IDENTIFIER
 %type <string> string
@@ -348,7 +347,7 @@ statement: instruction ';'
              state->inst_tail = $1;
              $1->next = NULL;
 
-             state->prog->NumInstructions++;
+              state->prog->arb.NumInstructions++;
           }
        }
        | namingStatement ';'
@@ -357,12 +356,12 @@ statement: instruction ';'
 instruction: ALU_instruction
        {
           $$ = $1;
-          state->prog->NumAluInstructions++;
+           state->prog->arb.NumAluInstructions++;
        }
        | TexInstruction
        {
           $$ = $1;
-          state->prog->NumTexInstructions++;
+           state->prog->arb.NumTexInstructions++;
        }
        ;
 
@@ -785,7 +784,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
           $$.Base.File = $1->param_binding_type;
 
           if ($3.Base.RelAddr) {
-              state->prog->IndirectRegisterFiles |= (1 << $$.Base.File);
+              state->prog->arb.IndirectRegisterFiles |= (1 << $$.Base.File);
              $1->param_accessed_indirectly = 1;
 
              $$.Base.RelAddr = 1;
@@ -1007,10 +1006,6 @@ vtxAttribItem: POSITION
        {
           $$ = VERT_ATTRIB_POS;
        }
-       | WEIGHT vtxOptWeightNum
-       {
-          $$ = VERT_ATTRIB_WEIGHT;
-       }
        | NORMAL
        {
           $$ = VERT_ATTRIB_NORMAL;
@@ -1049,7 +1044,6 @@ vtxAttribNum: INTEGER
        }
        ;
 
-vtxOptWeightNum:  | '[' vtxWeightNum ']';
 vtxWeightNum: INTEGER;
 
 fragAttribItem: POSITION
@@ -2218,9 +2212,30 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
 int
 validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state)
 {
-   const GLbitfield64 inputs = state->prog->info.inputs_read | state->InputsBound;
+   const GLbitfield inputs = state->prog->info.inputs_read | state->InputsBound;
+   GLbitfield ff_inputs = 0;
 
-   if (((inputs & VERT_BIT_FF_ALL) & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
+   /* Since Mesa internal attribute indices are different from
+    * how NV_vertex_program defines attribute aliasing, we have to construct
+    * a separate usage mask based on how the aliasing is defined.
+    *
+    * Note that attribute aliasing is optional if NV_vertex_program is
+    * unsupported.
+    */
+   if (inputs & VERT_BIT_POS)
+      ff_inputs |= 1 << 0;
+   if (inputs & VERT_BIT_NORMAL)
+      ff_inputs |= 1 << 2;
+   if (inputs & VERT_BIT_COLOR0)
+      ff_inputs |= 1 << 3;
+   if (inputs & VERT_BIT_COLOR1)
+      ff_inputs |= 1 << 4;
+   if (inputs & VERT_BIT_FOG)
+      ff_inputs |= 1 << 5;
+
+   ff_inputs |= ((inputs & VERT_BIT_TEX_ALL) >> VERT_ATTRIB_TEX0) << 8;
+
+   if ((ff_inputs & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
       yyerror(locp, state, "illegal use of generic attribute and name attribute");
       return 0;
    }
@@ -2247,18 +2262,19 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
 
       switch (t) {
       case at_temp:
-        if (state->prog->NumTemporaries >= state->limits->MaxTemps) {
+         if (state->prog->arb.NumTemporaries >= state->limits->MaxTemps) {
            yyerror(locp, state, "too many temporaries declared");
            free(s);
            return NULL;
         }
 
-        s->temp_binding = state->prog->NumTemporaries;
-        state->prog->NumTemporaries++;
+         s->temp_binding = state->prog->arb.NumTemporaries;
+         state->prog->arb.NumTemporaries++;
         break;
 
       case at_address:
-        if (state->prog->NumAddressRegs >= state->limits->MaxAddressRegs) {
+         if (state->prog->arb.NumAddressRegs >=
+             state->limits->MaxAddressRegs) {
            yyerror(locp, state, "too many address registers declared");
            free(s);
            return NULL;
@@ -2266,7 +2282,7 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
 
         /* FINISHME: Add support for multiple address registers.
          */
-        state->prog->NumAddressRegs++;
+         state->prog->arb.NumAddressRegs++;
         break;
 
       default:
@@ -2511,7 +2527,7 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st
 
    /* Make a copy of the program string and force it to be NUL-terminated.
     */
-   strz = (GLubyte *) malloc(len + 1);
+   strz = (GLubyte *) ralloc_size(state->mem_ctx, len + 1);
    if (strz == NULL) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
       return GL_FALSE;
@@ -2564,42 +2580,43 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st
    
    /* Add one instruction to store the "END" instruction.
     */
-   state->prog->Instructions =
-      _mesa_alloc_instructions(state->prog->NumInstructions + 1);
+   state->prog->arb.Instructions =
+      rzalloc_array(state->mem_ctx, struct prog_instruction,
+                    state->prog->arb.NumInstructions + 1);
 
-   if (state->prog->Instructions == NULL) {
+   if (state->prog->arb.Instructions == NULL) {
       goto error;
    }
 
    inst = state->inst_head;
-   for (i = 0; i < state->prog->NumInstructions; i++) {
+   for (i = 0; i < state->prog->arb.NumInstructions; i++) {
       struct asm_instruction *const temp = inst->next;
 
-      state->prog->Instructions[i] = inst->Base;
+      state->prog->arb.Instructions[i] = inst->Base;
       inst = temp;
    }
 
    /* Finally, tag on an OPCODE_END instruction */
    {
-      const GLuint numInst = state->prog->NumInstructions;
-      _mesa_init_instructions(state->prog->Instructions + numInst, 1);
-      state->prog->Instructions[numInst].Opcode = OPCODE_END;
+      const GLuint numInst = state->prog->arb.NumInstructions;
+      _mesa_init_instructions(state->prog->arb.Instructions + numInst, 1);
+      state->prog->arb.Instructions[numInst].Opcode = OPCODE_END;
    }
-   state->prog->NumInstructions++;
+   state->prog->arb.NumInstructions++;
 
-   state->prog->NumParameters = state->prog->Parameters->NumParameters;
-   state->prog->NumAttributes =
+   state->prog->arb.NumParameters = state->prog->Parameters->NumParameters;
+   state->prog->arb.NumAttributes =
       _mesa_bitcount_64(state->prog->info.inputs_read);
 
    /*
     * Initialize native counts to logical counts.  The device driver may
     * change them if program is translated into a hardware program.
     */
-   state->prog->NumNativeInstructions = state->prog->NumInstructions;
-   state->prog->NumNativeTemporaries = state->prog->NumTemporaries;
-   state->prog->NumNativeParameters = state->prog->NumParameters;
-   state->prog->NumNativeAttributes = state->prog->NumAttributes;
-   state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs;
+   state->prog->arb.NumNativeInstructions = state->prog->arb.NumInstructions;
+   state->prog->arb.NumNativeTemporaries = state->prog->arb.NumTemporaries;
+   state->prog->arb.NumNativeParameters = state->prog->arb.NumParameters;
+   state->prog->arb.NumNativeAttributes = state->prog->arb.NumAttributes;
+   state->prog->arb.NumNativeAddressRegs = state->prog->arb.NumAddressRegs;
 
    result = GL_TRUE;