gallium: split depth_clip into depth_clip_near & depth_clip_far
[mesa.git] / src / gallium / tests / trivial / tri.c
index f9b4696abef6ee8aca9e6135b39e7cd6668d0a59..3827edc0da3761ead2c3669a5bfb50442d20715e 100644 (file)
@@ -27,8 +27,8 @@
 #define USE_TRACE 0
 #define WIDTH 300
 #define HEIGHT 300
-#define NEAR 30
-#define FAR 1000
+#define NEAR 0
+#define FAR 1
 #define FLIP 0
 
 /* pipe_*_state structs */
@@ -48,7 +48,7 @@
 #include "cso_cache/cso_context.h"
 
 /* debug_dump_surface_bmp */
-#include "util/u_debug.h"
+#include "util/u_debug_image.h"
 /* util_draw_vertex_buffer helper */
 #include "util/u_draw_quad.h"
 /* FREE & CALLOC_STRUCT */
@@ -91,12 +91,12 @@ static void init_prog(struct program *p)
        assert(ret);
 
        /* init a pipe screen */
-       p->screen = pipe_loader_create_screen(p->dev, PIPE_SEARCH_DIR);
+       p->screen = pipe_loader_create_screen(p->dev);
        assert(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);
+       p->pipe = p->screen->context_create(p->screen, NULL, 0);
+       p->cso = cso_create_context(p->pipe, 0);
 
        /* set clear color */
        p->clear_color.f[0] = 0.3;
@@ -122,7 +122,7 @@ static void init_prog(struct program *p)
                };
 
                p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER,
-                                            PIPE_USAGE_STATIC, sizeof(vertices));
+                                            PIPE_USAGE_DEFAULT, sizeof(vertices));
                pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices);
        }
 
@@ -152,11 +152,12 @@ static void init_prog(struct program *p)
        /* rasterizer */
        memset(&p->rasterizer, 0, sizeof(p->rasterizer));
        p->rasterizer.cull_face = PIPE_FACE_NONE;
-       p->rasterizer.gl_rasterization_rules = 1;
-       p->rasterizer.depth_clip = 1;
+       p->rasterizer.half_pixel_center = 1;
+       p->rasterizer.bottom_edge_rule = 1;
+       p->rasterizer.depth_clip_near = 1;
+       p->rasterizer.depth_clip_far = 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;
@@ -171,7 +172,7 @@ static void init_prog(struct program *p)
        {
                float x = 0;
                float y = 0;
-               float z = FAR;
+               float z = NEAR;
                float half_width = (float)WIDTH / 2.0f;
                float half_height = (float)HEIGHT / 2.0f;
                float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
@@ -188,12 +189,10 @@ static void init_prog(struct program *p)
                p->viewport.scale[0] = half_width;
                p->viewport.scale[1] = half_height * scale;
                p->viewport.scale[2] = half_depth;
-               p->viewport.scale[3] = 1.0f;
 
                p->viewport.translate[0] = half_width + x;
                p->viewport.translate[1] = (half_height + y) * scale + bias;
                p->viewport.translate[2] = half_depth + z;
-               p->viewport.translate[3] = 0.0f;
        }
 
        /* vertex elements state */
@@ -210,20 +209,20 @@ static void init_prog(struct program *p)
 
        /* vertex shader */
        {
-                       const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
-                                                       TGSI_SEMANTIC_COLOR };
-                       const uint semantic_indexes[] = { 0, 0 };
-                       p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes);
+               const enum tgsi_semantic semantic_names[] =
+                       { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_COLOR };
+               const uint semantic_indexes[] = { 0, 0 };
+               p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes, FALSE);
        }
 
        /* fragment shader */
-       p->fs = util_make_fragment_passthrough_shader(p->pipe);
+       p->fs = util_make_fragment_passthrough_shader(p->pipe,
+                    TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE, TRUE);
 }
 
 static void close_prog(struct program *p)
 {
-       /* unset all state */
-       cso_release_all(p->cso);
+       cso_destroy_context(p->cso);
 
        p->pipe->delete_vs_state(p->pipe, p->vs);
        p->pipe->delete_fs_state(p->pipe, p->fs);
@@ -232,7 +231,6 @@ static void close_prog(struct program *p)
        pipe_resource_reference(&p->target, NULL);
        pipe_resource_reference(&p->vbuf, NULL);
 
-       cso_destroy_context(p->cso);
        p->pipe->destroy(p->pipe);
        p->screen->destroy(p->screen);
        pipe_loader_release(&p->dev, 1);
@@ -267,7 +265,7 @@ static void draw(struct program *p)
                                3,  /* verts */
                                2); /* attribs/vert */
 
-        p->pipe->flush(p->pipe, NULL);
+        p->pipe->flush(p->pipe, NULL, 0);
 
        debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
 }