1 hour ago, cmac said:
but I assumed the cost of sorting the entire array every frame was much more expensive than insertion sort on insert + std::erase(std::remove_if()) on removal. I guess I'll just have to run some performance tests and see for myself.
This is what I was thinking! But I guess this makes sense if you are doing a lot of creating and destroying like @0r0d mentions
1 hour ago, 0r0d said:
BTW I also keep my components in contiguous arrays, so iterating through all mesh components (for example) isnt so bad because the caches and prefetcher will help you out. If you have stuff all over memory, with your rendering data intermingled with other stuff... then the performance will suffer.
Can you elaborate more on this? The part about If you have stuff all over memory, with your rendering data intermingled with other stuff
Example if I have a set up roughly like this does this mean everything is all over?
//Vector of renderables. This is the list we will actually look at and traverse when rendering
cubeRenderable | { pointerToShader: shapeShader, pointerToTexture: NULL }
truckRenderable | { pointerToShader: truckShader, pointerToTexture: truckTexture }
enemyRenderable | { pointerToShader: enemyShader, pointerToTexture: enemyTexture }
boatRenderable | { pointerToShader: boatShader, pointerToTexture: boatTexture }
//Vector of created shaders. Used to keep track of the shaderes that have been created. Exists in a ShaderManager class
shapeShader | { comPointerVertexShader: 1, comPointerPixelShader: 2 }
truckShader | { comPointerVertexShader: 3, comPointerPixelShader: 4 }
enemyShader | { comPointerVertexShader: 5, comPointerPixelShader: 6 }
boatShader | { comPointerVertexShader: 7, comPointerPixelShader: 8 }
//Vector of loaded textures. Used to keep track of the textures that have been created. Exists in a TextureManager class
truckTexture | { width: 64, height: 64, comPointer: 9 }
enemyTexture | { width: 64, height: 64, comPointer: 10 }
boatTexture | { width: 64, height: 64, comPointer: 11 }
I kind of feel like it does, but I'm not really sure cause of the pointers and well I have never really taken a hard look at how memory management/cache works