Some initial RGB and RGBA floating point texture formats.
[mesa.git] / src / mesa / main / arbvertparse.c
index 0df17f370afa28957abecf7e940f527feaea8968..0bc2a2d04cef1b54a9323f125ce92780cdabd4e2 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "glheader.h"
 #include "context.h"
+#include "arbvertparse.h"
 #include "hash.h"
 #include "imports.h"
 #include "macros.h"
@@ -175,23 +176,7 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
    GLuint retval;
    struct arb_program ap;
        
-       retval = _mesa_parse_arb_program(ctx, str, len, &ap);
-
-   /* XXX: Parse error. Cleanup things and return */   
-   if (retval)
-   {
-      return;
-   }
-
-   /* XXX: Eh.. we parsed something that wasn't a vertex program. doh! */
-   if (ap.type != GL_VERTEX_PROGRAM_ARB)
-   {
-      return;      
-   }
-       
-#if DEBUG_VP
-   debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
-#endif
+   retval = _mesa_parse_arb_program(ctx, str, len, &ap);
 
    /* copy the relvant contents of the arb_program struct into the 
     * fragment_program struct
@@ -202,9 +187,37 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
    program->Base.NumAttributes   = ap.Base.NumAttributes;
    program->Base.NumAddressRegs  = ap.Base.NumAddressRegs;
 
-   program->Instructions   = ap.VPInstructions;
    program->IsPositionInvariant = ap.HintPositionInvariant;
    program->InputsRead     = ap.InputsRead;
    program->OutputsWritten = ap.OutputsWritten;
    program->Parameters     = ap.Parameters; 
+
+   /*  Parse error. Allocate a dummy program and return */     
+   if (retval)
+   {
+      program->Instructions = (struct vp_instruction *) _mesa_malloc (
+                                     sizeof(struct vp_instruction) );                    
+      program->Instructions[0].Opcode = VP_OPCODE_END;
+      return;
+   }
+
+   /* Eh.. we parsed something that wasn't a vertex program. doh! */
+   if (ap.type != GL_VERTEX_PROGRAM_ARB)
+   {
+      program->Instructions = (struct vp_instruction *) _mesa_malloc (
+                                     sizeof(struct vp_instruction) );                    
+      program->Instructions[0].Opcode = VP_OPCODE_END;
+
+      _mesa_error (ctx, GL_INVALID_OPERATION, "Parsed a non-vertex program as a vertex program");
+      return;      
+   }
+
+   program->Instructions   = ap.VPInstructions;
+
+#if DEBUG_VP
+   debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
+#else
+   (void) debug_vp_inst;
+#endif
+
 }