working on rt
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
PROG=rt_cu
|
PROG=rt_cu
|
||||||
ISPC_SRC=rt1.ispc
|
ISPC_SRC=rt1.ispc
|
||||||
CXX_SRC=rt_cu.cpp
|
CXX_SRC=rt_cu.cpp
|
||||||
|
|
||||||
CXX=g++
|
CXX=g++
|
||||||
CXXFLAGS=-O3 -I$(CUDATK)/include
|
CXXFLAGS=-O3 -I$(CUDATK)/include
|
||||||
@@ -8,7 +8,7 @@ LD=g++
|
|||||||
LDFLAGS=-lcuda
|
LDFLAGS=-lcuda
|
||||||
|
|
||||||
ISPC=ispc
|
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
|
LLVM32 = $(HOME)/usr/local/llvm/bin-3.2
|
||||||
LLVM = $(HOME)/usr/local/llvm/bin-3.3
|
LLVM = $(HOME)/usr/local/llvm/bin-3.3
|
||||||
@@ -27,6 +27,7 @@ CXX_OBJ=$(CXX_SRC:%.cpp=%.o)
|
|||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
|
|
||||||
|
$(CXX_OBJ) : kernel.ptx
|
||||||
$(PROG): $(CXX_OBJ) kernel.ptx
|
$(PROG): $(CXX_OBJ) kernel.ptx
|
||||||
/bin/cp kernel.ptx __kernels.ptx
|
/bin/cp kernel.ptx __kernels.ptx
|
||||||
$(LD) -o $@ $(CXX_OBJ) $(LDFLAGS)
|
$(LD) -o $@ $(CXX_OBJ) $(LDFLAGS)
|
||||||
@@ -36,7 +37,7 @@ $(PROG): $(CXX_OBJ) kernel.ptx
|
|||||||
|
|
||||||
|
|
||||||
%_ispc_nvptx64.bc: %.ispc
|
%_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
|
%.ptx: %.bc
|
||||||
$(LLVM32DIS) $<
|
$(LLVM32DIS) $<
|
||||||
|
|||||||
@@ -295,21 +295,15 @@ static inline void raytrace_tile(uniform int x0, uniform int x1,
|
|||||||
uniform float widthScale = (float)(baseWidth) / (float)(width);
|
uniform float widthScale = (float)(baseWidth) / (float)(width);
|
||||||
uniform float heightScale = (float)(baseHeight) / (float)(height);
|
uniform float heightScale = (float)(baseHeight) / (float)(height);
|
||||||
|
|
||||||
// foreach_tiled (y = y0 ... y1, x = x0 ... x1)
|
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)
|
|
||||||
{
|
{
|
||||||
const int x = xb + programIndex;
|
Ray ray;
|
||||||
Ray ray;
|
generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray);
|
||||||
generateRay(raster2camera, camera2world, x*widthScale, y*heightScale, ray);
|
BVHIntersect(nodes, triangles, ray);
|
||||||
BVHIntersect(nodes, triangles, ray);
|
|
||||||
|
|
||||||
int offset = y * width + x;
|
int offset = y * width + x;
|
||||||
if (x < x1)
|
image[offset] = ray.maxt;
|
||||||
{
|
id[offset] = ray.hitId;
|
||||||
image[offset] = ray.maxt;
|
|
||||||
id[offset] = ray.hitId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user