OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
spursSupportInterface.h
1/* [SCE CONFIDENTIAL DOCUMENT]
2 * PLAYSTATION(R)3 SPU Optimized Bullet Physics Library (http://bulletphysics.com)
3 * Copyright (C) 2007 Sony Computer Entertainment Inc.
4 * All Rights Reserved.
5 */
6
7
8#ifndef __SPURS_SUPPORT_INTERFACE_H
9#define __SPURS_SUPPORT_INTERFACE_H
10
11#include <cell/spurs/queue.h>
12#include "spursUtilityMacros.h"
13#include "spursThreadSupportInterface.h"
14
15#ifdef __SPU__
16#include <simd>
17
18#include <sdk_version.h>
19
20#if CELL_SDK_VERSION < 0x081000
21#define CELL_SPURS_TASK_ERROR_AGAIN CELL_SPURS_EAGAIN
22#define CELL_SPURS_TASK_ERROR_BUSY CELL_SPURS_EBUSY
23#endif // CELL_SDK_VERSION < 0x081000
24
25#else // __SPU__
26#include <cell/spurs/task.h>
27
28#endif // __SPU__
29
30#define CELL_SPURS_RESPONSE_QUEUE_SIZE 128
31
41// only one type of SPURS Task ELF
42// typedef enum {
43// // SPU_ELF_MID_PHASE=0,
44// // SPU_ELF_SOLVER,
45// SPU_ELF_SPEEX,
46// SPU_ELF_LAST,
47// } CellSpursElfId_t;
48
49typedef union CellSPURSArgument
50{
51 struct
52 {
53 CELL_PPU_POINTER(CellSpursQueue) ppuResponseQueue;
54 uint32_t uiCommand;
55 uint32_t uiArgument0;
56 uint32_t uiArgument1;
57 };
58
59#if __PPU__
60 CellSpursTaskArgument spursArgument;
61#elif __SPU__
62 vec_uint4 uiQWord;
63#endif
64} CellSPURSArgument __attribute__((aligned(16)));
65
66#if __SPU__
67#include "SPUAssert.h"
68#include <cell/spurs/task.h>
69
70static inline void sendResponseToPPU(uint32_t ppuQueueEA, uint32_t uiArgument0,
71 uint32_t uiArgument1, int iTag=1) {
72 CellSPURSArgument response
73 __attribute__ ((aligned(16)));
74
75 response.uiArgument0=uiArgument0;
76 response.uiArgument1=uiArgument1;
77
78 int iReturn;
79 do {
80 iReturn=cellSpursQueueTryPushBegin(ppuQueueEA, &response, iTag);
81 } while (iReturn == CELL_SPURS_TASK_ERROR_AGAIN ||
82 iReturn == CELL_SPURS_TASK_ERROR_BUSY);
83
84 SPU_ASSERT((iReturn == CELL_OK) && "Error writing to SPURS queue.");
85
86 cellSpursQueuePushEnd(ppuQueueEA, iTag);
87
88}
89
90static inline void sendResponseToPPUAndExit(uint32_t ppuQueueEA, uint32_t uiArgument0,
91 uint32_t uiArgument1, int iTag=1) {
92 CellSPURSArgument response
93 __attribute__ ((aligned(16)));
94
95 response.uiArgument0=uiArgument0;
96 response.uiArgument1=uiArgument1;
97
98 int iReturn;
99 do {
100 iReturn=cellSpursQueueTryPushBegin(ppuQueueEA, &response, iTag);
101 } while (iReturn == CELL_SPURS_TASK_ERROR_AGAIN ||
102 iReturn == CELL_SPURS_TASK_ERROR_BUSY);
103
104 SPU_ASSERT((iReturn == CELL_OK) && "Error writing to SPURS queue.");
105
106 cellSpursQueuePushEnd(ppuQueueEA, iTag);
107
108 cellSpursExit();
109}
110#elif __PPU__ // not __SPU__
111
112class SpursSupportInterface : public spursThreadSupportInterface
113{
114public:
115 SpursSupportInterface();
116 ~SpursSupportInterface();
117 int sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t uiArgument1=0);
118 int waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1);
119 int startSPU();
120 int stopSPU();
121
122protected:
123 //CellSpursElfId_t m_elfId;
124 void *m_spursTaskAddress;
125 CellSpursQueue m_responseQueue __attribute__((aligned(128)));
126 CellSPURSArgument m_aResponseBuffer[CELL_SPURS_RESPONSE_QUEUE_SIZE] __attribute__((aligned(16)));
127
128 bool m_bQueueInitialized;
129};
130#endif // __SPU__ / __PPU__
131
132
133#endif // CELL_SPURS_SUPPORT_H
Definition spursthreadsupportinterface.h:25
virtual int stopSPU()=0
tell the task scheduler we are done with the SPU tasks
virtual int waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1)=0
check for messages from SPUs
virtual int sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t uiArgument1)=0
send messages to SPUs
virtual int startSPU()=0
start the spus (can be called at the beginning of each frame, to make sure that the right SPU program...
Definition spursSupportInterface.h:50