radeonsi: force NaNs to 0
[mesa.git] / src / gallium / drivers / llvmpipe / lp_scene.h
index fff849fe5180b5d7356c164d29edb2f5a832eec5..19a38115afeb55eea491831ccc52594b70b999e2 100644 (file)
 #define LP_SCENE_H
 
 #include "os/os_thread.h"
-#include "lp_tile_soa.h"
 #include "lp_rast.h"
 #include "lp_debug.h"
 
 struct lp_scene_queue;
+struct lp_rast_state;
 
 /* We're limited to 2K by 2K for 32bit fixed point rasterization.
  * Will need a 64-bit version for larger framebuffers.
@@ -49,12 +49,18 @@ struct lp_scene_queue;
 #define TILES_Y (LP_MAX_HEIGHT / TILE_SIZE)
 
 
-#define CMD_BLOCK_MAX 128
-#define DATA_BLOCK_SIZE (64 * 1024 - 2 * sizeof(void *))
+/* Commands per command block (ideally so sizeof(cmd_block) is a power of
+ * two in size.)
+ */
+#define CMD_BLOCK_MAX 29
+
+/* Bytes per data block.
+ */
+#define DATA_BLOCK_SIZE (64 * 1024)
 
 /* Scene temporary storage is clamped to this size:
  */
-#define LP_SCENE_MAX_SIZE (4*1024*1024)
+#define LP_SCENE_MAX_SIZE (9*1024*1024)
 
 /* The maximum amount of texture storage referenced by a scene is
  * clamped ot this size:
@@ -75,10 +81,6 @@ struct cmd_block {
    struct cmd_block *next;
 };
 
-struct cmd_block_list {
-   struct cmd_block *head;
-   struct cmd_block *tail;
-};
 
 struct data_block {
    ubyte data[DATA_BLOCK_SIZE];
@@ -92,8 +94,7 @@ struct data_block {
  * For each screen tile we have one of these bins.
  */
 struct cmd_bin {
-   ushort x;
-   ushort y;
+   const struct lp_rast_state *last_state;       /* most recent state set in bin */
    struct cmd_block *head;
    struct cmd_block *tail;
 };
@@ -128,15 +129,24 @@ struct lp_scene {
    struct pipe_context *pipe;
    struct lp_fence *fence;
 
+   /* The queries still active at end of scene */
+   struct llvmpipe_query *active_queries[LP_MAX_ACTIVE_BINNED_QUERIES];
+   unsigned num_active_queries;
+   /* If queries were either active or there were begin/end query commands */
+   boolean had_queries;
+
    /* Framebuffer mappings - valid only between begin_rasterization()
     * and end_rasterization().
     */
    struct {
       uint8_t *map;
       unsigned stride;
-      unsigned blocksize;
+      unsigned layer_stride;
    } zsbuf, cbufs[PIPE_MAX_COLOR_BUFS];
-   
+
+   /* The amount of layers in the fb (minimum of all attachments) */
+   unsigned fb_max_layer;
+
    /** the framebuffer to render the scene into */
    struct pipe_framebuffer_state fb;
 
@@ -155,8 +165,7 @@ struct lp_scene {
    unsigned resource_reference_size;
 
    boolean alloc_failed;
-   boolean has_depthstencil_clear;
-
+   boolean discard;
    /**
     * Number of active tiles in each dimension.
     * This basically the framebuffer size divided by tile size
@@ -207,7 +216,7 @@ lp_scene_alloc( struct lp_scene *scene, unsigned size)
    assert(block != NULL);
 
    if (LP_DEBUG & DEBUG_MEM)
-      debug_printf("alloc %u block %u/%lu tot %u/%u\n",
+      debug_printf("alloc %u block %u/%u tot %u/%u\n",
                   size, block->used, DATA_BLOCK_SIZE,
                   scene->scene_size, LP_SCENE_MAX_SIZE);
 
@@ -240,7 +249,7 @@ lp_scene_alloc_aligned( struct lp_scene *scene, unsigned size,
    assert(block != NULL);
 
    if (LP_DEBUG & DEBUG_MEM)
-      debug_printf("alloc %u block %u/%lu tot %u/%u\n",
+      debug_printf("alloc %u block %u/%u tot %u/%u\n",
                   size + alignment - 1,
                   block->used, DATA_BLOCK_SIZE,
                   scene->scene_size, LP_SCENE_MAX_SIZE);
@@ -297,7 +306,7 @@ lp_scene_bin_command( struct lp_scene *scene,
 
    assert(x < scene->tiles_x);
    assert(y < scene->tiles_y);
-   assert(cmd <= LP_RAST_OP_END_QUERY);
+   assert(cmd < LP_RAST_OP_MAX);
 
    if (tail == NULL || tail->count == CMD_BLOCK_MAX) {
       tail = lp_scene_new_cmd_block( scene, bin );
@@ -318,6 +327,30 @@ lp_scene_bin_command( struct lp_scene *scene,
 }
 
 
+static INLINE boolean
+lp_scene_bin_cmd_with_state( struct lp_scene *scene,
+                             unsigned x, unsigned y,
+                             const struct lp_rast_state *state,
+                             unsigned cmd,
+                             union lp_rast_cmd_arg arg )
+{
+   struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
+
+   if (state != bin->last_state) {
+      bin->last_state = state;
+      if (!lp_scene_bin_command(scene, x, y,
+                                LP_RAST_OP_SET_STATE,
+                                lp_rast_arg_state(state)))
+         return FALSE;
+   }
+
+   if (!lp_scene_bin_command( scene, x, y, cmd, arg ))
+      return FALSE;
+
+   return TRUE;
+}
+
+
 /* Add a command to all active bins.
  */
 static INLINE boolean
@@ -348,7 +381,7 @@ void
 lp_scene_bin_iter_begin( struct lp_scene *scene );
 
 struct cmd_bin *
-lp_scene_bin_iter_next( struct lp_scene *scene );
+lp_scene_bin_iter_next( struct lp_scene *scene, int *x, int *y );
 
 
 
@@ -356,7 +389,8 @@ lp_scene_bin_iter_next( struct lp_scene *scene );
  */
 void
 lp_scene_begin_binning( struct lp_scene *scene,
-                        struct pipe_framebuffer_state *fb );
+                        struct pipe_framebuffer_state *fb,
+                        boolean discard );
 
 void
 lp_scene_end_binning( struct lp_scene *scene );