June 25, 2018, 03:09:55 AM

Author Topic: Triangles rendered and GPU Memory  (Read 354 times)

Offline Krischan

  • Full Member
  • ***
  • Posts: 130
    • Krischan's Homepage
Triangles rendered and GPU Memory
« on: March 13, 2018, 03:01:25 PM »
Do you remember the old Blitz3D command "Trisrendered()"? I wonder if it is possible to implement this in OpenB3D. So I'd like to know the number of the currently in the view frustum rendered triangles, and perhaps the vertices/surfaces too.

Another point on my wishlist is the GPU memory consumption. For nVidia cards I can calculate it using a nVidia extension, but how would look a solution covering ATI, nVidia and Intel? This code calculates the used GPU memory in KB:

Code: BlitzMax
  1. Const GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX:Int = $9048
  2. Const GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX:Int = $9049
  3.  
  4. Local MemTotal:Int
  5. Local MemAvailable:Int
  6. Local MemUsed:Int
  7.  
  8. glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX, VarPtr(MemTotal))
  9. glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX, VarPtr(MemAvailable))
  10.  
  11. MemUsed = MemTotal - MemAvailable
Kind regards
Krischan

Windows 10 Pro | iMac 27" Late 2013 [i7 4771 @ 3.5GHz | GTX 780M]
My Blitzbasic Archive | Extrasolar Project

Offline RemiD

  • Hero Member
  • *****
  • Posts: 595
Re: Triangles rendered and GPU Memory
« Reply #1 on: March 13, 2018, 06:44:41 PM »
Since you are talking about triangles, can you please tell me what is the max number of vertices and triangles that you can have in a surface (and render) without any crash, using openb3d ?

Thanks,

( about trisrendered(), i think that the number shown is not exactly the triangles in the FOV, but rather the triangles of surfaces in the FOV (considering their bounding boxes) )

Offline Krischan

  • Full Member
  • ***
  • Posts: 130
    • Krischan's Homepage
Re: Triangles rendered and GPU Memory
« Reply #2 on: March 13, 2018, 11:49:41 PM »
For the limit: I currently have no working demo but a quick test here works with 1024*1024*2 vertices on a single surface before the Renderworld function crashes if adding 1 single vertex more - should be about 699.000 tris. Well, 2.097.152 vertices are very slow.
Kind regards
Krischan

Windows 10 Pro | iMac 27" Late 2013 [i7 4771 @ 3.5GHz | GTX 780M]
My Blitzbasic Archive | Extrasolar Project

Offline RemiD

  • Hero Member
  • *****
  • Posts: 595
Re: Triangles rendered and GPU Memory
« Reply #3 on: March 14, 2018, 05:54:26 PM »
very good, thanks for the info. :)

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 276
Re: Triangles rendered and GPU Memory
« Reply #4 on: March 14, 2018, 09:54:46 PM »
I've added a TrisRendered function which I just lifted from Klepto's Minib3d Extended. It's pretty simple it just renders meshes from Camera's render_list which is constantly rebuilt. So all surfaces of a mesh are rendered even if not in view. See standard/alphamap.bmx for a quick demo, press ZXCV to hide/show meshes.

I think I remember Angros explaining something to do with frustrum culling, perhaps that is a second step to optimize rendering.

Offline Krischan

  • Full Member
  • ***
  • Posts: 130
    • Krischan's Homepage
Re: Triangles rendered and GPU Memory
« Reply #5 on: March 18, 2018, 09:51:45 PM »
Thanks for adding it. But compared to Blitz3D it would be nice if only the visible tris are counted. In my game I'm getting a rather constant value, even if I'm looking away from all meshes, huh?
Kind regards
Krischan

Windows 10 Pro | iMac 27" Late 2013 [i7 4771 @ 3.5GHz | GTX 780M]
My Blitzbasic Archive | Extrasolar Project

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 276
Re: Triangles rendered and GPU Memory
« Reply #6 on: March 19, 2018, 05:33:45 PM »
Well I wasn't sure what you meant but yes I'll have a look at this later, I'm just trying to get animations working for the native B3D loader first.

Offline Krischan

  • Full Member
  • ***
  • Posts: 130
    • Krischan's Homepage
Re: Triangles rendered and GPU Memory
« Reply #7 on: March 19, 2018, 07:00:03 PM »
No hurry, this has Priority "Z" ;D Thanks anyway for having a look at this, I've always missed this function in miniB3D.
Kind regards
Krischan

Windows 10 Pro | iMac 27" Late 2013 [i7 4771 @ 3.5GHz | GTX 780M]
My Blitzbasic Archive | Extrasolar Project