(RGLGCM PS3) Get rid of some extraneous elses

This commit is contained in:
twinaphex 2014-09-02 17:01:09 +02:00
parent e68f62040d
commit b742f46765
3 changed files with 78 additions and 114 deletions

View File

@ -206,7 +206,8 @@ GLboolean rglTexNameSpaceCreateNameLazy(void *data, GLuint name )
if ( !ns->data[name] ) if ( !ns->data[name] )
{ {
ns->data[name] = ns->create(); ns->data[name] = ns->create();
if ( ns->data[name] ) return GL_TRUE; if (ns->data[name])
return GL_TRUE;
} }
return GL_FALSE; return GL_FALSE;
} }
@ -219,7 +220,7 @@ GLboolean rglTexNameSpaceIsName(void *data, GLuint name )
if ((name > 0) && (name < ns->capacity)) if ((name > 0) && (name < ns->capacity))
return( ns->data[name] != 0 ); return( ns->data[name] != 0 );
else return GL_FALSE; return GL_FALSE;
} }
// Generate new n names in namespace ns // Generate new n names in namespace ns
@ -432,8 +433,9 @@ static uint32_t gmmInit(const void *localMemoryBase, const void *localStartAddre
memset(pAllocator, 0, sizeof(GmmAllocator)); memset(pAllocator, 0, sizeof(GmmAllocator));
if (pAllocator) if (!pAllocator)
{ return GMM_ERROR;
pAllocator->memoryBase = (uint32_t)localMemoryBase; pAllocator->memoryBase = (uint32_t)localMemoryBase;
pAllocator->startAddress = (uint32_t)localStartAddress; pAllocator->startAddress = (uint32_t)localStartAddress;
pAllocator->size = alignedLocalSize; pAllocator->size = alignedLocalSize;
@ -442,9 +444,6 @@ static uint32_t gmmInit(const void *localMemoryBase, const void *localStartAddre
pAllocator->totalSize = alignedLocalSize; pAllocator->totalSize = alignedLocalSize;
pGmmLocalAllocator = pAllocator; pGmmLocalAllocator = pAllocator;
}
else
return GMM_ERROR;
pLock = cellGcmGetLabelAddress(GMM_PPU_WAIT_INDEX); pLock = cellGcmGetLabelAddress(GMM_PPU_WAIT_INDEX);
*pLock = 0; *pLock = 0;
@ -585,7 +584,6 @@ static GmmTileBlock *gmmFindFreeTileBlock(
return pNewBlock; return pNewBlock;
} }
else
return NULL; return NULL;
} }
@ -845,47 +843,46 @@ static uint8_t gmmSizeToFreeIndex(uint32_t size)
{ {
if (size >= GMM_FREE_BIN_0 && size < GMM_FREE_BIN_1) if (size >= GMM_FREE_BIN_0 && size < GMM_FREE_BIN_1)
return 0; return 0;
else if (size >= GMM_FREE_BIN_1 && size < GMM_FREE_BIN_2) if (size >= GMM_FREE_BIN_1 && size < GMM_FREE_BIN_2)
return 1; return 1;
else if (size >= GMM_FREE_BIN_2 && size < GMM_FREE_BIN_3) if (size >= GMM_FREE_BIN_2 && size < GMM_FREE_BIN_3)
return 2; return 2;
else if (size >= GMM_FREE_BIN_3 && size < GMM_FREE_BIN_4) if (size >= GMM_FREE_BIN_3 && size < GMM_FREE_BIN_4)
return 3; return 3;
else if (size >= GMM_FREE_BIN_4 && size < GMM_FREE_BIN_5) if (size >= GMM_FREE_BIN_4 && size < GMM_FREE_BIN_5)
return 4; return 4;
else if (size >= GMM_FREE_BIN_5 && size < GMM_FREE_BIN_6) if (size >= GMM_FREE_BIN_5 && size < GMM_FREE_BIN_6)
return 5; return 5;
else if (size >= GMM_FREE_BIN_6 && size < GMM_FREE_BIN_7) if (size >= GMM_FREE_BIN_6 && size < GMM_FREE_BIN_7)
return 6; return 6;
else if (size >= GMM_FREE_BIN_7 && size < GMM_FREE_BIN_8) if (size >= GMM_FREE_BIN_7 && size < GMM_FREE_BIN_8)
return 7; return 7;
else if (size >= GMM_FREE_BIN_8 && size < GMM_FREE_BIN_9) if (size >= GMM_FREE_BIN_8 && size < GMM_FREE_BIN_9)
return 8; return 8;
else if (size >= GMM_FREE_BIN_9 && size < GMM_FREE_BIN_10) if (size >= GMM_FREE_BIN_9 && size < GMM_FREE_BIN_10)
return 9; return 9;
else if (size >= GMM_FREE_BIN_10 && size < GMM_FREE_BIN_11) if (size >= GMM_FREE_BIN_10 && size < GMM_FREE_BIN_11)
return 10; return 10;
else if (size >= GMM_FREE_BIN_11 && size < GMM_FREE_BIN_12) if (size >= GMM_FREE_BIN_11 && size < GMM_FREE_BIN_12)
return 11; return 11;
else if (size >= GMM_FREE_BIN_12 && size < GMM_FREE_BIN_13) if (size >= GMM_FREE_BIN_12 && size < GMM_FREE_BIN_13)
return 12; return 12;
else if (size >= GMM_FREE_BIN_13 && size < GMM_FREE_BIN_14) if (size >= GMM_FREE_BIN_13 && size < GMM_FREE_BIN_14)
return 13; return 13;
else if (size >= GMM_FREE_BIN_14 && size < GMM_FREE_BIN_15) if (size >= GMM_FREE_BIN_14 && size < GMM_FREE_BIN_15)
return 14; return 14;
else if (size >= GMM_FREE_BIN_15 && size < GMM_FREE_BIN_16) if (size >= GMM_FREE_BIN_15 && size < GMM_FREE_BIN_16)
return 15; return 15;
else if (size >= GMM_FREE_BIN_16 && size < GMM_FREE_BIN_17) if (size >= GMM_FREE_BIN_16 && size < GMM_FREE_BIN_17)
return 16; return 16;
else if (size >= GMM_FREE_BIN_17 && size < GMM_FREE_BIN_18) if (size >= GMM_FREE_BIN_17 && size < GMM_FREE_BIN_18)
return 17; return 17;
else if (size >= GMM_FREE_BIN_18 && size < GMM_FREE_BIN_19) if (size >= GMM_FREE_BIN_18 && size < GMM_FREE_BIN_19)
return 18; return 18;
else if (size >= GMM_FREE_BIN_19 && size < GMM_FREE_BIN_20) if (size >= GMM_FREE_BIN_19 && size < GMM_FREE_BIN_20)
return 19; return 19;
else if (size >= GMM_FREE_BIN_20 && size < GMM_FREE_BIN_21) if (size >= GMM_FREE_BIN_20 && size < GMM_FREE_BIN_21)
return 20; return 20;
else
return 21; return 21;
} }
@ -2017,8 +2014,7 @@ static unsigned int findValidPitch( unsigned int pitch )
{ {
if (pitch <= validPitch[0]) if (pitch <= validPitch[0])
return validPitch[0]; return validPitch[0];
else
{
// dummy linear search // dummy linear search
for ( GLuint i = 0;i < validPitchCount - 1;++i ) for ( GLuint i = 0;i < validPitchCount - 1;++i )
if (( pitch > validPitch[i] ) && ( pitch <= validPitch[i+1] ) ) if (( pitch > validPitch[i] ) && ( pitch <= validPitch[i+1] ) )
@ -2026,7 +2022,6 @@ static unsigned int findValidPitch( unsigned int pitch )
return validPitch[validPitchCount-1]; return validPitch[validPitchCount-1];
} }
}
static GLboolean rglDuringDestroyDevice = GL_FALSE; static GLboolean rglDuringDestroyDevice = GL_FALSE;

