From 2dbba8b024720c11cb2d812b5ccb61ecb9887faa Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Fri, 12 Oct 2007 13:57:53 -0400 Subject: Implement the conversion and do the initial execution pass. --- src/mesa/pipe/llvm/llvm_builtins.c | 90 ++++++++++++++++++++++++++++++++++++++ src/mesa/pipe/llvm/llvmtgsi.cpp | 6 ++- src/mesa/pipe/llvm/llvmtgsi.h | 6 ++- 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/mesa/pipe/llvm/llvm_builtins.c (limited to 'src/mesa/pipe/llvm') diff --git a/src/mesa/pipe/llvm/llvm_builtins.c b/src/mesa/pipe/llvm/llvm_builtins.c new file mode 100644 index 0000000000..0f0efeb303 --- /dev/null +++ b/src/mesa/pipe/llvm/llvm_builtins.c @@ -0,0 +1,90 @@ + + +inline float4 compute_clip(float4 vec, float4 scale, float4 trans) +{ + return vec*scale + trans; +} + + +inline float +dot4(const float4 a, const float4 b) +{ + float4 c = a*b; + return c.x + c.y + c.z + c.w; +} + +inline unsigned +compute_clipmask(float4 clip, const float4 (*plane), unsigned nr) +{ + unsigned mask = 0; + unsigned i; + + for (i = 0; i < nr; i++) { + if (dot4(clip, plane[i]) < 0) + mask |= (1<clip[0] = clip.x; + y = vOut->clip[1] = clip.y; + z = vOut->clip[2] = clip.z; + w = vOut->clip[3] = clip.w; + + vOut[i]->clipmask = compute_clipmask(res0, planes, nr_planes); + vOut[i]->edgeflag = 1; + + /* divide by w */ + w = 1.0f / w; + x *= w; + y *= w; + z *= w; + res0.x = x; res0.y = y; res0.z = z; res0.w = 1; + + /* Viewport mapping */ + res = res * scale + trans; + vOut->data[0][0] = res.x; + vOut->data[0][1] = res.y; + vOut->data[0][2] = res.z; + vOut->data[0][3] = w; + + /* Remaining attributes are packed into sequential post-transform + * vertex attrib slots. + * Skip 0 since we just did it above. + * Subtract two because of the VERTEX_HEADER, CLIP_POS attribs. + */ + for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) { + float4 vec = results[slot]; + vOut->data[slot][0] = vec.x; + vOut->data[slot][1] = vec.y; + vOut->data[slot][2] = vec.z; + vOut->data[slot][3] = vec.w; + + printf("output %d: %f %f %f %f\n", slot, + vOut->data[slot][0], + vOut->data[slot][1], + vOut->data[slot][2], + vOut->data[slot][3]); + } +} + +void run_vertex_shader(float ainputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS][4], + struct vertex_header *dests[VS_QUEUE_LENGTH], + float *aconsts[4] + int count) +{ + float4 inputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS]; + float4 *consts; +} diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index 2221a2c353..46b7561b5e 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -426,7 +426,11 @@ void ga_llvm_prog_delete(struct ga_llvm_prog *prog) free(prog); } -int ga_llvm_prog_exec(struct ga_llvm_prog *prog) +int ga_llvm_prog_exec(struct ga_llvm_prog *prog, + float (*inputs)[32][4], + void *dests[16*32*4], + float (*consts)[4], + int count) { //std::cout << "START "<(prog->module); diff --git a/src/mesa/pipe/llvm/llvmtgsi.h b/src/mesa/pipe/llvm/llvmtgsi.h index c0cee915b9..9fbb0ea8f9 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.h +++ b/src/mesa/pipe/llvm/llvmtgsi.h @@ -18,7 +18,11 @@ ga_llvm_from_tgsi(const struct tgsi_token *tokens); void ga_llvm_prog_delete(struct ga_llvm_prog *prog); -int ga_llvm_prog_exec(struct ga_llvm_prog *prog); +int ga_llvm_prog_exec(struct ga_llvm_prog *prog, + float (*inputs)[32][4], + void *dests[16*32*4], + float (*consts)[4], + int count); #if defined __cplusplus } // extern "C" -- cgit v1.2.3