COMP4300 - Game Programming - Lecture 17 - Optimizations, Cache Memory, Memory Pooling

preview_player
Показать описание
00:00 - Intro
00:37 - Game Performance
02:31 - Profiling Code
04:14 - Non-Obvious Performance Hits
05:50 - Important Optimizations
09:27 - Minimizing Data Structure Size
14:51 - Code Reuse and Modularity
16:09 - Minimize Dynamic Memory Allocation
19:05 - What is a Memory Pool?
20:56 - Cache Memory
31:59 - Cache Performance Example
39:43 - Cache Friendly Data
44:35 - ECS and Caching
47:15 - ECS Systems / Access Patterns
51:08 - ECS Memory Pool
1:02:07 - Memory Pool Example

Memorial University - Computer Science 4300 - Fall 2024
Intro to Game Programming

This is a course for students interested in learning the fundamentals of game programming and game engine architecture. Topics include an introduction to: vector math for games, rendering, animation, and artificial intelligence, collision detection, game physics, and user-interfaces. Students will be writing fully functional games using an ECS (Entities, Components, Systems) architecture, using the C++ programming language and the SFML graphics library.

Course Assignments / Files will not be released publicly
Рекомендации по теме
Комментарии
Автор

I use memory pooling for space partitioning and entities in my games, but you can pretty much use it for anything that needs contiguous memory. Good stuff, thanks for sharing!.

DDSTrainers
Автор

One of the best videos I've seen on the subject :).
I am currently implementing an ECS based on what is described in this video.
I have two questions though :

- If a system wants to access two different components from a same entity it is going to result in a cache miss because the two components are on different arrays.
Is there a way to prevent this ? The only lever I see is to merge the data into a single component.

- At which moment do you filter enabled components ? Do you have to add an if condition in the system loop to know whether or not the component is enabled for a given entity ?

Thank you !

joachimdivet
Автор

This lecture completely changed the way I was planning to write code. I'm new in programming (hobby), still in ''tutorials phase'' and never thought before about these subjects. Thanks for sharing. Regards from Brazil.

pedrofigueira
Автор

Dumb question but is memory pooling the same as writing your own malloc or memory allocation strategy? Because could we just ask for a page instead of calling malloc at the very top of our program?

agmui
Автор

I think a problem with this is that, it only works if your entities are using a lot of the components.

For example let's say entities 1-100 are a mix of plants and zombies.

So in the pool there might be 2 plants followed by 10 zombies, then 15 plants. Etc.

What this means is, since plants and zombies don't use the same components, like not all plants can walk. Not all zombies can shoot peas

We get a lot of cache misses. Although the components are grabbed in a contiguous manner, most of the components we get are disabled so it's a cache miss

TheCommunistRabbit
join shbcf.ru