• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
thedodgeruk

whats the fastest way to bucket sort pointers?

12 posts in this topic

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 ?
1

Share this post


Link to post
Share on other sites
[quote name='thedodgeruk' timestamp='1319132762' post='4874766']
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 ?

[/quote]



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.

1

Share this post


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

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

Share this post


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

Is it too slow to populate, to iterate over, to search through?
[/quote]

tred that , was way too slow .

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

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 [code]std::map<shader*, std::vector<model*>>[/code] (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?
[/quote]

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.
0

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.
0

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1319157840' post='4874876']
[quote name='thedodgeruk' timestamp='1319155020' post='4874858']
[quote name='Telastyn' timestamp='1319137120' post='4874788']
And [code]std::map<shader*, std::vector<model*>>[/code] (using smart pointers where appropriate) is insufficient?

Is it too slow to populate, to iterate over, to search through?
[/quote]

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


1

Share this post


Link to post
Share on other sites
Use assembly language, stop screwing around, if you want speed, size, or both, come to the dark side @ asmcommunity.net
No we do not support malicious stuff, we are good people who help each other, and welcome novices and experts alike.
I was forced to program in c and c++ all this year, and i learned a few things, like, MSVC IS CRAP and I like codeblocks, and so on.
-3

Share this post


Link to post
Share on other sites
How were you profiling? Were you profiling a Debug or Release build? If iterating through a 12 element std::map was the most expensive thing in your "engine", then you mustn't be doing a lot of work elsewhere in your program.

Can you show us some code? Maybe you are making a minor mistake that ends up doing unnecessary work.

For small numbers of keys, a map has a lot of constant and hidden* overheads. It is only when the number of keys is large that you see the benefits. I agree with Hodgman, I think a sorted linear contiguous structure like std::vector<> would be much more efficient, and not too hard to code.

* [size="1"]Hidden overhead includes cost of cache misses and allocations, which is ignored by big O analysis.[/size]
0

Share this post


Link to post
Share on other sites
A map (i.e. balanced binary tree) of vectors is totally overkill. Implementing it in assembly also wont help, as the inefficiency is in the algorithm / data-structure, not the implementation.

All you need is one [font="'Courier New"]std::vector[/font] plus [font="'Courier New"]std::sort[/font] ([i]or a custom radix sort if you've got thousands of entities and want that little bit of extra speed[/i]).
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0