From 6c2efb1384bc47de1d3b6c25275731fd9af3fdc9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Mar 2013 22:15:46 +0100 Subject: [PATCH] (RGL PS3) Get rid of rglMemcpy --- ps3/rgl/include/RGL/private.h | 7 -- ps3/rgl/src/ps3/include/rgl-externs.h | 1 - ps3/rgl/src/ps3/include/rgl-inline.h | 18 ++++ ps3/rgl/src/ps3/rgl_ps3.cpp | 130 +------------------------- ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 11 ++- 5 files changed, 28 insertions(+), 139 deletions(-) diff --git a/ps3/rgl/include/RGL/private.h b/ps3/rgl/include/RGL/private.h index b31bc9154b..db1c634038 100644 --- a/ps3/rgl/include/RGL/private.h +++ b/ps3/rgl/include/RGL/private.h @@ -123,17 +123,10 @@ void rglPlatformFramebufferGetParameteriv( GLenum pname, GLint* params ); //---------------------------------------- // VertexArray.c //---------------------------------------- -void rglVertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); void rglVertexAttribPointerNV( GLuint index, GLint fsize, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer ); void rglEnableVertexAttribArrayNV( GLuint index ); void rglDisableVertexAttribArrayNV( GLuint index ); -//---------------------------------------- -// Platform/Init.c -//---------------------------------------- -extern void rglPlatformInit (void *data); -extern void rglPlatformExit (void); - //---------------------------------------- // Device/Device.c //---------------------------------------- diff --git a/ps3/rgl/src/ps3/include/rgl-externs.h b/ps3/rgl/src/ps3/include/rgl-externs.h index e8046fe583..fb0b42449e 100644 --- a/ps3/rgl/src/ps3/include/rgl-externs.h +++ b/ps3/rgl/src/ps3/include/rgl-externs.h @@ -9,7 +9,6 @@ int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords); void rglGcmFifoGlSetRenderTarget (const void *args); void rglCreatePushBuffer (void *data); void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, const char *src, unsigned int size ); -void rglGcmMemcpy( const GLuint dstId, unsigned dstOffset, unsigned int pitch, const GLuint srcId, GLuint srcOffset, unsigned int size ); void rglGcmFreeTiledSurface (GLuint bufferId); void rglGcmCopySurface(const void *data, GLuint srcX, GLuint srcY, diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 699c2d7579..db2b059e9d 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -295,3 +295,21 @@ static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer) rglGcmBufferObject *gcmBuffer = (rglGcmBufferObject *)bufferObject->platformBufferObject; return gcmBuffer->bufferId; } + +static inline void rglGcmTransferData +( + GLuint dstId, + GLuint dstIdOffset, + GLint dstPitch, + GLuint srcId, + GLuint srcIdOffset, + GLint srcPitch, + GLint bytesPerRow, + GLint rowCount + ) +{ + GLuint dstOffset = gmmIdToOffset(dstId) + dstIdOffset; + GLuint srcOffset = gmmIdToOffset(srcId) + srcIdOffset; + + GCM_FUNC( cellGcmSetTransferData, CELL_GCM_TRANSFER_LOCAL_TO_LOCAL, dstOffset, dstPitch, srcOffset, srcPitch, bytesPerRow, rowCount ); +} diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 9e0818d63e..2b207e0563 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -1576,25 +1576,6 @@ uint32_t gmmAlloc(void *data, /*============================================================ SURFACE COPYING ============================================================ */ - -static inline void rglGcmTransferData -( - GLuint dstId, - GLuint dstIdOffset, - GLint dstPitch, - GLuint srcId, - GLuint srcIdOffset, - GLint srcPitch, - GLint bytesPerRow, - GLint rowCount - ) -{ - GLuint dstOffset = gmmIdToOffset(dstId) + dstIdOffset; - GLuint srcOffset = gmmIdToOffset(srcId) + srcIdOffset; - - GCM_FUNC( cellGcmSetTransferData, CELL_GCM_TRANSFER_LOCAL_TO_LOCAL, dstOffset, dstPitch, srcOffset, srcPitch, bytesPerRow, rowCount ); -} - void rglGcmCopySurface( const void *data, GLuint srcX, GLuint srcY, @@ -1913,75 +1894,6 @@ void rglGcmAllocDestroy() rglGcmDestroy(); } -void rglGcmMemcpy( const GLuint dstId, unsigned dstOffset, unsigned int pitch, const GLuint srcId, GLuint srcOffset, unsigned int size ) -{ - // check alignment - // Vid to vid copy requires 64-byte aligned base address (for dst pointer). - if ((gmmIdToOffset(dstId) % 64 ) == 0 && ( dstOffset % 2 ) == 0 && - (gmmIdToOffset(srcId) % 2 ) == 0 && ( srcOffset % 2) == 0 && - ( size % 2 ) == 0 && ( pitch % 64 ) == 0 ) - { - // configure a 2D transfer - // - // align destination - { - pitch = pitch ? : 64; // minimum pitch - // target buffer isn't tiled, we just need to align on pitch - const GLuint dstOffsetAlign = dstOffset % pitch; - if ( dstOffsetAlign ) - { - const GLuint firstBytes = MIN( pitch - dstOffsetAlign, size ); - - rglGcmFifoGlTransferDataVidToVid( - dstId, - 0, - pitch, // dst pitch - dstOffsetAlign / 2, dstOffset / pitch, // dst x,y start - srcId, - srcOffset, - pitch, // src pitch - 0, 0, // src x,y start - firstBytes / 2, 1, // size in pixels - 2 ); // pixel size in bytes - dstOffset += firstBytes; - srcOffset += firstBytes; - size -= firstBytes; - } - } - - const GLuint fullLines = size / pitch; - const GLuint extraBytes = size % pitch; - if ( fullLines ) - rglGcmFifoGlTransferDataVidToVid( - dstId, - 0, - pitch, // dst pitch - 0, dstOffset / pitch, // dst x,y start - srcId, - srcOffset, - pitch, // src pitch - 0, 0, // src x,y start - pitch / 2, fullLines, // size in pixels - 2 ); // pixel size in bytes - if ( extraBytes ) - rglGcmFifoGlTransferDataVidToVid( - dstId, - 0, - pitch, // dst pitch - 0, fullLines + dstOffset / pitch, // dst x,y start - srcId, - srcOffset, - pitch, // src pitch - 0, fullLines, // src x,y start - extraBytes / 2, 1, // size in pixels - 2 ); // pixel size in bytes - } - else - { - rglGcmTransferData( dstId, dstOffset, size, srcId, 0, size, size, 1 ); - } -} - void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, const char *src, unsigned int size ) { @@ -1990,7 +1902,7 @@ void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, 0, size); memcpy( gmmIdToAddress(id), src, size ); - rglGcmMemcpy( dstId, dstOffset, pitch, id, 0, size ); + rglGcmTransferData( dstId, dstOffset, size, id, 0, size, size, 1 ); gmmFree( id ); } @@ -2010,32 +1922,6 @@ static inline int rescIsEnabled (void *data) RGL_DEVICE_PARAMETERS_RESC_ADJUST_ASPECT_RATIO ); } -// Platform-specific initialization for Cell processor: -// manage allocation/free of SPUs, and optional debugging console. - -void rglPlatformInit (void *data) -{ - (void)data; -} - - -void rglPlatformExit(void) -{ -} - -/*============================================================ - PLATFORM REPORTING - ============================================================ */ - -void rglInitConsole (GLuint enable) -{ - (void)enable; -} - -void rglExitConsole(void) -{ -} - /*============================================================ DEVICE CONTEXT CREATION ============================================================ */ @@ -2095,7 +1981,6 @@ void rglPsglPlatformInit (void *data) break; } - rglPlatformInit( options ); rglDeviceInit( options ); _CurrentContext = NULL; _CurrentDevice = NULL; @@ -2115,7 +2000,6 @@ void rglPsglPlatformExit(void) psglMakeCurrent( NULL, NULL ); rglDeviceExit(); - rglPlatformExit(); _CurrentContext = NULL; @@ -4825,18 +4709,6 @@ void rglDisableVertexAttribArrayNV (GLuint index) RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); } -void rglVertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - RGLcontext* LContext = _CurrentContext; - - rglAttribute* attrib = LContext->attribs->attrib + index; - attrib->value[0] = x; - attrib->value[1] = y; - attrib->value[2] = z; - attrib->value[3] = w; - RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); -} - /*============================================================ DEVICE CONTEXT CREATION ============================================================ */ diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index ceb3228f6e..101852fdef 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -60,7 +60,14 @@ static void setAttribConstantIndex (void *data, const void* __restrict v, const const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); GLuint index = parameterResource->resource - CG_ATTR0; float * f = ( float* ) v; - rglVertexAttrib4fNV( index, f[0], f[1], f[2], f[3] ); + RGLcontext* LContext = _CurrentContext; + + rglAttribute* attrib = LContext->attribs->attrib + index; + attrib->value[0] = f[0]; + attrib->value[1] = f[1]; + attrib->value[2] = f[2]; + attrib->value[3] = f[3]; + RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); } void rglPlatformSetVertexRegister4fv (unsigned int reg, const float * __restrict v) @@ -1220,7 +1227,7 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr rglGcmBufferObject* dst = (rglGcmBufferObject*)in_dst->platformBufferObject; rglGcmBufferObject* src = (rglGcmBufferObject*)in_src->platformBufferObject; - rglGcmMemcpy( dst->bufferId, 0, dst->pitch, src->bufferId, 0, src->bufferSize ); + rglGcmTransferData( dst->bufferId, 0, src->bufferSize, src->bufferId, 0, src->bufferSize, src->bufferSize, 1 ); // be conservative here. Whenever we write to any Buffer Object, invalidate the vertex cache driver->invalidateVertexCache = GL_TRUE;