View File

@ -78,11 +78,9 @@ static int rglGcmGenerateProgram (void *data, int profileIndex, const CgProgramH
size_t parameterSize = parameterHeader->entryCount * sizeof( CgRuntimeParameter ); size_t parameterSize = parameterHeader->entryCount * sizeof( CgRuntimeParameter );
void *memoryBlock; void *memoryBlock = NULL;
if ( parameterSize ) if ( parameterSize )
memoryBlock = memalign( 16, parameterSize ); memoryBlock = memalign( 16, parameterSize );
else
memoryBlock = NULL;
program->rtParametersCount = parameterHeader->entryCount; program->rtParametersCount = parameterHeader->entryCount;
program->runtimeParameters = ( CgRuntimeParameter* )memoryBlock; program->runtimeParameters = ( CgRuntimeParameter* )memoryBlock;
@ -197,16 +195,15 @@ CGprogram rglpCgUpdateProgramAtIndex( CGprogramGroup group, int index, int refco
} }
group->refCount += refcount; group->refCount += refcount;
if (refcount < 0) if (refcount < 0)
{ {
if (group->refCount == 0 && !group->userCreated) if (group->refCount == 0 && !group->userCreated)
rglCgDestroyProgramGroup( group ); rglCgDestroyProgramGroup( group );
return NULL; return NULL;
} }
else
return group->programs[index].program; return group->programs[index].program;
} }
else
return NULL; return NULL;
} }
@ -286,6 +283,8 @@ CGprogramGroup rglCgCreateProgramGroup( CGcontext ctx, const char *name, void *
group->userCreated = true; group->userCreated = true;
group->refCount = 0; group->refCount = 0;
group->filedata = ( char* )ptr; group->filedata = ( char* )ptr;
group->name = NULL;
if ( name ) if ( name )
{ {
int len = strlen( name ); int len = strlen( name );
@ -294,8 +293,6 @@ CGprogramGroup rglCgCreateProgramGroup( CGcontext ctx, const char *name, void *
break; break;
strcpy( group->name, name ); strcpy( group->name, name );
} }
else
group->name = NULL;
//copy the default values //copy the default values
if ( elfConstTableSize ) if ( elfConstTableSize )
@ -743,12 +740,9 @@ static CGparameter rglAdvanceParameter( CGparameter param, int distance )
ret |= ( arrayIndex << CG_PARAMETERSIZE ); ret |= ( arrayIndex << CG_PARAMETERSIZE );
return ( CGparameter )ret; return ( CGparameter )ret;
} }
else
{
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
} }
}
//stop when the distance is 0 //stop when the distance is 0
const CgParameterEntry *endEntry = rtParameter->program->parametersEntries + rtParameter->program->rtParametersCount; const CgParameterEntry *endEntry = rtParameter->program->parametersEntries + rtParameter->program->rtParametersCount;
@ -800,7 +794,6 @@ static CGparameter rglAdvanceParameter( CGparameter param, int distance )
CgRuntimeParameter *nextParameter = rtParameter + offset; CgRuntimeParameter *nextParameter = rtParameter + offset;
return nextParameter->id; return nextParameter->id;
} }
else
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
@ -1022,14 +1015,12 @@ static _CGparameter *_cgGetNamedParameter( _CGprogram* progPtr, const char* name
if ( !bWasUnrolled ) if ( !bWasUnrolled )
currentEntry++; currentEntry++;
} }
else
break;//not found break;//not found
} }
//have we found it ? //have we found it ?
if ( itemIndex != -1 ) if ( itemIndex != -1 )
return ( _CGparameter* )( program->runtimeParameters + itemIndex ); return ( _CGparameter* )( program->runtimeParameters + itemIndex );
else
return NULL; return NULL;
} }
@ -1055,7 +1046,6 @@ CG_API CGparameter cgGetNamedParameter( CGprogram prog, const char* name )
ret |= ( arrayIndex << CG_PARAMETERSIZE ); ret |= ( arrayIndex << CG_PARAMETERSIZE );
return ( CGparameter )ret; return ( CGparameter )ret;
} }
else
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
@ -1116,7 +1106,6 @@ CG_API CGparameter cgGetNextParameter( CGparameter param )
ret |= ( arrayIndex << CG_PARAMETERSIZE ); ret |= ( arrayIndex << CG_PARAMETERSIZE );
return ( CGparameter )ret; return ( CGparameter )ret;
} }
else
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
} }
@ -1157,12 +1146,9 @@ CG_API CGparameter cgGetNextParameter( CGparameter param )
bNextExists = true; bNextExists = true;
break; break;
} }
else
{
//no more items at this level return null //no more items at this level return null
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
}
break; break;
} }
case CGP_INTRINSIC: case CGP_INTRINSIC:
@ -1189,15 +1175,11 @@ CG_API CGparameter cgGetNextParameter( CGparameter param )
//the next item doesn't have the same global flag... since they are grouped, it means we have quitted the current struct //the next item doesn't have the same global flag... since they are grouped, it means we have quitted the current struct
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
else
return nextParam; return nextParam;
} }
else
{
//case where we were at the root and there is no more items //case where we were at the root and there is no more items
return ( CGparameter )NULL; return ( CGparameter )NULL;
} }
}
CG_API const char* cgGetParameterSemantic( CGparameter param ) CG_API const char* cgGetParameterSemantic( CGparameter param )
{ {
@ -1250,18 +1232,17 @@ CG_API CGenum cgGetParameterVariability( CGparameter param )
CgRuntimeParameter *rtParameter = ( CgRuntimeParameter* )rglCgGLTestParameter( param ); CgRuntimeParameter *rtParameter = ( CgRuntimeParameter* )rglCgGLTestParameter( param );
if ( !rtParameter ) if ( !rtParameter )
return ( CGenum )0; return ( CGenum )0;
else
{ {
unsigned int variability = rtParameter->parameterEntry->flags & CGPV_MASK; unsigned int variability = rtParameter->parameterEntry->flags & CGPV_MASK;
if ( variability == CGPV_UNIFORM ) if ( variability == CGPV_UNIFORM )
return CG_UNIFORM; return CG_UNIFORM;
else if ( variability == CGPV_VARYING ) if ( variability == CGPV_VARYING )
return CG_VARYING; return CG_VARYING;
else if ( variability == CGPV_CONSTANT ) if ( variability == CGPV_CONSTANT )
return CG_CONSTANT; return CG_CONSTANT;
else if ( variability == CGPV_MIXED ) if ( variability == CGPV_MIXED )
return CG_MIXED; return CG_MIXED;
else
return ( CGenum )0; return ( CGenum )0;
} }
} }
@ -1272,16 +1253,14 @@ CG_API CGenum cgGetParameterDirection( CGparameter param )
CgRuntimeParameter *rtParameter = ( CgRuntimeParameter* )rglCgGLTestParameter( param ); CgRuntimeParameter *rtParameter = ( CgRuntimeParameter* )rglCgGLTestParameter( param );
if ( !rtParameter ) if ( !rtParameter )
return CG_ERROR; return CG_ERROR;
else
{ {
unsigned int direction = rtParameter->parameterEntry->flags & CGPD_MASK; unsigned int direction = rtParameter->parameterEntry->flags & CGPD_MASK;
if ( direction == CGPD_IN ) if ( direction == CGPD_IN )
return CG_IN; return CG_IN;
else if ( direction == CGPD_OUT ) if ( direction == CGPD_OUT )
return CG_OUT; return CG_OUT;
else if ( direction == CGPD_INOUT ) if ( direction == CGPD_INOUT )
return CG_INOUT; return CG_INOUT;
else
return CG_ERROR; return CG_ERROR;
} }
} }
@ -2778,7 +2757,6 @@ static bool cgGetElfProgramByName( CGELFBinary *elfBinary, const char *name, CGE
if ( res != -1 ) if ( res != -1 )
return cgGetElfProgramByIndex( elfBinary, res, elfProgram ); return cgGetElfProgramByIndex( elfBinary, res, elfProgram );
else
return false; return false;
} }
@ -4785,11 +4763,8 @@ static int getStride(CgBaseType *type)
{ {
if (classnames[type->_type-1] == CG_PARAMETERCLASS_MATRIX) if (classnames[type->_type-1] == CG_PARAMETERCLASS_MATRIX)
return rows[type->_type-1]; return rows[type->_type-1];
else
return 1; return 1;
} }
else
{
if (type->_type == CG_STRUCT + 128) if (type->_type == CG_STRUCT + 128)
{ {
CgStructureType *structureType = (CgStructureType *)type; CgStructureType *structureType = (CgStructureType *)type;
@ -4800,14 +4775,9 @@ static int getStride(CgBaseType *type)
res += getStride(structureType->_elements[i]._type); res += getStride(structureType->_elements[i]._type);
return res; return res;
} }
else
{
//RGL_ASSERT2(0,("arrays of arrays not supported")); //RGL_ASSERT2(0,("arrays of arrays not supported"));
return -9999999; return -9999999;
} }
//if array ??
}
}
static int getSizeofSubArray(_CGNVCONTAINERS &containers, int dimensionIndex, int dimensionCount, int endianness) static int getSizeofSubArray(_CGNVCONTAINERS &containers, int dimensionIndex, int dimensionCount, int endianness)
{ {

View File

@ -1819,7 +1819,6 @@ static GLuint rglGetGcmTextureSize (void *data)
bytesNeeded += layout->pixelBits * width * height / 8; bytesNeeded += layout->pixelBits * width * height / 8;
else else
bytesNeeded += height * layout->pitch; bytesNeeded += height * layout->pitch;
return rglPad( bytesNeeded, faceAlign ); return rglPad( bytesNeeded, faceAlign );
} }