void NativeThreadIntersectionDevice::IntersectionThread(NativeThreadIntersectionDevice *renderDevice) { LR_LOG(renderDevice->deviceContext, "[NativeThread device::" << renderDevice->deviceName << "] Rendering thread started"); try { RayBufferQueue *queue = renderDevice->externalRayBufferQueue ? renderDevice->externalRayBufferQueue : &(renderDevice->rayBufferQueue); const double startTime = WallClockTime(); while (!boost::this_thread::interruption_requested()) { const double t1 = WallClockTime(); RayBuffer *rayBuffer = queue->PopToDo(); renderDevice->statsDeviceIdleTime += WallClockTime() - t1; // Trace rays const Ray *rb = rayBuffer->GetRayBuffer(); RayHit *hb = rayBuffer->GetHitBuffer(); const size_t rayCount = rayBuffer->GetRayCount(); for (unsigned int i = 0; i < rayCount; ++i) { hb[i].SetMiss(); renderDevice->dataSet->Intersect(&rb[i], &hb[i]); } renderDevice->statsTotalDataParallelRayCount += rayCount; queue->PushDone(rayBuffer); renderDevice->statsDeviceTotalTime = WallClockTime() - startTime; } LR_LOG(renderDevice->deviceContext, "[NativeThread device::" << renderDevice->deviceName << "] Rendering thread halted"); } catch (boost::thread_interrupted) { LR_LOG(renderDevice->deviceContext, "[NativeThread device::" << renderDevice->deviceName << "] Rendering thread halted"); } }
void FPGAIntersectionDevice::IntersectionThread(FPGAIntersectionDevice *renderDevice) { LR_LOG(renderDevice->deviceContext, "[FPGA device::" << renderDevice->deviceName << "] Rendering thread started"); try { RayBufferQueue *queue = renderDevice->rayBufferQueue; const double startTime = WallClockTime(); while (!boost::this_thread::interruption_requested()) { const double t1 = WallClockTime(); RayBuffer *rayBuffer = queue->PopToDo(); renderDevice->statsDeviceIdleTime += WallClockTime() - t1; // Trace rays const Ray *rb = rayBuffer->GetRayBuffer(); RayHit *hb = rayBuffer->GetHitBuffer(); const size_t rayCount = rayBuffer->GetRayCount(); for (unsigned int i = 0; i < rayCount; ++i) { hb[i].SetMiss(); //renderDevice->accel->Intersect(&rb[i], &hb[i]); } if (xrti_intersect((void *)rb, rayCount*sizeof(Ray), rayCount, (void *)hb, rayCount*sizeof(RayHit)) < 0) { throw std::runtime_error("xrti_intersect failed"); } renderDevice->statsDeviceTotalTime = WallClockTime() - startTime; renderDevice->statsTotalDataParallelRayCount += rayCount; queue->PushDone(rayBuffer); // FILE *f = fopen("/mnt/scratch/sam/ray_tracer/tb_generator/data/rays.txt", "w"); // unsigned char *b = (unsigned char *)rb; // for (u_int i = 0; i < rayCount * sizeof(luxrays::Ray); i++) { // fprintf(f, "%02x", b[i]); // if ((i + 1) % 48 == 0) // fprintf(f, "\n"); // } // fclose(f); // f = fopen("/mnt/scratch/sam/ray_tracer/tb_generator/data/hits.txt", "w"); // b = (unsigned char *)hb; // for (u_int i = 0; i < rayCount * sizeof(luxrays::RayHit); i++) { // fprintf(f, "%02x", b[i]); // if ((i + 1) % 20 == 0) // fprintf(f, "\n"); // } // fclose(f); } LR_LOG(renderDevice->deviceContext, "[FPGA device::" << renderDevice->deviceName << "] Rendering thread halted"); } catch (boost::thread_interrupted) { LR_LOG(renderDevice->deviceContext, "[FPGA device::" << renderDevice->deviceName << "] Rendering thread halted"); } }