Ma-Shell Posted September 28, 2019 Share Posted September 28, 2019 Doing a performance-test with LW 4.7, I wanted to draw an element ins tanced multiple thousands of times. Using RenderDoc I found out, that Leadwerks batches these into groups of 256 elements each, so instead of having one call to glDrawElementsInstanced, instead I have quite many (which in my eyes are not needed). Also looking at the shaders, I found that they usually have a line like #define MAX_INSTANCES 256 I believe that there is a lot of wasted potential because of this for rendering large groups of the same entity. Is there a reason for this limit? Can we increase it somehow? Will the same limitation be there in Turbo? I have attached the source code for my test. App.h App.cpp main.cpp Quote Link to comment Share on other sites More sharing options...
Josh Posted September 28, 2019 Share Posted September 28, 2019 The max number of instances is defined by the minimum guaranteed size of uniform buffers in OpenGL 4.0. I believe the size is 16384, which means it can fit 256 4x4 matrices at a time. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Ma-Shell Posted September 28, 2019 Author Share Posted September 28, 2019 ah, I see, so you're refering to GL_MAX_UNIFORM_BLOCK_SIZE (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGet.xhtml)? I think, it would make sense, to query that number in the beginning and use that instead of the fixed 256. Otherwise every system would suffer, only so that it can run on lower end systems. EDIT: Of course I mean use that number divided by 64 Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted September 28, 2019 Author Share Posted September 28, 2019 Also, looking at https://www.gamedev.net/forums/topic/673534-instancing-and-the-various-ways-to-supply-per-instance-data/?do=findComment&comment=5264179, you can create the buffer much larger first, then copy all data and later repeatedly use glBindBufferRange instead of glBufferSubData, copying all data in one go and being much faster Quote Link to comment Share on other sites More sharing options...
Josh Posted September 29, 2019 Share Posted September 29, 2019 Vulkan has buffers of pretty much unlimited size, so in the new renderer this is already resolved. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.