Sign in to follow this  
tracegame

what does video memory keep,how can i direct read and write to

Recommended Posts

tracegame    164
just wondering,what does it really keep,some pixel data?

and how can i direct read and write the whole video memory?

is there a way to dump the whole video memory like common memory?

if video memory is a large canvas,can i display it's direct image on screen?

Share this post


Link to post
Share on other sites
Hodgman    51234
[quote name='tracegame' timestamp='1339571816' post='4948743']1) just wondering,what does it really keep,some pixel data?
2) and how can i direct read and write the whole video memory?
3) is there a way to dump the whole video memory like common memory?
4) if video memory is a large canvas,can i display it's direct image on screen?
[/quote]1) Whatever you put in it - usually [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb174363(v=vs.85).aspx"]textures[/url] and [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb174364(v=vs.85).aspx"]vertices[/url].
2+3) You're not supposed to be able to do that, it's a virtualised resource, just like regular system RAM. Only the OS or it's device drivers should be able to do such a thing.
4) No. You can only [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb174423(v=vs.85).aspx"]present[/url] specific parts of video memory to the screen, such as a texture that you allocated earlier. Edited by Hodgman

Share this post


Link to post
Share on other sites
tracegame    164
thank you,but right now i really want to try to do such thing.
it all begins with WinHex,a software can dump RAM i guess,lead me to think this way.
if RAM can be dumped,so i think maybe video RAM can also do that??
you mentioned Only the OS or it's device drivers should be able to do such a thing,i have no idea of OS and DD.
is it possible to learn some way to do that,is is too hard to learn such way?

i searched something,it tells me to use assembly language to access some address,but windows forbids me to do that,
so i got no idea how to do that. Edited by tracegame

Share this post


Link to post
Share on other sites
SimonForsman    7642
[quote name='tracegame' timestamp='1339572634' post='4948750']
thank you,but right now i really want to try to do such thing.
it all begins with WinHex,a software can dump RAM i guess,lead me to think this way.
if RAM can be dumped,so i think maybe video RAM can also do that??
you mentioned Only the OS or it's device drivers should be able to do such a thing,i have no idea of OS and DD.
is it possible to learn some way to do that,is is too hard to learn such way?

i searched something,it tells me to use assembly language to access some address,but windows forbids me to do that,
so i got no idea how to do that.
[/quote]

You could download the Windows DDK and write your own driver (drivers in windows are allowed to mess around quite a bit). (Just remember that most GPUs are highly proprietary so the exact details on how to access them varies and can be hard to find) Edited by SimonForsman

Share this post


Link to post
Share on other sites
Bacterius    13165
It is possible to make a VRAM dump but you can't do that with standard userland software, it needs to be done in kernel space. Windows (or any other modern OS, for that matter) will not let you touch whatever memory address you want, because your program is essentially sandboxed in a per-process environment (this is called virtualization). So ultimately, the operating system and the associated drivers get to decide what your program can read from and write to. Think of it as a very relaxed virtual machine, because that's basically what it is.


Windows used to allow you to read from physical memory in user space (starting from Vista this is no longer possible and requires a driver), this is how WinHex does it. However no such facility exists for video memory, because, I guess, not many people have a need for that, and it depends a lot of what your graphics card is. Many integrated graphics cards actually use system memory instead of their own on-chip memory, can you see the problem there?


You could certainly write up a graphics driver that will read video memory directly and dump it to a file, but there are a few difficulties with that approach:
- it is very difficult (writing a driver is certainly not trivial, and may also be harmful to your computer if you don't know what you are doing)
- there are security issues in using a homemade driver (and you may also need to get Microsoft to sign your driver, good luck with that)


Why do you need to read video memory? Its contents are largely meaningless, and if you simply want to read the frontbuffer (the image that the graphics card is about to push to the monitor) as many people who ask this question do, there are simpler options involving DMA.

Video memory contains much, much more than just the image that's about to go on your screen, so if you just want to read that, a full dump clearly isn't the right way to go. Edited by Bacterius

Share this post


Link to post
Share on other sites
Dustin Hopper    186
Look into CUDA or OpenCL development, these two APIs allow for device memory computation on the device, and give support for pushing data back and forth from RAM and GPU.

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