#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 */
#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 */
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;
};
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);
}
p->rasterizer.cull_face = PIPE_FACE_NONE;
p->rasterizer.half_pixel_center = 1;
p->rasterizer.bottom_edge_rule = 1;
- p->rasterizer.depth_clip = 1;
+ p->rasterizer.depth_clip_near = 1;
+ p->rasterizer.depth_clip_far = 1;
surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM;
surf_tmpl.u.tex.level = 0;
{
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;
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 */
/* 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,
- TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE);
+ 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);
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);