summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw/draw_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_context.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 73d5b6e403..95d9671987 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -35,6 +35,7 @@
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_cpu_detect.h"
+#include "util/u_inlines.h"
#include "draw_context.h"
#include "draw_vs.h"
#include "draw_gs.h"
@@ -87,8 +88,14 @@ draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm)
goto fail;
#if HAVE_LLVM
- if (draw_get_option_use_llvm() && gallivm) {
- draw->llvm = draw_llvm_create(draw, gallivm);
+ if (draw_get_option_use_llvm()) {
+ if (!gallivm) {
+ gallivm = gallivm_create();
+ draw->own_gallivm = gallivm;
+ }
+
+ if (gallivm)
+ draw->llvm = draw_llvm_create(draw, gallivm);
}
#endif
@@ -164,6 +171,10 @@ void draw_destroy( struct draw_context *draw )
}
}
+ for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
+ pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL);
+ }
+
/* Not so fast -- we're just borrowing this at the moment.
*
if (draw->render)
@@ -175,8 +186,11 @@ void draw_destroy( struct draw_context *draw )
draw_vs_destroy( draw );
draw_gs_destroy( draw );
#ifdef HAVE_LLVM
- if(draw->llvm)
+ if (draw->llvm)
draw_llvm_destroy( draw->llvm );
+
+ if (draw->own_gallivm)
+ gallivm_destroy(draw->own_gallivm);
#endif
FREE( draw );
@@ -307,8 +321,9 @@ draw_set_vertex_buffers(struct draw_context *draw,
{
assert(count <= PIPE_MAX_ATTRIBS);
- memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0]));
- draw->pt.nr_vertex_buffers = count;
+ util_copy_vertex_buffers(draw->pt.vertex_buffer,
+ &draw->pt.nr_vertex_buffers,
+ buffers, count);
}
@@ -395,7 +410,7 @@ void
draw_wide_line_threshold(struct draw_context *draw, float threshold)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->pipeline.wide_line_threshold = threshold;
+ draw->pipeline.wide_line_threshold = roundf(threshold);
}