White space and copyright fixes in examples.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2010-2011, Intel Corporation
|
||||
Copyright (c) 2010-2014, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +28,7 @@
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -83,7 +83,7 @@ static void writeImage(int *idImage, float *depthImage, int width, int height,
|
||||
fputc(g, f);
|
||||
fputc(b, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
printf("Wrote image file %s\n", filename);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) {
|
||||
if (fread(&(var), sizeof(var), n, f) != (unsigned int)n) { \
|
||||
fprintf(stderr, "Unexpected EOF reading scene file\n"); \
|
||||
return 1; \
|
||||
} else /* eat ; */
|
||||
} else /* eat ; */
|
||||
|
||||
//
|
||||
// Read the camera specification information from the camera file
|
||||
@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
|
||||
READ(raster2camera[0][0], 16);
|
||||
|
||||
//
|
||||
// Read in the serialized BVH
|
||||
// Read in the serialized BVH
|
||||
//
|
||||
sprintf(fnbuf, "%s.bvh", filename);
|
||||
f = fopen(fnbuf, "rb");
|
||||
@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
|
||||
READ(nodes[i].pad, 1);
|
||||
}
|
||||
|
||||
// And then read the triangles
|
||||
// And then read the triangles
|
||||
uint nTris;
|
||||
READ(nTris, 1);
|
||||
Triangle *triangles = new Triangle[nTris];
|
||||
@@ -204,7 +204,7 @@ int main(int argc, char *argv[]) {
|
||||
// the first interseciton
|
||||
int *id = new int[width*height];
|
||||
float *image = new float[width*height];
|
||||
|
||||
|
||||
ispc_memset(id, 0, width*height*sizeof(int));
|
||||
ispc_memset(image, 0, width*height*sizeof(float));
|
||||
|
||||
@@ -220,7 +220,7 @@ int main(int argc, char *argv[]) {
|
||||
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] msec\n", dt);
|
||||
minTimeISPCtasks = std::min(dt, minTimeISPCtasks);
|
||||
}
|
||||
printf("[rt ispc + tasks]:\t\t[%.3f] msec for %d x %d image\n",
|
||||
printf("[rt ispc + tasks]:\t\t[%.3f] msec for %d x %d image\n",
|
||||
minTimeISPCtasks, width, height);
|
||||
|
||||
writeImage(id, image, width, height, "rt-ispc-tasks.ppm");
|
||||
|
||||
@@ -96,7 +96,7 @@ static inline float Dot(const float3 a, const float3 b) {
|
||||
|
||||
__device__
|
||||
inline
|
||||
static void generateRay( const float raster2camera[4][4],
|
||||
static void generateRay( const float raster2camera[4][4],
|
||||
const float camera2world[4][4],
|
||||
float x, float y, Ray &ray) {
|
||||
ray.mint = 0.f;
|
||||
@@ -113,11 +113,11 @@ static void generateRay( const float raster2camera[4][4],
|
||||
camy /= camw;
|
||||
camz /= camw;
|
||||
|
||||
ray.dir.x = camera2world[0][0] * camx + camera2world[0][1] * camy +
|
||||
ray.dir.x = camera2world[0][0] * camx + camera2world[0][1] * camy +
|
||||
camera2world[0][2] * camz;
|
||||
ray.dir.y = camera2world[1][0] * camx + camera2world[1][1] * camy +
|
||||
ray.dir.y = camera2world[1][0] * camx + camera2world[1][1] * camy +
|
||||
camera2world[1][2] * camz;
|
||||
ray.dir.z = camera2world[2][0] * camx + camera2world[2][1] * camy +
|
||||
ray.dir.z = camera2world[2][0] * camx + camera2world[2][1] * camy +
|
||||
camera2world[2][2] * camz;
|
||||
|
||||
ray.origin.x = camera2world[0][3] / camera2world[3][3];
|
||||
@@ -139,7 +139,7 @@ static void generateRay( const float raster2camera[4][4],
|
||||
|
||||
__device__
|
||||
inline
|
||||
static bool BBoxIntersect(const float bounds[2][3],
|
||||
static bool BBoxIntersect(const float bounds[2][3],
|
||||
const Ray &ray) {
|
||||
float3 bounds0 = { bounds[0][0], bounds[0][1], bounds[0][2] };
|
||||
float3 bounds1 = { bounds[1][0], bounds[1][1], bounds[1][2] };
|
||||
@@ -172,7 +172,7 @@ static bool BBoxIntersect(const float bounds[2][3],
|
||||
}
|
||||
t0 = max(tNear.z, t0);
|
||||
t1 = min(tFar.z, t1);
|
||||
|
||||
|
||||
return (t0 <= t1);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ static bool TriIntersect(const Triangle &tri, Ray &ray) {
|
||||
|
||||
__device__
|
||||
inline
|
||||
bool BVHIntersect(const LinearBVHNode nodes[],
|
||||
bool BVHIntersect(const LinearBVHNode nodes[],
|
||||
const Triangle tris[], Ray &r,
|
||||
int todo[]) {
|
||||
Ray ray = r;
|
||||
@@ -240,7 +240,7 @@ bool BVHIntersect(const LinearBVHNode nodes[],
|
||||
if (TriIntersect(tris[primitivesOffset+i], ray))
|
||||
hit = true;
|
||||
}
|
||||
if (todoOffset == 0)
|
||||
if (todoOffset == 0)
|
||||
break;
|
||||
nodeNum = todo[--todoOffset];
|
||||
}
|
||||
@@ -275,10 +275,10 @@ bool BVHIntersect(const LinearBVHNode nodes[],
|
||||
__device__
|
||||
inline
|
||||
static void raytrace_tile( int x0, int x1,
|
||||
int y0, int y1,
|
||||
int y0, int y1,
|
||||
int width, int height,
|
||||
int baseWidth, int baseHeight,
|
||||
const float raster2camera[4][4],
|
||||
const float raster2camera[4][4],
|
||||
const float camera2world[4][4],
|
||||
float image[], int id[],
|
||||
const LinearBVHNode nodes[],
|
||||
@@ -317,7 +317,7 @@ static void raytrace_tile( int x0, int x1,
|
||||
__global__
|
||||
void raytrace_tile_task( int width, int height,
|
||||
int baseWidth, int baseHeight,
|
||||
const float raster2camera[4][4],
|
||||
const float raster2camera[4][4],
|
||||
const float camera2world[4][4],
|
||||
float image[], int id[],
|
||||
const LinearBVHNode nodes[],
|
||||
@@ -328,8 +328,8 @@ void raytrace_tile_task( int width, int height,
|
||||
int x1 = min(x0 + dx, width);
|
||||
int y0 = (taskIndex / xBuckets) * dy;
|
||||
int y1 = min(y0 + dy, height);
|
||||
|
||||
raytrace_tile(x0, x1, y0, y1, width, height, baseWidth, baseHeight,
|
||||
|
||||
raytrace_tile(x0, x1, y0, y1, width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world, image,
|
||||
id, nodes, triangles);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ void raytrace_tile_task( int width, int height,
|
||||
|
||||
extern "C" __global__ void raytrace_ispc_tasks___export( int width, int height,
|
||||
int baseWidth, int baseHeight,
|
||||
const float raster2camera[4][4],
|
||||
const float raster2camera[4][4],
|
||||
const float camera2world[4][4],
|
||||
float image[], int id[],
|
||||
const LinearBVHNode nodes[],
|
||||
@@ -347,8 +347,8 @@ extern "C" __global__ void raytrace_ispc_tasks___export( int width, int height,
|
||||
int yBuckets = (height + (dy-1)) / dy;
|
||||
int nTasks = xBuckets * yBuckets;
|
||||
launch(nTasks,1,1,raytrace_tile_task)
|
||||
(width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world,
|
||||
(width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world,
|
||||
image, id, nodes, triangles);
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
@@ -357,7 +357,7 @@ extern "C" __global__ void raytrace_ispc_tasks___export( int width, int height,
|
||||
|
||||
extern "C" __host__ void raytrace_ispc_tasks( int width, int height,
|
||||
int baseWidth, int baseHeight,
|
||||
const float raster2camera[4][4],
|
||||
const float raster2camera[4][4],
|
||||
const float camera2world[4][4],
|
||||
float image[], int id[],
|
||||
const LinearBVHNode nodes[],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2010-2011, Intel Corporation
|
||||
Copyright (c) 2010-2014, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +28,7 @@
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 1
|
||||
@@ -90,7 +90,7 @@ static inline float Dot(const float3 a, const float3 b) {
|
||||
#if 1
|
||||
inline
|
||||
#endif
|
||||
static void generateRay(uniform const float raster2camera[4][4],
|
||||
static void generateRay(uniform const float raster2camera[4][4],
|
||||
uniform const float camera2world[4][4],
|
||||
float x, float y, Ray &ray) {
|
||||
ray.mint = 0.f;
|
||||
@@ -107,11 +107,11 @@ static void generateRay(uniform const float raster2camera[4][4],
|
||||
camy /= camw;
|
||||
camz /= camw;
|
||||
|
||||
ray.dir.x = camera2world[0][0] * camx + camera2world[0][1] * camy +
|
||||
ray.dir.x = camera2world[0][0] * camx + camera2world[0][1] * camy +
|
||||
camera2world[0][2] * camz;
|
||||
ray.dir.y = camera2world[1][0] * camx + camera2world[1][1] * camy +
|
||||
ray.dir.y = camera2world[1][0] * camx + camera2world[1][1] * camy +
|
||||
camera2world[1][2] * camz;
|
||||
ray.dir.z = camera2world[2][0] * camx + camera2world[2][1] * camy +
|
||||
ray.dir.z = camera2world[2][0] * camx + camera2world[2][1] * camy +
|
||||
camera2world[2][2] * camz;
|
||||
|
||||
ray.origin.x = camera2world[0][3] / camera2world[3][3];
|
||||
@@ -129,7 +129,7 @@ static void generateRay(uniform const float raster2camera[4][4],
|
||||
#if 1
|
||||
inline
|
||||
#endif
|
||||
static bool_t BBoxIntersect(const uniform float bounds[2][3],
|
||||
static bool_t BBoxIntersect(const uniform float bounds[2][3],
|
||||
const Ray &ray) {
|
||||
const uniform float3 bounds0 = { bounds[0][0], bounds[0][1], bounds[0][2] };
|
||||
const uniform float3 bounds1 = { bounds[1][0], bounds[1][1], bounds[1][2] };
|
||||
@@ -162,7 +162,7 @@ static bool_t BBoxIntersect(const uniform float bounds[2][3],
|
||||
}
|
||||
t0 = max(tNear.z, t0);
|
||||
t1 = min(tFar.z, t1);
|
||||
|
||||
|
||||
return (t0 <= t1);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ static bool_t TriIntersect(const uniform_t Triangle tri, Ray &ray) {
|
||||
inline
|
||||
#endif
|
||||
bool_t
|
||||
BVHIntersect(const uniform LinearBVHNode nodes[],
|
||||
BVHIntersect(const uniform LinearBVHNode nodes[],
|
||||
const uniform Triangle tris[], Ray &r) {
|
||||
Ray ray = r;
|
||||
bool_t hit = false;
|
||||
@@ -235,7 +235,7 @@ BVHIntersect(const uniform LinearBVHNode nodes[],
|
||||
if (TriIntersect(tris[primitivesOffset+i], ray))
|
||||
hit = true;
|
||||
}
|
||||
if (todoOffset == 0)
|
||||
if (todoOffset == 0)
|
||||
break;
|
||||
nodeNum = todo[--todoOffset];
|
||||
}
|
||||
@@ -276,10 +276,10 @@ BVHIntersect(const uniform LinearBVHNode nodes[],
|
||||
inline
|
||||
#endif
|
||||
static void raytrace_tile(uniform int x0, uniform int x1,
|
||||
uniform int y0, uniform int y1,
|
||||
uniform int y0, uniform int y1,
|
||||
uniform int width, uniform int height,
|
||||
uniform int baseWidth, uniform int baseHeight,
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float camera2world[4][4],
|
||||
uniform float image[], uniform int id[],
|
||||
const uniform LinearBVHNode nodes[],
|
||||
@@ -302,7 +302,7 @@ static void raytrace_tile(uniform int x0, uniform int x1,
|
||||
|
||||
export void raytrace_ispc(uniform int width, uniform int height,
|
||||
uniform int baseWidth, uniform int baseHeight,
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float camera2world[4][4],
|
||||
uniform float image[], uniform int id[],
|
||||
const uniform LinearBVHNode nodes[],
|
||||
@@ -315,7 +315,7 @@ export void raytrace_ispc(uniform int width, uniform int height,
|
||||
|
||||
task void raytrace_tile_task(uniform int width, uniform int height,
|
||||
uniform int baseWidth, uniform int baseHeight,
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float camera2world[4][4],
|
||||
uniform float image[], uniform int id[],
|
||||
const uniform LinearBVHNode nodes[],
|
||||
@@ -326,8 +326,8 @@ task void raytrace_tile_task(uniform int width, uniform int height,
|
||||
const uniform int x1 = min(x0 + dx, width);
|
||||
const uniform int y0 = (taskIndex / xBuckets) * dy;
|
||||
const uniform int y1 = min(y0 + dy, height);
|
||||
|
||||
raytrace_tile(x0, x1, y0, y1, width, height, baseWidth, baseHeight,
|
||||
|
||||
raytrace_tile(x0, x1, y0, y1, width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world, image,
|
||||
id, nodes, triangles);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ task void raytrace_tile_task(uniform int width, uniform int height,
|
||||
|
||||
export void raytrace_ispc_tasks(uniform int width, uniform int height,
|
||||
uniform int baseWidth, uniform int baseHeight,
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float raster2camera[4][4],
|
||||
const uniform float camera2world[4][4],
|
||||
uniform float image[], uniform int id[],
|
||||
const uniform LinearBVHNode nodes[],
|
||||
@@ -344,8 +344,8 @@ export void raytrace_ispc_tasks(uniform int width, uniform int height,
|
||||
const uniform int xBuckets = (width + (dx-1)) / dx;
|
||||
const uniform int yBuckets = (height + (dy-1)) / dy;
|
||||
const uniform int nTasks = xBuckets * yBuckets;
|
||||
launch[nTasks] raytrace_tile_task(width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world,
|
||||
launch[nTasks] raytrace_tile_task(width, height, baseWidth, baseHeight,
|
||||
raster2camera, camera2world,
|
||||
image, id, nodes, triangles);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user