Пример #1
0
// Like reference implementation of emit_photons_from_diffuse_point_light as described
// in "Realistic Image Synthesis using Photon Mapping" page 57.
void PhotonTracer::traceLight(const Light& light, int numberOfPhotons)
{
    int n = 0, c = 0;
	int c2 = numberOfPhotons/50;

	PerformanceTimer pt;
	pt.start();
    
	while (n < numberOfPhotons)
    {
        //Vector3 dir = light.emitPhoton();
        //Vector3 power = light.power() * light.color();
        //Ray ray(light.getPosition(), dir);

        PhotonRay photon = light.emitPhoton();
        Ray ray(photon.origin, photon.direction);

        int photons = tracePhoton(ray, photon.power, 0);
		n += photons;
		c += photons;

		if(c > c2)
		{
			c = 0;
			pt.stop();
			printf("%.2f seconds. %.2f %% done. Remaining: %.2f sec.\r",
				pt.elapsedSec(),
				(n/float(numberOfPhotons))*100.f, pt.elapsedSec()*(float(numberOfPhotons)/float(n) - 1));
			pt.start();
		}

    }
    _photonMap->scale_photon_power(1 / (float)numberOfPhotons); 
}
/**
 * Stop the performance tracer.
 */
void PnPBreakdown::stop(void)
{
    if (gPnPBreakdown.isRunning()) {
        gPnPBreakdown.formattedTrace("PnPBreakdown", __FUNCTION__);
        gPnPBreakdown.stop();
    }
}
/**
 * Stops the AAAprofiler trace and prints out results.
 */
void AAAProfiler::stop(void)
{
    if (gAAAProfiler.isRunning()) {
        LOGD("3A profiling time::\t%lldms\n",
             gAAAProfiler.timeUs() / 1000);
        gAAAProfiler.stop();
    }
}
void Shot2Shot::stop(void)
{
    if (gShot2Shot.isRunning()) {
        if (gPnPBreakdown.isRunning())
            PnPBreakdown::step("Shot2Shot::stop");
            LOGD("shot2shot latency: %lld us.", gShot2Shot.timeUs());
        gShot2Shot.stop();
    }
}
/**
 * Stops the FaceLock trace and prints out results.
 */
void FaceLock::stop(int mFaceNum)
{
    if (gFaceLock.isRunning()) {
        LOGD("FaceLock face num: %d , Need frame: %d , From preview frame got to face lock successfully:\t%lld ms\n",
             mFaceNum, gFaceLockFrame, gFaceLock.timeUs() / 1000);
        gFaceLock.mRequested = false;
        gFaceLock.stop();
    }
}
void HDRShot2Preview::stop(void)
{
    if (gHDRShot2Preview.isRunning() && gHDRCalled) {
        gHDRCalled = false;
        if (gPnPBreakdown.isRunning())
            PnPBreakdown::step("HDRShot2Preview::stop");
        LOGD("hdr shot2preview latency: %lld us", gHDRShot2Preview.timeUs());
        gHDRShot2Preview.stop();
    }
}
/**
 * Stops the launch2FocusLock trace and prints out results.
 */
void Launch2FocusLock::stop(void)
{
    if (gLaunch2FocusLock.isRunning()) {
        if (gPnPBreakdown.isRunning())
            PnPBreakdown::step("Launch2FocusLock::stop");
        LOGD("LAUNCH time calculated from create instance to lock the focus frame:\t%lld ms\n",
             gLaunch2FocusLock.timeUs() / 1000);
        gLaunch2FocusLock.stop();
    }
}
Пример #8
0
OsFile::~OsFile()
{
#ifdef _DEBUG
    PerformanceTimer t;
    t.start();
#endif

    CloseHandle(m_handle);

#ifdef _DEBUG
    t.stop();
    ms_time+= t.getElapsedTime();
#endif
}
/**
 * Stops the launch2preview trace and prints out results.
 */
void Launch2Preview::stop(int mFrameNum)
{
    if (gLaunch2Preview.isRunning()) {
        if (gPnPBreakdown.isRunning())
            PnPBreakdown::step("Launch2Preview::stop");
        if (mFrameNum == 1) {
            LOGD("LAUNCH time to the 1st preview frame show:\t%lld ms\n",
                 gLaunch2Preview.timeUs() / 1000);
        } else {
            LOGD("LAUNCH: skip %d frame, time to the 1st preview frame show:\t%lld ms\n",
                 (mFrameNum - 1), gLaunch2Preview.timeUs() / 1000);
        }

        gLaunch2Preview.stop();
    }
}
Пример #10
0
void OsFile::seek(int newFilePosition)
{
#ifdef _DEBUG
    PerformanceTimer t;
    t.start();
#endif

    if (m_offset != newFilePosition)
    {
        const DWORD result = SetFilePointer(m_handle, newFilePosition, NULL, FILE_BEGIN);
        DEBUG_FATAL(static_cast<int>(result) != newFilePosition, ("SetFilePointer failed"));
        UNREF(result);
        m_offset = newFilePosition;
    }

#ifdef _DEBUG
    t.stop();
    ms_time += t.getElapsedTime();
#endif
}
/**
 * Stop the performance tracer.
 */
