When I use a 128x128 transparent texture, staticly allocated in VRAM, I get 5-6 white line artifakts across the texture. However if I use the same texture in system ram it works perfectly. The format Im using is 4444, Ive also tried 8888 but same result.
I dont think it's an texture allocation problem since my other textures work like they should. Im mixing 5650 and 4444 textures. Ive tried to only have my transparent texture in VRAM but I get the same white artifakts.
I also don't think it's a cache flush problem since it's only my transparent texture that get these artifacts.
Im also using the PSPTexTool, created by Henrik Rydgård, to convert my png textures.
here is my code for GU Init
Code: Select all
m_pBackBuffer = m_VRAM.getStaticVramBuffer( m_BufferWidth, m_ScreenHeight, GU_PSM_5650 );
m_pFrontBuffer = m_VRAM.getStaticVramBuffer( m_BufferWidth, m_ScreenHeight, GU_PSM_5650 );
m_pZBuffer = m_VRAM.getStaticVramBuffer( m_BufferWidth, m_ScreenHeight, GU_PSM_4444 );
m_pShadowMapTarget = m_VRAM.getStaticVramTexture( 128, 128, GU_PSM_4444 );
sceGuInit();
sceGuStart( GU_DIRECT, GetDrawList() );
sceGuDrawBuffer( GU_PSM_5650, m_pBackBuffer, m_BufferWidth );
sceGuDispBuffer( m_ScreenWidth, m_ScreenHeight, m_pFrontBuffer, m_BufferWidth );
sceGuDepthBuffer( m_pZBuffer, m_BufferWidth );
sceGuOffset( 2048 - (m_ScreenWidth/2),2048 - (m_ScreenHeight/2) );
sceGuViewport( 2048,2048, m_ScreenWidth, m_ScreenHeight);
sceGuDepthRange( 65535,0 );
sceGuScissor( 0, 0, m_ScreenWidth, m_ScreenHeight );
sceGuEnable(GU_SCISSOR_TEST);
sceGuDepthFunc(GU_GEQUAL);
sceGuEnable(GU_DEPTH_TEST);
sceGuFrontFace(GU_CW);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_CULL_FACE);
sceGuEnable(GU_TEXTURE_2D);
sceGuEnable(GU_CLIP_PLANES);
// sceGuClutMode(GU_PSM_4444,0,255,0);
// sceGuClutLoad(256/8,palette);
sceGuEnable(GU_LIGHTING);
sceGuEnable(GU_LIGHT0);
sceGuEnable(GU_LIGHT1);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
here is the code for uploading the texture to vram. Im doing this when I load my level. getStaticVramTexture is the same as in the sdk samples.
Code: Select all
void TextureManager::UploadTexture( unsigned int a_idTexture, bool a_bStatic )
{
Texture* pTexture = m_vTexturePool[ a_idTexture ];
if( a_bStatic )
{
pTexture->m_pVRAM = m_pVRAM->getStaticVramTexture( pTexture->m_ulCanvasWidth, pTexture->m_ulHeight, pTexture->m_Format );
sceGuStart( GU_DIRECT, m_pDevice->GetDrawList() );
sceGuCopyImage( pTexture->m_Format, 0, 0, pTexture->m_ulWidth, pTexture->m_ulHeight, pTexture->m_ulCanvasWidth, pTexture->m_pBuffer, 0, 0, pTexture->m_ulCanvasWidth, pTexture->m_pVRAM );
sceGuFinish();
sceGuSync( 0, 0 );
}
else
{
pTexture->m_pVRAM = (void*) sceGuGetMemory( (pTexture->m_ulCanvasWidth*pTexture->m_ulCanvasHeight)*pTexture->m_bpp );
sceGuCopyImage( pTexture->m_Format, 0, 0, pTexture->m_ulWidth, pTexture->m_ulHeight, pTexture->m_ulCanvasWidth, pTexture->m_pBuffer, 0, 0, pTexture->m_ulCanvasWidth, pTexture->m_pVRAM );
sceGuTexSync();
}
}
here is the code for activating the texture
Code: Select all
void TextureManager::SetTexture( unsigned int a_idTexture )
{
Texture* pTexture = m_vTexturePool[ a_idTexture ];
sceGuEnable( GU_TEXTURE_2D );
sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGBA );
sceGuTexWrap( GU_REPEAT, GU_REPEAT );
sceGuTexFilter( GU_LINEAR, GU_LINEAR );
sceGuTexScale( 1.0f, 1.0f );
sceGuTexOffset( 0.0f, 0.0f );
if( pTexture->m_pVRAM != NULL )
{
sceGuTexMode( pTexture->m_Format, 0, 0, pTexture->m_bSwizzled );
sceGuTexImage( 0, pTexture->m_ulCanvasWidth, pTexture->m_ulCanvasHeight, pTexture->m_ulCanvasWidth, pTexture->m_pVRAM );
}
else
{
sceGuTexMode( pTexture->m_Format, 0, 0, pTexture->m_bSwizzled );
sceGuTexImage( 0, pTexture->m_ulCanvasWidth, pTexture->m_ulCanvasHeight, pTexture->m_ulCanvasWidth, pTexture->m_pBuffer );
}
}
this is how I render the transparent objects.
Code: Select all
sceGuStart( GU_DIRECT, GetDrawList() );
sceGuClearColor( 0xff554433 );
sceGuClearDepth( 0 );
sceGuClear( GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT );
sceGuTexEnvColor( 0xffff00 );
sceGuAmbientColor( 0xffffffff );
sceGuSpecular(12.0f);
sceGuAmbient(0x00222222);
// Update camera
m_pCamera->Update( m_CellSelector.GetPos() );
sceGumMatrixMode(GU_MODEL);
sceGuDisable( GU_LIGHTING );
sceGuEnable( GU_BLEND );
sceGuBlendFunc( GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 );
sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGBA );
m_pTextureManager->SetTexture( 4 );
// Draw player X
for( size_t i=0; i<m_PlayerXData.m_vOnCells.size(); i++ )
{
sceGumLoadIdentity();
sceGumTranslate( &m_PlayerXData.m_vOnCells[i]->m_vPos );
sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_NORMAL_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_3D, m_PlayerXMesh.GetNumVerts(), 0, m_PlayerXMesh.GetVertices() );
}
sceGuFinish();
sceGuSync( 0, 0 );
sceDisplayWaitVblankStart();
m_pBackBuffer = sceGuSwapBuffers();
Hope I have provided you all with usefull information. Tell me if I need to add something. Thanks in advance.
PS. Ill try to get a screenshot.
// CentralUnit