working on rt

This commit is contained in:
Evghenii
2013-11-14 22:54:37 +01:00
parent 294fb039fe
commit 86652738c0
2 changed files with 11 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
PROG=rt_cu
ISPC_SRC=rt1.ispc
CXX_SRC=rt_cu.cpp
CXX_SRC=rt_cu.cpp
CXX=g++
CXXFLAGS=-O3 -I$(CUDATK)/include
@@ -8,7 +8,7 @@ LD=g++
LDFLAGS=-lcuda
ISPC=ispc
ISPCFLAGS=-O3 --math-lib=default --target=nvptx64,avx
ISPCFLAGS=-O3 --math-lib=default --target=nvptx64 --opt=fast-math
LLVM32 = $(HOME)/usr/local/llvm/bin-3.2
LLVM = $(HOME)/usr/local/llvm/bin-3.3
@@ -27,6 +27,7 @@ CXX_OBJ=$(CXX_SRC:%.cpp=%.o)
all: $(PROG)
$(CXX_OBJ) : kernel.ptx
$(PROG): $(CXX_OBJ) kernel.ptx
/bin/cp kernel.ptx __kernels.ptx
$(LD) -o $@ $(CXX_OBJ) $(LDFLAGS)
@@ -36,7 +37,7 @@ $(PROG): $(CXX_OBJ) kernel.ptx
%_ispc_nvptx64.bc: %.ispc
$(ISPC) $(ISPCFLAGS) --emit-llvm -o `basename $< .ispc`_ispc.bc -h `basename $< .ispc`_ispc.h $< --emit-llvm
$(ISPC) $(ISPCFLAGS) --emit-llvm -o `basename $< .ispc`_ispc_nvptx64.bc -h `basename $< .ispc`_ispc.h $< --emit-llvm
%.ptx: %.bc
$(LLVM32DIS) $<

View File

@@ -295,21 +295,15 @@ static inline void raytrace_tile(uniform int x0, uniform int x1,
uniform float widthScale = (float)(baseWidth) / (float)(width);
uniform float heightScale = (float)(baseHeight) / (float)(height);
// foreach_tiled (y = y0 ... y1, x = x0 ... x1)
for (uniform int y = y0; y < y1; y++)
for (uniform int xb = x0; xb < x1; xb += programCount)
foreach_tiled (y = y0 ... y1, x = x0 ... x1)
{
const int x = xb + programIndex;
Ray ray;
generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray);
BVHIntersect(nodes, triangles, ray);
Ray ray;
generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray);
BVHIntersect(nodes, triangles, ray);
int offset = y * width + x;
if (x < x1)
{
image[offset] = ray.maxt;
id[offset] = ray.hitId;
}
int offset = y * width + x;
image[offset] = ray.maxt;
id[offset] = ray.hitId;
}
}