Triangles rendered and GPU Memory

Started by Krischan, March 13, 2018, 15:01:25

Previous topic - Next topic

Krischan

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) Select
Const GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX:Int = $9048
Const GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX:Int = $9049

Local MemTotal:Int
Local MemAvailable:Int
Local MemUsed:Int

glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX, VarPtr(MemTotal))
glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX, VarPtr(MemAvailable))

MemUsed = MemTotal - MemAvailable
Kind regards
Krischan

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

RemiD

#1
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) )

Krischan

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]
Metaverse | Blitzbasic Archive | My Github projects

RemiD


markcwm

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.

Krischan

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]
Metaverse | Blitzbasic Archive | My Github projects

markcwm

#6
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.

Krischan

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]
Metaverse | Blitzbasic Archive | My Github projects

Flanker

Quote from: Krischan on March 13, 2018, 23:49:41
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.

Krischan

Quote from: Flanker on December 05, 2018, 17:27:13Hello, 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]
Metaverse | Blitzbasic Archive | My Github projects

Flanker

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.