September 23, 2019, 12:59:04 PM

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

Offline Krischan

  • Full Member
  • ***
  • Posts: 200
    • 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 | i7 9700K@ 3.6GHz | RTX 2080 8GB]
My Blitzbasic Archive | Extrasolar Project | My Github projects

Offline RemiD

  • Hero Member
  • *****
  • Posts: 852
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) )
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Krischan

  • Full Member
  • ***
  • Posts: 200
    • 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 | i7 9700K@ 3.6GHz | RTX 2080 8GB]
My Blitzbasic Archive | Extrasolar Project | My Github projects

Offline RemiD

  • Hero Member
  • *****
  • Posts: 852
Re: Triangles rendered and GPU Memory
« Reply #3 on: March 14, 2018, 05:54:26 PM »
very good, thanks for the info. :)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 400
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: 200
    • 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 | i7 9700K@ 3.6GHz | RTX 2080 8GB]
My Blitzbasic Archive | Extrasolar Project | My Github projects

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 400
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: 200
    • 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 | i7 9700K@ 3.6GHz | RTX 2080 8GB]
My Blitzbasic Archive | Extrasolar Project | My Github projects

Offline Flanker

  • Jr. Member
  • **
  • Posts: 39
    • Youtube channel on Blitzmax programming prototypes
Re: Triangles rendered and GPU Memory
« Reply #8 on: December 05, 2018, 05:27:13 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.

Hello, this thread is old but are you sure about it ? 255x255x2 is the maximum I can get, one more triangle and the mesh is messed up. I'm still looking forward to unleash that limit. Also the actual TrisRendered() command doesn't seem to return a correct value, if you create only one mesh with one triangle it returns 3 (vertices ?). I think it counts 3 for each triangle.

Anyway it's been a long time since I didn't update to the latest version of openb3d, glad to see that quite a lot of things have been fixed already :-)
Everyone knew it was impossible, until someone who didn't know made it.

Offline Krischan

  • Full Member
  • ***
  • Posts: 200
    • Krischan's Homepage
Re: Triangles rendered and GPU Memory
« Reply #9 on: January 04, 2019, 11:46:00 PM »
Hello, this thread is old but are you sure about it ? 255x255x2 is the maximum I can get, one more triangle and the mesh is messed up. I'm still looking forward to unleash that limit. Also the actual TrisRendered() command doesn't seem to return a correct value, if you create only one mesh with one triangle it returns 3 (vertices ?). I think it counts 3 for each triangle.

See my new OpenB3D Questions thread - it's not possible on a single mesh - I've used CopyEntity (Instancing) to achieve this (for example in the demo there are 6.25 million quads which are about 25 Million vertices or roughly 12.5 Million triangles if this is correct). But afaik Blitz3D was able to calculate instanced mesh tris, too. And I'd still love to see that in a function.
Kind regards
Krischan

Windows 10 Pro | i7 9700K@ 3.6GHz | RTX 2080 8GB]
My Blitzbasic Archive | Extrasolar Project | My Github projects

Offline Flanker

  • Jr. Member
  • **
  • Posts: 39
    • Youtube channel on Blitzmax programming prototypes
Re: Triangles rendered and GPU Memory
« Reply #10 on: January 05, 2019, 01:50:21 AM »
Yes you can still use multiple entities with instancing, but it would be simpler to remove any vertices/triangles limit. I don't know much about the code behind OpenB3D, but it looks like it could just be a limit from a wrong data type (byte, or short, instead of an int).

Talking about instancing, I found the command RepeatMesh() lost in a thread of the old forum. I managed to render 4000 animated B3D with good FPS wich is quite impressive, even if the animations are not interpolated (it didn't work with CopyEntity()). And I believe this command also disables the visibility check meaning that all entities are always rendered, even when not visible.
Everyone knew it was impossible, until someone who didn't know made it.