I am really clueless about whats going on here. I writeback all the data in cache at the beginning of each frame. Is there something else I should be aware of?
I have tried inlining, not inlining, returning const referece, returning reference, returning value, and making the function non-const. Sometimes I get serious graphical errors, other times the psp just shuts off.
It works, otherwise I get strange graphical error, or the PSP shuts down. Am I handling the cache properly? Should I be writing cache back somewhere? I have tried after the graphics calls (after pspRenderer->RenderScene()), but that didt fix.
Just a quick guess: Check for fCurMs and tickRes to be != 0 to get sure. However, tickRes should be a constant, no?
Btw: is GetTickRes() and GetElapsedTime() returning a u32/u64 or float?
Raphael wrote:Just a quick guess: Check for fCurMs and tickRes to be != 0 to get sure. However, tickRes should be a constant, no?
Btw: is GetTickRes() and GetElapsedTime() returning a u32/u64 or float?
Yes, ideally tickRes would be constant (well, ideally I wouldnt need it at all), however I was playing with return values and such to see what happened. GetElapsedTime returns a float.
My latest attempt seems to work, but I am still not sure why. I create the object on the heap using the new operator. I guess there may not have been enough room on the stack? I also tried declaring it in the global namespace, but that had the same problems. Think I might be missing some detail here.
EDIT: Oh, and the algorithm works, it prints the correct FPS (when it works somewhat) but the image is completely messed up. Sometimes it also just crashes.
Raphael wrote:
Btw: is GetTickRes() and GetElapsedTime() returning a u32/u64 or float?
GetElapsedTime returns a float.
Well, my guess was that in the one case, where you typecast the GetTickRes to u32, the rounding of a int divide will keep the span and thus the fCurMs from becoming 0, which would cause a crash. But that's idiotic alltogether, since then it should be the other way around (int div rounding down to zero more likely).
In either case, checking for divisors to be non-zero should be done to get on the safe side in every case.
lokust wrote:
Yeah, I suppose I should do that ;) But wouldnt a dbz always crash, and not just produce strange graphical errors?
That's true :) Most graphical issues are cache-related, though I also had one or two cases in which this definitely wasn't the case and only the aproach of completely rewriting some code parts helped.
Allotgether, PSP dev seems to be much more open to random missbehaviour than PC development :)
Getting the proper constructors and such to run for C++ objects that are staticly instantiated can often be a difficulty if the C++ compiler/environment isn't all that great. There is a function that is supposed to do that for you called __ctor or something like that (that name might be way off).
The order of those operations can really be messy, so it's always safer on a less stable toolchain to create things using the heap. It shouldn't be a problem for objects created on the stack at runtime, just those created outside of any function.
From what I've heard and known, C++ development on SONY consoles has not been too favorably looked upon. It works on PS2 today, but the early compilers were C only.
(This is all just conjecture though.... Maybe I shouldn't post it....)