Squashed commit of the following:
[mesa.git] / src / gallium / drivers / llvmpipe / lp_scene.h
index 7255727785126f2f8991ba94cb7677fc22d26807..a1fb8bf541b8ebf0d5ac79ed4f177bb07d97bb37 100644 (file)
 #ifndef LP_SCENE_H
 #define LP_SCENE_H
 
-#include "pipe/p_thread.h"
+#include "os/os_thread.h"
 #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.
@@ -56,8 +57,7 @@
 
 /* switch to a non-pointer value for this:
  */
-typedef void (*lp_rast_cmd)( struct lp_rasterizer *,
-                             unsigned thread_index,
+typedef void (*lp_rast_cmd)( struct lp_rasterizer_task *,
                              const union lp_rast_cmd_arg );
 
 struct cmd_block {
@@ -97,6 +97,13 @@ struct data_block_list {
 };
 
 
+/** List of texture references */
+struct texture_ref {
+   struct pipe_resource *texture;
+   struct texture_ref *prev, *next;  /**< linked list w/ u_simple_list.h */
+};
+
+
 /**
  * All bins and bin data are contained here.
  * Per-bin data goes into the 'tile' bins.
@@ -106,12 +113,19 @@ struct data_block_list {
  * scenes:
  */
 struct lp_scene {
-   struct cmd_bin tile[TILES_X][TILES_Y];
-   struct data_block_list data;
+   struct pipe_context *pipe;
+
+   /* Scene's buffers are mapped at the time the scene is enqueued:
+    */
+   void *cbuf_map[PIPE_MAX_COLOR_BUFS];
+   uint8_t *zsbuf_map;
 
    /** the framebuffer to render the scene into */
    struct pipe_framebuffer_state fb;
 
+   /** list of textures referenced by the scene commands */
+   struct texture_ref textures;
+
    boolean write_depth;
 
    /**
@@ -122,25 +136,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 );
 
@@ -150,6 +167,12 @@ 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_resource *texture );
+
+boolean lp_scene_is_resource_referenced( const struct lp_scene *scene,
+                                        const struct pipe_resource *texture );
+
 
 /**
  * Allocate space for a command/data in the bin's data buffer.
@@ -215,6 +238,10 @@ lp_scene_get_bin(struct lp_scene *scene, unsigned x, unsigned y)
 }
 
 
+/** Remove all commands from a bin */
+void
+lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y);
+
 
 /* Add a command to bin[x][y].
  */
@@ -227,6 +254,9 @@ lp_scene_bin_command( struct lp_scene *scene,
    struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
    struct cmd_block_list *list = &bin->commands;
 
+   assert(x < scene->tiles_x);
+   assert(y < scene->tiles_y);
+
    if (list->tail->count == CMD_BLOCK_MAX) {
       lp_bin_new_cmd_block( list );
    }
@@ -274,5 +304,13 @@ lp_scene_bin_iter_begin( struct lp_scene *scene );
 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,
+                    boolean write_depth );
+
+void
+lp_scene_begin_binning( struct lp_scene *scene,
+                        struct pipe_framebuffer_state *fb );
 
 #endif /* LP_BIN_H */