(RGL PS3) Cleanups

This commit is contained in:
twinaphex 2013-11-02 01:13:25 +01:00
parent 484dd5c828
commit 7be9b2df18
5 changed files with 18 additions and 79 deletions

View File

@ -356,6 +356,7 @@ static void ps3_input_set_keybinds(void *data, unsigned device,
static void* ps3_input_init(void)
{
unsigned i;
ps3_input_t *ps3 = (ps3_input_t*)calloc(1, sizeof(*ps3));
if (!ps3)
return NULL;

View File

@ -113,7 +113,6 @@ uint32_t gmmInit(
);
uint32_t gmmDestroy(void);
uint32_t gmmIdToOffset(const uint32_t id);
char *gmmIdToAddress(const uint32_t id);
uint32_t gmmFPOffsetToId(
@ -132,7 +131,16 @@ uint32_t gmmAlloc(
const uint32_t size
);
uint32_t gmmGetBlockSize (const uint32_t id);
extern GmmAllocator *pGmmLocalAllocator;
#define GMM_ADDRESS_TO_OFFSET(address) (address - pGmmLocalAllocator->memoryBase)
#define gmmGetBlockSize(id) (((GmmBaseBlock*)id)->size)
#define gmmGetTileData(id) (((GmmTileBlock*)id)->pData)
#define gmmIdToOffset(id) (GMM_ADDRESS_TO_OFFSET(((GmmBaseBlock*)id)->address))
#define gmmAllocFixedTileBlock() ((GmmTileBlock*)gmmAllocFixed(1))
#define gmmFreeFixedTileBlock(data) (gmmFreeFixed(1, (GmmTileBlock*)data))
#define gmmFreeFixedBlock(data) (gmmFreeFixed(0, (GmmBlock*)data))
void gmmSetTileAttrib(
const uint32_t id,
@ -140,6 +148,4 @@ void gmmSetTileAttrib(
void *pData
);
void *gmmGetTileData (const uint32_t id);
#endif

View File

@ -28,7 +28,7 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat)
#define rglGcmSetVertexData4f(thisContext, index, v) \
thisContext->current[0] = (((4) << (18)) | (CELL_GCM_NV4097_SET_VERTEX_DATA4F_M + (index) * 16)); \
__builtin_memcpy(&thisContext->current[1], v, sizeof(float)*4); \
memcpy(&thisContext->current[1], v, sizeof(float)*4); \
thisContext->current += 5;
#define rglGcmSetVertexDataArray(thisContext, index, frequency, stride, size, type, location, offset) \
@ -448,9 +448,8 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon
for (i = 0; i < loop; i++)
{
thisContext->current[0] = (((32) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_PROGRAM);
__builtin_memcpy(&thisContext->current[1], &rawData[0], sizeof(uint32_t)*16);
__builtin_memcpy(&thisContext->current[17], &rawData[16], sizeof(uint32_t)*16);
memcpy(&thisContext->current[1], &rawData[0], sizeof(uint32_t)*16);
memcpy(&thisContext->current[17], &rawData[16], sizeof(uint32_t)*16);
thisContext->current += (1 + 32);
rawData += 32;

View File

@ -279,13 +279,12 @@ void rglTexNameSpaceDeleteNames(void *data, GLsizei n, const GLuint *names )
MEMORY MANAGER
============================================================ */
static GmmAllocator *pGmmLocalAllocator = NULL;
GmmAllocator *pGmmLocalAllocator = NULL;
static volatile uint32_t *pLock = NULL;
static uint32_t cachedLockValue = 0;
static GmmFixedAllocData *pGmmFixedAllocData = NULL;
#define PAD(x, pad) ((x + pad - 1) / pad * pad)
#define GMM_ADDRESS_TO_OFFSET(address) (address - pGmmLocalAllocator->memoryBase)
static uint32_t gmmInitFixedAllocator(void)
{
@ -439,23 +438,6 @@ static void gmmDestroyFixedAllocator (void)
#define GMM_ALLOC_FIXED_BLOCK() ((GmmBlock*)gmmAllocFixed(0))
static void gmmFreeFixedBlock (void *data)
{
GmmBlock *pBlock = (GmmBlock*)data;
gmmFreeFixed(0, pBlock);
}
static GmmTileBlock *gmmAllocFixedTileBlock (void)
{
return (GmmTileBlock *)gmmAllocFixed(1);
}
static void gmmFreeFixedTileBlock (void *data)
{
GmmTileBlock *pTileBlock = (GmmTileBlock*)data;
gmmFreeFixed(1, pTileBlock);
}
uint32_t gmmInit(
const void *localMemoryBase,
const void *localStartAddress,
@ -547,16 +529,6 @@ uint32_t gmmDestroy (void)
return CELL_OK;
}
uint32_t gmmGetBlockSize(const uint32_t id)
{
return ((GmmBaseBlock *)id)->size;
}
void *gmmGetTileData(const uint32_t id)
{
return ((GmmTileBlock *)id)->pData;
}
void gmmSetTileAttrib(const uint32_t id, const uint32_t tag,
void *pData)
{
@ -566,12 +538,6 @@ void gmmSetTileAttrib(const uint32_t id, const uint32_t tag,
pTileBlock->pData = pData;
}
uint32_t gmmIdToOffset(const uint32_t id)
{
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id;
return GMM_ADDRESS_TO_OFFSET(pBaseBlock->address);
}
char *gmmIdToAddress (const uint32_t id)
{
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id;
@ -621,9 +587,7 @@ static GmmBlock *gmmAllocBlock(
{
pNewBlock = GMM_ALLOC_FIXED_BLOCK();
if (pNewBlock == NULL)
{
return NULL;
}
memset(pNewBlock, 0, sizeof(GmmBlock));
@ -1119,7 +1083,7 @@ static inline void gmmLocalMemcpy(void *data, const uint32_t dstOffset,
int32_t sizeLeft = moveSize;
int32_t dimension = 4096;
while (sizeLeft > 0)
while (sizeLeft)
{
while(sizeLeft >= dimension*dimension*4)
{
@ -1138,7 +1102,7 @@ static inline void gmmLocalMemcpy(void *data, const uint32_t dstOffset,
4);
offset = offset + dimension*dimension*4;
sizeLeft = sizeLeft - (dimension*dimension*4);
sizeLeft -= (dimension*dimension*4);
}
dimension = dimension >> 1;
@ -1147,7 +1111,7 @@ static inline void gmmLocalMemcpy(void *data, const uint32_t dstOffset,
break;
}
if (sizeLeft > 0)
if (sizeLeft)
{
rglGcmSetTransferImage(gCellGcmCurrentContext,
CELL_GCM_TRANSFER_LOCAL_TO_LOCAL,
@ -1172,12 +1136,10 @@ static inline void gmmMemcpy(void *data, const uint8_t mode,
CellGcmContextData *thisContext = (CellGcmContextData*)data;
if (dstOffset + moveSize <= srcOffset)
{
gmmLocalMemcpy(thisContext,
dstOffset,
srcOffset,
moveSize);
}
else
{
uint32_t moveBlockSize = srcOffset-dstOffset;
@ -1318,9 +1280,7 @@ static uint8_t gmmInternalSweep(void *data)
}
if (pBlock->pPrev)
{
availableSize = pBlock->base.address - (pBlock->pPrev->base.address + pBlock->pPrev->base.size);
}
pTempBlock = pTempBlockNext;
}

View File

@ -4981,33 +4981,6 @@ static void fillStructureItems(_CGNVCONTAINERS &containers, CgStructureType *str
unsigned short *arrayDefaultValueIndex = NULL);
int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTableOffset, void **binaryShader, int *size,
std::vector<char> &stringTable, std::vector<float> &defaultValues)
{
FILE *fp = fopen(sourceFile, "rb");
if (fp)
{
fseek(fp,0,SEEK_END);
size_t filesize = ftell(fp);
fseek(fp,0,SEEK_SET);
void *data = malloc(filesize);
if (data == NULL)
{
fclose(fp);
//RGL_ASSERT2(0,("not enough memory to read the shader source"));
return -2;
}
fread(data,filesize,1,fp);
fclose(fp);
int res = convertNvToElfFromMemory(data,filesize,endianness,constTableOffset, binaryShader, size,stringTable,defaultValues);
free(data);
return res;
}
//RGL_ASSERT2(0,("couldn't open source file %s\n",sourceFile));
return -1;
}
#define swap16(v) ((v>>16) | (v<<16))
int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize,