Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

whats the fastest way to bucket sort pointers?

This topic is 2607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have shaders only 12 of them so far , they will be increasing and entitys,

every entity has a pointer to a shader

i want to bucket each entity into groups of shaders.

i used stl::maps but this seams slow , is there a faster way ?

Share this post


Link to post
Share on other sites
Advertisement

i have shaders only 12 of them so far , they will be increasing and entitys,

every entity has a pointer to a shader

i want to bucket each entity into groups of shaders.

i used stl::maps but this seams slow , is there a faster way ?





i ahve entitys , ie. models , and they all have shader pointers . this is so that they have a ppointer to the differnt shaders

i want to sort all the models into seperate vectors, for fast access. they need to be sorted vai the pointers of the shaders.

Share this post


Link to post
Share on other sites
And std::map<shader*, std::vector<model*>> (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?

Share this post


Link to post
Share on other sites

And std::map<shader*, std::vector<model*>> (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?


tred that , was way too slow .

had to re configure my engine to use enums : got the speed now though

Share this post


Link to post
Share on other sites
Did you profile your code to see what was slow? What exactly do you mean by "using enums"? How would it gain you speed?

Share this post


Link to post
Share on other sites
Just sort them all into the one vector. Your "buckets" are then different ranges within that vector.

Share this post


Link to post
Share on other sites

[quote name='Telastyn' timestamp='1319137120' post='4874788']
And std::map<shader*, std::vector<model*>> (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?


tred that , was way too slow .

had to re configure my engine to use enums : got the speed now though
[/quote]

enums aren't any smaller or easier to hash than pointers. If you're not using pointers and are copying your entire object every time... yeah, that's going to suck.

But since you won't actually tell us anything meaningful... best of luck with that.

Share this post


Link to post
Share on other sites
maps can be slow if you don't know how to use them properly, and fast if you do. There are various tricks like making use of swap and const-references etc that you need to know to use them efficiently.

Without seeing your code, my experience tells me to assume that you used them poorly, because that assumption is most often correct.

Share this post


Link to post
Share on other sites

[quote name='thedodgeruk' timestamp='1319155020' post='4874858']
[quote name='Telastyn' timestamp='1319137120' post='4874788']
And std::map<shader*, std::vector<model*>> (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?


tred that , was way too slow .

had to re configure my engine to use enums : got the speed now though
[/quote]

enums aren't any smaller or easier to hash than pointers. If you're not using pointers and are copying your entire object every time... yeah, that's going to suck.

But since you won't actually tell us anything meaningful... best of luck with that.
[/quote]


erm , need to sort my entitys so that i have less state changes on the GPU , so need to bucket sort all my enttiys via the shader pointer , so when done i have one bucket for all entitys that have shader plaincolour, other plainTexture , other phong , other normalmapping ect

and did an analize and it was saying with map, it was saying the slowest thing in my engine was itterating through the map , once i collected all my info into the buckets


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!