#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 */
+/**
+ * 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 )
make_empty_list(ref_list);
}
+ scene->scene_size = 0;
+
scene->has_color_clear = FALSE;
scene->has_depth_clear = FALSE;
}
}
-/** 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 )
{
pipe_resource_reference(&ref->resource, resource);
insert_at_tail(ref_list, ref);
}
+
+ scene->scene_size += llvmpipe_resource_size(resource);
}
/** list of resources referenced by the scene commands */
struct resource_ref resources;
+ /** 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 write_depth;
boolean has_color_clear;
boolean has_depth_clear;
lp_bin_new_data_block( list );
}
+ scene->scene_size += size;
+
{
struct data_block *tail = list->tail;
ubyte *data = tail->data + tail->used;
lp_bin_new_data_block( list );
}
+ scene->scene_size += size;
+
{
struct data_block *tail = list->tail;
ubyte *data = tail->data + tail->used;
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;
}
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 */
}
+/**
+ * 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],
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.