summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2015-04-09 00:49:11 +0200
committerRoland Scheidegger <[email protected]>2015-04-09 01:32:30 +0200
commit586536a4e1c34725b3b38c3425db569fac0c91e9 (patch)
tree92392ea54cf37be68e60f92eb207d072e470caeb /src/gallium/drivers/llvmpipe
parent09e7e2016b702e2c4b79a2c01e8abc1365b4c422 (diff)
gallivm: don't use control flow when doing indirect constant buffer lookups
llvm goes crazy when doing that, using way more memory and time, though there's probably more to it - this points to a very much similar issue as fixed in 8a9f5ecdb116d0449d63f7b94efbfa8b205d826f. In any case I've seen a quite plain looking vertex shader with just ~50 simple tgsi instructions (but with a dozen or so such indirect constant buffer lookups) go from a terribly high ~440ms compile time (consuming 25MB of memory in the process) down to a still awful ~230ms and 13MB with this fix (with llvm 3.3), so there's still obvious improvements possible (but I have no clue why it's so slow...). The resulting shader is most likely also faster (certainly seemed so though I don't have any hard numbers as it may have been influenced by compile times) since generally fetching constants outside the buffer range is most likely an app error (that is we expect all indices to be valid). It is possible this fixes some mysterious vertex shader slowdowns we've seen ever since we are conforming to newer apis at least partially (the main draw loop also has similar looking conditionals which we probably could do without - if not for the fetch at least for the additional elts condition.) v2: use static vars for the fake bufs, minor code cleanups Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 3b0056c49cb..96cc77c250c 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -999,6 +999,7 @@ lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
static boolean
try_update_scene_state( struct lp_setup_context *setup )
{
+ static const float fake_const_buf[4];
boolean new_scene = (setup->fs.stored == NULL);
struct lp_scene *scene = setup->scene;
unsigned i;
@@ -1103,14 +1104,15 @@ try_update_scene_state( struct lp_setup_context *setup )
setup->constants[i].stored_size = current_size;
setup->constants[i].stored_data = stored;
}
+ setup->fs.current.jit_context.constants[i] =
+ setup->constants[i].stored_data;
}
else {
setup->constants[i].stored_size = 0;
setup->constants[i].stored_data = NULL;
+ setup->fs.current.jit_context.constants[i] = fake_const_buf;
}
- setup->fs.current.jit_context.constants[i] =
- setup->constants[i].stored_data;
num_constants =
setup->constants[i].stored_size / (sizeof(float) * 4);
setup->fs.current.jit_context.num_constants[i] = num_constants;