llvmpipe: calculate overall width and height, pass to rasterizer
authorKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 09:24:19 +0000 (10:24 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 9 Oct 2009 09:24:19 +0000 (10:24 +0100)
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_rast_priv.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_setup_context.h

index 695ddc089a46f7f8c70d298c0a185a3be2baedb9..6ac44feb4c709ae19a694d85a5abd799d18fbb46 100644 (file)
@@ -48,6 +48,17 @@ struct lp_rasterizer *lp_rast_create( void )
    return rast;
 }
 
+
+void lp_rast_begin( struct lp_rasterizer *rast,
+                    unsigned width,
+                    unsigned height )
+{
+   rast->width = width;
+   rast->height = height;
+   rast->check_for_clipped_tiles = (width % TILESIZE != 0 ||
+                                    height % TILESIZE != 0);
+}
+
 void lp_rast_bind_color( struct lp_rasterizer *rast,
                          struct pipe_surface *cbuf,
                          boolean write_color )
@@ -195,8 +206,7 @@ void lp_rast_shade_quads( struct lp_rasterizer *rast,
  */
 
 
-void lp_rast_end_tile( struct lp_rasterizer *rast,
-                       boolean write_depth )
+void lp_rast_end_tile( struct lp_rasterizer *rast )
 {
    struct pipe_surface *surface;
    struct pipe_screen *screen;
@@ -213,10 +223,10 @@ void lp_rast_end_tile( struct lp_rasterizer *rast,
 
    screen = surface->texture->screen;
 
-   if(x + w > surface->width)
-      w = surface->width - x;
-   if(y + h > surface->height)
-      h = surface->height - y;
+   if(x + w > rast->width)
+      w = rast->width - x;
+   if(y + h > rast->height)
+      h = rast->height - y;
 
    transfer = screen->get_tex_transfer(screen,
                                        surface->texture,
@@ -240,7 +250,7 @@ void lp_rast_end_tile( struct lp_rasterizer *rast,
 
    screen->tex_transfer_destroy(transfer);
 
-   if (write_depth) {
+   if (0) {
       /* FIXME: call u_tile func to store depth/stencil to surface */
    }
 }
index 64d668f998360da85074e6f7819318c4a65d4294..26d057beb29dc3a4568128348d9453af23e4e108 100644 (file)
@@ -97,6 +97,11 @@ struct lp_rast_triangle {
    float dx23;
    float dx31;
 
+   /* XXX: these are only used inside lp_setup_tri.c, don't really
+    * need to bin them:
+    */
+   float oneoverarea;
+
    /* inputs for the shader */
    struct lp_rast_shader_inputs inputs;
 };
@@ -105,13 +110,17 @@ struct lp_rast_triangle {
 
 struct lp_rasterizer *lp_rast_create( void );
 
+void lp_rast_begin( struct lp_rasterizer *,
+                    unsigned width,
+                    unsigned height);
+
 void lp_rast_bind_color( struct lp_rasterizer *,
                          struct pipe_surface *cbuf,
                          boolean write_when_done );
 
-void lp_rast_bind_depth( struct lp_rasterizer *,
-                         struct pipe_surface *zsbuf,
-                         boolean write_when_done );
+void lp_rast_bind_zstencil( struct lp_rasterizer *,
+                            struct pipe_surface *zsbuf,
+                            boolean write_when_done );
 
 /* Begining of each tile:
  */
index 29e4c8fd800765ac9507b0fcc5c19d5915391bf9..d7a8b9c257d944b5085fddc6bc492bb103c096d7 100644 (file)
@@ -52,7 +52,11 @@ struct lp_rasterizer {
       
    unsigned x;
    unsigned y;
+   boolean clipped_tile;
 
+   boolean check_for_clipped_tiles;
+   unsigned width;
+   unsigned height;
    
    struct {
       struct pipe_surface *cbuf;
index 9f1b3d21f092e8ee295a7abafe2afffab357a8ed..4f100808165512c636b720b267904eab41273172 100644 (file)
@@ -160,13 +160,23 @@ rasterize_bins( struct setup_context *setup,
    struct cmd_block *block;
    unsigned i,j,k;
 
+   if (setup->state != SETUP_ACTIVE) {
+      /* this can happen, not a big deal */
+      debug_printf("%s called when not binning\n", __FUNCTION__);
+      return;
+   }
+
+   lp_rast_begin( rast,
+                  setup->fb.width,
+                  setup->fb.height );
+
    lp_rast_bind_color( rast, 
                        setup->fb.cbuf, 
-                       TRUE );                    /* WRITE */
+                       setup->fb.cbuf != NULL );
                        
-   lp_rast_bind_depth( rast,
-                       setup->fb.zsbuf,
-                       write_depth );             /* WRITE */
+   lp_rast_bind_zstencil( rast,
+                          setup->fb.zsbuf,
+                          setup->fb.zsbuf != NULL && write_depth );
 
    for (i = 0; i < setup->tiles_x; i++) {
       for (j = 0; j < setup->tiles_y; j++) {
@@ -193,15 +203,38 @@ rasterize_bins( struct setup_context *setup,
 static void
 begin_binning( struct setup_context *setup )
 {
+   if (!setup->fb.cbuf && !setup->fb.zsbuf) {
+      setup->fb.width = 0;
+      setup->fb.height = 0;
+   }
+   else if (!setup->fb.zsbuf) {
+      setup->fb.width = setup->fb.cbuf->width;
+      setup->fb.height = setup->fb.cbuf->height;
+   }
+   else if (!setup->fb.cbuf) {
+      setup->fb.width = setup->fb.zsbuf->width;
+      setup->fb.height = setup->fb.zsbuf->height;
+   }
+   else {
+      /* XXX: not sure what we're really supposed to do for
+       * mis-matched color & depth buffer sizes.
+       */
+      setup->fb.width = MIN2(setup->fb.cbuf->width,
+                             setup->fb.zsbuf->width);
+      setup->fb.height = MIN2(setup->fb.cbuf->height,
+                              setup->fb.zsbuf->height);
+   }
+
+   setup->tiles_x = align(setup->fb.width, TILESIZE);
+   setup->tiles_y = align(setup->fb.height, TILESIZE);
+
    if (setup->fb.cbuf) {
       if (setup->clear.flags & PIPE_CLEAR_COLOR)
          bin_everywhere( setup, 
                          lp_rast_clear_color, 
                          &setup->clear.color );
       else
-         bin_everywhere( setup, 
-                         lp_rast_load_color, 
-                         NULL );
+         bin_everywhere( setup, lp_rast_load_color, NULL );
    }
 
    if (setup->fb.zsbuf) {
@@ -210,9 +243,7 @@ begin_binning( struct setup_context *setup )
                          lp_rast_clear_zstencil, 
                          &setup->clear.zstencil );
       else
-         bin_everywhere( setup, 
-                         lp_rast_load_zstencil, 
-                         NULL );
+         bin_everywhere( setup, lp_rast_load_zstencil, NULL );
    }
 }
 
index 04f9f878926a85f4b5c843386858a9247119380e..bd439fa8578bbfdf03fb8cb6295938eed1c4cc83 100644 (file)
@@ -37,9 +37,15 @@ enum lp_interp {
    LP_INTERP_FACING
 };
 
+/* Describes how to generate all the fragment shader inputs from the
+ * the vertices passed into our triangle/line/point functions.
+ *
+ * Vertices are treated as an array of float[4] values, indexed by
+ * src_index.
+ */
 struct lp_shader_input {
-   enum lp_interp interp;
-   unsigned vs_output;
+   enum lp_interp interp;       /* how to interpolate values */
+   unsigned src_index;          /* where to find values in incoming vertices */
 };
 
 struct pipe_texture;
index 37caeed85fda5b8575243210920b3a623bc1febd..7410ac70b8166ce28f11d9cb9cfe0bbfcb79c629 100644 (file)
@@ -87,6 +87,8 @@ struct setup_context {
    struct {
       struct pipe_surface *cbuf;
       struct pipe_surface *zsbuf;
+      unsigned width;
+      unsigned height;
    } fb;
 
    struct {