gallium: fix shader mem leak
[mesa.git] / src / mesa / state_tracker / st_cb_bitmap.c
index d73cd4abfa9e12b2eeed08961e5a8475e014c59f..e95ff5e2e0d36dc9c145859961732ce784020a25 100644 (file)
@@ -50,7 +50,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
 #include "util/p_tile.h"
 #include "util/u_draw_quad.h"
 #include "util/u_simple_shaders.h"
@@ -199,6 +198,10 @@ combined_bitmap_fragment_program(GLcontext *ctx)
          _mesa_combine_programs(ctx,
                                 &bitmap_prog->Base.Base, &stfp->Base.Base);
       stfp->bitmap_program->bitmap_sampler = sampler;
+
+      /* done with this after combining */
+      st_reference_fragprog(st, &bitmap_prog, NULL);
+
 #if 0
       {
          struct gl_program *p = &stfp->bitmap_program->Base.Base;
@@ -372,9 +375,8 @@ setup_bitmap_vertex_data(struct st_context *st,
    void *buf;
 
    if (!st->bitmap.vbuf) {
-      st->bitmap.vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
-                                                   PIPE_BUFFER_USAGE_VERTEX,
-                                                   sizeof(st->bitmap.vertices));
+      st->bitmap.vbuf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
+                                           sizeof(st->bitmap.vertices));
    }
 
    /* Positions are in clip coords since we need to do clipping in case
@@ -413,10 +415,9 @@ setup_bitmap_vertex_data(struct st_context *st,
    }
 
    /* put vertex data into vbuf */
-   buf = pipe->winsys->buffer_map(pipe->winsys, st->bitmap.vbuf,
-                                  PIPE_BUFFER_USAGE_CPU_WRITE);
+   buf = pipe_buffer_map(pipe, st->bitmap.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
    memcpy(buf, st->bitmap.vertices, sizeof(st->bitmap.vertices));
-   pipe->winsys->buffer_unmap(pipe->winsys, st->bitmap.vbuf);
+   pipe_buffer_unmap(pipe, st->bitmap.vbuf);
 }
 
 
@@ -725,8 +726,8 @@ st_init_bitmap(struct st_context *st)
    st->bitmap.rasterizer.bypass_vs = 1;
 
    /* find a usable texture format */
-   if (screen->is_format_supported(screen, PIPE_FORMAT_U_I8, PIPE_TEXTURE)) {
-      st->bitmap.tex_format = PIPE_FORMAT_U_I8;
+   if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE)) {
+      st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
    }
    else {
       /* XXX support more formats */
@@ -746,22 +747,13 @@ st_destroy_bitmap(struct st_context *st)
 {
    struct pipe_context *pipe = st->pipe;
 
-#if 0
-   if (st->bitmap.combined_prog) {
-      st_delete_program(st->ctx, &st->bitmap.combined_prog->Base.Base);
-   }
-
-   if (st->bitmap.program) {
-      st_delete_program(st->ctx, &st->bitmap.program->Base.Base);
-   }
-#endif
    if (st->bitmap.vs) {
       cso_delete_vertex_shader(st->cso_context, st->bitmap.vs);
       st->bitmap.vs = NULL;
    }
 
    if (st->bitmap.vbuf) {
-      pipe->winsys->buffer_destroy(pipe->winsys, st->bitmap.vbuf);
+      pipe_buffer_destroy(pipe, st->bitmap.vbuf);
       st->bitmap.vbuf = NULL;
    }