#ifndef TMP_H #define TMP_H #include "optixPathTracer.h" #include #include extern "C" { __constant__ Params params; } __forceinline__ __device__ float other_function( const s0 *s0i1, const s0 *s0i0) { const s0 *curr = s0i0; const s0 *next = s0i1; // loop runs for 2 iterations // in the first iteration, curr = s0i0 and next = s0i1 // in the second iteration, curr = s0i1 and next = s0i1 // note that the loop does not modify the s0 structs for (int index = 0; index < 2; index++) { // this assertion fails in the second iteration of the loop which // it should not. in the second iteration, current = s0i1 // v1 should be 1.f, v2 should be false, v3 should be true GPU_ASSERT(curr->v1 != 0.f || (curr->v3 && curr->v2)); curr = next; } return 0.f; } __forceinline__ __device__ void eval() { s0 s0i0; s0i0.v1 = 1.f; s0i0.v2 = false; s0i0.v3 = false; s3 *s3i0 = params.d_s3is; s0 s0i1 = s3i0->v6; // s0i1 = params.d_s3is->v6 which was set on host side: // params.d_s3is->v6.v1 = undef // params.d_s3is->v6.v2 = false // params.d_s3is->v6.v3 = true // hence the operand of the conditional operator below evals to false // hence s0i1.v1 is set to: 1.f * fabsf(-1.f) = 1.f s0i1.v1 = (s3i0->v6.v3 && s3i0->v6.v2) ? 0.f : 1.f * fabsf(-1.f); // un-commenting this assertion makes the assertion in the // other_function succeed. // GPU_ASSERT(!(s3i0->v6.v3 && s3i0->v6.v2)); float ret = other_function(&s0i1, &s0i0); } #endif