2

I'm trying to switch images on each incoming vsync pulse. In hardware the vsync pulse of my vga-signal can be easily used by using a trigger for each edge event of the incoming pulse ( VHDL).

Now my question: Is it possible to trigger and swap images on this vsync signal in software, preferabele in a windows environment? So each screen refresh iteration would swap to another image. Any language, program is welcome. This triggering has to be as accurate as possible.. ( < 1 ms)

thanks!

JeanDark
  • 29
  • 1

1 Answers1

1

This:

windows environment

and this:

This triggering has to be as accurate as possible.. ( < 1 ms)

are incompatible. Windows is not a real-time operating system, so it cannot guarantee a particular piece of code will run within a certain amount of time from an event.

How is your VSYNC pulse being captured? That will also have some non-trivial latency associated with it.

Martin Thompson
  • 16,395
  • 1
  • 38
  • 56
  • Thank you for your comment, could you maybe specify how to code detection of a vsync pulse ( screen refresh ) with maximum reliability towards delay? As working with any kind of software within an OS is never as trustworthy as hardware clock. – JeanDark May 13 '14 at 20:20
  • @JeanDark - you can't write code until you understand how you are detecting the pulse and communicating that to the computer. You may have enough control of your hardware system to do it within a device driver, which is probably your best bet for minimising the potential variations. – Martin Thompson May 14 '14 at 09:37
  • 2
    Yeah. That said, this is relatively easy to do in DirectX - as you can then have a change of the rendered image and tie that to the next vsync. For anything that low on hardware you basically have to go close to the driver level. – TomTom May 14 '14 at 09:41
  • @TomTom - as I understand it, DirectX allows you to do this based on the outgoing VSYNC to the monitor - and the drivers have good access to the video card to know when that will be. The OP wants to do this based on an *incoming* VSYNC pulse (using some as yet unspecified interface). – Martin Thompson May 14 '14 at 09:46
  • I am not sure about that - it is not really clear. If that is the case though hen - good luck. Hardware level driver stuff. – TomTom May 14 '14 at 09:51
  • It is indeed on an OUTGOING vsync puls towards an external monitor ( by using an ordinary VGA cable). I want the images to render on that external monitor at "exactly" 60hz, so 16.6 ms/image. Tried it with a video @ 60 hz in VLC but VLC cant deliver perfect 60 Hz output. @TomTom Could you send me a link for a directX tutorial on this matter? To clarify: I tried the same project in hardware ( FPGA) and it worked like a charm when measuring it with a logic analyser. But it seems software is a whole different story.. – JeanDark May 14 '14 at 13:46
  • No tutorial, but multi image queueing (I.e. a chain of prepared imnages) and switching syncrhonized by vsync is standard directx baseline stuff.... to avoid smearing effects. http://msdn.microsoft.com/en-us/library/windows/desktop/bb172585(v=vs.85).aspx, D3DPRESENT_INTERVAL_ONE (and also the default). – TomTom May 14 '14 at 13:56
  • @JeanDark - in that case, you have a very different system to what I thought you were describing! TomTom has guided you correctly – Martin Thompson May 14 '14 at 15:56
  • I've managed to fix it using DirectX by loading images from the backbuffer to the front buffer on each render of a new frame. By using D3DPRESENT_INTERVAL_ONE.. Thanks! – JeanDark May 17 '14 at 13:59