• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Noctumus

Visual artifact, advice would be appreciated (beginner, D3D9)

10 posts in this topic

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):
 
motion_normal.png
 
And this is what appears to be happening when the glitch occurs:
 
motion_glitch.png
 
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):
 
glitch_screenshot.png
 
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 blink.png
 
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
Edited by Noctumus
0

Share this post


Link to post
Share on other sites

Have you taken a log of your frame times to see what delta time there is when the glitch occurs?  You might be able to gain some information there based on the statistics of how often the glitch occurs.

 

I have seen similar behavior before with my laptop, and the issue seemed to disappear when I built in release mode, but had the glitch in debug mode.  I believe after a few driver updates the issue went away, but who knows if that is the same topic.

 

One point about your problem description - how do you know it is jumping ahead, then back, then forward again?  It looks to me like you just end up with one frame taking longer than the others, so there is larger movement due to your animation having more time to move.  Is there something that I'm not understanding here?

0

Share this post


Link to post
Share on other sites

Have you taken a log of your frame times to see what delta time there is when the glitch occurs?  You might be able to gain some information there based on the statistics of how often the glitch occurs.

I made a version that deliberately generated glitches in order to determine how big the delta time would have to be in order to cause these visual artifacts. Then I added functionality to keep track of the minimum, maximum, and average values and tried capping the dt to ensure it would always lie close to the average (+/- 20%). This, however, didn't solve the problem. Even when the dt couldn't possibly be anywhere near the value required to generate these huge gaps the glitches still occurred. This is also one of the things that made me think it's probably something related to D3D that's causing it (like some buffer not being flushed or whatever). I haven't tried logging the times though, but even if I did I'm not sure it would even help me figure out what's causing the problem.
 

One point about your problem description - how do you know it is jumping ahead, then back, then forward again?  It looks to me like you just end up with one frame taking longer than the others, so there is larger movement due to your animation having more time to move.  Is there something that I'm not understanding here?

I don't know if this ping-pong pattern is what's actually happening; it's just how I perceive it when the program is running and since a single frame only lasts around 16 ms at 60 Hz I could very well be wrong. In fact I actually think your own theory is much more plausible, but even so I don't know what to do about it. I mean it's a pretty simple program and without more knowledge about D3D it feels like there's not a whole lot of things left to try :/

Thanks for your feedback.
0

Share this post


Link to post
Share on other sites

Are you running your latest possible drivers, and executing the release build outside of the IDE?

0

Share this post


Link to post
Share on other sites

Open up the DirectX control panel, go into the Direct3D 9 tab, and switch over to the Debug version of the Direct3D 9 runtime. Also turn up the "output level" to one notch left of the "more" side (all the way to the "more" side spams out too many useless warnings).

 

Then when your game is running, watch the output window to see if any interesting errors are logged.

 

Also, watch the screen to see if it ever flickers green or pink -- this is an indication that you've called Present without actually drawing anything first. With the debug runtime, you'll get a pink/green screen when doing this, but in the normal mode, you'll get undefined results, which includes seeing the previous frame repeated (which could explain your one-frame backwards jitter).

0

Share this post


Link to post
Share on other sites

I highly doubt there is a glitch at all, especially not a ping-pong glitch.

It appears to be just skipping a frame, which could be due to any number of natural causes.

  1. A missed v-blank, even slightly, will cause you to move on to the next frame and a later position, since you are using QueryPerformanceCounter().
  2. Any form of exterior lag can build up to cause a skip such as that.
    • It happens every 10 seconds with v-sync and 3 without.  That indicates that there is likely a memory buffer or similar that is building up each frame and then flushing once it gets too large, causing the lag.  At a faster framerate it builds up faster and flushes more frequently.
    • This could be related to printf() or std::cout if you are printing debug information frequently.
    • Or it could be any number of memory mismanagement issues that cause the operating system to purge pages etc.
    • As Jason Z mentioned, even running in the debugger in the IDE can cause this kind of jitter, so always run in release mode outside of the IDE.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites


This could be related to printf() or std::cout if you are printing debug information frequently.

