示例#1
0
Patch * TerrainPager::GetPatch(const PatchID &patchID)
{
	if (patchID.GetI() < 0 || patchID.GetJ() < 0)	// reject call
		return NULL;

	// Check the working set to see if it is loaded
	Patch *pPatch = findPatch(patchID);
	if (NULL != pPatch)
	{
		pPatch->IncrementReferenceCount();
		return pPatch;
	}

	// not within the working set.
	// go get it.

	// get a free slot.
	assert(!readyPatchQueue.empty());	// uptil now we just assume that we have a patch pool that is sufficient to our needs.
	unsigned int index = readyPatchQueue.front();
	readyPatchQueue.pop();				// mark this patch as occupied.

	// load the patch into this slot
	pPatch = pPatches[index];
	pPatch->Reset();					// reset internal values of nbLoadedVertices, currentLoadedLevel.
	pPatch->SetID(patchID);

	jobManager->RequestFillPatch(*pPatch, utilizeTextures);

	// push it onto the list
	workingSet.push_back(pPatch);
	pPatch->IncrementReferenceCount();			// this one is used.
	pPatch->SetIterator(--workingSet.end());	// the iterator of the latest added item.
	
	return pPatch;
}
示例#2
0
void TerrainPager::FreePatch(const PatchID &patchID)
{
	if (patchID.GetI() < 0 || patchID.GetJ() < 0)	// reject call
		return;

	// Check the working set to see if it is loaded
	Patch *pPatch = findPatch(patchID);
	assert(NULL != pPatch);
	FreePatch(pPatch);
}
示例#3
0
void R2D2Audio::play3DAudio(vec3 position)
{

	if(_lastPlayTime + _delay < glfwGetTime())
	{
		_lastPlayTime = glfwGetTime();
		GLfloat random = rand() % 3 + 1;

		if (random == 0)
			_music = _engine->play3D(findPatch("r2d2a"), vec3df(0, 0, 0), false, false, true);
		if (random == 1)
			_music = _engine->play3D(findPatch("r2d2b"), vec3df(0, 0, 0), false, false, true);
		else 
			_music = _engine->play3D(findPatch("r2d2c"), vec3df(0, 0, 0), false, false, true);

		_music->setMinDistance(2.0f);
		_music->setPosition(vec3df(position.x, position.y, position.z));
	
	}

}
示例#4
0
/*
 * The strategy for this goes as follows:
 *
 * 1) Scan the stack, looking at all return addresses that could go into JIT
 *    code.
 * 2) If an address corresponds to a call site registered by |callSite| during
 *    the last compilation, remember it.
 * 3) Purge the old compiled state and return if there were no active frames of
 *    this script on the stack.
 * 4) Fix up the stack by replacing all saved addresses with the addresses the
 *    new compiler gives us for the call sites.
 */
bool
Recompiler::recompile()
{
    JS_ASSERT(script->hasJITCode());

    Vector<PatchableAddress> normalPatches(cx);
    Vector<PatchableAddress> ctorPatches(cx);

    JSStackFrame *firstCtorFrame = NULL;
    JSStackFrame *firstNormalFrame = NULL;

    // Find all JIT'd stack frames to account for return addresses that will
    // need to be patched after recompilation.
    for (VMFrame *f = script->compartment->jaegerCompartment->activeFrame();
            f != NULL;
            f = f->previous) {

        // Scan all frames owned by this VMFrame.
        JSStackFrame *end = f->entryfp->prev();
        for (JSStackFrame *fp = f->fp(); fp != end; fp = fp->prev()) {
            // Remember the latest frame for each type of JIT'd code, so the
            // compiler will have a frame to re-JIT from.
            if (!firstCtorFrame && fp->script() == script && fp->isConstructing())
                firstCtorFrame = fp;
            else if (!firstNormalFrame && fp->script() == script && !fp->isConstructing())
                firstNormalFrame = fp;

            void **addr = fp->addressOfNativeReturnAddress();
            if (script->jitCtor && script->jitCtor->isValidCode(*addr)) {
                if (!ctorPatches.append(findPatch(script->jitCtor, addr)))
                    return false;
            } else if (script->jitNormal && script->jitNormal->isValidCode(*addr)) {
                if (!normalPatches.append(findPatch(script->jitNormal, addr)))
                    return false;
            }
        }

        void **addr = f->returnAddressLocation();
        if (script->jitCtor && script->jitCtor->isValidCode(*addr)) {
            if (!ctorPatches.append(findPatch(script->jitCtor, addr)))
                return false;
        } else if (script->jitNormal && script->jitNormal->isValidCode(*addr)) {
            if (!normalPatches.append(findPatch(script->jitNormal, addr)))
                return false;
        }
    }

    Vector<CallSite> normalSites(cx);
    Vector<CallSite> ctorSites(cx);

    if (script->jitNormal && !saveTraps(script->jitNormal, &normalSites))
        return false;
    if (script->jitCtor && !saveTraps(script->jitCtor, &ctorSites))
        return false;

    ReleaseScriptCode(cx, script);

    if (normalPatches.length() &&
            !recompile(firstNormalFrame, normalPatches, normalSites)) {
        return false;
    }

    if (ctorPatches.length() &&
            !recompile(firstCtorFrame, ctorPatches, ctorSites)) {
        return false;
    }

    return true;
}