llvmpipe: make shader-related functions static, clean-up initializations
[mesa.git] / src / gallium / drivers / llvmpipe / lp_scene.h
index 8d725cd4375a7d40ec1698c17ffa13354a653bb1..9467cd6f16d174d6273b8a7d28626bfbb327cd91 100644 (file)
 #include "lp_tile_soa.h"
 #include "lp_rast.h"
 
+struct lp_scene_queue;
 
 /* We're limited to 2K by 2K for 32bit fixed point rasterization.
  * Will need a 64-bit version for larger framebuffers.
  */
-#define MAXHEIGHT 2048
-#define MAXWIDTH 2048
-#define TILES_X (MAXWIDTH / TILE_SIZE)
-#define TILES_Y (MAXHEIGHT / TILE_SIZE)
+#define TILES_X (LP_MAX_WIDTH / TILE_SIZE)
+#define TILES_Y (LP_MAX_HEIGHT / TILE_SIZE)
 
 
 #define CMD_BLOCK_MAX 128
@@ -96,10 +95,10 @@ struct data_block_list {
 };
 
 
-/** List of texture references */
-struct texture_ref {
-   struct pipe_texture *texture;
-   struct texture_ref *prev, *next;  /**< linked list w/ u_simple_list.h */
+/** List of resource references */
+struct resource_ref {
+   struct pipe_resource *resource;
+   struct resource_ref *prev, *next;  /**< linked list w/ u_simple_list.h */
 };
 
 
@@ -112,16 +111,21 @@ struct texture_ref {
  * scenes:
  */
 struct lp_scene {
-   struct cmd_bin tile[TILES_X][TILES_Y];
-   struct data_block_list data;
+   struct pipe_context *pipe;
 
    /** the framebuffer to render the scene into */
    struct pipe_framebuffer_state fb;
 
-   /** list of textures referenced by the scene commands */
-   struct texture_ref textures;
+   /** 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;
 
    /**
     * Number of active tiles in each dimension.
@@ -131,25 +135,28 @@ struct lp_scene {
 
    int curr_x, curr_y;  /**< for iterating over bins */
    pipe_mutex mutex;
+
+   /* Where to place this scene once it has been rasterized:
+    */
+   struct lp_scene_queue *empty_queue;
+
+   struct cmd_bin tile[TILES_X][TILES_Y];
+   struct data_block_list data;
 };
 
 
 
-struct lp_scene *lp_scene_create(void);
+struct lp_scene *lp_scene_create(struct pipe_context *pipe,
+                                 struct lp_scene_queue *empty_queue);
 
 void lp_scene_destroy(struct lp_scene *scene);
 
 
-void lp_scene_init(struct lp_scene *scene);
 
 boolean lp_scene_is_empty(struct lp_scene *scene );
 
 void lp_scene_reset(struct lp_scene *scene );
 
-void lp_scene_free_bin_data(struct lp_scene *scene);
-
-void lp_scene_set_framebuffer_size( struct lp_scene *scene,
-                                  unsigned width, unsigned height );
 
 void lp_bin_new_data_block( struct data_block_list *list );
 
@@ -159,11 +166,11 @@ unsigned lp_scene_data_size( const struct lp_scene *scene );
 
 unsigned lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y );
 
-void lp_scene_texture_reference( struct lp_scene *scene,
-                                 struct pipe_texture *texture );
+void lp_scene_add_resource_reference(struct lp_scene *scene,
+                                     struct pipe_resource *resource);
 
-boolean lp_scene_is_texture_referenced( const struct lp_scene *scene,
-                                        const struct pipe_texture *texture );
+boolean lp_scene_is_resource_referenced(const struct lp_scene *scene,
+                                        const struct pipe_resource *resource );
 
 
 /**
@@ -179,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;
@@ -201,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;
@@ -217,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;
 }
@@ -297,4 +309,20 @@ struct cmd_bin *
 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 );
+
+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 */