summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-11-30 16:07:52 -0700
committerBrian Paul <brianp@vmware.com>2010-11-30 16:35:12 -0700
commitefc82aef35a2aac5d2ed9774f6d28f2626796416 (patch)
tree72fe4482d72dbeb8e41b15793b21f38de62ef834 /src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
parent1f1375d4d876c2c85156e02a177254684446040b (diff)
gallivm/llvmpipe: squash merge of the llvm-context branch
This branch defines a gallivm_state structure which contains the LLVMBuilderRef, LLVMContextRef, etc. All data structures built with this object can be periodically freed during a "garbage collection" operation. The gallivm_state object has to be passed to most of the builder functions where LLVMBuilderRef used to be used. Conflicts: src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c src/gallium/drivers/llvmpipe/lp_state_setup.c
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c27
1 files changed, 17 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 a53a768d02..2e3afb22c4 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
@@ -34,6 +34,7 @@
#include "draw/draw_pt.h"
#include "draw/draw_vs.h"
#include "draw/draw_llvm.h"
+#include "gallivm/lp_bld_init.h"
struct llvm_middle_end {
@@ -72,19 +73,18 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
struct draw_llvm_variant_list_item *li;
unsigned i;
unsigned instance_id_index = ~0;
-
-
- unsigned out_prim = (draw->gs.geometry_shader ?
- draw->gs.geometry_shader->output_primitive :
- in_prim);
+ const unsigned out_prim = (draw->gs.geometry_shader ?
+ draw->gs.geometry_shader->output_primitive :
+ in_prim);
/* Add one to num_outputs because the pipeline occasionally tags on
* an additional texcoord, eg for AA lines.
*/
- unsigned nr = MAX2( shader->base.info.num_inputs,
- shader->base.info.num_outputs + 1 );
+ const unsigned nr = MAX2( shader->base.info.num_inputs,
+ shader->base.info.num_outputs + 1 );
/* Scan for instanceID system value.
+ * XXX but we never use instance_id_index?!
*/
for (i = 0; i < shader->base.info.num_inputs; i++) {
if (shader->base.info.input_semantic_name[i] == TGSI_SEMANTIC_INSTANCEID) {
@@ -133,9 +133,10 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
key = draw_llvm_make_variant_key(fpme->llvm, store);
+ /* Search shader's list of variants for the key */
li = first_elem(&shader->variants);
- while(!at_end(&shader->variants, li)) {
- if(memcmp(&li->base->key, key, shader->variant_key_size) == 0) {
+ while (!at_end(&shader->variants, li)) {
+ if (memcmp(&li->base->key, key, shader->variant_key_size) == 0) {
variant = li->base;
break;
}
@@ -143,10 +144,16 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle,
}
if (variant) {
+ /* found the variant, move to head of global list (for LRU) */
move_to_head(&fpme->llvm->vs_variants_list, &variant->list_item_global);
}
else {
+ /* Need to create new variant */
unsigned i;
+
+ /* First check if we've created too many variants. If so, free
+ * 25% of the LRU to avoid using too much memory.
+ */
if (fpme->llvm->nr_variants >= DRAW_MAX_SHADER_VARIANTS) {
/*
* XXX: should we flush here ?
@@ -422,7 +429,7 @@ draw_pt_fetch_pipeline_or_emit_llvm(struct draw_context *draw)
{
struct llvm_middle_end *fpme = 0;
- if (!draw->engine)
+ if (!draw->llvm->gallivm->engine)
return NULL;
fpme = CALLOC_STRUCT( llvm_middle_end );