mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
(GCMGL) Cleanups #3
This commit is contained in:
parent
c6a091ef7f
commit
c7daeb29a9
@ -131,15 +131,12 @@ extern PSGLdeviceParameters * rglShadowDeviceParameters (void);
|
||||
extern GLboolean rglPlatformDeviceInit (void *data);
|
||||
extern void rglPlatformDeviceExit (void);
|
||||
extern int rglPlatformCreateDevice (void *data);
|
||||
extern void rglPlatformDestroyDevice (void *data);
|
||||
extern void rglPlatformSwapBuffers (void *data);
|
||||
extern const GLvoid* rglPlatformGetProcAddress (const char *funcName);
|
||||
|
||||
//----------------------------------------
|
||||
// Raster/.../PlatformRaster.c
|
||||
//----------------------------------------
|
||||
void* rglPlatformRasterInit (void);
|
||||
void rglPlatformRasterExit (void* data);
|
||||
void rglPlatformRasterDestroyResources (void);
|
||||
GLboolean rglPlatformNeedsConversion (const rglAttributeState* as, GLuint index);
|
||||
void rglInvalidateAttributes (void);
|
||||
|
@ -285,7 +285,7 @@
|
||||
gcm_emit_at(thisContext->current, 1, ((enable) | ((alphaToCoverage) << 4) | ((alphaToOne) << 8) | ((sampleMask) << 16))); \
|
||||
gcm_finish_n_commands(thisContext->current, 2);
|
||||
|
||||
#define rglGcmFifoFinish(ref, offset_bytes) \
|
||||
#define rglGcmFifoFinish(fifo, ref, offset_bytes) \
|
||||
ref = rglGcmFifoPutReference( fifo ); \
|
||||
rglGcmFifoFlush( fifo, offset_bytes ); \
|
||||
while (rglGcmFifoReferenceInUse(fifo, ref));
|
||||
|
@ -52,7 +52,7 @@ typedef struct
|
||||
// double/triple buffering management
|
||||
GLuint drawBuffer; // 0, 1, or 2
|
||||
GLuint scanBuffer; // 0, 1, or 2
|
||||
// resc buffers (maintain pointers for freeing in rglPlatformDestroyDevice)
|
||||
// resc buffers
|
||||
GLuint RescColorBuffersId;
|
||||
GLuint RescVertexArrayId;
|
||||
GLuint RescFragmentShaderId;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <cell/sysmodule.h>
|
||||
#include <cell/gcm.h>
|
||||
#include <cell/gcm/gcm_method_data.h>
|
||||
#include <cell/resc.h>
|
||||
|
||||
static GLuint nvFenceCounter = 0;
|
||||
@ -890,10 +889,7 @@ static uint8_t gmmSizeToFreeIndex(uint32_t size)
|
||||
return 21;
|
||||
}
|
||||
|
||||
static void gmmAddFree(
|
||||
GmmAllocator *pAllocator,
|
||||
GmmBlock *pBlock
|
||||
)
|
||||
static void gmmAddFree(GmmAllocator *pAllocator, GmmBlock *pBlock)
|
||||
{
|
||||
uint8_t freeIndex = gmmSizeToFreeIndex(pBlock->base.size);
|
||||
|
||||
@ -1428,7 +1424,7 @@ GLuint rglGcmFifoPutReference (void *data)
|
||||
|
||||
if (( fifo->lastSWReferenceWritten & 0x7fffffff ) == 0 )
|
||||
{
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
}
|
||||
|
||||
return fifo->lastSWReferenceWritten;
|
||||
@ -1526,7 +1522,7 @@ GLboolean rglGcmInitFromRM( rglGcmResource *rmResource )
|
||||
|
||||
rglGcmFifoInit( &rglGcmSt->fifo, rmResource->dmaControl, rmResource->dmaPushBufferOffset, (uint32_t*)rmResource->dmaPushBuffer, rmResource->dmaPushBufferSize );
|
||||
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
|
||||
// Set the GPU to a known state
|
||||
// initialize the default OpenGL state
|
||||
@ -1571,7 +1567,7 @@ GLboolean rglGcmInitFromRM( rglGcmResource *rmResource )
|
||||
|
||||
// wait for setup to complete
|
||||
offset_bytes = 0;
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@ -1679,44 +1675,6 @@ enable: 0,
|
||||
|
||||
static int rglInitCompleted = 0;
|
||||
|
||||
void rglPsglPlatformInit (void *data)
|
||||
{
|
||||
RGLinitOptions *options = (RGLinitOptions*)data;
|
||||
|
||||
if ( !rglInitCompleted )
|
||||
{
|
||||
cellSysmoduleLoadModule( CELL_SYSMODULE_GCM_SYS );
|
||||
cellSysmoduleLoadModule( CELL_SYSMODULE_RESC );
|
||||
|
||||
rglDeviceInit( options );
|
||||
_CurrentContext = NULL;
|
||||
_CurrentDevice = NULL;
|
||||
}
|
||||
|
||||
rglInitCompleted = 1;
|
||||
}
|
||||
|
||||
void rglPsglPlatformExit(void)
|
||||
{
|
||||
RGLcontext* LContext = _CurrentContext;
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
rglGcmFifo * fifo = &rglGcmState_i.fifo;
|
||||
|
||||
if ( LContext )
|
||||
{
|
||||
unsigned int offset_bytes = 0;
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFlush(fifo, offset_bytes);
|
||||
|
||||
psglMakeCurrent( NULL, NULL );
|
||||
rglDeviceExit();
|
||||
|
||||
_CurrentContext = NULL;
|
||||
|
||||
rglInitCompleted = 0;
|
||||
}
|
||||
}
|
||||
|
||||
RGL_EXPORT RGLdevice* rglPlatformCreateDeviceAuto( GLenum colorFormat, GLenum depthFormat, GLenum multisamplingMode )
|
||||
{
|
||||
RGLdeviceParameters parameters;
|
||||
@ -2010,7 +1968,6 @@ GLboolean rglPlatformDeviceInit (void *data)
|
||||
return rglGcmInit( options, &rglGcmResource );
|
||||
}
|
||||
|
||||
|
||||
void rglPlatformDeviceExit (void)
|
||||
{
|
||||
rglGcmDestroy();
|
||||
@ -2098,7 +2055,7 @@ GLboolean rglGcmTryResizeTileRegion( GLuint address, GLuint size, void* data )
|
||||
rglGcmUtilWaitForIdle();
|
||||
|
||||
retVal = cellGcmUnbindTile( region->id );
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
@ -2121,7 +2078,7 @@ GLboolean rglGcmTryResizeTileRegion( GLuint address, GLuint size, void* data )
|
||||
retVal = cellGcmBindTile( region->id );
|
||||
|
||||
offset_bytes = 0;
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@ -2741,7 +2698,7 @@ int rglPlatformCreateDevice (void *data)
|
||||
|
||||
cellGcmSetFlipMode( gcmDevice->vsync ? CELL_GCM_DISPLAY_VSYNC : CELL_GCM_DISPLAY_HSYNC );
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
|
||||
for ( int i = 0; i < params->bufferingMode; ++i )
|
||||
{
|
||||
@ -2761,52 +2718,6 @@ int rglPlatformCreateDevice (void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rglPlatformDestroyDevice (void *data)
|
||||
{
|
||||
RGLdevice *device = (RGLdevice*)data;
|
||||
rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo;
|
||||
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
|
||||
RGLdeviceParameters *params = &device->deviceParameters;
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
GLuint ref;
|
||||
unsigned int offset_bytes = 0;
|
||||
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
|
||||
// Stop flip callback
|
||||
if ( rescIsEnabled( params ) )
|
||||
cellRescSetFlipHandler(NULL);
|
||||
else
|
||||
cellGcmSetFlipHandler(NULL);
|
||||
|
||||
// Stop VBlank callback
|
||||
if ( rescIsEnabled( &device->deviceParameters ) )
|
||||
cellRescSetVBlankHandler(NULL);
|
||||
else
|
||||
cellGcmSetVBlankHandler(NULL);
|
||||
|
||||
// Destroy semaphore
|
||||
int res = sys_semaphore_destroy(FlipSem);
|
||||
(void)res; // prevent unused variable warning in opt build
|
||||
|
||||
if ( rescIsEnabled( params ) )
|
||||
{
|
||||
cellRescExit();
|
||||
rglGcmFreeTiledSurface(gcmDevice->RescColorBuffersId);
|
||||
gmmFree(gcmDevice->RescVertexArrayId);
|
||||
gmmFree(gcmDevice->RescFragmentShaderId);
|
||||
}
|
||||
|
||||
rglDuringDestroyDevice = GL_TRUE;
|
||||
for ( int i = 0; i < params->bufferingMode; ++i )
|
||||
{
|
||||
if ( gcmDevice->color[i].pool != RGLGCM_SURFACE_POOL_NONE )
|
||||
rglGcmFreeTiledSurface( gcmDevice->color[i].dataId );
|
||||
}
|
||||
rglDuringDestroyDevice = GL_FALSE;
|
||||
}
|
||||
|
||||
GLAPI void RGL_EXPORT psglSwap (void)
|
||||
{
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
@ -3857,7 +3768,7 @@ void RGL_EXPORT psglDestroyContext (void *data)
|
||||
if ( _CurrentContext == LContext )
|
||||
{
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
}
|
||||
|
||||
while ( LContext->RGLcgContextHead != ( CGcontext )NULL )
|
||||
@ -4001,12 +3912,40 @@ GLAPI const GLubyte* APIENTRY glGetString( GLenum name )
|
||||
|
||||
void psglInit (void *data)
|
||||
{
|
||||
rglPsglPlatformInit((RGLinitOptions*)data);
|
||||
RGLinitOptions *options = (RGLinitOptions*)data;
|
||||
|
||||
if ( !rglInitCompleted )
|
||||
{
|
||||
cellSysmoduleLoadModule( CELL_SYSMODULE_GCM_SYS );
|
||||
cellSysmoduleLoadModule( CELL_SYSMODULE_RESC );
|
||||
|
||||
rglDeviceInit( options );
|
||||
_CurrentContext = NULL;
|
||||
_CurrentDevice = NULL;
|
||||
}
|
||||
|
||||
rglInitCompleted = 1;
|
||||
}
|
||||
|
||||
void psglExit(void)
|
||||
{
|
||||
rglPsglPlatformExit();
|
||||
RGLcontext* LContext = _CurrentContext;
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
rglGcmFifo * fifo = &rglGcmState_i.fifo;
|
||||
|
||||
if ( LContext )
|
||||
{
|
||||
unsigned int offset_bytes = 0;
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFlush(fifo, offset_bytes);
|
||||
|
||||
psglMakeCurrent( NULL, NULL );
|
||||
rglDeviceExit();
|
||||
|
||||
_CurrentContext = NULL;
|
||||
|
||||
rglInitCompleted = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
@ -4405,13 +4344,54 @@ RGL_EXPORT void psglGetRenderBufferDimensions (const RGLdevice * device, GLuint
|
||||
RGL_EXPORT void psglDestroyDevice (void *data)
|
||||
{
|
||||
RGLdevice *device = (RGLdevice*)data;
|
||||
rglGcmDriver *driver = (rglGcmDriver*)device->rasterDriver;
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo;
|
||||
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
|
||||
RGLdeviceParameters *params = &device->deviceParameters;
|
||||
GLuint ref;
|
||||
unsigned int offset_bytes = 0;
|
||||
|
||||
if (_CurrentDevice == device)
|
||||
psglMakeCurrent( NULL, NULL );
|
||||
|
||||
if (device->rasterDriver)
|
||||
rglPlatformRasterExit( device->rasterDriver );
|
||||
if (driver)
|
||||
free(driver);
|
||||
|
||||
rglPlatformDestroyDevice( device );
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
|
||||
// Stop flip callback
|
||||
if ( rescIsEnabled( params ) )
|
||||
cellRescSetFlipHandler(NULL);
|
||||
else
|
||||
cellGcmSetFlipHandler(NULL);
|
||||
|
||||
// Stop VBlank callback
|
||||
if ( rescIsEnabled( &device->deviceParameters ) )
|
||||
cellRescSetVBlankHandler(NULL);
|
||||
else
|
||||
cellGcmSetVBlankHandler(NULL);
|
||||
|
||||
// Destroy semaphore
|
||||
int res = sys_semaphore_destroy(FlipSem);
|
||||
(void)res; // prevent unused variable warning in opt build
|
||||
|
||||
if ( rescIsEnabled( params ) )
|
||||
{
|
||||
cellRescExit();
|
||||
rglGcmFreeTiledSurface(gcmDevice->RescColorBuffersId);
|
||||
gmmFree(gcmDevice->RescVertexArrayId);
|
||||
gmmFree(gcmDevice->RescFragmentShaderId);
|
||||
}
|
||||
|
||||
rglDuringDestroyDevice = GL_TRUE;
|
||||
for ( int i = 0; i < params->bufferingMode; ++i )
|
||||
{
|
||||
if ( gcmDevice->color[i].pool != RGLGCM_SURFACE_POOL_NONE )
|
||||
rglGcmFreeTiledSurface( gcmDevice->color[i].dataId );
|
||||
}
|
||||
rglDuringDestroyDevice = GL_FALSE;
|
||||
|
||||
free( device );
|
||||
}
|
||||
@ -4427,7 +4407,24 @@ void RGL_EXPORT psglMakeCurrent (RGLcontext *context, RGLdevice *device)
|
||||
_CurrentDevice = device;
|
||||
|
||||
if ( !device->rasterDriver )
|
||||
device->rasterDriver = rglPlatformRasterInit();
|
||||
{
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo;
|
||||
GLuint ref;
|
||||
unsigned int offset_bytes = 0;
|
||||
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
|
||||
rglGcmDriver *driver = (rglGcmDriver*)malloc(sizeof(rglGcmDriver));
|
||||
memset(driver, 0, sizeof(rglGcmDriver));
|
||||
|
||||
driver->rt.yInverted = true;
|
||||
driver->invalidateVertexCache = GL_FALSE;
|
||||
driver->flushBufferCount = 0;
|
||||
|
||||
device->rasterDriver = driver;
|
||||
}
|
||||
|
||||
//attach context
|
||||
if (!context->everAttached)
|
||||
|
@ -892,7 +892,7 @@ char *rglPlatformBufferObjectMap (void *data, GLenum access)
|
||||
unsigned int offset_bytes = 0;
|
||||
// must wait in order to read
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
rglGcmFifoFinish(fifo, ref, offset_bytes);
|
||||
}
|
||||
|
||||
rglBuffer->mapAccess = access;
|
||||
@ -1204,39 +1204,6 @@ GLenum rglPlatformFramebufferCheckStatus (void *data)
|
||||
#define RGLGCM_MAX_VERTEX_BUFFER_SIZE (2 << 20)
|
||||
#define RGLGCM_MAX_INDEX_BUFFER_SIZE (1 << 20)
|
||||
|
||||
// Initialize the driver and setup the fixed function pipeline
|
||||
// shader and needed connections between GL state and the shader
|
||||
void *rglPlatformRasterInit (void)
|
||||
{
|
||||
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
|
||||
rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo;
|
||||
GLuint ref;
|
||||
unsigned int offset_bytes = 0;
|
||||
|
||||
rglGcmSetInvalidateVertexCache(thisContext);
|
||||
rglGcmFifoFinish(ref, offset_bytes);
|
||||
|
||||
rglGcmDriver *driver = (rglGcmDriver*)malloc(sizeof(rglGcmDriver));
|
||||
memset(driver, 0, sizeof(rglGcmDriver));
|
||||
|
||||
driver->rt.yInverted = true;
|
||||
driver->invalidateVertexCache = GL_FALSE;
|
||||
driver->flushBufferCount = 0;
|
||||
|
||||
// [YLIN] Make it 16 byte align
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
// Destroy the driver, and free all its used memory
|
||||
void rglPlatformRasterExit (void *data)
|
||||
{
|
||||
rglGcmDriver *driver = (rglGcmDriver*)data;
|
||||
|
||||
if (driver)
|
||||
free(driver);
|
||||
}
|
||||
|
||||
void rglDumpFifo (char *name);
|
||||
|
||||
#undef RGLGCM_REMAP_MODES
|
||||
@ -2449,26 +2416,6 @@ GLenum rglPlatformChooseInternalStorage (void *data, GLenum internalFormat )
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
|
||||
static inline void textureReferences_pushBack(rglTexture *element)
|
||||
{
|
||||
RGLcontext* LContext = (RGLcontext*)_CurrentContext;
|
||||
rglTexture *texture = (rglTexture*)rglGetCurrentTexture( LContext->CurrentImageUnit, GL_TEXTURE_2D );
|
||||
rglBufferObject *bufferObject = (rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer];
|
||||
|
||||
uint32_t newCapacity = bufferObject->textureReferences.count + 1;
|
||||
|
||||
if (newCapacity > bufferObject->textureReferences.capacity)
|
||||
{
|
||||
if ( newCapacity > bufferObject->textureReferences.capacity )
|
||||
newCapacity = ( newCapacity > bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment ) ? newCapacity : ( bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment );
|
||||
|
||||
bufferObject->textureReferences.array = (rglTexture**)realloc((void *)(bufferObject->textureReferences.array), sizeof(rglTexture) * newCapacity);
|
||||
bufferObject->textureReferences.capacity = newCapacity;
|
||||
}
|
||||
new((void *)(bufferObject->textureReferences.array + bufferObject->textureReferences.count))rglTexture((const rglTexture&)element);
|
||||
++bufferObject->textureReferences.count;
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels,
|
||||
GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset )
|
||||
{
|
||||
@ -2543,7 +2490,18 @@ GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels,
|
||||
texture->revalidate |= RGL_TEXTURE_REVALIDATE_PARAMETERS;
|
||||
rglTextureTouchFBOs( texture );
|
||||
|
||||
textureReferences_pushBack(texture);
|
||||
uint32_t newCapacity = bufferObject->textureReferences.count + 1;
|
||||
|
||||
if (newCapacity > bufferObject->textureReferences.capacity)
|
||||
{
|
||||
if ( newCapacity > bufferObject->textureReferences.capacity )
|
||||
newCapacity = ( newCapacity > bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment ) ? newCapacity : ( bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment );
|
||||
|
||||
bufferObject->textureReferences.array = (rglTexture**)realloc((void *)(bufferObject->textureReferences.array), sizeof(rglTexture) * newCapacity);
|
||||
bufferObject->textureReferences.capacity = newCapacity;
|
||||
}
|
||||
new((void *)(bufferObject->textureReferences.array + bufferObject->textureReferences.count))rglTexture((const rglTexture&)texture);
|
||||
++bufferObject->textureReferences.count;
|
||||
|
||||
texture->referenceBuffer = bufferObject;
|
||||
texture->offset = offset;
|
||||
|
Loading…
x
Reference in New Issue
Block a user