llvmpipe: add LP_PERF flag to disable various aspects of rasterization
authorKeith Whitwell <keithw@vmware.com>
Thu, 16 Sep 2010 09:45:52 +0000 (10:45 +0100)
committerKeith Whitwell <keithw@vmware.com>
Thu, 16 Sep 2010 16:34:19 +0000 (17:34 +0100)
Allows disabling various operations (mainly texture-related, but
will grow) to try & identify bottlenecks.

Unlike LP_DEBUG, this is active even in release builds - which is
necessary for performance investigation.

src/gallium/drivers/llvmpipe/lp_clear.c
src/gallium/drivers/llvmpipe/lp_debug.h
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_state_surface.c
src/gallium/drivers/llvmpipe/lp_tex_sample.c

index 3e8c4109251bf6a96dfba285eed17c5feb3f3d17..b486b243eb5e0ba19c47e426ede5617d65177c29 100644 (file)
@@ -36,6 +36,7 @@
 #include "lp_clear.h"
 #include "lp_context.h"
 #include "lp_setup.h"
+#include "lp_debug.h"
 
 
 /**
@@ -54,5 +55,8 @@ llvmpipe_clear(struct pipe_context *pipe,
    if (llvmpipe->no_rast)
       return;
 
+   if (LP_PERF & PERF_NO_DEPTH)
+      buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
+
    lp_setup_clear( llvmpipe->setup, rgba, depth, stencil, buffers );
 }
index add43e4fca295ca2f3abd4791a7a6c566603a132..588cda52ad040df9011b0df346c29321439e0540 100644 (file)
@@ -50,6 +50,19 @@ st_print_current(void);
 #define DEBUG_FENCE         0x2000
 #define DEBUG_MEM           0x4000
 
+/* Performance flags.  These are active even on release builds.
+ */
+#define PERF_TEX_MEM        0x1        /* minimize texture cache footprint */
+#define PERF_NO_MIP_LINEAR  0x2        /* MIP_FILTER_LINEAR ==> _NEAREST */
+#define PERF_NO_MIPMAPS     0x4        /* MIP_FILTER_NONE always */
+#define PERF_NO_LINEAR      0x8        /* FILTER_NEAREST always */
+#define PERF_NO_TEX         0x10       /* sample white always */
+#define PERF_NO_BLEND       0x20       /* disable blending */
+#define PERF_NO_DEPTH       0x40       /* disable depth buffering entirely */
+#define PERF_NO_ALPHATEST   0x80       /* disable alpha testing */
+
+
+extern int LP_PERF;
 
 #ifdef DEBUG
 extern int LP_DEBUG;
index 0d40dc50201c9132943afc5c9ea4ee580050c9f9..f920607d05320281915a5f79183b2d4c3e64b696 100644 (file)
@@ -68,6 +68,19 @@ static const struct debug_named_value lp_debug_flags[] = {
 };
 #endif
 
+int LP_PERF = 0;
+static const struct debug_named_value lp_perf_flags[] = {
+   { "texmem",         PERF_TEX_MEM, NULL },
+   { "no_mipmap",      PERF_NO_MIPMAPS, NULL },
+   { "no_linear",      PERF_NO_LINEAR, NULL },
+   { "no_mip_linear",  PERF_NO_MIP_LINEAR, NULL },
+   { "no_tex",         PERF_NO_TEX, NULL },
+   { "no_blend",       PERF_NO_BLEND, NULL },
+   { "no_depth",       PERF_NO_DEPTH, NULL },
+   { "no_alphatest",   PERF_NO_ALPHATEST, NULL },
+   DEBUG_NAMED_VALUE_END
+};
+
 
 static const char *
 llvmpipe_get_vendor(struct pipe_screen *screen)
@@ -372,6 +385,8 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
    LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
 #endif
 
+   LP_PERF = debug_get_flags_option("LP_PERF", lp_perf_flags, 0 );
+
    if (!screen)
       return NULL;
 
index e6a8196761549bedd4ddf89575bb13909db3a491..6674d281d1e2c14965962b8ab3fd0594a7520a5d 100644 (file)
@@ -651,11 +651,12 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                jit_tex->row_stride[j] = lp_tex->row_stride[j];
                jit_tex->img_stride[j] = lp_tex->img_stride[j];
 
