Greetings, Forum!
I've recently begun studying Direct3D 9 but have unfortunately encountered a little bug in my latest experiment; a simple program that rotates a textured 6 pointed star figure about the 3 axes with a single directional light (source code available
here). To describe the bug imagine I was rendering a ball instead of a star moving from the left side of the screen to the right. Then, this is what it looks like when the program runs normally (the top number being the frame in which the ball is rendered):
And this is what appears to be happening when the glitch occurs:
I tried running the program without clearing the screen in each frame and managed to capture what it looks like when the glitch occurs with vsync enabled at 60 Hz (all three arrows point to visual artifacts caused by the same glitch):
It appears what I thought was happening could actually be the case (especially if you look closely (click image to magnify) at what's going on near the left arrow). The problem is I don't have a clue what the heck is causing it. Taken into consideration I have less than a week's experience with Direct3D there's a good chance it's something very basic I'm missing that one of you can teach me about. At least I hope so, because right now it's driving me nuts
Here are some of the things I have gathered so far from testing and experimenting:
The glitch is apparently not caused by
- A floating point rounding error
- The performance counter returning a wrong value
The glitch is apparently not affected by whether
- I use hardware or software vertex processing (D3DCREATE flags)
- I use performance counters (QPF/QPC) or multimedia timers (timeGetTime) for calculating the delta time
- I restrict the program to only run on a single CPU core or not
Some other observations:
- The glitch appears, on average, about once every 10th second on my computer when vsync is enabled and about once every 3rd second when it's not (using D3DPRESENT_INTERVAL_IMMEDIATE in the present parameters to disable it)
- The impact/magnitude of the glitch doesn't seem to be affected by whether vsync is enabled or not
- The glitch appears very randomly; not at any specific angle or time and sometimes (much) less frequent than others (every now and then the program can run smoothly without any problems for several minutes)
I tried creating the device using D3DDEVTYPE_REF but this causes the framerate to drop so dramatically it's impossible for me to determine if the glitch still occurs. I also examined a couple of my Direct3D accelerated games to see if something similar could occur in one of them, but that didn't seem to be the case.
PS: If you want to compile and run the program you can download the texture
here