Should Be Simple
BlitzMax Forums/BlitzMax Programming/Should Be Simple
| ||
Hello, I was wondering if there was a way to get this to work.Graphics 800,600 Local img:TImage,pic:TPixmap img=CreateImage(800,600,1,dynamicimage) DrawOval 50,50,400,300 pic=LockImage(img,0,1,1) pic=GrabPixmap(0,0,800,600) UnlockImage img Cls DrawImage img,0,0 Flip WaitChar I'm trying to avoid GrabImage as it's quite slow. Essentially copying a Pixmap to a Timage without using LoadImage() as that is also slow. |
| ||
I see what your trying to do, but it wont work like that obviously ;) I made a test that did exactly what you are trying to do a while back btw. By re-implementing GrabPixmap but change it to copy from the backbuffer into an already created pixmap, sortof what GrabImage does but without the upload. But it turned out to be no faster than GrabPixmap :( Though it seems much of the slowness regarding this has been fixed in Windows 10. Try it out and see if it helps anything, but do read the comments if your running Windows 7 as it might need special care. Faster GrabPixmap , GrabToPixmap() But honestly, with my current setup i dont worry about GrabPixmap|LoadImage at all. I average 4ms for a GrabPixmap and 0-1ms for LoadImage, in both D3D9 and GL, which is pretty fast! GrabImage though is rather slow for me too, average 42ms, even though on paper it has more going for it than GrabPixmap, go figure :/. |
| ||
If this is about copying the screen so that only the changed part must be drawn then test whether it is necessary. Simply redrawing everything may well be fast enough. |
| ||
Well darnit. Not faster then, Grable. Here is my benchmark test program: Also on my computer. If I UNREM the DrawImage img,0,0 bit and REM the FLIP 0, then run, my computer goes bonkers ! It says my graphic card has crashed, recovered, and the keyboard and mouse are very slow to respond even after the program has exited. What's going on here ? |
| ||
Well, without the Flip that loop will peg the CPU for 1 second at 100%, stealing juice from everything else. Depending on the hardware (and the OS) this might be really bad. Usually the reason other things get slow, even after its done with its thing is because all the queues (input and otherwise) are now WAY behind on processing, so they get priority until they can catch up. Of course with newer CPUs and multiple cores (and an OS to support it), this is less of an issue. Also, older GPUs and their drivers can render too fast too, leading to crashes in the driver, speculating that the driver keeps filling up its draw queues and probably overflowing at some point since the GPU cant drain them fast enough. So the answer as always is: It depends :p IMO, FPS isnt detailed enough for benching this. You need to check each individual function to see what really is the bottleneck here: Sample output, Skylake 6700K + AMD R9 390, Windows 10. 0 1 3 0 --- 0 1 2 0 0 2 2 1 --- 0 1 2 0 0 2 2 0 --- 0 1 2 0 0 2 3 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 2 2 1 --- 0 1 2 0 0 2 2 0 --- 0 1 2 0 0 2 4 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 1 4 1 --- 0 1 2 0 0 1 3 1 --- 0 1 2 0 0 2 2 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 2 3 1 --- 0 1 2 0 0 1 4 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 3 2 1 --- 0 1 2 0 0 2 2 1 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 1 3 0 --- 0 1 2 0 0 2 2 1 --- 0 1 2 0 |
| ||
Keep in mind: pixmaps are stored in normal RAM, images are stored in videocard RAM -- regardless of how you juggle things around, they still have to be transferred back and forth. |
| ||
Hi Grable: I'm getting back an error message. "Identifier: Totalframes not found." Xlsior, why is this ? Is there a difference between video ram and normal ram ? |
| ||
@dw817 Yeah just something i forgot to remove, you can delete it, but i imagine you did that already :p I am curious to see the output of that benchmark on your machine though... And just to ask, did you try GrabToPixmap? If you are on anything lower than Windows 10 it might be faster, at least it was for me when i tested it on Windows 7. |
| ||
Xlsior, why is this ? Is there a difference between video ram and normal ram ? Yes, unless you have an integrated video adapter like the Intel ones instead of a discrete one like AMD/NVidia. The reason is that the video ram is stored ON the video card, and the video ram is much faster than normal RAM. Before any image can be shown, it needs to be transmitted from normal RAM over the PCI bus to the video RAM, and that is slower than drawing it directly from video RAM in the first place. |