summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c63
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_draw_arrays.c28
-rw-r--r--src/gallium/drivers/llvmpipe/lp_limits.h6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.c82
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.h22
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c41
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_vbuf.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state.h139
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_blend.c46
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_clip.c31
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c34
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_rasterizer.c17
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_sampler.c30
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_vertex.c20
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_vs.c23
-rw-r--r--src/gallium/drivers/llvmpipe/lp_surface.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_surface.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c28
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.h4
23 files changed, 327 insertions, 313 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index f7cf06d8d4..32b80d3a9f 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -97,63 +97,24 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
llvmpipe->pipe.winsys = screen->winsys;
llvmpipe->pipe.screen = screen;
llvmpipe->pipe.priv = priv;
- llvmpipe->pipe.destroy = llvmpipe_destroy;
-
- /* state setters */
- llvmpipe->pipe.create_blend_state = llvmpipe_create_blend_state;
- llvmpipe->pipe.bind_blend_state = llvmpipe_bind_blend_state;
- llvmpipe->pipe.delete_blend_state = llvmpipe_delete_blend_state;
-
- llvmpipe->pipe.create_sampler_state = llvmpipe_create_sampler_state;
- llvmpipe->pipe.bind_fragment_sampler_states = llvmpipe_bind_sampler_states;
- llvmpipe->pipe.bind_vertex_sampler_states = llvmpipe_bind_vertex_sampler_states;
- llvmpipe->pipe.delete_sampler_state = llvmpipe_delete_sampler_state;
-
- llvmpipe->pipe.create_depth_stencil_alpha_state = llvmpipe_create_depth_stencil_state;
- llvmpipe->pipe.bind_depth_stencil_alpha_state = llvmpipe_bind_depth_stencil_state;
- llvmpipe->pipe.delete_depth_stencil_alpha_state = llvmpipe_delete_depth_stencil_state;
-
- llvmpipe->pipe.create_rasterizer_state = llvmpipe_create_rasterizer_state;
- llvmpipe->pipe.bind_rasterizer_state = llvmpipe_bind_rasterizer_state;
- llvmpipe->pipe.delete_rasterizer_state = llvmpipe_delete_rasterizer_state;
-
- llvmpipe->pipe.create_fs_state = llvmpipe_create_fs_state;
- llvmpipe->pipe.bind_fs_state = llvmpipe_bind_fs_state;
- llvmpipe->pipe.delete_fs_state = llvmpipe_delete_fs_state;
-
- llvmpipe->pipe.create_vs_state = llvmpipe_create_vs_state;
- llvmpipe->pipe.bind_vs_state = llvmpipe_bind_vs_state;
- llvmpipe->pipe.delete_vs_state = llvmpipe_delete_vs_state;
- llvmpipe->pipe.create_vertex_elements_state = llvmpipe_create_vertex_elements_state;
- llvmpipe->pipe.bind_vertex_elements_state = llvmpipe_bind_vertex_elements_state;
- llvmpipe->pipe.delete_vertex_elements_state = llvmpipe_delete_vertex_elements_state;
-
- llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color;
- llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
- llvmpipe->pipe.set_clip_state = llvmpipe_set_clip_state;
- llvmpipe->pipe.set_constant_buffer = llvmpipe_set_constant_buffer;
+ /* Init the pipe context methods */
+ llvmpipe->pipe.destroy = llvmpipe_destroy;
llvmpipe->pipe.set_framebuffer_state = llvmpipe_set_framebuffer_state;
- llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple;
- llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state;
- llvmpipe->pipe.set_fragment_sampler_views = llvmpipe_set_fragment_sampler_views;
- llvmpipe->pipe.set_vertex_sampler_views = llvmpipe_set_vertex_sampler_views;
- llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view;
- llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy;
- llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state;
-
- llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers;
-
- llvmpipe->pipe.draw_arrays = llvmpipe_draw_arrays;
- llvmpipe->pipe.draw_elements = llvmpipe_draw_elements;
- llvmpipe->pipe.draw_range_elements = llvmpipe_draw_range_elements;
-
llvmpipe->pipe.clear = llvmpipe_clear;
llvmpipe->pipe.flush = llvmpipe_flush;
-
+ llvmpipe_init_blend_funcs(llvmpipe);
+ llvmpipe_init_clip_funcs(llvmpipe);
+ llvmpipe_init_draw_funcs(llvmpipe);
+ llvmpipe_init_sampler_funcs(llvmpipe);
llvmpipe_init_query_funcs( llvmpipe );
+ llvmpipe_init_vertex_funcs(llvmpipe);
+ llvmpipe_init_fs_funcs(llvmpipe);
+ llvmpipe_init_vs_funcs(llvmpipe);
+ llvmpipe_init_rasterizer_funcs(llvmpipe);
llvmpipe_init_context_resource_funcs( &llvmpipe->pipe );
+ llvmpipe_init_surface_functions(llvmpipe);
/*
* Create drawing context and plug our rendering stage into it.
@@ -186,8 +147,6 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
draw_install_pstipple_stage(llvmpipe->draw, &llvmpipe->pipe);
#endif
- lp_init_surface_functions(llvmpipe);
-
lp_reset_counters();
return &llvmpipe->pipe;
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index 4848101ffb..4e597b2479 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -94,9 +94,6 @@ struct llvmpipe_context {
/** Vertex format */
struct vertex_info vertex_info;
- /** Which vertex shader output slot contains point size */
- int psize_slot;
-
/** The tiling engine */
struct lp_setup_context *setup;
diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index 0b63e1c889..98780d7631 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -42,20 +42,12 @@
-void
-llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count)
-{
- llvmpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count);
-}
-
-
/**
* Draw vertex arrays, with optional indexing.
* Basically, map the vertex buffers (and drawing surfaces), then hand off
* the drawing to the 'draw' module.
*/
-void
+static void
llvmpipe_draw_range_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
@@ -115,7 +107,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_draw_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
unsigned indexSize,
@@ -128,3 +120,19 @@ llvmpipe_draw_elements(struct pipe_context *pipe,
mode, start, count );
}
+
+static void
+llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
+ unsigned start, unsigned count)
+{
+ llvmpipe_draw_elements(pipe, NULL, 0, 0, mode, start, count);
+}
+
+
+void
+llvmpipe_init_draw_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.draw_arrays = llvmpipe_draw_arrays;
+ llvmpipe->pipe.draw_elements = llvmpipe_draw_elements;
+ llvmpipe->pipe.draw_range_elements = llvmpipe_draw_range_elements;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h
index c7c5a1eca8..4102a9df67 100644
--- a/src/gallium/drivers/llvmpipe/lp_limits.h
+++ b/src/gallium/drivers/llvmpipe/lp_limits.h
@@ -61,4 +61,10 @@
#define LP_MAX_THREADS 8
+/**
+ * Max bytes per scene. This may be replaced by a runtime parameter.
+ */
+#define LP_MAX_SCENE_SIZE (512 * 1024 * 1024)
+
+
#endif /* LP_LIMITS_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 400404fc52..a00a592f2f 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -882,9 +882,9 @@ create_rast_threads(struct lp_rasterizer *rast)
/**
- * Create new lp_rasterizer.
- * \param empty the queue to put empty scenes on after we've finished
- * processing them.
+ * Create new lp_rasterizer. If num_threads is zero, don't create any
+ * new threads, do rendering synchronously.
+ * \param num_threads number of rasterizer threads to create
*/
struct lp_rasterizer *
lp_rast_create( unsigned num_threads )
@@ -944,6 +944,8 @@ void lp_rast_destroy( struct lp_rasterizer *rast )
/* for synchronizing rasterization threads */
pipe_barrier_destroy( &rast->barrier );
+ lp_scene_queue_destroy(rast->full_scenes);
+
FREE(rast);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 18457ff4ce..5884d12721 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -105,7 +105,7 @@ struct lp_rasterizer
* (potentially) shared, these empty scenes should be returned to
* the context which created them rather than retained here.
*/
- struct lp_scene_queue *empty_scenes;
+ /* struct lp_scene_queue *empty_scenes; */
/** The scene currently being rasterized by the threads */
struct lp_scene *curr_scene;
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index 71d9529230..1482a777ff 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -32,7 +32,6 @@
#include "util/u_surface.h"
#include "lp_scene.h"
#include "lp_scene_queue.h"
-#include "lp_debug.h"
/** List of texture references */
@@ -43,6 +42,10 @@ struct texture_ref {
+/**
+ * Create a new scene object.
+ * \param queue the queue to put newly rendered/emptied scenes into
+ */
struct lp_scene *
lp_scene_create( struct pipe_context *pipe,
struct lp_scene_queue *queue )
@@ -195,6 +198,8 @@ lp_scene_reset(struct lp_scene *scene )
make_empty_list(ref_list);
}
+ scene->scene_size = 0;
+
scene->has_color_clear = FALSE;
scene->has_depth_clear = FALSE;
}
@@ -226,7 +231,10 @@ lp_bin_new_data_block( struct data_block_list *list )
}
-/** Return number of bytes used for all bin data within a scene */
+/**
+ * Return number of bytes used for all bin data within a scene.
+ * This does not include resources (textures) referenced by the scene.
+ */
unsigned
lp_scene_data_size( const struct lp_scene *scene )
{
@@ -267,6 +275,8 @@ lp_scene_add_resource_reference(struct lp_scene *scene,
pipe_resource_reference(&ref->resource, resource);
insert_at_tail(ref_list, ref);
}
+
+ scene->scene_size += llvmpipe_resource_size(resource);
}
@@ -401,61 +411,6 @@ end:
}
-
-/**
- * Prepare this scene for the rasterizer.
- * Map the framebuffer surfaces. Initialize the 'rast' state.
- */
-static boolean
-lp_scene_map_buffers( struct lp_scene *scene )
-{
- LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
-
- /* XXX framebuffer surfaces are no longer mapped here */
- /* XXX move all map/unmap stuff into rast module... */
-
- return TRUE;
-}
-
-
-
-/**
- * Called after rasterizer as finished rasterizing a scene.
- *
- * We want to call this from the pipe_context's current thread to
- * avoid having to have mutexes on the transfer functions.
- */
-static void
-lp_scene_unmap_buffers( struct lp_scene *scene )
-{
-#if 0
- unsigned i;
-
- for (i = 0; i < scene->fb.nr_cbufs; i++) {
- if (scene->cbuf_map[i]) {
- struct pipe_surface *cbuf = scene->fb.cbufs[i];
- llvmpipe_resource_unmap(cbuf->texture,
- cbuf->face,
- cbuf->level,
- cbuf->zslice);
- scene->cbuf_map[i] = NULL;
- }
- }
-
- if (scene->zsbuf_map) {
- struct pipe_surface *zsbuf = scene->fb.zsbuf;
- llvmpipe_resource_unmap(zsbuf->texture,
- zsbuf->face,
- zsbuf->level,
- zsbuf->zslice);
- scene->zsbuf_map = NULL;
- }
-#endif
-
- util_unreference_framebuffer_state( &scene->fb );
-}
-
-
void lp_scene_begin_binning( struct lp_scene *scene,
struct pipe_framebuffer_state *fb )
{
@@ -472,8 +427,7 @@ void lp_scene_begin_binning( struct lp_scene *scene,
void lp_scene_rasterize( struct lp_scene *scene,
- struct lp_rasterizer *rast,
- boolean write_depth )
+ struct lp_rasterizer *rast )
{
if (0) {
unsigned x, y;
@@ -487,11 +441,6 @@ void lp_scene_rasterize( struct lp_scene *scene,
}
}
- scene->write_depth = (scene->fb.zsbuf != NULL &&
- write_depth);
-
- lp_scene_map_buffers( scene );
-
/* Enqueue the scene for rasterization, then immediately wait for
* it to finish.
*/
@@ -502,6 +451,9 @@ void lp_scene_rasterize( struct lp_scene *scene,
* transfers become per-context:
*/
lp_rast_finish( rast );
- lp_scene_unmap_buffers( scene );
+
+ util_unreference_framebuffer_state( &scene->fb );
+
+ /* put scene into the empty list */
lp_scene_enqueue( scene->empty_queue, scene );
}
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h
index 3e2bd0e7b3..9467cd6f16 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.h
+++ b/src/gallium/drivers/llvmpipe/lp_scene.h
@@ -119,7 +119,11 @@ struct lp_scene {
/** list of resources referenced by the scene commands */
struct resource_ref resources;
- boolean write_depth;
+ /** Approx memory used by the scene (in bytes). This includes the
+ * shared and per-tile bins plus any referenced resources/textures.
+ */
+ unsigned scene_size;
+
boolean has_color_clear;
boolean has_depth_clear;
@@ -182,6 +186,8 @@ lp_scene_alloc( struct lp_scene *scene, unsigned size)
lp_bin_new_data_block( list );
}
+ scene->scene_size += size;
+
{
struct data_block *tail = list->tail;
ubyte *data = tail->data + tail->used;
@@ -204,6 +210,8 @@ lp_scene_alloc_aligned( struct lp_scene *scene, unsigned size,
lp_bin_new_data_block( list );
}
+ scene->scene_size += size;
+
{
struct data_block *tail = list->tail;
ubyte *data = tail->data + tail->used;
@@ -220,6 +228,7 @@ static INLINE void
lp_scene_putback_data( struct lp_scene *scene, unsigned size)
{
struct data_block_list *list = &scene->data;
+ scene->scene_size -= size;
assert(list->tail->used >= size);
list->tail->used -= size;
}
@@ -302,11 +311,18 @@ lp_scene_bin_iter_next( struct lp_scene *scene, int *bin_x, int *bin_y );
void
lp_scene_rasterize( struct lp_scene *scene,
- struct lp_rasterizer *rast,
- boolean write_depth );
+ struct lp_rasterizer *rast );
void
lp_scene_begin_binning( struct lp_scene *scene,
struct pipe_framebuffer_state *fb );
+
+static INLINE unsigned
+lp_scene_get_size(const struct lp_scene *scene)
+{
+ return scene->scene_size;
+}
+
+
#endif /* LP_BIN_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 00a897c86f..111eedc4f2 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -97,6 +97,8 @@ llvmpipe_get_param(struct pipe_screen *screen, int param)
return 1;
case PIPE_CAP_GLSL:
return 1;
+ case PIPE_CAP_SM3:
+ return 1;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
case PIPE_CAP_POINT_SPRITE:
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index abc659c369..2150956008 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -74,6 +74,26 @@ lp_setup_get_current_scene(struct lp_setup_context *setup)
}
+/**
+ * Check if the size of the current scene has exceeded the limit.
+ * If so, flush/render it.
+ */
+static void
+setup_check_scene_size_and_flush(struct lp_setup_context *setup)
+{
+ if (setup->scene) {
+ struct lp_scene *scene = lp_setup_get_current_scene(setup);
+ unsigned size = lp_scene_get_size(scene);
+
+ if (size > LP_MAX_SCENE_SIZE) {
+ /*printf("LLVMPIPE: scene size = %u, flushing.\n", size);*/
+ set_scene_state( setup, SETUP_FLUSHED );
+ /*assert(lp_scene_get_size(scene) == 0);*/
+ }
+ }
+}
+
+
static void
first_triangle( struct lp_setup_context *setup,
const float (*v0)[4],
@@ -132,14 +152,11 @@ static void reset_context( struct lp_setup_context *setup )
/** Rasterize all scene's bins */
static void
-lp_setup_rasterize_scene( struct lp_setup_context *setup,
- boolean write_depth )
+lp_setup_rasterize_scene( struct lp_setup_context *setup )
{
struct lp_scene *scene = lp_setup_get_current_scene(setup);
- lp_scene_rasterize(scene,
- setup->rast,
- write_depth);
+ lp_scene_rasterize(scene, setup->rast);
reset_context( setup );
@@ -190,7 +207,7 @@ execute_clears( struct lp_setup_context *setup )
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
begin_binning( setup );
- lp_setup_rasterize_scene( setup, TRUE );
+ lp_setup_rasterize_scene( setup );
}
@@ -221,7 +238,7 @@ set_scene_state( struct lp_setup_context *setup,
if (old_state == SETUP_CLEARED)
execute_clears( setup );
else
- lp_setup_rasterize_scene( setup, TRUE );
+ lp_setup_rasterize_scene( setup );
break;
default:
@@ -596,10 +613,14 @@ lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
void
lp_setup_update_state( struct lp_setup_context *setup )
{
- struct lp_scene *scene = lp_setup_get_current_scene(setup);
+ struct lp_scene *scene;
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
+ setup_check_scene_size_and_flush(setup);
+
+ scene = lp_setup_get_current_scene(setup);
+
assert(setup->fs.current.jit_function);
/* Some of the 'draw' pipeline stages may have changed some driver state.
@@ -741,6 +762,8 @@ lp_setup_destroy( struct lp_setup_context *setup )
reset_context( setup );
+ util_unreference_framebuffer_state(&setup->fb);
+
for (i = 0; i < Elements(setup->fs.current_tex); i++) {
pipe_resource_reference(&setup->fs.current_tex[i], NULL);
}
@@ -755,6 +778,8 @@ lp_setup_destroy( struct lp_setup_context *setup )
lp_scene_destroy(scene);
}
+ lp_scene_queue_destroy(setup->empty_scenes);
+
lp_rast_destroy( setup->rast );
FREE( setup );
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
index a401275478..5d3122e8ba 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
@@ -440,7 +440,12 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
static void
lp_setup_vbuf_destroy(struct vbuf_render *vbr)
{
- lp_setup_destroy(lp_setup_context(vbr));
+ struct lp_setup_context *setup = lp_setup_context(vbr);
+ if (setup->vertex_buffer) {
+ align_free(setup->vertex_buffer);
+ setup->vertex_buffer = NULL;
+ }
+ lp_setup_destroy(setup);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h
index dcbff190b6..18143807c9 100644
--- a/src/gallium/drivers/llvmpipe/lp_state.h
+++ b/src/gallium/drivers/llvmpipe/lp_state.h
@@ -31,11 +31,10 @@
#ifndef LP_STATE_H
#define LP_STATE_H
-#include "gallivm/lp_bld.h"
-
#include "pipe/p_state.h"
#include "tgsi/tgsi_scan.h"
#include "lp_jit.h"
+#include "gallivm/lp_bld.h"
#include "gallivm/lp_bld_sample.h" /* for struct lp_sampler_static_state */
@@ -85,8 +84,6 @@ struct lp_fragment_shader_variant_key
struct lp_fragment_shader_variant
{
- struct lp_fragment_shader *shader;
-
struct lp_fragment_shader_variant_key key;
LLVMValueRef function[2];
@@ -97,11 +94,7 @@ struct lp_fragment_shader_variant
};
-/**
- * Subclass of pipe_shader_state (though it doesn't really need to be).
- *
- * This is starting to look an awful lot like a quad pipeline stage...
- */
+/** Subclass of pipe_shader_state */
struct lp_fragment_shader
{
struct pipe_shader_state base;
@@ -109,140 +102,58 @@ struct lp_fragment_shader
struct tgsi_shader_info info;
struct lp_fragment_shader_variant *variants;
-
- struct lp_fragment_shader_variant *current;
};
/** Subclass of pipe_shader_state */
-struct lp_vertex_shader {
+struct lp_vertex_shader
+{
struct pipe_shader_state shader;
struct draw_vertex_shader *draw_data;
};
-struct lp_velems_state {
+
+/** Vertex element state */
+struct lp_velems_state
+{
unsigned count;
struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
};
-void *
-llvmpipe_create_blend_state(struct pipe_context *,
- const struct pipe_blend_state *);
-void llvmpipe_bind_blend_state(struct pipe_context *,
- void *);
-void llvmpipe_delete_blend_state(struct pipe_context *,
- void *);
-
-void *
-llvmpipe_create_sampler_state(struct pipe_context *,
- const struct pipe_sampler_state *);
-void llvmpipe_bind_sampler_states(struct pipe_context *, unsigned, void **);
void
-llvmpipe_bind_vertex_sampler_states(struct pipe_context *,
- unsigned num_samplers,
- void **samplers);
-void llvmpipe_delete_sampler_state(struct pipe_context *, void *);
-
-void *
-llvmpipe_create_depth_stencil_state(struct pipe_context *,
- const struct pipe_depth_stencil_alpha_state *);
-void llvmpipe_bind_depth_stencil_state(struct pipe_context *, void *);
-void llvmpipe_delete_depth_stencil_state(struct pipe_context *, void *);
-
-void *
-llvmpipe_create_rasterizer_state(struct pipe_context *,
- const struct pipe_rasterizer_state *);
-void llvmpipe_bind_rasterizer_state(struct pipe_context *, void *);
-void llvmpipe_delete_rasterizer_state(struct pipe_context *, void *);
-
-void llvmpipe_set_framebuffer_state( struct pipe_context *,
- const struct pipe_framebuffer_state * );
-
-void llvmpipe_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color );
-
-void llvmpipe_set_stencil_ref( struct pipe_context *pipe,
- const struct pipe_stencil_ref *stencil_ref );
-
-void llvmpipe_set_clip_state( struct pipe_context *,
- const struct pipe_clip_state * );
-
-void llvmpipe_set_constant_buffer(struct pipe_context *,
- uint shader, uint index,
- struct pipe_resource *buf);
-
-void *llvmpipe_create_fs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void llvmpipe_bind_fs_state(struct pipe_context *, void *);
-void llvmpipe_delete_fs_state(struct pipe_context *, void *);
-void *llvmpipe_create_vs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void llvmpipe_bind_vs_state(struct pipe_context *, void *);
-void llvmpipe_delete_vs_state(struct pipe_context *, void *);
-
-void *llvmpipe_create_vertex_elements_state(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_element *);
-void llvmpipe_bind_vertex_elements_state(struct pipe_context *, void *);
-void llvmpipe_delete_vertex_elements_state(struct pipe_context *, void *);
-
-void llvmpipe_set_polygon_stipple( struct pipe_context *,
- const struct pipe_poly_stipple * );
-
-void llvmpipe_set_scissor_state( struct pipe_context *,
- const struct pipe_scissor_state * );
-
-void llvmpipe_set_fragment_sampler_views(struct pipe_context *,
- unsigned num,
- struct pipe_sampler_view **);
+llvmpipe_set_framebuffer_state(struct pipe_context *,
+ const struct pipe_framebuffer_state *);
void
-llvmpipe_set_vertex_sampler_views(struct pipe_context *,
- unsigned num,
- struct pipe_sampler_view **);
-
-struct pipe_sampler_view *
-llvmpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_resource *texture,
- const struct pipe_sampler_view *templ);
+llvmpipe_update_fs(struct llvmpipe_context *lp);
void
-llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
- struct pipe_sampler_view *view);
+llvmpipe_update_derived(struct llvmpipe_context *llvmpipe);
-void llvmpipe_set_viewport_state( struct pipe_context *,
- const struct pipe_viewport_state * );
-
-void llvmpipe_set_vertex_buffers(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_buffer *);
+void
+llvmpipe_init_sampler_funcs(struct llvmpipe_context *llvmpipe);
-void llvmpipe_update_fs(struct llvmpipe_context *lp);
+void
+llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe);
-void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe );
+void
+llvmpipe_init_vertex_funcs(struct llvmpipe_context *llvmpipe);
+void
+llvmpipe_init_draw_funcs(struct llvmpipe_context *llvmpipe);
-void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count);
+void
+llvmpipe_init_clip_funcs(struct llvmpipe_context *llvmpipe);
-void llvmpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_resource *indexBuffer,
- unsigned indexSize, int indexBias,
- unsigned mode, unsigned start, unsigned count);
void
-llvmpipe_draw_range_elements(struct pipe_context *pipe,
- struct pipe_resource *indexBuffer,
- unsigned indexSize, int indexBias,
- unsigned min_index,
- unsigned max_index,
- unsigned mode, unsigned start, unsigned count);
+llvmpipe_init_fs_funcs(struct llvmpipe_context *llvmpipe);
void
-llvmpipe_map_texture_surfaces(struct llvmpipe_context *lp);
+llvmpipe_init_vs_funcs(struct llvmpipe_context *llvmpipe);
void
-llvmpipe_unmap_texture_surfaces(struct llvmpipe_context *lp);
+llvmpipe_init_rasterizer_funcs(struct llvmpipe_context *llvmpipe);
#endif
diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c
index 4ee28473e8..8569507f4e 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c
@@ -40,15 +40,16 @@
#include "lp_state.h"
-void *
+static void *
llvmpipe_create_blend_state(struct pipe_context *pipe,
const struct pipe_blend_state *blend)
{
return mem_dup(blend, sizeof(*blend));
}
-void llvmpipe_bind_blend_state( struct pipe_context *pipe,
- void *blend )
+
+static void
+llvmpipe_bind_blend_state(struct pipe_context *pipe, void *blend)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -62,15 +63,17 @@ void llvmpipe_bind_blend_state( struct pipe_context *pipe,
llvmpipe->dirty |= LP_NEW_BLEND;
}
-void llvmpipe_delete_blend_state(struct pipe_context *pipe,
- void *blend)
+
+static void
+llvmpipe_delete_blend_state(struct pipe_context *pipe, void *blend)
{
FREE( blend );
}
-void llvmpipe_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color )
+static void
+llvmpipe_set_blend_color(struct pipe_context *pipe,
+ const struct pipe_blend_color *blend_color)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -93,14 +96,15 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe,
*/
-void *
+static void *
llvmpipe_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_alpha_state *depth_stencil)
{
return mem_dup(depth_stencil, sizeof(*depth_stencil));
}
-void
+
+static void
llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
void *depth_stencil)
{
@@ -116,14 +120,17 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
}
-void
+
+static void
llvmpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
{
FREE( depth );
}
-void llvmpipe_set_stencil_ref( struct pipe_context *pipe,
- const struct pipe_stencil_ref *stencil_ref )
+
+static void
+llvmpipe_set_stencil_ref(struct pipe_context *pipe,
+ const struct pipe_stencil_ref *stencil_ref)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -142,3 +149,18 @@ void llvmpipe_set_stencil_ref( struct pipe_context *pipe,
}
+void
+llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_blend_state = llvmpipe_create_blend_state;
+ llvmpipe->pipe.bind_blend_state = llvmpipe_bind_blend_state;
+ llvmpipe->pipe.delete_blend_state = llvmpipe_delete_blend_state;
+
+ llvmpipe->pipe.create_depth_stencil_alpha_state = llvmpipe_create_depth_stencil_state;
+ llvmpipe->pipe.bind_depth_stencil_alpha_state = llvmpipe_bind_depth_stencil_state;
+ llvmpipe->pipe.delete_depth_stencil_alpha_state = llvmpipe_delete_depth_stencil_state;
+
+ llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color;
+
+ llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_clip.c b/src/gallium/drivers/llvmpipe/lp_state_clip.c
index df68f27acc..32ae079cc1 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_clip.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_clip.c
@@ -32,8 +32,9 @@
#include "draw/draw_context.h"
-void llvmpipe_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
+static void
+llvmpipe_set_clip_state(struct pipe_context *pipe,
+ const struct pipe_clip_state *clip)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -42,8 +43,9 @@ void llvmpipe_set_clip_state( struct pipe_context *pipe,
}
-void llvmpipe_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
+static void
+llvmpipe_set_viewport_state(struct pipe_context *pipe,
+ const struct pipe_viewport_state *viewport)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -55,8 +57,9 @@ void llvmpipe_set_viewport_state( struct pipe_context *pipe,
}
-void llvmpipe_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
+static void
+llvmpipe_set_scissor_state(struct pipe_context *pipe,
+ const struct pipe_scissor_state *scissor)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -67,8 +70,9 @@ void llvmpipe_set_scissor_state( struct pipe_context *pipe,
}
-void llvmpipe_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
+static void
+llvmpipe_set_polygon_stipple(struct pipe_context *pipe,
+ const struct pipe_poly_stipple *stipple)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -77,3 +81,14 @@ void llvmpipe_set_polygon_stipple( struct pipe_context *pipe,
llvmpipe->poly_stipple = *stipple; /* struct copy */
llvmpipe->dirty |= LP_NEW_STIPPLE;
}
+
+
+
+void
+llvmpipe_init_clip_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.set_clip_state = llvmpipe_set_clip_state;
+ llvmpipe->pipe.set_polygon_stipple = llvmpipe_set_polygon_stipple;
+ llvmpipe->pipe.set_scissor_state = llvmpipe_set_scissor_state;
+ llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 9e9d9bcfb5..965777b641 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -621,7 +621,6 @@ generate_fragment(struct llvmpipe_context *lp,
LLVMTypeRef fs_vec_type;
LLVMTypeRef fs_int_vec_type;
LLVMTypeRef blend_vec_type;
- LLVMTypeRef blend_int_vec_type;
LLVMTypeRef arg_types[15];
LLVMTypeRef func_type;
LLVMTypeRef int32_vec4_type = lp_build_int32_vec4_type();
@@ -680,7 +679,6 @@ generate_fragment(struct llvmpipe_context *lp,
fs_int_vec_type = lp_build_int_vec_type(fs_type);
blend_vec_type = lp_build_vec_type(blend_type);
- blend_int_vec_type = lp_build_int_vec_type(blend_type);
arg_types[0] = screen->context_ptr_type; /* context */
arg_types[1] = LLVMInt32Type(); /* x */
@@ -939,7 +937,6 @@ generate_variant(struct llvmpipe_context *lp,
if(!variant)
return NULL;
- variant->shader = shader;
memcpy(&variant->key, key, sizeof *key);
generate_fragment(lp, shader, variant, 0);
@@ -953,7 +950,7 @@ generate_variant(struct llvmpipe_context *lp,
}
-void *
+static void *
llvmpipe_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
@@ -969,11 +966,16 @@ llvmpipe_create_fs_state(struct pipe_context *pipe,
/* we need to keep a local copy of the tokens */
shader->base.tokens = tgsi_dup_tokens(templ->tokens);
+ if (LP_DEBUG & DEBUG_TGSI) {
+ debug_printf("llvmpipe: Create fragment shader %p:\n", (void *) shader);
+ tgsi_dump(templ->tokens, 0);
+ }
+
return shader;
}
-void
+static void
llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -989,7 +991,7 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
}
-void
+static void
llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -1032,7 +1034,7 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
-void
+static void
llvmpipe_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
struct pipe_resource *constants)
@@ -1163,8 +1165,6 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
LP_COUNT_ADD(nr_llvm_compiles, 2); /* emit vs. omit in/out test */
}
- shader->current = variant;
-
/* TODO: put this in the variant */
/* TODO: most of these can be relaxed, in particular the colormask */
opaque = !key.blend.logicop_enable &&
@@ -1178,7 +1178,19 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
? TRUE : FALSE;
lp_setup_set_fs_functions(lp->setup,
- shader->current->jit_function[RAST_WHOLE],
- shader->current->jit_function[RAST_EDGE_TEST],
+ variant->jit_function[RAST_WHOLE],
+ variant->jit_function[RAST_EDGE_TEST],
opaque);
}
+
+
+
+void
+llvmpipe_init_fs_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_fs_state = llvmpipe_create_fs_state;
+ llvmpipe->pipe.bind_fs_state = llvmpipe_bind_fs_state;
+ llvmpipe->pipe.delete_fs_state = llvmpipe_delete_fs_state;
+
+ llvmpipe->pipe.set_constant_buffer = llvmpipe_set_constant_buffer;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index 3fba5e4e75..622eb47ff4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -34,7 +34,7 @@
-void *
+static void *
llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
const struct pipe_rasterizer_state *rast)
{
@@ -46,7 +46,7 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
-void
+static void
llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -79,10 +79,19 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
}
-void llvmpipe_delete_rasterizer_state(struct pipe_context *pipe,
- void *rasterizer)
+static void
+llvmpipe_delete_rasterizer_state(struct pipe_context *pipe,
+ void *rasterizer)
{
FREE( rasterizer );
}
+
+void
+llvmpipe_init_rasterizer_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_rasterizer_state = llvmpipe_create_rasterizer_state;
+ llvmpipe->pipe.bind_rasterizer_state = llvmpipe_bind_rasterizer_state;
+ llvmpipe->pipe.delete_rasterizer_state = llvmpipe_delete_rasterizer_state;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 3552ff50ce..55d43368a3 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -41,7 +41,7 @@
-void *
+static void *
llvmpipe_create_sampler_state(struct pipe_context *pipe,
const struct pipe_sampler_state *sampler)
{
@@ -49,7 +49,7 @@ llvmpipe_create_sampler_state(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_bind_sampler_states(struct pipe_context *pipe,
unsigned num, void **sampler)
{
@@ -76,7 +76,7 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
unsigned num_samplers,
void **samplers)
@@ -104,7 +104,7 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
unsigned num,
struct pipe_sampler_view **views)
@@ -133,7 +133,7 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
unsigned num,
struct pipe_sampler_view **views)
@@ -163,7 +163,7 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
}
-struct pipe_sampler_view *
+static struct pipe_sampler_view *
llvmpipe_create_sampler_view(struct pipe_context *pipe,
struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
@@ -182,7 +182,7 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
@@ -191,7 +191,7 @@ llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
}
-void
+static void
llvmpipe_delete_sampler_state(struct pipe_context *pipe,
void *sampler)
{
@@ -199,4 +199,16 @@ llvmpipe_delete_sampler_state(struct pipe_context *pipe,
}
-
+void
+llvmpipe_init_sampler_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_sampler_state = llvmpipe_create_sampler_state;
+
+ llvmpipe->pipe.bind_fragment_sampler_states = llvmpipe_bind_sampler_states;
+ llvmpipe->pipe.bind_vertex_sampler_states = llvmpipe_bind_vertex_sampler_states;
+ llvmpipe->pipe.set_fragment_sampler_views = llvmpipe_set_fragment_sampler_views;
+ llvmpipe->pipe.set_vertex_sampler_views = llvmpipe_set_vertex_sampler_views;
+ llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view;
+ llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy;
+ llvmpipe->pipe.delete_sampler_state = llvmpipe_delete_sampler_state;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c
index f6427aa908..113f13db01 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c
@@ -35,7 +35,7 @@
#include "draw/draw_context.h"
-void *
+static void *
llvmpipe_create_vertex_elements_state(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_element *attribs)
@@ -50,7 +50,7 @@ llvmpipe_create_vertex_elements_state(struct pipe_context *pipe,
return velems;
}
-void
+static void
llvmpipe_bind_vertex_elements_state(struct pipe_context *pipe,
void *velems)
{
@@ -65,13 +65,13 @@ llvmpipe_bind_vertex_elements_state(struct pipe_context *pipe,
draw_set_vertex_elements(llvmpipe->draw, lp_velems->count, lp_velems->velem);
}
-void
+static void
llvmpipe_delete_vertex_elements_state(struct pipe_context *pipe, void *velems)
{
FREE( velems );
}
-void
+static void
llvmpipe_set_vertex_buffers(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_buffer *buffers)
@@ -87,3 +87,15 @@ llvmpipe_set_vertex_buffers(struct pipe_context *pipe,
draw_set_vertex_buffers(llvmpipe->draw, count, buffers);
}
+
+
+
+void
+llvmpipe_init_vertex_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_vertex_elements_state = llvmpipe_create_vertex_elements_state;
+ llvmpipe->pipe.bind_vertex_elements_state = llvmpipe_bind_vertex_elements_state;
+ llvmpipe->pipe.delete_vertex_elements_state = llvmpipe_delete_vertex_elements_state;
+
+ llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_state_vs.c b/src/gallium/drivers/llvmpipe/lp_state_vs.c
index 884e3878e6..f2d8808990 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_vs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_vs.c
@@ -28,15 +28,17 @@
#include "pipe/p_defines.h"
+#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_parse.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "lp_context.h"
+#include "lp_debug.h"
#include "lp_state.h"
-void *
+static void *
llvmpipe_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
@@ -57,6 +59,11 @@ llvmpipe_create_vs_state(struct pipe_context *pipe,
if (state->draw_data == NULL)
goto fail;
+ if (LP_DEBUG & DEBUG_TGSI) {
+ debug_printf("llvmpipe: Create vertex shader %p:\n", (void *) state);
+ tgsi_dump(templ->tokens, 0);
+ }
+
return state;
fail:
@@ -69,7 +76,7 @@ fail:
}
-void
+static void
llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -87,7 +94,7 @@ llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
}
-void
+static void
llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
@@ -99,3 +106,13 @@ llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
FREE( (void *)state->shader.tokens );
FREE( state );
}
+
+
+
+void
+llvmpipe_init_vs_funcs(struct llvmpipe_context *llvmpipe)
+{
+ llvmpipe->pipe.create_vs_state = llvmpipe_create_vs_state;
+ llvmpipe->pipe.bind_vs_state = llvmpipe_bind_vs_state;
+ llvmpipe->pipe.delete_vs_state = llvmpipe_delete_vs_state;
+}
diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c
index 1432782cef..8bd83f576f 100644
--- a/src/gallium/drivers/llvmpipe/lp_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_surface.c
@@ -146,7 +146,7 @@ lp_surface_copy(struct pipe_context *pipe,
void
-lp_init_surface_functions(struct llvmpipe_context *lp)
+llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
{
lp->pipe.surface_copy = lp_surface_copy;
lp->pipe.surface_fill = util_surface_fill;
diff --git a/src/gallium/drivers/llvmpipe/lp_surface.h b/src/gallium/drivers/llvmpipe/lp_surface.h
index 4d78a53c4f..b1b896ebd9 100644
--- a/src/gallium/drivers/llvmpipe/lp_surface.h
+++ b/src/gallium/drivers/llvmpipe/lp_surface.h
@@ -36,7 +36,7 @@ struct llvmpipe_context;
extern void
-lp_init_surface_functions(struct llvmpipe_context *lp);
+llvmpipe_init_surface_functions(struct llvmpipe_context *lp);
#endif /* LP_SURFACE_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 29bdfe36ae..2f41d620c8 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -241,6 +241,13 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
/* display target */
struct sw_winsys *winsys = screen->winsys;
winsys->displaytarget_destroy(winsys, lpr->dt);
+
+ if (lpr->tiled[0].data) {
+ align_free(lpr->tiled[0].data);
+ lpr->tiled[0].data = NULL;
+ }
+
+ FREE(lpr->layout[0]);
}
else if (resource_is_texture(pt)) {
/* regular texture */
@@ -1160,6 +1167,27 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr,
}
+/**
+ * Return size of resource in bytes
+ */
+unsigned
+llvmpipe_resource_size(const struct pipe_resource *resource)
+{
+ const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource);
+ unsigned lvl, size = 0;
+
+ for (lvl = 0; lvl <= lpr->base.last_level; lvl++) {
+ if (lpr->linear[lvl].data)
+ size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_LINEAR);
+
+ if (lpr->tiled[lvl].data)
+ size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_TILED);
+ }
+
+ return size;
+}
+
+
void
llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
{
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h
index 7d0ae263e5..a8d08d6247 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.h
+++ b/src/gallium/drivers/llvmpipe/lp_texture.h
@@ -184,6 +184,10 @@ void *
llvmpipe_resource_data(struct pipe_resource *resource);
+unsigned
+llvmpipe_resource_size(const struct pipe_resource *resource);
+
+
ubyte *
llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
unsigned face_slice, unsigned level,