Yes, my work was done in another OS.
I like to say that the operating system has, at best, a loose grasp of the
concept of “time” which boils down to “time monotonically increases in
each core”. As others have suggested, D3D would be the safest approach.
At least one question I don’t have the answer to for flat displays is the
duration of the Vsync interval. There was a time when I could quote it
for a variety of screen resolutions, but that time is now more than 20
years in the past.
Probably tbe fastest way to accomplish a notification to user space is to
enqueue a DPC request, and let the DPC do the completion of a custom
DeviceIoControl. There seems to be a horrid fascination with using events
to notify user space, but this is a clumsy and convoluted way to handle
what is actually a very simple concept. Look for threads discussing
“inverted call”, and forget that you ever heard of events as a
kernel-to-userspace notification mechanism, except, just maybe, in the
context of using an Event in the OVERLAPPED structure–which, I might add,
is still a lousy way to handle it.
joe
Hi Joe,
swapping frame pointers (or maybe overlay frame pointers)
on VSync would be a dream, of course. That would be step 3,
if it is possible to achieve at all from my own driver. My first 2
steps would be (1) counting the VSyncs. And (2) notifying user
land about them. I guess you did that high-performance video
stuff on another OS and not on Windows?I know that timing in user land isn’t too reliable, even if you use
the highest possible thread priority. My video rendering code is
working in such a way that I don’t necessarily have to run inside
of the VSync period (although of course that would be great!).
It’s ok if I’m getting the VSync notification a bit too late sometimes.About the event: What would be the best (performing) way to
notify user land from within an ISR routine? Maybe using
IoQueueWorkItem would work? Of course that would involve
waking up 2 threads until notification reaches user land. I guess
there’s no way to do the wakeup initiation directly from within
the ISR routine?Thanks, Mathias.
2012/7/8
>
>> First, you can’t set an event in an ISR. See the documentation for
>> KeSetEvent.
>>
>> Second, I don’t care how high the priority of your thread is, the
>> liklihood that it will start running before the vertical retrace is
>> complete is vanishingly small. Even if you use the new Multimedia
>> scheduler support in Vista+, the highest priority you can run a user
>> thread is something like 26, and scheduling a user thread is a
>> very-heavy-duty operation.
>>
>> Back in the days when I was involved in high-performance video, we used
>> Vsync to swap frame buffer pointers, and tat was pretty much all we
>> could
>> do. In the case of video, we would let the application get ahead, but
>> if
>> it fell behind we could skip N frames to get back into realtime sync.
>> But
>> this was all done in the ISR, with no user threads involved at all. As
>> soon as you introduce the concept of scheduling a thread, you are into
>> random and large delays relative to what you can tolerate. Think of
>> tens
>> of milliseconds to potentially hundreds of milliseconds latency between
>> setting the event and the user code running.
>> joe
>>
>> > Hey guys,
>> >
>> > in order to optimize the performance and reliability (tearing etc) of
>> my
>> > video renderer, I’d like to get access to the VSync interrupt for
>> > informational purposes. Basically what I have in mind is that I would
>> > write a little kernel mode driver which connects to the VSync
>> interrupt
>> > and then simply sets an event in the ISR routine. The event would then
>> > wake up a high-priority user mode thread, which would perform video
>> > playback related tasks.
>> >
>> > Of course, in an ideal world either the OS or the GPU drivers would
>> allow
>> > me to access this kind of functionality through APIs. But since this
>> is
>> > not available, I’d like to try to realize it myself. Obviously I can’t
>> > write a full GPU driver. Just want to send VSync notifications to my
>> user
>> > land video renderer somehow, if it is possible in any way.
>> >
>> > From what I can see, I can find out which interrupt vector the GPU
>> uses
>> > via setupapi in user land. And I already have code written for kernel
>> land
>> > which successfully finds the GPU PDO. So far, so good. So here are my
>> > questions:
>> >
>> > (1) Is it “ok” for me to simply call IoConnectInterrupt(Ex) in my
>> virtual
>> > driver to connect to the VSync interrupt? I understand that it’s not
>> > really strictly how the PnP model is supposed to work because my
>> driver
>> > isn’t really a hardware driver. So would doing this risk system
>> stability?
>> >
>> > (2) In my ISR routine, I would ideally like to directly call
>> ZwSetEvent.
>> > But that doesn’t seem to be possible because ZwSetEvent requires
>> > PASSIVE_LEVEL? Is there any other way I can directly set an event for
>> user
>> > land from inside my ISR routine?
>> >
>> > (3) I understand interrupts can be shared by multiple different
>> hardware
>> > devices. In my ISR routine, is there any way for me to find out which
>> > hardware the “current” interrupt came from?
>> >
>> > (4) From what I can see, every GPU just has one interrupt, even though
>> it
>> > might have multiple displays connected. Is there any way for me to
>> find
>> > out which display the VSync interrupt originates from? I guess
>> probably
>> > not, but I thought I’d ask, just in case…
>> >
>> > Thank you!
>> >
>> > —
>> > NTDEV is sponsored by OSR
>> >
>> > For our schedule of WDF, WDM, debugging and other seminars visit:
>> > http://www.osr.com/seminars
>> >
>> > To unsubscribe, visit the List Server section of OSR Online at
>> > http://www.osronline.com/page.cfm?name=ListServer
>> >
>>
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer