Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411500 Posts in 69373 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 01:20:33 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)General programming discussion
Pages: 1 ... 8 9 [10] 11 12 ... 16
Print
Author Topic: General programming discussion  (Read 29240 times)
qMopey
Level 6
*


View Profile WWW
« Reply #180 on: November 19, 2017, 12:41:19 PM »

Yes they are different.

The first one consists of a single stream of data. If you utilize all of this data, and loop over it linearly, you will have 100% efficient cache utilization (along with a cache miss or two when you first start iterating and pull the array into the cache).

The second one uses four data streams, meaning when you start looping on each array (assuming it is not already cached), you will hit four in total cache misses or so.

The purpose of the second option is to increase cache utilization. For each cache line (64 bytes) you pull into memory, what percentage of the cache line is actually used? This is your cache utilization. If an algorithm only needs to access transforms, and loops over the first option, you will have very poor cache utilization.

Cache utilization matters as when a cache line is pulled into cache, another is evicted. The less evictions you have, theoretically the better performance you have.

You can separate your data streams further, and do:

Code:
id* transform_ids;
id* renderdata_ids;
id* animator_ids;
id* physicsdata_ids;

Transform* transforms;
Renderdata* renderdata;
Animator* animators;
Physicsdata* physicsdata;

The whole point is to try and only pull into the cache what you need when you need it, and avoid pulling in extraneous stuff. Though, arguably, it's more important to just start putting things into arrays, and the whole "separating things into multiple streams" thing becomes less important. Basically: diminishing returns.

In practice all options are likely to be *fast enough* for all real games made on these forums, so it probably doesn't matter much.
Logged
oahda
Level 10
*****



View Profile
« Reply #181 on: November 19, 2017, 12:47:48 PM »

Thank you both! Yeah, I was thinking since most of these will usually be processed together (rendering needs both the transform and the animator and the renderdata for example). But the second is still better?

(and just for some context since you said "likely fast enough", this is a full 3D game which I possibly want to run on mobile and definitely on consoles)
Logged

qMopey
Level 6
*


View Profile WWW
« Reply #182 on: November 19, 2017, 01:15:43 PM »

“Better” becomes very fuzzy. There’s a juggling of priorities. More data streams puts more pressure onto registers. High register pressure can potentially result into stack spilling. This is just one example. It completely depends on the exact use case. We’re talking about splitting hairs here, so to speak; you should try different options out and measure performance stats to get a feel for this stuff.
Logged
oahda
Level 10
*****



View Profile
« Reply #183 on: November 19, 2017, 01:30:43 PM »

Yeah. Maybe I'll try to implement both in a way that I can try each just by changing a define or something and then do profiling.
Logged

JWki
Level 4
****


View Profile
« Reply #184 on: November 20, 2017, 12:07:44 AM »

Thank you both! Yeah, I was thinking since most of these will usually be processed together (rendering needs both the transform and the animator and the renderdata for example). But the second is still better?

(and just for some context since you said "likely fast enough", this is a full 3D game which I possibly want to run on mobile and definitely on consoles)

Another tip: a thing that a lot of people struggle with is "both rendering and physics need a transform" and then they try to figure out how to share that data in the most efficient way because it doesn't even occur to them that they could just duplicate the data in both systems.

BTW if you really really seriously want to get on consoles you'll need to lose STL and also get comfy with the idea of ditching opengl for those builds. And if you want to target the last generation (Xbox 360, PS3), especially PS3 requires a whole different way of designing your data transformations due to it's unique architecture.
Logged
Ordnas
Level 10
*****



View Profile WWW
« Reply #185 on: November 20, 2017, 12:58:07 AM »

Thank you both! Yeah, I was thinking since most of these will usually be processed together (rendering needs both the transform and the animator and the renderdata for example). But the second is still better?

(and just for some context since you said "likely fast enough", this is a full 3D game which I possibly want to run on mobile and definitely on consoles)

Another tip: a thing that a lot of people struggle with is "both rendering and physics need a transform" and then they try to figure out how to share that data in the most efficient way because it doesn't even occur to them that they could just duplicate the data in both systems.

BTW if you really really seriously want to get on consoles you'll need to lose STL and also get comfy with the idea of ditching opengl for those builds. And if you want to target the last generation (Xbox 360, PS3), especially PS3 requires a whole different way of designing your data transformations due to it's unique architecture.

Or I think that now we have less constraints due to the fact that PS4 and XONE have a more PC-like architecture and we can start to forget the unique PS3 hardware.
Logged

Games:

oahda
Level 10
*****



View Profile
« Reply #186 on: November 20, 2017, 01:51:39 AM »

TBH Switch is the only one I'm really interested in. Will be happy to make any changes necessary if that day comes. I know about PS3 and I'm not touching it. Tongue
Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #187 on: November 21, 2017, 12:42:07 AM »

TBH Switch is the only one I'm really interested in. Will be happy to make any changes necessary if that day comes. I know about PS3 and I'm not touching it. Tongue

Switch compiler is more "fussy" than Visual Studio about variable shadowing, order of variable in construction list and other errors that VS compiler by default would forgive.
Logged

Games:

oahda
Level 10
*****



View Profile
« Reply #188 on: November 21, 2017, 12:48:56 AM »

Yeah, my setup requires me to keep making sure my code compiles on both LLVM and GCC anyway. c: Plus I enable somewhat picky warnings to catch things like that.
Logged

