void processDecodeInit(unsigned int uiPtr) { SpursSpeexTaskOutput spuOutput; cellDmaGet(&gviSpursSpeexTaskDesc, uiPtr, sizeof(SpursSpeexTaskDesc), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] CMD_SAMPLE_TASK_DECODE_INIT_COMMAND\n"); if (gviSpursSpeexTaskDesc.mDebugPause) { snPause(); } gviSpursSpeexDecoderInitialize(&spuOutput); if (spuOutput.mSpeexReturnCode < 0) { spuDebugPrintf("[Speex][SPU] failed to initialize decoder, ret = %d\n", spuOutput.mSpeexReturnCode); } cellDmaPut(&spuOutput, (uint64_t)gviSpursSpeexTaskDesc.mSpeexTaskOutput, sizeof(SpursSpeexTaskOutput), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaLargePut(gviSpursSpeexStateBuffer, (uint64_t)gviSpursSpeexTaskDesc.mSpeexStateBuffer, gviSpursSpeexTaskDesc.mSpeexStateBufferSize, DMA_TAG(1), 0,0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] buffer dma done\n"); }
void processDecodeSet(unsigned int uiPtr) { SpursSpeexTaskOutput spuOutput; cellDmaGet(&gviSpursSpeexTaskDesc, uiPtr, sizeof(SpursSpeexTaskDesc), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] CMD_SAMPLE_TASK_DECODESET_COMMAND\n"); if (gviSpursSpeexTaskDesc.mDebugPause) { snPause(); } cellDmaLargeGet(gviSpursSpeexStateBuffer, (uint64_t)gviSpursSpeexTaskDesc.mSpeexStateBuffer, SPEEX_DECODER_STATE_BUFFER_SIZE, DMA_TAG(1), 0,0); cellDmaWaitTagStatusAll(DMA_MASK(1)); gviSpursSpeexDecodeSet(&spuOutput); if (spuOutput.mSpeexReturnCode < 0) { spuDebugPrintf("SPU: failed to encode, ret = %d\n", spuOutput.mSpeexReturnCode); } cellDmaPut(&spuOutput, (uint64_t)gviSpursSpeexTaskDesc.mSpeexTaskOutput, sizeof(SpursSpeexTaskOutput), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); cellDmaLargePut(gviSpursSpeexStateBuffer, (uint64_t)gviSpursSpeexTaskDesc.mSpeexStateBuffer, SPEEX_DECODER_STATE_BUFFER_SIZE, DMA_TAG(1), 0,0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] buffer dma done\n"); }
void procesEncodeInit(unsigned int uiPtr) { SpursSpeexTaskOutput spuOutput; //spuDebugPrintf("[Speex][SPU] CMD_SAMPLE_TASK_ENCODE_INIT_COMMAND\n"); cellDmaGet(&gviSpursSpeexTaskDesc, uiPtr, sizeof(SpursSpeexTaskDesc), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); if (gviSpursSpeexTaskDesc.mDebugPause) { snPause(); } gviSpursSpeexEncoderInitialize(&spuOutput); if (spuOutput.mSpeexReturnCode < 0) { spuDebugPrintf("[Speex][SPU] failed to initialize encoder, ret = %d\n", spuOutput.mSpeexReturnCode); } //spuDebugPrintf("[Speex][SPU] done with initializing things for speex, now returning data via DMA put\n"); //printGlobalTaskDescData(); cellDmaPut(&spuOutput, (uint64_t)gviSpursSpeexTaskDesc.mSpeexTaskOutput, sizeof(SpursSpeexTaskOutput), DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] task dma done\n"); cellDmaLargePut(gviSpursSpeexStateBuffer, (uint64_t)gviSpursSpeexTaskDesc.mSpeexStateBuffer, SPEEX_ENCODER_STATE_BUFFER_SIZE, DMA_TAG(1), 0,0); cellDmaWaitTagStatusAll(DMA_MASK(1)); //spuDebugPrintf("[Speex][SPU] buffer dma done\n"); }
void dmaStoreRayOutput (ppu_address_t rayOutputAddr, const SpuRaycastTaskWorkUnitOut* rayOutput, uint32_t dmaTag) { cellDmaLargePut (rayOutput, rayOutputAddr, sizeof(*rayOutput), DMA_TAG(dmaTag), 0, 0); }
//-- MAIN METHOD void processSampleTask(void* userPtr, void* lsMemory) { // BT_PROFILE("processSampleTask"); SampleTask_LocalStoreMemory* localMemory = (SampleTask_LocalStoreMemory*)lsMemory; SpuSampleTaskDesc* taskDescPtr = (SpuSampleTaskDesc*)userPtr; SpuSampleTaskDesc& taskDesc = *taskDescPtr; switch (taskDesc.m_sampleCommand) { case CMD_SAMPLE_INTEGRATE_BODIES: { btTransform predictedTrans; btCollisionObject** eaPtr = (btCollisionObject**)taskDesc.m_mainMemoryPtr; int batchSize = taskDesc.m_sampleValue; if (batchSize>MAX_NUM_BODIES) { spu_printf("SPU Error: exceed number of bodies, see MAX_NUM_BODIES in SpuSampleTask.cpp\n"); break; } int dmaArraySize = batchSize*sizeof(void*); uint64_t ppuArrayAddress = reinterpret_cast<uint64_t>(eaPtr); // spu_printf("array location is at %llx, batchSize = %d, DMA size = %d\n",ppuArrayAddress,batchSize,dmaArraySize); if (dmaArraySize>=16) { cellDmaLargeGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); } else { stallingUnalignedDmaSmallGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize); } for ( int i=0;i<batchSize;i++) { ///DMA rigid body void* localPtr = &localMemory->gLocalRigidBody[0]; void* shortAdd = localMemory->gPointerArray[i]; uint64_t ppuRigidBodyAddress = reinterpret_cast<uint64_t>(shortAdd); // spu_printf("cellDmaGet at CMD_SAMPLE_INTEGRATE_BODIES from %llx to %llx\n",ppuRigidBodyAddress,localPtr); int dmaBodySize = sizeof(btRigidBody); cellDmaGet((void*)localPtr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); float timeStep = 1.f/60.f; btRigidBody* body = (btRigidBody*) localPtr;//btRigidBody::upcast(colObj); if (body) { if (body->isActive() && (!body->isStaticOrKinematicObject())) { body->predictIntegratedTransform(timeStep, predictedTrans); body->proceedToTransform( predictedTrans); void* ptr = (void*)localPtr; // spu_printf("cellDmaLargePut from %llx to LS %llx\n",ptr,ppuRigidBodyAddress); cellDmaLargePut(ptr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); } } } break; } case CMD_SAMPLE_PREDICT_MOTION_BODIES: { btTransform predictedTrans; btCollisionObject** eaPtr = (btCollisionObject**)taskDesc.m_mainMemoryPtr; int batchSize = taskDesc.m_sampleValue; int dmaArraySize = batchSize*sizeof(void*); if (batchSize>MAX_NUM_BODIES) { spu_printf("SPU Error: exceed number of bodies, see MAX_NUM_BODIES in SpuSampleTask.cpp\n"); break; } uint64_t ppuArrayAddress = reinterpret_cast<uint64_t>(eaPtr); // spu_printf("array location is at %llx, batchSize = %d, DMA size = %d\n",ppuArrayAddress,batchSize,dmaArraySize); if (dmaArraySize>=16) { cellDmaLargeGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); } else { stallingUnalignedDmaSmallGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize); } for ( int i=0;i<batchSize;i++) { ///DMA rigid body void* localPtr = &localMemory->gLocalRigidBody[0]; void* shortAdd = localMemory->gPointerArray[i]; uint64_t ppuRigidBodyAddress = reinterpret_cast<uint64_t>(shortAdd); // spu_printf("cellDmaGet at CMD_SAMPLE_INTEGRATE_BODIES from %llx to %llx\n",ppuRigidBodyAddress,localPtr); int dmaBodySize = sizeof(btRigidBody); cellDmaGet((void*)localPtr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); float timeStep = 1.f/60.f; btRigidBody* body = (btRigidBody*) localPtr;//btRigidBody::upcast(colObj); if (body) { if (!body->isStaticOrKinematicObject()) { if (body->isActive()) { body->integrateVelocities( timeStep); //damping body->applyDamping(timeStep); body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform()); void* ptr = (void*)localPtr; cellDmaLargePut(ptr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0); cellDmaWaitTagStatusAll(DMA_MASK(1)); } } } } break; } default: { } }; }