X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Ftests%2Ftrivial%2Ftri.c;h=a555200842e6e75b7e0e332724022b0bd6949156;hb=0fc21ecfc0891d239f20bf7724e51bc75503570c;hp=48305240a4b8d920ecebff69d379121216588407;hpb=e4c54d404959aa1bce26caa313c0a47e65ff211a;p=mesa.git diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c index 48305240a4b..a555200842e 100644 --- a/src/gallium/tests/trivial/tri.c +++ b/src/gallium/tests/trivial/tri.c @@ -55,21 +55,12 @@ #include "util/u_memory.h" /* util_make_[fragment|vertex]_passthrough_shader */ #include "util/u_simple_shaders.h" - -/* softpipe software driver */ -#include "softpipe/sp_public.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 +/* to get a hardware pipe driver */ +#include "pipe-loader/pipe_loader.h" struct program { + struct pipe_loader_device *dev; struct pipe_screen *screen; struct pipe_context *pipe; struct cso_context *cso; @@ -84,7 +75,7 @@ struct program void *vs; void *fs; - float clear_color[4]; + union pipe_color_union clear_color; struct pipe_resource *vbuf; struct pipe_resource *target; @@ -92,19 +83,26 @@ struct program static void init_prog(struct program *p) { - /* create the software rasterizer */ - p->screen = softpipe_create_screen(null_sw_create()); -#if USE_TRACE - p->screen = trace_screen_create(p->screen); -#endif - p->pipe = p->screen->context_create(p->screen, NULL); + struct pipe_surface surf_tmpl; + int ret; + + /* find a hardware device */ + ret = pipe_loader_probe(&p->dev, 1); + assert(ret); + + /* init a pipe screen */ + p->screen = pipe_loader_create_screen(p->dev, PIPE_SEARCH_DIR); + assert(p->screen); + + /* create the pipe driver context and cso context */ + p->pipe = p->screen->context_create(p->screen, NULL, 0); p->cso = cso_create_context(p->pipe); /* set clear color */ - p->clear_color[0] = 0.3; - p->clear_color[1] = 0.1; - p->clear_color[2] = 0.3; - p->clear_color[3] = 1.0; + p->clear_color.f[0] = 0.3; + p->clear_color.f[1] = 0.1; + p->clear_color.f[2] = 0.3; + p->clear_color.f[3] = 1.0; /* vertex buffer */ { @@ -123,7 +121,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_DEFAULT, sizeof(vertices)); pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices); } @@ -136,6 +135,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 +151,21 @@ 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.gl_rasterization_rules = 1; - + p->rasterizer.cull_face = PIPE_FACE_NONE; + p->rasterizer.half_pixel_center = 1; + p->rasterizer.bottom_edge_rule = 1; + p->rasterizer.depth_clip = 1; + + surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM; + 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 */ { @@ -183,12 +188,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 */ @@ -208,17 +211,17 @@ static void init_prog(struct program *p) 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); + 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); @@ -227,9 +230,9 @@ 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); FREE(p); } @@ -240,7 +243,7 @@ static void draw(struct program *p) cso_set_framebuffer(p->cso, &p->framebuffer); /* clear the render target */ - p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0); + p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); /* set misc state we care about */ cso_set_blend(p->cso, &p->blend); @@ -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, - p->vbuf, 0, + util_draw_vertex_buffer(p->pipe, p->cso, + p->vbuf, 0, 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, 0); debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); }