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 3e8c410..b486b24 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 add43e4..588cda5 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 0d40dc5..f920607 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 e6a8196..6674d28 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 5b39d9d..6bba907 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 715ce2f..17a4a0e 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 4b135aa..cd1a5b1 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 65208dd..4e026cc 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],