void IOBreakdown::stop(void)
{
    if (gIOBreakdown.isRunning()) {
        gIOBreakdown.formattedTrace("IOBreakdown", __FUNCTION__);
        gIOBreakdown.stop();
    }

    if (mMemInfoEnabled) {
        if(mPipeFD >= 0)
            if (::close(mPipeFD) < 0)
                LOGE("Close trace_pipe error!");

        if(mDbgFD >= 0)
            if (::close(mDbgFD) < 0)
                LOGE("Close dbgopt error!");

        mPipeFD = -1;
        mDbgFD = -1;
        mMemInfoEnabled = false;
    }
}
Пример #12
0
OsFile *OsFile::open(const char *fileName, bool randomAccess)
{
#ifdef _DEBUG
    PerformanceTimer t;
    t.start();
#endif

    // attempt to open the file
    HANDLE handle = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | (randomAccess ? FILE_FLAG_RANDOM_ACCESS : 0), NULL);

    // check to make sure the file opened sucessfully
    if (handle == INVALID_HANDLE_VALUE)
        return NULL;

#ifdef _DEBUG
    t.stop();
    ms_time += t.getElapsedTime();
#endif

    return new OsFile(handle);
}
/**
 * Stops the SwitchCameras trace and prints out results.
 */
void SwitchCameras::stop(void)
{
    if (gSwitchCameras.isRunning() && gSwitchCamerasCalled == true) {
        if (gPnPBreakdown.isRunning())
            PnPBreakdown::step("Switch::stop");
        if (gSwitchCamerasOriginalVideoMode == gSwitchCamerasVideoMode) {
            LOGD("Using %s mode, Switch from %s camera to %s camera, SWITCH time::\t%lldms\n",
                    (gSwitchCamerasVideoMode ? "video" : "camera"),
                    ((gSwitchCamerasOriginalCameraId == 0) ? "back" : "front"),
                    ((gSwitchCamerasOriginalCameraId == 1) ? "back" : "front"),
                    gSwitchCameras.timeUs() / 1000);
        } else {
            LOGD("Using %s camera, Switch from %s mode to %s mode, SWITCH time::\t%lldms\n",
                    ((gSwitchCamerasOriginalCameraId == 0) ? "back" : "front"),
                    (gSwitchCamerasOriginalVideoMode ? "video" : "camera"),
                    (gSwitchCamerasVideoMode ? "video" : "camera"),
                    gSwitchCameras.timeUs() / 1000);
        }
        gSwitchCamerasCalled = false;
        gSwitchCameras.stop();
    }
}
Пример #14
0
int OsFile::getFileSize(const char *fileName)
{
    NOT_NULL(fileName);

#ifdef _DEBUG
    PerformanceTimer t;
    t.start();
#endif

    HANDLE handle = CreateFile(fileName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (handle == INVALID_HANDLE_VALUE)
        return -1;

    int const size = GetFileSize(handle, NULL);
    CloseHandle(handle);

#ifdef _DEBUG
    t.stop();
    ms_time += t.getElapsedTime();
#endif
    return size;
}
Пример #15
0
int OsFile::read(void *destinationBuffer, int numberOfBytes)
{
#ifdef _DEBUG
    PerformanceTimer t;
    t.start();
#endif

    DWORD amountReadDword;
    BOOL result = ReadFile(m_handle, destinationBuffer, static_cast<uint>(numberOfBytes), &amountReadDword, NULL);

// miles crasher hack
#if 0
    FATAL(!result, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
#else
    if(!result)
    {
        if(GetLastError() == 998) // access violation - buffer coming from miles hosed
        {
            WARNING(true,("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
            return 0;
        }
        else
        {
            FATAL(true, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
        }
    }
#endif
// end miles crasher hack

#ifdef _DEBUG
    t.stop();
    ms_time += t.getElapsedTime();
#endif

    m_offset += static_cast<int>(amountReadDword);
    return static_cast<int>(amountReadDword);
}