(RGL PS3) Reimplement more cellGcm functions

This commit is contained in:
twinaphex 2013-04-14 21:24:33 +02:00
parent 09ad685541
commit 9d1eab4b0e
3 changed files with 90 additions and 11 deletions

View File

@ -90,6 +90,79 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat)
(thisContext->current)[1] = (color); \
(thisContext->current) += 2;
#define rglGcmSetTextureBorder(thisContext, index, texture, border) \
uint32_t format, offset, control1, control3, imagerect; \
offset = texture->offset; \
format = (texture->location + 1) | (texture->cubemap << 2) | (border << 3) | (texture->dimension << 4) | (texture->format << 8) | (texture->mipmap << 16); \
imagerect = texture->height | (texture->width << 16); \
control1 = texture->remap; \
control3 = texture->pitch | (texture->depth << 20); \
(thisContext->current)[0] = (((2) << (18)) | ((0x00001a00) + ((index)) * 32)); \
(thisContext->current)[1] = (offset); \
(thisContext->current)[2] = (format); \
(thisContext->current) += 3; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001a18) + ((index)) * 32)); \
(thisContext->current)[1] = (imagerect); \
(thisContext->current) += 2; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001840) + ((index)) * 4)); \
(thisContext->current)[1] = (control3); \
(thisContext->current) += 2; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001a10) + ((index)) * 32)); \
(thisContext->current)[1] = (control1); \
(thisContext->current) += 2;
#define rglGcmSetUserClipPlaneControl(thisContext, plane0, plane1, plane2, plane3, plane4, plane5) \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001478))); \
(thisContext->current)[1] = ((plane0) | ((plane1) << 4) | ((plane2) << 8) | ((plane3) << 12) | ((plane4) << 16) | ((plane5) << 20)); \
(thisContext->current) += 2;
#define rglGcmSetInvalidateTextureCache(thisContext, value) \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001fd8))); \
(thisContext->current)[1] = (value); \
(thisContext->current) += 2;
#define rglGcmSetViewport(thisContext, x, y, w, h, min, max, scale, offset) \
CellGcmCast d0,d1; \
d0.f = min; \
d1.f = max; \
CellGcmCast o[4],s[4]; \
o[0].f = offset[0]; \
o[1].f = offset[1]; \
o[2].f = offset[2]; \
o[3].f = offset[3]; \
s[0].f = scale[0]; \
s[1].f = scale[1]; \
s[2].f = scale[2]; \
s[3].f = scale[3]; \
(thisContext->current)[0] = (((2) << (18)) | ((0x00000a00))); \
(thisContext->current)[1] = (((x)) | (((w)) << 16)); \
(thisContext->current)[2] = (((y)) | (((h)) << 16)); \
(thisContext->current) += 3; \
(thisContext->current)[0] = (((2) << (18)) | ((0x00000394))); \
(thisContext->current)[1] = (d0.u); \
(thisContext->current)[2] = (d1.u); \
(thisContext->current) += 3; \
(thisContext->current)[0] = (((8) << (18)) | ((0x00000a20))); \
(thisContext->current)[1] = (o[0].u); \
(thisContext->current)[2] = (o[1].u); \
(thisContext->current)[3] = (o[2].u); \
(thisContext->current)[4] = (o[3].u); \
(thisContext->current)[5] = (s[0].u); \
(thisContext->current)[6] = (s[1].u); \
(thisContext->current)[7] = (s[2].u); \
(thisContext->current)[8] = (s[3].u); \
(thisContext->current) += 9; \
(thisContext->current)[0] = (((8) << (18)) | ((0x00000a20))); \
(thisContext->current)[1] = (o[0].u); \
(thisContext->current)[2] = (o[1].u); \
(thisContext->current)[3] = (o[2].u); \
(thisContext->current)[4] = (o[3].u); \
(thisContext->current)[5] = (s[0].u); \
(thisContext->current)[6] = (s[1].u); \
(thisContext->current)[7] = (s[2].u); \
(thisContext->current)[8] = (s[3].u); \
(thisContext->current) += 9;
static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, uint8_t mode,
uint32_t first, uint32_t count)
{
@ -152,6 +225,7 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u
static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFar)
{
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
rglGcmViewportState *vp = (rglGcmViewportState*)data;
rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget;
@ -214,7 +288,7 @@ static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFa
float scale[4] = { vp->xScale, vp->yScale, z_scale, 0.0f};
float offset[4] = { vp->xCenter, vp->yCenter, z_center, 0.0f};
GCM_FUNC( cellGcmSetViewport, clipX0, clipY0, clipX1 - clipX0,
rglGcmSetViewport(thisContext, clipX0, clipY0, clipX1 - clipX0,
clipY1 - clipY0, zNear, zFar, scale, offset );
}

View File

@ -3105,7 +3105,10 @@ GLAPI void RGL_EXPORT psglSwap (void)
if ( rescIsEnabled( &device->deviceParameters ) )
cellRescSetWaitFlip(); // GPU will wait until flip actually occurs
else
cellGcmSetWaitFlip(); // GPU will wait until flip actually occurs
{
// GPU will wait until flip actually occurs
rglGcmSetWaitLabel(gCellGcmCurrentContext, 1, 0);
}
}
if ( rescIsEnabled( &device->deviceParameters ) )
@ -3120,14 +3123,17 @@ GLAPI void RGL_EXPORT psglSwap (void)
}
}
else
cellGcmSetFlip((uint8_t)drawBuffer);
cellGcmSetFlipUnsafe(gCellGcmCurrentContext, (uint8_t)drawBuffer);
if ( device->deviceParameters.bufferingMode != RGL_BUFFERING_MODE_TRIPLE )
{
if ( rescIsEnabled( &device->deviceParameters ) )
cellRescSetWaitFlip(); // GPU will wait until flip actually occurs
else
cellGcmSetWaitFlip(); // GPU will wait until flip actually occurs
{
// GPU will wait until flip actually occurs
rglGcmSetWaitLabel(gCellGcmCurrentContext, 1, 0);
}
}
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;