JWki
Level 4
****


View Profile
« Reply #189 on: November 21, 2017, 12:52:59 AM »

Yeah, my setup requires me to keep making sure my code compiles on both LLVM and GCC anyway. c: Plus I enable somewhat picky warnings to catch things like that.

Can recommend -Wall and -Werror.
Logged
oahda
Level 10
*****



View Profile
« Reply #190 on: November 21, 2017, 01:28:15 AM »

Yeah, I would enable -Werror if I didn't have third-party code slapped into my codebase which won't compile if I do that. But I treat the warnings in my own code as such and make sure to eliminate them. Considered compiling the external code to a separate static library and linking against that instead but meh. This works. c:
Logged

JWki
Level 4
****


View Profile
« Reply #191 on: November 21, 2017, 03:42:12 AM »

Yeah, I would enable -Werror if I didn't have third-party code slapped into my codebase which won't compile if I do that. But I treat the warnings in my own code as such and make sure to eliminate them. Considered compiling the external code to a separate static library and linking against that instead but meh. This works. c:

Yeah what I do is either compile in a separate library or wrap with #pragmas when possible (i.e. header only libs which is most of my deps). "Compiles without warnings" has become one of my criteria when choosing libraries though.
But either way, I found that after a while I usually don't write code that would produce a warning in the first place, at least in MSVC, because you get used to fixing them a priori. It's a really good practice.
Logged
oahda
Level 10
*****



View Profile
« Reply #192 on: November 21, 2017, 03:50:16 AM »

Yes, definitely. Most of the times I don't get warnings anyway because I know to avoid them. I keep checking just to be sure, of course.
Logged

ferreiradaselva
Level 3
***



View Profile
« Reply #193 on: November 21, 2017, 07:29:33 AM »

"Compiles without warnings" has become one of my criteria when choosing libraries though.

One reason I'm thinking about writing a lib for loading .ogg files. STB ogg loader is full of warnings, to the point I have no idea where to start to fix.
Logged

ferreiradaselva
Level 3
***



View Profile
« Reply #194 on: December 13, 2017, 07:22:17 AM »

I'm really digging this:





I want to write one fluid simulation eventually. I've found some example codes, already, it seems simple.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #195 on: December 13, 2017, 09:59:53 AM »

I want to write one fluid simulation eventually. I've found some example codes, already, it seems simple.

Neat. This is something I'm going to be working on soon. If you have/find any other good resources, please share them!
Logged

JWki
Level 4
****


View Profile
« Reply #196 on: December 14, 2017, 01:32:19 AM »

I'm really digging this:





I want to write one fluid simulation eventually. I've found some example codes, already, it seems simple.

It is surprisingly few code but depending on what you wanna do it's not necessarily simple. Shallow water surface sim is pretty straightforward, full body simulation is a bit more complex (and expensive).
Logged
ferreiradaselva
Level 3
***



View Profile
« Reply #197 on: December 14, 2017, 02:08:48 AM »

I want to write one fluid simulation eventually. I've found some example codes, already, it seems simple.

Neat. This is something I'm going to be working on soon. If you have/find any other good resources, please share them!

This was the most simple example I found: https://www.mikeash.com/pyblog/fluid-simulation-for-dummies.html
Certainly has caveats.

It is surprisingly few code but depending on what you wanna do it's not necessarily simple. Shallow water surface sim is pretty straightforward, full body simulation is a bit more complex (and expensive).

I'm aware it's expensive. I will do just for fun. Hand Any Key

More fun videos:









The last one is by Matthias Müller-Fischer. There are the name of his papers in the description of his videos.
Logged

Ordnas
Level 10
*****



View Profile WWW
« Reply #198 on: December 15, 2017, 01:07:14 AM »

I want to write one fluid simulation eventually. I've found some example codes, already, it seems simple.

Neat. This is something I'm going to be working on soon. If you have/find any other good resources, please share them!

This was the most simple example I found: https://www.mikeash.com/pyblog/fluid-simulation-for-dummies.html
Certainly has caveats.

It is surprisingly few code but depending on what you wanna do it's not necessarily simple. Shallow water surface sim is pretty straightforward, full body simulation is a bit more complex (and expensive).

I'm aware it's expensive. I will do just for fun. Hand Any Key

More fun videos:









The last one is by Matthias Müller-Fischer. There are the name of his papers in the description of his videos.

Very interesting to watch, I am wondering when all that good we will see in an actual game.

Someone suggest this book: https://www.amazon.com/PHYSICAL-FLUID-DYNAMICS-D-Tritton/dp/9579437017, explains without going too much on the maths side and more on how things work.
Logged

Games:

buto
Level 0
***



View Profile WWW
« Reply #199 on: December 15, 2017, 05:10:59 AM »

Yeah, I would enable -Werror if I didn't have third-party code slapped into my codebase which won't compile if I do that. But I treat the warnings in my own code as such and make sure to eliminate them. Considered compiling the external code to a separate static library and linking against that instead but meh. This works. c:

Since I'm typically also only interested in my own warnings, I sometimes declare includes from external libraries as "system includes" in my build system. In CMAKE one could e.g. do the following to hide any boost-internal warnings:

Code:
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

Maybe there's some more elegant way though...
Logged

Pages: 1 ... 8 9 [10] 11 12 ... 16
Print
Jump to:  

Theme orange-lt created by panic