|
|
@ -6,11 +6,13 @@ public class RenderKernel extends Kernel{ |
|
|
|
|
|
|
|
|
|
|
|
int[] pixels; |
|
|
|
int[] pixels; |
|
|
|
float[] tris; |
|
|
|
float[] tris; |
|
|
|
|
|
|
|
float[] transformedTris; |
|
|
|
|
|
|
|
float[] depthBuffer; |
|
|
|
int[] tex; |
|
|
|
int[] tex; |
|
|
|
int width,tex_width; |
|
|
|
int width,tex_width; |
|
|
|
int height,tex_height; |
|
|
|
int height,tex_height; |
|
|
|
|
|
|
|
|
|
|
|
RenderKernel(int[] pixels,float[] tris,int[] tex,int width,int height,int tex_width,int tex_height) { |
|
|
|
RenderKernel(int[] pixels,float[] tris,int[] tex,int width,int height,int tex_width,int tex_height,float[] depthBuffer) { |
|
|
|
this.pixels=pixels; |
|
|
|
this.pixels=pixels; |
|
|
|
this.tris=tris; |
|
|
|
this.tris=tris; |
|
|
|
this.width=width; |
|
|
|
this.width=width; |
|
|
@ -18,36 +20,41 @@ public class RenderKernel extends Kernel{ |
|
|
|
this.tex=tex; |
|
|
|
this.tex=tex; |
|
|
|
this.tex_width=tex_width; |
|
|
|
this.tex_width=tex_width; |
|
|
|
this.tex_height=tex_height; |
|
|
|
this.tex_height=tex_height; |
|
|
|
|
|
|
|
this.depthBuffer=depthBuffer; |
|
|
|
|
|
|
|
this.transformedTris = new float[this.tris.length]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
|
|
|
|
for (int i=0;i<tris.length;i++) { |
|
|
|
|
|
|
|
transformedTris[i]=tris[i]; |
|
|
|
|
|
|
|
} |
|
|
|
int id = getGlobalId(); |
|
|
|
int id = getGlobalId(); |
|
|
|
float x1=tris[id*21+0]; |
|
|
|
float x1=transformedTris[id*21+0]; |
|
|
|
float y1=tris[id*21+1]; |
|
|
|
float y1=transformedTris[id*21+1]; |
|
|
|
float z1=tris[id*21+2]; |
|
|
|
float z1=transformedTris[id*21+2]; |
|
|
|
float w1=tris[id*21+3]; |
|
|
|
float w1=transformedTris[id*21+3]; |
|
|
|
float x2=tris[id*21+4]; |
|
|
|
float x2=transformedTris[id*21+4]; |
|
|
|
float y2=tris[id*21+5]; |
|
|
|
float y2=transformedTris[id*21+5]; |
|
|
|
float z2=tris[id*21+6]; |
|
|
|
float z2=transformedTris[id*21+6]; |
|
|
|
float w2=tris[id*21+7]; |
|
|
|
float w2=transformedTris[id*21+7]; |
|
|
|
float x3=tris[id*21+8]; |
|
|
|
float x3=transformedTris[id*21+8]; |
|
|
|
float y3=tris[id*21+9]; |
|
|
|
float y3=transformedTris[id*21+9]; |
|
|
|
float z3=tris[id*21+10]; |
|
|
|
float z3=transformedTris[id*21+10]; |
|
|
|
float w3=tris[id*21+11]; |
|
|
|
float w3=transformedTris[id*21+11]; |
|
|
|
float Tu1=tris[id*21+12]; |
|
|
|
float Tu=transformedTris[id*21+12]; |
|
|
|
float Tv1=tris[id*21+13]; |
|
|
|
float Tv=transformedTris[id*21+13]; |
|
|
|
float Tw1=tris[id*21+14]; |
|
|
|
float Tw=transformedTris[id*21+14]; |
|
|
|
float Uu2=tris[id*21+15]; |
|
|
|
float Uu=transformedTris[id*21+15]; |
|
|
|
float Uv2=tris[id*21+16]; |
|
|
|
float Uv=transformedTris[id*21+16]; |
|
|
|
float Uw2=tris[id*21+17]; |
|
|
|
float Uw=transformedTris[id*21+17]; |
|
|
|
float Vu3=tris[id*21+18]; |
|
|
|
float Vu=transformedTris[id*21+18]; |
|
|
|
float Vv3=tris[id*21+19]; |
|
|
|
float Vv=transformedTris[id*21+19]; |
|
|
|
float Vw3=tris[id*21+20]; |
|
|
|
float Vw=transformedTris[id*21+20]; |
|
|
|
TexturedTriangle( |
|
|
|
TexturedTriangle( |
|
|
|
(int)x1,(int)y1,0f,0f,1f, |
|
|
|
(int)x1,(int)y1,Tu,Tv,Tw, |
|
|
|
(int)x2,(int)y2,1f,0f,1f, |
|
|
|
(int)x2,(int)y2,Uu,Uv,Uw, |
|
|
|
(int)x3,(int)y3,1f,1f,1f, |
|
|
|
(int)x3,(int)y3,Vu,Vv,Vw, |
|
|
|
getGlobalId()%256,1f); |
|
|
|
getGlobalId()%256,1f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|