Results 1 to 9 of 9

Thread: OpenGL stunts: Watching GPU memory occupancy

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Lightbulb OpenGL stunts: Watching GPU memory occupancy

    I found out there is a way to retrieve total/available memory on GPU. There is GL_NVX_gpu_memory_info on NVIDIA hardware and GL_ATI_meminfo on AMD cards.
    The code I provide below works only for NVIDIA cards, once my friend gets ATi I will test the GL_ATI_meminfo and provide solution working on Radeons as well.

    It is interesting to watch how much GPU memory uses for example Firefox, try to launch the program and then just open new tabs in FireFox 5.

    The proggie is very elemental, it allocates 512x512 textures as user commands via PageUp/PageDown. The textures are created on the fly.


    Petr
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Petr Schreiber; 11-08-2011 at 22:46.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    Thanks Petr,

    Interesting to see how many megabytes of memory is consumed by even the simplest of graphics programs. One of my Opengl benchmark programs takes up 15 meg of main memory then a further 9 Meg of GPU memory, which expands towards 100 Meg as the window is enlarged.

    And here was I thinking that my basic runtime space of 3 megs was seriously bloated

    Charles

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Charles,

    I must admit I was surprised too. But this proggie is extreme case - it uses anisotropic filtering in conjunction with mip maps. And it creates multiple textures (up to 1024).
    Each texture is 512x512, in RGBA8 format + mipmaps. That means just for all the levels:
    512x512x4 + 256x256x4 + 128x128x4 + 64x64x4 + 32x32x4 + 16x16x4 + 8x8x4 + 4x4x4 + 2x2x4 + 1x1x4 = 1 398 100 bytes!

    Each bubble on the image has its own unique copy of the texture, which is horror scenario specifically designed for quick gluttonizing of memory

    How did it behaved on your GPU, did you managed to fill whole memory? On my PC I did not managed to get it full


    Petr

    P.S. It is good to mention that after launching the program I see 160MB occupied - that does not mean the program ate 160MB after start. It displays global state affected by other programs as well.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404
    Another cool proggie Petr. Here is a screenshot with it maxed out as I could get it on my old dual core. I can't believe this computer is 6 years old already, but I did upgrade the video card twice.
    I like the little bug wobble too of your objects!
    Attached Images Attached Images

  5. #5
    How did it behaved on your GPU, did you managed to fill whole memory?
    I have not tested to the limit, Petr. The nVidia GT120 has 1 Gig of memory available, which is plenty for most apps. I will try next time I boot into Vista.

    Charles

  6. #6
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    56

    Smile

    your graphics card is very slow. Nvidia Geforce 120 GT is only G96 typ: meant is a 9500 GT or 9600 GT.
    you get this by Media Markt. Nvidia cheats here with the names.

  7. #7
    It maintains 60FPS up to around 700 Meg of Texture space, then drops rapidly to 30FPS

    At 1 Gig there are 729 textures and 1.25 million polygons. (30FPS)

    No overflow problems.

    Charles

  8. #8
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Thank you Charles 60FPS and then drop to 30FPS - that seems like forced VSync kicked in. Very nice speed anyway!

    The code I posted stops adding textures once it detects submitting the data does not change the memory.

    At home I used modded version with this limitation gone, as my card is split personality - it has 512MB own memory but can texture from RAM as well.
    The results I saw in the modified version showed that this is not very big win as the performance gets unpredictable - few hundred MB from RAM was still very smooth, but then it suddenly dropped and whole system stopped being responsive (that's why I didn't published the unlocked version, it is not very pleasant to experience PC "stalled").


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    I updated the first post with version, where it is more evident, that each texture is different.
    To make the resolution obvious, the texture is composed of stripes. So dense, it makes very interesting artifacts (moire).


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. Memory information
    By Petr Schreiber in forum Win API interface
    Replies: 11
    Last Post: 09-11-2020, 13:53
  2. Replies: 2
    Last Post: 27-06-2011, 11:46
  3. Copying memory in C
    By danbaron in forum Science
    Replies: 10
    Last Post: 07-06-2011, 09:53

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •