SDL tearing/flickering during update
SDL tearing/flickering during update
Im having some trouble with SDL on psp.
The screen , for some reason , flickers during update (sdl_flip()) , and ONLY, when objects are moving(and we're talking about 5-10 objects which use the same surface...).
I have tried every possible solution that i found after searching on forums , but , nothing really worked (Except setting Software mode rendering , and screen bpp to 16).
Also , removing displayvblank() function(before calling sdl_flip) with my own timer , improved the frames a little more..
sceKernelDcacheWritebackAll before rendering anything didnt help either.
Any other suggestions?
EDIT: Screen surface is double-buffered (init code : sdl_init(480,272,16,SDL_DOUBLEBUF | SDL_SWSURFACE)
The screen , for some reason , flickers during update (sdl_flip()) , and ONLY, when objects are moving(and we're talking about 5-10 objects which use the same surface...).
I have tried every possible solution that i found after searching on forums , but , nothing really worked (Except setting Software mode rendering , and screen bpp to 16).
Also , removing displayvblank() function(before calling sdl_flip) with my own timer , improved the frames a little more..
sceKernelDcacheWritebackAll before rendering anything didnt help either.
Any other suggestions?
EDIT: Screen surface is double-buffered (init code : sdl_init(480,272,16,SDL_DOUBLEBUF | SDL_SWSURFACE)
Can't find any solution.
I've been trying for more than 3 hours.
Things that i've tried:
-Optimize loaded surfaces to screen format : result : a little boost
-Created an even more accurate timer : result : better visual result
What i haven't tried yet:
-Convert sdl surface to 8bit mode..
Tearing still occurs , and makes the game unplayable(who's going to play a platform game with so bad performance?....no one)
I've been thinking to switch to SDL+OpenGL(im more familiar with opengl),
But i have a few questions ...
1) OpenGL is Hardware or Software accelerated?
2) In windows/linux the standar way to initialize SDL + opengl , is :
SDL_Setvideomode(width,height,bpp,SDL_OPENGL|SDL_GL_DOUBLEBUFFER)
It will work the same on psp?
3) PSPGL is what im after(hardware opengl support on psp)?
Thanks for looking..
I've been trying for more than 3 hours.
Things that i've tried:
-Optimize loaded surfaces to screen format : result : a little boost
-Created an even more accurate timer : result : better visual result
What i haven't tried yet:
-Convert sdl surface to 8bit mode..
Tearing still occurs , and makes the game unplayable(who's going to play a platform game with so bad performance?....no one)
I've been thinking to switch to SDL+OpenGL(im more familiar with opengl),
But i have a few questions ...
1) OpenGL is Hardware or Software accelerated?
2) In windows/linux the standar way to initialize SDL + opengl , is :
SDL_Setvideomode(width,height,bpp,SDL_OPENGL|SDL_GL_DOUBLEBUFFER)
It will work the same on psp?
3) PSPGL is what im after(hardware opengl support on psp)?
Thanks for looking..
foreword: i know nothing about SDL
1) ?????? If it was software it would be not accelerated at all. Punctualization: on PC, if openGl can't find an hardware way to perform a base task, it will do it in software. Actually this was true 5 years ago, now a card has every basilar acceleration needed, while advanced ones (extensions and shaders) are generally too complex to be emulated. As i already said, pspGl is good, but is still lacking some useful features...
2) see foreword
3) yes, pspGl is a layer upon GE and i think it's doing in hardware all the things it can do in hardware (like GU/GUM)...don't really know about matrix manipulation on VFPU...
1) ?????? If it was software it would be not accelerated at all. Punctualization: on PC, if openGl can't find an hardware way to perform a base task, it will do it in software. Actually this was true 5 years ago, now a card has every basilar acceleration needed, while advanced ones (extensions and shaders) are generally too complex to be emulated. As i already said, pspGl is good, but is still lacking some useful features...
2) see foreword
3) yes, pspGl is a layer upon GE and i think it's doing in hardware all the things it can do in hardware (like GU/GUM)...don't really know about matrix manipulation on VFPU...
I think SDL already handles waiting for vblank (the docs are unclear if the platform should do this, and if I recall correctly the PSP does). Also try SDL_HWSURFACE as the code paths for SWSURFACE and HWSURFACE are very different. as always you can check the source for all the details :)removing displayvblank() function(before calling sdl_flip) with my own timer
@Jean:
Thanks for the reply , you covered all my questions :)
@Jimparis:
I dont know why , but with SWSURFACE the program runs a little faster.
But again , since the tearing effect is there , you can only see this effect
in debug log where all statistics are printed.
Im so disapointed with SDL...so much work for nothing.
_____________________________________________
I just installed PSPGL(modified version) , and after all the trouble installing it (had to edit a header..),
it seems that every opengl command will hang the psp!(..........so bad luck)
Here's my code:
And my makefile:
Thanks for the reply , you covered all my questions :)
@Jimparis:
I dont know why , but with SWSURFACE the program runs a little faster.
But again , since the tearing effect is there , you can only see this effect
in debug log where all statistics are printed.
Im so disapointed with SDL...so much work for nothing.
_____________________________________________
I just installed PSPGL(modified version) , and after all the trouble installing it (had to edit a header..),
it seems that every opengl command will hang the psp!(..........so bad luck)
Here's my code:
Code: Select all
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "Callbacks.h"
#include "NamedTextures.h"
PSP_MODULE_INFO("GLAPP", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VFPU | PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(20480);
/*typedef enum
{
BALL = 255
};*/
int main()
{
CALLBACKS::SetupCallbacks();
SDL_Init (SDL_INIT_VIDEO);
SDL_SetVideoMode( 480, 272, 32, SDL_OPENGL|SDL_GL_DOUBLEBUFFER );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
//2d
glViewport(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, SCREEN_WIDTH,SCREEN_HEIGHT, 0, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
/*
CNamedTextures texture_list;
texture_list.add("sprite.tga",BALL);
texture_list.callByName(BALL);*/
glTranslatef(50,50,0);
// a quad
glBegin( GL_QUADS ),glColor4f( 1.0, 1.0, 1.0, 1.0 );
glVertex3f( 0, 0, 0 ),glVertex3f( 32, 0, 0 );
glVertex3f( 32, 32, 0 ),glVertex3f( 0, 32, 0 );
glEnd();
SDL_GL_SwapBuffers();
SDL_Delay(5000);
Code: Select all
-CFLAGS= -Wall -g -G0 -I/usr/local/pspdev/psp/include -I/usr/local/pspdev/psp/sdk/include -fsingle-precision-constant -O2 \
-DHAVE_OPENGL
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -c
OBJS=main.o NamedTextures.o ImageLoader.o CallBacks.o
TARGET = sdlgltest
BUILD_PRX = 1
PSP_FW_VERSION = 371
LIBDIR =
LDFLAGS =
LIBS= -lstdc++ -lSDL -lGLU -lGL -lpng -ljpeg -lz -lm -lstdc++ -lc -lc -lpsputility -lpspdebug -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspvfpu -lpspuser -lpsprtc -lpsppower -lpspdebug -lpspge -lpspaudio -lpspctrl -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpsphprm -lpspsdk
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = sdlgltest
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
HardDrive : yes , i've tried already, without any results.
@jimparis:
My code looks EXACTLY(WELL,also includes pseudo-code ..) like this:
@jimparis:
My code looks EXACTLY(WELL,also includes pseudo-code ..) like this:
Code: Select all
CALLBACKS::SetupCallbacks();
MEMORYTRACKER::Init();
set clock speed 333
SDL_Init (SDL_INIT_VIDEO);
screen=SDL_SetVideoMode( 480, 272, 16, SDL_SWSURFACE | SDL_DOUBLEBUF );
CEvents* e = ALLOC_TRACKMEM(CEvents); // a define that creates dynamically(using 'new' operator) the object,
// and updates memory tracker...for statistics
CTimer* t = ALLOC_TRACKMEM(CTimer);
CResource* rc = ALLOC_TRACKMEM(CResource);
rc->init(); //load player's object & bullet system
e->init();
e->start();
t->reset();
while( (e->running()) )
{
e->proccess();//read SDL input events/messages etc.
handle player movement
if e->keyPressed(KEY_L) then
rc->Player->fire() <-add more 2 dimensional vectors in the list
the 2d vector for bullet system looks like this:
class Vector2
{
public:
float x,y,w,h;
unsigned int texture_index;
};
Function FIRE() adds a vector in the list, and the renderer
draws the double-buffered images(uses 1 surface or 1 set of animation)
if(t->get() >= 10){
clear screen
rc->render(screen);
sdl flip (screen)
t->reset();
}
t->update();
}
rc->release();
e->release();
t->release();
DEALLOC_TRACKMEM(rc,D_NO_ARRAY);
DEALLOC_TRACKMEM(e,D_NO_ARRAY);
DEALLOC_TRACKMEM(t,D_NO_ARRAY);
MEMORYTRACKER::Release();
SDL_Quit();
Last edited by PosX100 on Thu Apr 10, 2008 1:46 am, edited 2 times in total.
Then it's amazing it compiles at all.PosX100 wrote:My code looks EXACTLY like this:Code: Select all
rc->render(screen); sdl flip (screen)
Yep! When I was working on Doom, I had a bunch of printfs going to see how far it got. Once it was finally working, the screen blinked every time a debug printf occurred. It took about ten minutes to find the printfs to disable to make the screen quit blinking. :)Smong wrote:I can't see any evidence of you using pspDebugScreen*, but if you are I think that can cause some flickering, I've seen at least one game that has this issue.
I don't print anything on screen or to a file.
Only memory tracker has a function that prints the results to a file.
But since the files are loaded before the loop, there isn't any problem.
And just a note: The tearing occurs when i move the objects around the screen.
To get an idea:
I have a spaceship controlled by player.
The ship has unlimited ammo.
When i press the button to fire , the bullets start moving.
The bullets also collide with screen(just like geometry wars) , and they go crazy until they're "alive"(there is a timer for this porpuse).
Now , add to this the tearing/flickering effect , and you should understand how serious is the problem.
Anyway,im not going to work with SDL anymore(on psp i mean).
If anyone knows what im doing wrong with sdl opengl please let me know..
My last hope is GU , which is similar to opengl(i think its a wrapper...not sure)...
Thanks , and sorry for the trouble.
Only memory tracker has a function that prints the results to a file.
But since the files are loaded before the loop, there isn't any problem.
And just a note: The tearing occurs when i move the objects around the screen.
To get an idea:
I have a spaceship controlled by player.
The ship has unlimited ammo.
When i press the button to fire , the bullets start moving.
The bullets also collide with screen(just like geometry wars) , and they go crazy until they're "alive"(there is a timer for this porpuse).
Now , add to this the tearing/flickering effect , and you should understand how serious is the problem.
Anyway,im not going to work with SDL anymore(on psp i mean).
If anyone knows what im doing wrong with sdl opengl please let me know..
My last hope is GU , which is similar to opengl(i think its a wrapper...not sure)...
Thanks , and sorry for the trouble.