diff options
author | Zack Rusin <zackr@vmware.com> | 2010-07-06 12:35:23 -0400 |
---|---|---|
committer | Zack Rusin <zackr@vmware.com> | 2010-07-06 13:29:04 -0400 |
commit | ca88683459016d2cdc82175c718ee429e9440cf0 (patch) | |
tree | 581ff799a3f79af4c8370f705485eb7001c6997d /src | |
parent | 01eebfe1b6de2e36dd3af0952fc8329b7073a100 (diff) |
draw: make sure softpipe doesn't crash with vertex tex sampling
softpipe doesn't implement the draw's llvm tex sampling interface
so make sure draw can handle the cases where the driver doesn't
implement the interface
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 42653d36ec..facdafcc01 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -307,11 +307,12 @@ generate_vs(struct draw_llvm *llvm, LLVMValueRef (*outputs)[NUM_CHANNELS], const LLVMValueRef (*inputs)[NUM_CHANNELS], LLVMValueRef context_ptr, - struct lp_build_sampler_soa *sampler) + struct lp_build_sampler_soa *draw_sampler) { const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens; struct lp_type vs_type; LLVMValueRef consts_ptr = draw_jit_context_vs_constants(builder, context_ptr); + struct lp_build_sampler_soa *sampler = 0; memset(&vs_type, 0, sizeof vs_type); vs_type.floating = TRUE; /* floating point values */ @@ -327,6 +328,10 @@ generate_vs(struct draw_llvm *llvm, tgsi_dump(tokens, 0); } + if (llvm->draw->num_sampler_views && + llvm->draw->num_samplers) + sampler = draw_sampler; + lp_build_tgsi_soa(builder, tokens, vs_type, @@ -972,12 +977,16 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, &llvm->draw->vs.vertex_shader->state, sizeof(struct pipe_shader_state)); - for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i) { - struct draw_vertex_shader *shader = llvm->draw->vs.vertex_shader; - if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) - lp_sampler_static_state(&key->sampler[i], - llvm->draw->sampler_views[i], - llvm->draw->samplers[i]); + /* if the driver implemented the sampling hooks then + * setup our sampling state */ + if (llvm->draw->num_sampler_views && llvm->draw->num_samplers) { + for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i) { + struct draw_vertex_shader *shader = llvm->draw->vs.vertex_shader; + if(shader->info.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) + lp_sampler_static_state(&key->sampler[i], + llvm->draw->sampler_views[i], + llvm->draw->samplers[i]); + } } } |