diff options
author | Zack Rusin <[email protected]> | 2010-03-31 22:15:12 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2010-03-31 22:15:12 -0400 |
commit | ae5487d4276007e466b6a7c783d6fb740f9539c5 (patch) | |
tree | 0886144bd2a074551d938dec47a41f7fb7ec0dcf /src/gallium/auxiliary/draw/draw_llvm.c | |
parent | 880e3fb09b538f6f0b6fad2db7e0e10e9df43555 (diff) |
draw llvm: fix iteration over buffers
fetching was converting garbage
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_llvm.c')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 6347acb0b96..2978621826b 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -10,6 +10,7 @@ #include "gallivm/lp_bld_flow.h" #include "gallivm/lp_bld_debug.h" #include "gallivm/lp_bld_tgsi.h" +#include "gallivm/lp_bld_printf.h" #include "util/u_cpu_detect.h" @@ -229,6 +230,23 @@ generate_vs(struct draw_llvm *llvm, NULL/*sampler*/); } + +static void print_vectorf(LLVMBuilderRef builder, + LLVMValueRef vec) +{ + LLVMValueRef val[4]; + val[0] = LLVMBuildExtractElement(builder, vec, + LLVMConstInt(LLVMInt32Type(), 0, 0), ""); + val[1] = LLVMBuildExtractElement(builder, vec, + LLVMConstInt(LLVMInt32Type(), 1, 0), ""); + val[2] = LLVMBuildExtractElement(builder, vec, + LLVMConstInt(LLVMInt32Type(), 2, 0), ""); + val[3] = LLVMBuildExtractElement(builder, vec, + LLVMConstInt(LLVMInt32Type(), 3, 0), ""); + lp_build_printf(builder, "vector = [%f, %f, %f, %f]\n", + val[0], val[1], val[2], val[3]); +} + static void generate_fetch(LLVMBuilderRef builder, LLVMValueRef vbuffers_ptr, @@ -244,6 +262,8 @@ generate_fetch(LLVMBuilderRef builder, LLVMConstInt(LLVMInt32Type(), vbuf->stride, 0), index, ""); + vbuffer_ptr = LLVMBuildLoad(builder, vbuffer_ptr, "vbuffer"); + stride = LLVMBuildAdd(builder, stride, LLVMConstInt(LLVMInt32Type(), vbuf->buffer_offset, 0), ""); @@ -251,6 +271,7 @@ generate_fetch(LLVMBuilderRef builder, LLVMConstInt(LLVMInt32Type(), velem->src_offset, 0), ""); + /*lp_build_printf(builder, "vbuf index = %d, stride is %d\n", indices, stride);*/ vbuffer_ptr = LLVMBuildGEP(builder, vbuffer_ptr, &stride, 1, ""); *res = draw_llvm_translate_from(builder, vbuffer_ptr, velem->src_format); @@ -386,6 +407,7 @@ draw_llvm_generate(struct draw_llvm *llvm) end = lp_build_add(&bld, start, count); step = LLVMConstInt(LLVMInt32Type(), max_vertices, 0); + lp_build_loop_begin(builder, start, &lp_loop); { LLVMValueRef inputs[PIPE_MAX_SHADER_INPUTS][NUM_CHANNELS]; @@ -404,6 +426,7 @@ draw_llvm_generate(struct draw_llvm *llvm) velem->vertex_buffer_index]; generate_fetch(builder, vbuffers_ptr, &aos_attribs[j][i], velem, vbuf, true_index); + /*print_vectorf(builder, aos_attribs[j][i]);*/ } } convert_to_soa(builder, aos_attribs, inputs, @@ -416,7 +439,6 @@ draw_llvm_generate(struct draw_llvm *llvm) ptr_aos, context_ptr, io); - LLVMDumpModule(llvm->module); } lp_build_loop_end(builder, end, step, &lp_loop); @@ -441,7 +463,6 @@ draw_llvm_generate(struct draw_llvm *llvm) LLVMDumpValue(function); debug_printf("\n"); } - llvm->jit_func = (draw_jit_vert_func)LLVMGetPointerToGlobal(llvm->draw->engine, function); if (1) |