summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2015-04-09 00:49:11 +0200
committerRoland Scheidegger <sroland@vmware.com>2015-04-09 01:32:30 +0200
commit586536a4e1c34725b3b38c3425db569fac0c91e9 (patch)
tree92392ea54cf37be68e60f92eb207d072e470caeb /src/gallium/auxiliary/draw
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 <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index 0dfafdca51a..d17d6959b44 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -271,30 +271,38 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
static void
llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
{
+ static const float fake_const_buf[4];
struct llvm_middle_end *fpme = llvm_middle_end(middle);
struct draw_context *draw = fpme->draw;
+ struct draw_llvm *llvm = fpme->llvm;
unsigned i;
- for (i = 0; i < Elements(fpme->llvm->jit_context.vs_constants); ++i) {
+ for (i = 0; i < Elements(llvm->jit_context.vs_constants); ++i) {
int num_consts =
draw->pt.user.vs_constants_size[i] / (sizeof(float) * 4);
- fpme->llvm->jit_context.vs_constants[i] = draw->pt.user.vs_constants[i];
- fpme->llvm->jit_context.num_vs_constants[i] = num_consts;
+ llvm->jit_context.vs_constants[i] = draw->pt.user.vs_constants[i];
+ llvm->jit_context.num_vs_constants[i] = num_consts;
+ if (num_consts == 0) {
+ llvm->jit_context.vs_constants[i] = fake_const_buf;
+ }
}
- for (i = 0; i < Elements(fpme->llvm->gs_jit_context.constants); ++i) {
+ for (i = 0; i < Elements(llvm->gs_jit_context.constants); ++i) {
int num_consts =
draw->pt.user.gs_constants_size[i] / (sizeof(float) * 4);
- fpme->llvm->gs_jit_context.constants[i] = draw->pt.user.gs_constants[i];
- fpme->llvm->gs_jit_context.num_constants[i] = num_consts;
+ llvm->gs_jit_context.constants[i] = draw->pt.user.gs_constants[i];
+ llvm->gs_jit_context.num_constants[i] = num_consts;
+ if (num_consts == 0) {
+ llvm->gs_jit_context.constants[i] = fake_const_buf;
+ }
}
- fpme->llvm->jit_context.planes =
+ llvm->jit_context.planes =
(float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0];
- fpme->llvm->gs_jit_context.planes =
+ llvm->gs_jit_context.planes =
(float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0];
- fpme->llvm->jit_context.viewports = draw->viewports;
- fpme->llvm->gs_jit_context.viewports = draw->viewports;
+ llvm->jit_context.viewports = draw->viewports;
+ llvm->gs_jit_context.viewports = draw->viewports;
}