tgsi: report opcode name in addition to the number when translation fails
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_twoside.c
index 01d905c153492558fb5d919742bed574016e2544..eef0238b157f89392a72868ea893e633324d4cb0 100644 (file)
 /* Authors:  Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw_vs.h"
-
+#include "draw_pipe.h"
 
 struct twoside_stage {
    struct draw_stage stage;
@@ -85,7 +86,8 @@ static void twoside_tri( struct draw_stage *stage,
       struct prim_header tmp;
 
       tmp.det = header->det;
-      tmp.edgeflags = header->edgeflags;
+      tmp.flags = header->flags;
+      tmp.pad = header->pad;
       /* copy back attribs to front attribs */
       tmp.v[0] = copy_bfc(twoside, header->v[0], 0);
       tmp.v[1] = copy_bfc(twoside, header->v[1], 1);
@@ -99,27 +101,12 @@ static void twoside_tri( struct draw_stage *stage,
 }
 
 
-static void twoside_line( struct draw_stage *stage,
-                      struct prim_header *header )
-{
-   /* pass-through */
-   stage->next->line( stage->next, header );
-}
-
-
-static void twoside_point( struct draw_stage *stage,
-                       struct prim_header *header )
-{
-   /* pass-through */
-   stage->next->point( stage->next, header );
-}
-
 
 static void twoside_first_tri( struct draw_stage *stage, 
                               struct prim_header *header )
 {
    struct twoside_stage *twoside = twoside_stage(stage);
-   const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
+   const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader;
    uint i;
 
    twoside->attrib_front0 = 0;
@@ -187,17 +174,27 @@ static void twoside_destroy( struct draw_stage *stage )
 struct draw_stage *draw_twoside_stage( struct draw_context *draw )
 {
    struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
+   if (twoside == NULL)
+      goto fail;
 
-   draw_alloc_temp_verts( &twoside->stage, 3 );
+   if (!draw_alloc_temp_verts( &twoside->stage, 3 ))
+      goto fail;
 
    twoside->stage.draw = draw;
+   twoside->stage.name = "twoside";
    twoside->stage.next = NULL;
-   twoside->stage.point = twoside_point;
-   twoside->stage.line = twoside_line;
+   twoside->stage.point = draw_pipe_passthrough_point;
+   twoside->stage.line = draw_pipe_passthrough_line;
    twoside->stage.tri = twoside_first_tri;
    twoside->stage.flush = twoside_flush;
    twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
    twoside->stage.destroy = twoside_destroy;
 
    return &twoside->stage;
+
+ fail:
+   if (twoside)
+      twoside->stage.destroy( &twoside->stage );
+
+   return NULL;
 }