This commit is contained in:
ejcoumans
2007-07-09 05:35:20 +00:00
parent 121fd7808e
commit 6915b168b2
2 changed files with 28 additions and 44 deletions

View File

@@ -14,12 +14,12 @@ subject to the following restrictions:
*/ */
//#define __CELLOS_LV2__ 1 //#define __CELLOS_LV2__ 1
#define USE_SAMPLE_PROCESS 1
#ifdef USE_SAMPLE_PROCESS #ifdef USE_SAMPLE_PROCESS
#include "btThreadSupportInterface.h"
#include "SpuLibspe2Support.h"
#include "Win32ThreadSupport.h"
//#include "SPUAssert.h" //#include "SPUAssert.h"
#include <string.h> #include <string.h>
@@ -43,20 +43,6 @@ void* SamplelsMemoryFunc()
return 0; return 0;
} }
#ifdef USE_IBM_CELL_SDK
//SpuLibspe2Support gSampleSPU(SPU_ELF_SAMPLE,SAMPLE_NUM_WORKUNIT_TASKS);
#elif defined(WIN32)
Win32ThreadSupport gSampleSPU(Win32ThreadSupport::Win32ThreadConstructionInfo("sample",
SampleThreadFunc,
SamplelsMemoryFunc,
SAMPLE_NUM_WORKUNIT_TASKS));
#elif defined(__CELLOS_LV2__)
#include "CellSPURSSupport.ppu.h"
CellSPURSSupport gSampleSPU(SPU_ELF_SAMPLE);
#endif
extern "C" { extern "C" {
@@ -67,14 +53,15 @@ extern "C" {
//SpuSampleTaskDesc g_spuSampleTaskDesc[SAMPLE_NUM_WORKUNIT_TASKS]; SpuSampleTaskProcess::SpuSampleTaskProcess(btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks)
:m_threadInterface(threadInterface),
m_maxNumOutstandingTasks(maxNumOutstandingTasks)
SpuSampleTaskProcess::SpuSampleTaskProcess()
{ {
for (int i = 0; i < SAMPLE_NUM_WORKUNIT_TASKS; i++) m_taskBusy.resize(m_maxNumOutstandingTasks);
m_spuSampleTaskDesc.resize(m_maxNumOutstandingTasks);
for (int i = 0; i < m_maxNumOutstandingTasks; i++)
{ {
m_taskBusy[i] = false; m_taskBusy[i] = false;
} }
@@ -85,20 +72,12 @@ SpuSampleTaskProcess::SpuSampleTaskProcess()
m_threadInterface->startSPU(); m_threadInterface->startSPU();
#ifdef WIN32
Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo(
"sample",SampleThreadFunc,SamplelsMemoryFunc);
gSampleSPU.startSPU(threadConstructionInfo);
#else
gSampleSPU.startSPU();
#endif
} }
SpuSampleTaskProcess::~SpuSampleTaskProcess() SpuSampleTaskProcess::~SpuSampleTaskProcess()
{ {
gSampleSPU.stopSPU(); m_threadInterface->stopSPU();
} }
@@ -110,7 +89,7 @@ void SpuSampleTaskProcess::initialize()
printf("SpuSampleTaskProcess::initialize()\n"); printf("SpuSampleTaskProcess::initialize()\n");
#endif //DEBUG_SPU_TASK_SCHEDULING #endif //DEBUG_SPU_TASK_SCHEDULING
for (int i = 0; i < SAMPLE_NUM_WORKUNIT_TASKS; i++) for (int i = 0; i < m_maxNumOutstandingTasks; i++)
{ {
m_taskBusy[i] = false; m_taskBusy[i] = false;
} }
@@ -131,7 +110,7 @@ void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue)
m_taskBusy[m_currentTask] = true; m_taskBusy[m_currentTask] = true;
m_numBusyTasks++; m_numBusyTasks++;
SpuSampleTaskDesc& taskDesc = g_spuSampleTaskDesc[m_currentTask]; SpuSampleTaskDesc& taskDesc = m_spuSampleTaskDesc[m_currentTask];
{ {
// send task description in event message // send task description in event message
// no error checking here... // no error checking here...
@@ -145,16 +124,16 @@ void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue)
} }
gSampleSPU.sendRequest(CMD_SAMPLE_TASK_COMMAND, (uint32_t) &taskDesc, m_currentTask); m_threadInterface->sendRequest(CMD_SAMPLE_TASK_COMMAND, (uint32_t) &taskDesc, m_currentTask);
// if all tasks busy, wait for spu event to clear the task. // if all tasks busy, wait for spu event to clear the task.
if (m_numBusyTasks >= SAMPLE_NUM_WORKUNIT_TASKS) if (m_numBusyTasks >= m_maxNumOutstandingTasks)
{ {
unsigned int taskId; unsigned int taskId;
unsigned int outputSize; unsigned int outputSize;
gSampleSPU.waitForResponse(&taskId, &outputSize); m_threadInterface->waitForResponse(&taskId, &outputSize);
//printf("PPU: after issue, received event: %u %d\n", taskId, outputSize); //printf("PPU: after issue, received event: %u %d\n", taskId, outputSize);
@@ -166,7 +145,7 @@ void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue)
} }
// find new task buffer // find new task buffer
for (unsigned int i = 0; i < SAMPLE_NUM_WORKUNIT_TASKS; i++) for (unsigned int i = 0; i < m_maxNumOutstandingTasks; i++)
{ {
if (!m_taskBusy[i]) if (!m_taskBusy[i])
{ {
@@ -200,7 +179,7 @@ void SpuSampleTaskProcess::flush()
{ {
gSampleSPU.waitForResponse(&taskId, &outputSize); m_threadInterface->waitForResponse(&taskId, &outputSize);
} }
//printf("PPU: flushing, received event: %u %d\n", taskId, outputSize); //printf("PPU: flushing, received event: %u %d\n", taskId, outputSize);

View File

@@ -23,9 +23,7 @@ subject to the following restrictions:
#include <stdlib.h> #include <stdlib.h>
///maximum outstanding tasks #include "LinearMath/btAlignedObjectArray.h"
#define SAMPLE_NUM_WORKUNIT_TASKS 4
///SpuSampleTaskDesc ///SpuSampleTaskDesc
@@ -52,7 +50,9 @@ __attribute__ ((aligned (16)))
class SpuSampleTaskProcess class SpuSampleTaskProcess
{ {
// track task buffers that are being used, and total busy tasks // track task buffers that are being used, and total busy tasks
bool m_taskBusy[SAMPLE_NUM_WORKUNIT_TASKS]; btAlignedObjectArray<bool> m_taskBusy;
btAlignedObjectArray<SpuSampleTaskDesc>m_spuSampleTaskDesc;
unsigned int m_numBusyTasks; unsigned int m_numBusyTasks;
// the current task and the current entry to insert a new work unit // the current task and the current entry to insert a new work unit
@@ -62,9 +62,14 @@ class SpuSampleTaskProcess
void postProcess(int taskId, int outputSize); void postProcess(int taskId, int outputSize);
class btThreadSupportInterface* m_threadInterface;
unsigned int m_maxNumOutstandingTasks;
public: public:
SpuSampleTaskProcess(); SpuSampleTaskProcess(btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks);
~SpuSampleTaskProcess(); ~SpuSampleTaskProcess();