View File

@ -301,9 +301,7 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndex (voi
for ( long row = 0; row < ROWS; ++row )
{
for ( long col = 0; col < COLS; ++col )
{
tmp[row*4 + col] = dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row];
}
for ( long col = COLS; col < 4; ++col ) tmp[row*4 + col] = dst[row*4+col];
}
@ -323,9 +321,7 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndexArray
for ( long row = 0; row < ROWS; ++row )
{
for ( long col = 0; col < COLS; ++col )
{
tmp[row*4 + col] = dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row];
}
for ( long col = COLS; col < 4; ++col ) tmp[row*4 + col] = dst[row*4+col];
}
GCM_FUNC( cellGcmSetVertexProgramParameterBlock, resource, ROWS, tmp );
@ -1635,8 +1631,10 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
// set up the texture unit with the info for the current texture
// bind texture , control 1,3,format and remap
const CellGcmTexture *texture = (const CellGcmTexture*)&platformTexture->gcmTexture;
rglGcmSetTextureBorder(thisContext, unit, texture, 0x1);
GCM_FUNC_SAFE( cellGcmSetTexture, unit, &platformTexture->gcmTexture );
CellGcmContextData *gcm_context = (CellGcmContextData*)&rglGcmState_i.fifo;
cellGcmReserveMethodSizeInline(gcm_context, 11);
uint32_t *current = gcm_context->current;
@ -1721,7 +1719,7 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
rglOutOfSpaceCallback( fifo, spaceInWords );
GCM_FUNC( cellGcmSetVertexProgramLoad, &conf, program->ucode );
GCM_FUNC( cellGcmSetUserClipPlaneControl, 0, 0, 0, 0, 0, 0 );
rglGcmSetUserClipPlaneControl(thisContext, 0, 0, 0, 0, 0, 0 );
rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant;
s->vertexProgramAttribMask = program->header.vertexProgram.attributeOutputMask;
@ -2286,6 +2284,7 @@ void rglPlatformFreeGcmTexture (void *data)
// Validate texture resources
static void rglPlatformValidateTextureResources (void *data)
{
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
rglTexture *texture = (rglTexture*)data;
texture->isComplete = GL_TRUE;
@ -2459,7 +2458,7 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE,
if ( bounceBufferId != GMM_ERROR )
gmmFree( bounceBufferId );
GCM_FUNC( cellGcmSetInvalidateTextureCache, CELL_GCM_INVALIDATE_TEXTURE );
rglGcmSetInvalidateTextureCache(thisContext, CELL_GCM_INVALIDATE_TEXTURE );
}
// gcmTexture method command