X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Ftests%2Fgraw%2Fshader-leak.c;h=cc5cd8a4bcd93e4eeae6158016fee0477a5e676a;hb=0464ee7f9d9383175c31192500ee9e6d9f01fe60;hp=ec30871e82c1adca89672f72be63cc4b3544d14e;hpb=48fda8c446c127298e8a523a321d4da131c2834d;p=mesa.git diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c index ec30871e82c..cc5cd8a4bcd 100644 --- a/src/gallium/tests/graw/shader-leak.c +++ b/src/gallium/tests/graw/shader-leak.c @@ -3,23 +3,23 @@ */ #include -#include "state_tracker/graw.h" +#include "frontend/graw.h" #include "pipe/p_screen.h" #include "pipe/p_context.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "util/u_debug.h" /* debug_dump_surface_bmp() */ #include "util/u_memory.h" /* Offset() */ #include "util/u_draw_quad.h" +#include "util/u_inlines.h" static int num_iters = 100; enum pipe_format formats[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_RGBA8888_UNORM, + PIPE_FORMAT_BGRA8888_UNORM, PIPE_FORMAT_NONE }; @@ -29,6 +29,7 @@ static const int HEIGHT = 300; static struct pipe_screen *screen = NULL; static struct pipe_context *ctx = NULL; static struct pipe_surface *surf = NULL; +static struct pipe_resource *tex = NULL; static void *window = NULL; struct vertex { @@ -49,25 +50,23 @@ static struct vertex vertices[1] = static void set_viewport( float x, float y, float width, float height, - float near, float far) + float zNear, float zFar) { - float z = far; + float z = zFar; float half_width = (float)width / 2.0f; float half_height = (float)height / 2.0f; - float half_depth = ((float)far - (float)near) / 2.0f; + float half_depth = ((float)zFar - (float)zNear) / 2.0f; struct pipe_viewport_state vp; vp.scale[0] = half_width; vp.scale[1] = half_height; vp.scale[2] = half_depth; - vp.scale[3] = 1.0f; vp.translate[0] = half_width + x; vp.translate[1] = half_height + y; vp.translate[2] = half_depth + z; - vp.translate[3] = 0.0f; - ctx->set_viewport_state( ctx, &vp ); + ctx->set_viewport_states( ctx, 0, 1, &vp ); } static void set_vertices( void ) @@ -86,16 +85,17 @@ static void set_vertices( void ) handle = ctx->create_vertex_elements_state(ctx, 2, ve); ctx->bind_vertex_elements_state(ctx, handle); + memset(&vbuf, 0, sizeof vbuf); vbuf.stride = sizeof(struct vertex); - vbuf.max_index = sizeof(vertices) / vbuf.stride; vbuf.buffer_offset = 0; - vbuf.buffer = screen->user_buffer_create(screen, - vertices, - sizeof(vertices), - PIPE_BIND_VERTEX_BUFFER); + vbuf.buffer.resource = pipe_buffer_create_with_data(ctx, + PIPE_BIND_VERTEX_BUFFER, + PIPE_USAGE_DEFAULT, + sizeof(vertices), + vertices); - ctx->set_vertex_buffers(ctx, 1, &vbuf); + ctx->set_vertex_buffers(ctx, 0, 1, &vbuf); } static void set_vertex_shader( void ) @@ -138,7 +138,7 @@ set_fragment_shader( void ) static void draw( void ) { - float clear_color[4] = {0, 0, 0, 1}; + union pipe_color_union clear_color = { {0,0,0,1} }; int i; printf("Creating %d shaders\n", num_iters); @@ -148,15 +148,15 @@ static void draw( void ) ctx->bind_fs_state(ctx, fs); - ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); + ctx->clear(ctx, PIPE_CLEAR_COLOR, NULL, &clear_color, 0, 0); util_draw_arrays(ctx, PIPE_PRIM_POINTS, 0, 1); - ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->flush(ctx, NULL, 0); ctx->bind_fs_state(ctx, NULL); ctx->delete_fs_state(ctx, fs); } - screen->flush_frontbuffer(screen, surf, window); + screen->flush_frontbuffer(screen, tex, 0, 0, window, NULL); ctx->destroy(ctx); exit(0); @@ -166,7 +166,8 @@ static void draw( void ) static void init( void ) { struct pipe_framebuffer_state fb; - struct pipe_resource *tex, templat; + struct pipe_resource templat; + struct pipe_surface surf_tmpl; int i; /* It's hard to say whether window or screen should be created @@ -175,26 +176,29 @@ static void init( void ) * Also, no easy way of querying supported formats if the screen * cannot be created first. */ - for (i = 0; - window == NULL && formats[i] != PIPE_FORMAT_NONE; - i++) { - - screen = graw_create_window_and_screen(0,0,300,300, + for (i = 0; formats[i] != PIPE_FORMAT_NONE; i++) { + screen = graw_create_window_and_screen(0, 0, 300, 300, formats[i], &window); + if (window && screen) + break; } - - ctx = screen->context_create(screen, NULL); + if (!screen || !window) { + fprintf(stderr, "Unable to create window\n"); + exit(1); + } + + ctx = screen->context_create(screen, NULL, 0); if (ctx == NULL) exit(3); + memset(&templat, 0, sizeof(templat)); templat.target = PIPE_TEXTURE_2D; templat.format = formats[i]; templat.width0 = WIDTH; templat.height0 = HEIGHT; templat.depth0 = 1; templat.last_level = 0; - templat.nr_samples = 1; templat.bind = (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET); @@ -204,11 +208,15 @@ static void init( void ) exit(4); } - surf = screen->get_tex_surface(screen, tex, 0, 0, 0, - PIPE_BIND_RENDER_TARGET | - PIPE_BIND_DISPLAY_TARGET); - if (surf == NULL) + surf_tmpl.format = templat.format; + surf_tmpl.u.tex.level = 0; + surf_tmpl.u.tex.first_layer = 0; + surf_tmpl.u.tex.last_layer = 0; + surf = ctx->create_surface(ctx, tex, &surf_tmpl); + if (surf == NULL) { + fprintf(stderr, "Unable to create tex surface!\n"); exit(5); + } memset(&fb, 0, sizeof fb); fb.nr_cbufs = 1; @@ -240,7 +248,10 @@ static void init( void ) void *handle; memset(&rasterizer, 0, sizeof rasterizer); rasterizer.cull_face = PIPE_FACE_NONE; - rasterizer.gl_rasterization_rules = 1; + rasterizer.half_pixel_center = 1; + rasterizer.bottom_edge_rule = 1; + rasterizer.depth_clip_near = 1; + rasterizer.depth_clip_far = 1; handle = ctx->create_rasterizer_state(ctx, &rasterizer); ctx->bind_rasterizer_state(ctx, handle); }