Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / gallium / tests / trivial / tri.c
index 48305240a4b8d920ecebff69d379121216588407..656e92ee8861abaa7fe150938777d83e22dcbd66 100644 (file)
 /* util_make_[fragment|vertex]_passthrough_shader */
 #include "util/u_simple_shaders.h"
 
-/* softpipe software driver */
-#include "softpipe/sp_public.h"
-
+/* sw_screen_create: to get a software pipe driver */
+#include "target-helpers/inline_sw_helper.h"
+/* debug_screen_wrap: to wrap with debug pipe drivers */
+#include "target-helpers/inline_debug_helper.h"
 /* null software winsys */
 #include "sw/null/null_sw_winsys.h"
 
-/* traceing support see src/gallium/drivers/trace/README for more info. */
-#if USE_TRACE
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
 struct program
 {
        struct pipe_screen *screen;
@@ -92,11 +87,13 @@ struct program
 
 static void init_prog(struct program *p)
 {
+       struct pipe_surface surf_tmpl;
        /* create the software rasterizer */
-       p->screen = softpipe_create_screen(null_sw_create());
-#if USE_TRACE
-       p->screen = trace_screen_create(p->screen);
-#endif
+       p->screen = sw_screen_create(null_sw_create());
+       /* wrap the screen with any debugger */
+       p->screen = debug_screen_wrap(p->screen);
+
+       /* create the pipe driver context and cso context */
        p->pipe = p->screen->context_create(p->screen, NULL);
        p->cso = cso_create_context(p->pipe);
 
@@ -123,7 +120,8 @@ static void init_prog(struct program *p)
                        }
                };
 
-               p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER, sizeof(vertices));
+               p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER,
+                                            PIPE_USAGE_STATIC, sizeof(vertices));
                pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices);
        }
 
@@ -136,6 +134,7 @@ static void init_prog(struct program *p)
                tmplt.width0 = WIDTH;
                tmplt.height0 = HEIGHT;
                tmplt.depth0 = 1;
+               tmplt.array_size = 1;
                tmplt.last_level = 0;
                tmplt.bind = PIPE_BIND_RENDER_TARGET;
 
@@ -151,16 +150,20 @@ static void init_prog(struct program *p)
 
        /* rasterizer */
        memset(&p->rasterizer, 0, sizeof(p->rasterizer));
-       p->rasterizer.front_winding = PIPE_WINDING_CW;
-       p->rasterizer.cull_mode = PIPE_WINDING_NONE;
+       p->rasterizer.cull_face = PIPE_FACE_NONE;
        p->rasterizer.gl_rasterization_rules = 1;
 
+       surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM;
+       surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
+       surf_tmpl.u.tex.level = 0;
+       surf_tmpl.u.tex.first_layer = 0;
+       surf_tmpl.u.tex.last_layer = 0;
        /* drawing destination */
        memset(&p->framebuffer, 0, sizeof(p->framebuffer));
        p->framebuffer.width = WIDTH;
        p->framebuffer.height = HEIGHT;
        p->framebuffer.nr_cbufs = 1;
-       p->framebuffer.cbufs[0] = p->screen->get_tex_surface(p->screen, p->target, 0, 0, 0, PIPE_BIND_RENDER_TARGET);
+       p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, p->target, &surf_tmpl);
 
        /* viewport, depth isn't really needed */
        {
@@ -255,13 +258,13 @@ static void draw(struct program *p)
        /* vertex element data */
        cso_set_vertex_elements(p->cso, 2, p->velem);
 
-       util_draw_vertex_buffer(p->pipe,
+       util_draw_vertex_buffer(p->pipe, p->cso,
                                p->vbuf, 0,
                                PIPE_PRIM_TRIANGLES,
                                3,  /* verts */
                                2); /* attribs/vert */
 
-       p->pipe->flush(p->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+        p->pipe->flush(p->pipe, NULL);
 
        debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
 }