This is a good lead - any type of logging could lead to semi-periodic jitters in framerate as the file buffer is purged.

0

Share this post


Link to post
Share on other sites

Are you running your latest possible drivers, and executing the release build outside of the IDE?

I appreciate your feedback but I just updated my driver less than a week ago and all tests were executed outside the IDE.
 

Open up the DirectX control panel, go into the Direct3D 9 tab, and switch over to the Debug version of the Direct3D 9 runtime. Also turn up the "output level" to one notch left of the "more" side (all the way to the "more" side spams out too many useless warnings).
 
Then when your game is running, watch the output window to see if any interesting errors are logged.
 
Also, watch the screen to see if it ever flickers green or pink -- this is an indication that you've called Present without actually drawing anything first. With the debug runtime, you'll get a pink/green screen when doing this, but in the normal mode, you'll get undefined results, which includes seeing the previous frame repeated (which could explain your one-frame backwards jitter).

Thanks for enlightening me about the DirectX Control Panel wink.png I tried creating an IDE project and did what you instructed which actually resulted in a couple of warnings from the DX environment. However, after having adjusted the code accordingly the glitches still occurred and the screen didn't turn pink/green at any point (unfortunately since what you described about seeing the previous frame repeated could definitely have been what was happening).

The good news is I think I may have found a way to figure out what's causing the trouble since the program is heavily based on one of the tutorials that ship with the DirectX SDK which, despite the similarity, does not have the same problem as my own program. What I'll do is simply use the tutorial as a starting point and try to "morph" it into my own program gradually and see when the glitches start appearing. I'll let you know if I find it.
0

Share this post


Link to post
Share on other sites

Quite frequently the difference is in the inconspicuous debug output you add to your own projects…

 

And now that you have not seen green or pink it should be very obvious this is not really a glitch, but rather just a missed frame.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites


[quote name ='Jason Z']
Are you running your latest possible drivers, and executing the release build outside of the IDE?

[/quote]
I appreciate your feedback but I just updated my driver less than a week ago and all tests were executed outside the IDE.

Sorry, I don't mean to beat a dead horse, and I'm not trying to pick at details, but did you mention that you were running the release build?  I have seen a very similar thing in the past that only occurs in the debug build, so I want to make sure you aren't seeing the same issue.

 

Also, just out of curiosity, can you describe your hardware and OS?  Is the same behavior seen on a different system, or is the issue isolated to your machine?

0

Share this post


Link to post
Share on other sites

After reading this article by Microsoft about timing in games in which they encourage always clamping the delta values (and even imply they could potentially be negative due to bugs) when using QueryPerformanceCounter I decided I could have ruled out this function returning erroneous values a bit too early. And indeed I had. This function was exactly what was causing the glitches and although I had tried capping the delta values earlier I can only assume I must have done something wrong because now it's running flawlessly! I even made a festive screensaver to celebrate:

 

screensaver.png

 

Thanks for all your feedback and suggestions smile.png

 

PS: Jason, I did run the program in release mode and if it's still of any interest here are the specs for my computer:

 

Operating System: Windows 7 Home Premium, 64-bit (Service Pack 1)
Processor: Intel Core i5-3570K CPU @ 3.4 GHz
Motherboard: ASUS Maximus V GENE
Memory: Kingston HyperX Predator DDR3 4x4 GB
DirectX version: 11.0
Direct3D API version: 11
Direct3D feature level: 11_0
GPU processor: GeForce GTX 560 Ti:
  • Driver version: 331.65 (November 7 2013)
  • CUDA Cores: 384
  • Core clock: 822 MHz
  • Shader clock: 1645 MHz
  • Memory data rate: 4008 MHz
  • Memory interface: 256-bit
  • Memory bandwidth: 128.26 GB/s
  • Total available graphics memory: 4095 MB
  • Dedicated video memory: 2048 MB GDDR5
  • System video memory: 0 MB
  • Shared system memory: 2047 MB
  • Video BIOS version: 70.24.21.00.60
  • IRQ: 16
  • Bus: PCI Express x16 Gen2
Edited by Noctumus
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0