-               if (!jit_tex->data[j]) {
+               if ((LP_PERF & PERF_TEX_MEM) ||
+                  !jit_tex->data[j]) {
                   /* out of memory - use dummy tile memory */
                   jit_tex->data[j] = lp_dummy_tile;
-                  jit_tex->width = TILE_SIZE;
-                  jit_tex->height = TILE_SIZE;
+                  jit_tex->width = TILE_SIZE/8;
+                  jit_tex->height = TILE_SIZE/8;
                   jit_tex->depth = 1;
                   jit_tex->last_level = 0;
                   jit_tex->row_stride[j] = 0;
index 5b39d9d1a91aa4a599e7f6f28db56ff80921a9b4..6bba9077d1b5a88c5ebde9d8c2f2b4661bb118db 100644 (file)
 #include "lp_screen.h"
 #include "lp_context.h"
 #include "lp_state.h"
+#include "lp_debug.h"
 
 
 static void *
 llvmpipe_create_blend_state(struct pipe_context *pipe,
                             const struct pipe_blend_state *blend)
 {
-   return mem_dup(blend, sizeof(*blend));
+   struct pipe_blend_state *state = mem_dup(blend, sizeof *blend);
+   int i;
+
+   if (LP_PERF & PERF_NO_BLEND) {
+      state->independent_blend_enable = 0;
+      for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
+        state->rt[i].blend_enable = 0;
+   }
+
+   return state;
 }
 
 
@@ -100,7 +110,22 @@ static void *
 llvmpipe_create_depth_stencil_state(struct pipe_context *pipe,
                                    const struct pipe_depth_stencil_alpha_state *depth_stencil)
 {
-   return mem_dup(depth_stencil, sizeof(*depth_stencil));
+   struct pipe_depth_stencil_alpha_state *state;
+
+   state = mem_dup(depth_stencil, sizeof *depth_stencil);
+
+   if (LP_PERF & PERF_NO_DEPTH) {
+      state->depth.enabled = 0;
+      state->depth.writemask = 0;
+      state->stencil[0].enabled = 0;
+      state->stencil[1].enabled = 0;
+   }
+
+   if (LP_PERF & PERF_NO_ALPHATEST) {
+      state->alpha.enabled = 0;
+   }
+
+   return state;
 }
 
 
index 715ce2f02e4e8dd4909ccb2f63a99a0657f6ba35..17a4a0ed02d2c12d8f726373b264b73687235604 100644 (file)
@@ -37,6 +37,7 @@
 #include "lp_context.h"
 #include "lp_screen.h"
 #include "lp_state.h"
+#include "lp_debug.h"
 #include "state_tracker/sw_winsys.h"
 
 
@@ -44,7 +45,22 @@ static void *
 llvmpipe_create_sampler_state(struct pipe_context *pipe,
                               const struct pipe_sampler_state *sampler)
 {
-   return mem_dup(sampler, sizeof(*sampler));
+   struct pipe_sampler_state *state = mem_dup(sampler, sizeof *sampler);
+
+   if (LP_PERF & PERF_NO_MIP_LINEAR) {
+      if (state->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR)
+        state->min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
+   }
+
+   if (LP_PERF & PERF_NO_MIPMAPS)
+      state->min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
+
+   if (LP_PERF & PERF_NO_LINEAR) {
+      state->mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+      state->min_img_filter = PIPE_TEX_FILTER_NEAREST;
+   }
+
+   return state;
 }
 
 
index 4b135aaf8ba575126c3eb8c607b9f57efcdf01c2..cd1a5b19803f841d4d03f8c1ee85881c21711d60 100644 (file)
@@ -60,6 +60,10 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe,
 
       util_copy_framebuffer_state(&lp->framebuffer, fb);
 
+      if (LP_PERF & PERF_NO_DEPTH) {
+        pipe_surface_reference(&lp->framebuffer.zsbuf, NULL);
+      }
+
       /* Tell draw module how deep the Z/depth buffer is */
       if (lp->framebuffer.zsbuf) {
          int depth_bits;
index 65208dd5d5c9484ab35182185a8300e5862b8c1d..4e026cc8ffbbbd7810603d0dcabf507754dd5187 100644 (file)
@@ -48,6 +48,7 @@
 #include "gallivm/lp_bld_tgsi.h"
 #include "lp_jit.h"
 #include "lp_tex_sample.h"
+#include "lp_debug.h"
 
 
 /**
@@ -179,6 +180,11 @@ lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
    struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base;
 
    assert(unit < PIPE_MAX_SAMPLERS);
+   
+   if (LP_PERF & PERF_NO_TEX) {
+      lp_build_sample_nop(type, texel);
+      return;
+   }
 
    lp_build_sample_soa(builder,
                        &sampler->dynamic_state.static_state[unit],