summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/llvm
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-10-12 13:57:53 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-10-24 11:21:03 -0400
commit2dbba8b024720c11cb2d812b5ccb61ecb9887faa (patch)
treeed3fd1386378a7e64bf2a2ba7521930f9c973b86 /src/mesa/pipe/llvm
parent11bc1f015a781760c419bdd53b326132b5146971 (diff)
Implement the conversion and do the initial execution pass.
Diffstat (limited to 'src/mesa/pipe/llvm')
-rw-r--r--src/mesa/pipe/llvm/llvm_builtins.c90
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.cpp6
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.h6
3 files changed, 100 insertions, 2 deletions
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<<i);
+ }
+
+ return mask;
+}
+
+inline void collect_results(float4 *results, struct vertex_header *vOut,
+ float4 *planes, int nr_planes,
+ float4 scale, float4 trans)
+{
+ /* store results */
+ unsigned slot;
+ float x, y, z, w;
+
+ /* Handle attr[0] (position) specially:
+ */
+ float4 res0 = results[0];
+ x = vOut->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 "<<std::endl;
llvm::Module *mod = static_cast<llvm::Module*>(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"