546120250450653184, 867967467770920960, 1322594445548802050, 1514227321271635970, 1554821487797760000, 1611409453806403586, 1698349154106274129

This commit is contained in:
ed committed 2026-08-27 19:52:09 -04:00
1 parent 11efeff692
commit 1c92f5879d
31 files changed
+1227

No files matched your search

@@ -0,0 +1,37 @@
---
title: "@EricLengyel @ben_nuttall Gives me the heebie jeebies since overflow is undefined behaviour in C."
type: archive
source: twitter
source_url: "https://x.com/fanf/status/546412114408407041"
author: "Tony Finch"
handle: fanf
post_id: "546412114408407041"
date: 2014-12-20
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "@EricLengyel @ben_nuttall Gives me the heebie jeebies since overflow is undefined behaviour in C."
in_reply_to: ""
parent_post_id: "546120250450653184"
---
## Source
- URL: https://x.com/fanf/status/546412114408407041
- Author: Tony Finch (@fanf)
- Posted: 2014-12-20 21:09:34
## Branch
**1/** **@fanf** ^546412114408407041
**@EricLengyel** **@ben_nuttall**
Gives me the heebie jeebies since overflow is undefined behaviour in C. Need more (unsigned) casts…
## Related
- Spine: [[archive/threads/EricLengyel/2014-12-20-remember-that-integer-range-checks-can-always-be]]
@@ -0,0 +1,32 @@
---
title: "Remember that integer range checks can always be done with only one comparison: (unsigned) (x - min) <= (unsigned) (max - min)"
type: archive
source: twitter
source_url: "https://x.com/EricLengyel/status/546120250450653184"
author: "Eric Lengyel"
handle: EricLengyel
post_id: "546120250450653184"
date: 2014-12-20
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "Remember that integer range checks can always be done with only one comparison: (unsigned) (x - min) <= (unsigned) (max - min)"
in_reply_to: ""
---
## Source
- URL: https://x.com/EricLengyel/status/546120250450653184
- Author: Eric Lengyel (@EricLengyel)
- Posted: 2014-12-20 01:49:48
## Thread
**1/** **@EricLengyel** ^546120250450653184
Remember that integer range checks can always be done with only one comparison: (unsigned) (x - min) <= (unsigned) (max - min)
Branches: [[archive/threads/EricLengyel/2014-12-20-remember-that-integer-range-checks-can-always-be/2014-12-20-fanf-gives-me-the-heebie-jeebies-since-overflow-is]]
@@ -0,0 +1,37 @@
---
title: "@EricLengyel @dsuoch Yeah, this is one of the things coworkers hate me for"
type: archive
source: twitter
source_url: "https://x.com/noop_dev/status/868150884194189314"
author: "Boris Chuprin"
handle: noop_dev
post_id: "868150884194189314"
date: 2017-05-26
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "@EricLengyel @dsuoch Yeah, this is one of the things coworkers hate me for"
in_reply_to: ""
parent_post_id: "867967467770920960"
---
## Source
- URL: https://x.com/noop_dev/status/868150884194189314
- Author: Boris Chuprin (@noop_dev)
- Posted: 2017-05-26 17:04:34
## Branch
**1/** **@noop_dev** ^868150884194189314
**@EricLengyel** **@dsuoch**
Yeah, this is one of the things coworkers hate me for
## Related
- Spine: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed]]
@@ -0,0 +1,37 @@
---
title: "@EricLengyel Otherwise UB if hi == INT_MAX and lo == INT_MIN"
type: archive
source: twitter
source_url: "https://x.com/vaughncato/status/868087562287579137"
author: "Vaughn Cato"
handle: vaughncato
post_id: "868087562287579137"
date: 2017-05-26
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "@EricLengyel Otherwise UB if hi == INT_MAX and lo == INT_MIN"
in_reply_to: ""
parent_post_id: "867967467770920960"
---
## Source
- URL: https://x.com/vaughncato/status/868087562287579137
- Author: Vaughn Cato (@vaughncato)
- Posted: 2017-05-26 12:52:57
## Branch
**1/** **@vaughncato** ^868087562287579137
**@EricLengyel**
Otherwise UB if hi == INT_MAX and lo == INT_MIN
## Related
- Spine: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed]]
@@ -0,0 +1,43 @@
---
title: "@EricLengyel Shouldn't that be `unsigned(x)-unsigned(lo) <= unsigned(hi)-unsigned(lo)`"
type: archive
source: twitter
source_url: "https://x.com/vaughncato/status/868086438092582912"
author: "Vaughn Cato"
handle: vaughncato
post_id: "868086438092582912"
date: 2017-05-26
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "@EricLengyel Shouldn't that be `unsigned(x)-unsigned(lo) <= unsigned(hi)-unsigned(lo)`"
in_reply_to: ""
parent_post_id: "867967467770920960"
---
## Source
- URL: https://x.com/vaughncato/status/868086438092582912
- Author: Vaughn Cato (@vaughncato)
- Posted: 2017-05-26 12:48:29
## Branch
**1/** **@vaughncato** ^868086438092582912
**@EricLengyel**
Shouldn't that be `unsigned(x)-unsigned(lo) <= unsigned(hi)-unsigned(lo)`
**2/** **@EricLengyel** ^868252570136870912
**@vaughncato**
Sure. Let me take this opportunity to say that I have zero respect for a language that has any undefined behavior whatsoever.
## Related
- Spine: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed]]
@@ -0,0 +1,37 @@
---
title: "@EricLengyel @Atrix256 One of my favs."
type: archive
source: twitter
source_url: "https://x.com/sreekotay/status/868268000499167232"
author: "sree kotay"
handle: sreekotay
post_id: "868268000499167232"
date: 2017-05-27
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "@EricLengyel @Atrix256 One of my favs."
in_reply_to: ""
parent_post_id: "867967467770920960"
---
## Source
- URL: https://x.com/sreekotay/status/868268000499167232
- Author: sree kotay (@sreekotay)
- Posted: 2017-05-27 00:49:57
## Branch
**1/** **@sreekotay** ^868268000499167232
**@EricLengyel** **@Atrix256**
One of my favs. And special cases possible for testing power of 2 ranges (just a mask, no subtracts)... :)
## Related
- Spine: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed]]
@@ -0,0 +1,32 @@
---
title: "Needs repeating: You can always perform a signed integer range test with a single comparison."
type: archive
source: twitter
source_url: "https://x.com/EricLengyel/status/867967467770920960"
author: "Eric Lengyel"
handle: EricLengyel
post_id: "867967467770920960"
date: 2017-05-26
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "Needs repeating: You can always perform a signed integer range test with a single comparison."
in_reply_to: ""
---
## Source
- URL: https://x.com/EricLengyel/status/867967467770920960
- Author: Eric Lengyel (@EricLengyel)
- Posted: 2017-05-26 04:55:45
## Thread
**1/** **@EricLengyel** ^867967467770920960
Needs repeating: You can always perform a signed integer range test with a single comparison. unsigned(x - lo) <= unsigned(hi - lo)
Branches: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-vaughncato-shouldnt-that-be-unsigned-x-unsigned-lo-unsigned]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-vaughncato-otherwise-ub-if-hi-int-max-and-lo-int-min]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-noop_dev-yeah-this-is-one-of-the-things-coworkers-hate-me]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-27-sreekotay-one-of-my-favs-and-special-cases-possible-for]]
+2
View File
@@ -9,4 +9,6 @@ tags:
- EricLengyel
---
- [[archive/threads/EricLengyel/2014-12-20-remember-that-integer-range-checks-can-always-be]]
- [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed]]
- [[archive/threads/EricLengyel/2026-01-23-ive-worked-very-hard-over-many-years-to-develop-a]]
@@ -0,0 +1,39 @@
---
title: "@SebAaltonen I ended up going with an approach where I read the \"chunk data\" and then emit to an indice+mesh buffer and write the indirect dispatch from a compute shader."
type: archive
source: twitter
source_url: "https://x.com/Wunkolo/status/1336028429997678592"
author: "wunk"
handle: Wunkolo
post_id: "1336028429997678592"
date: 2020-12-07
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen I ended up going with an approach where I read the \"chunk data\" and then emit to an indice+mesh buffer and write the indirect dispatch from a compute shader."
in_reply_to: ""
parent_post_id: "1335872884464640000"
---
## Source
- URL: https://x.com/Wunkolo/status/1336028429997678592
- Author: wunk (@Wunkolo)
- Posted: 2020-12-07 19:22:54
## Branch
**1/** **@Wunkolo** ^1336028429997678592
**@SebAaltonen**
I ended up going with an approach where I read the "chunk data" and then emit to an indice+mesh buffer and write the indirect dispatch from a compute shader.
Seems to run pretty fast for having varying per-face or per-vertex attributes(lighting/normals)
https://x.com/Wunkolo/status/1309657816269901825
## Related
- Spine: [[archive/threads/SebAaltonen/2020-10-31-this-is-how-you-generate-a-cube-in-vertex-shader]]
@@ -0,0 +1,97 @@
---
title: "This is how you generate a cube in vertex shader."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1322594445548802050"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1322594445548802050"
date: 2020-10-31
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "This is how you generate a cube in vertex shader."
in_reply_to: ""
---
## Source
- URL: https://x.com/SebAaltonen/status/1322594445548802050
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2020-10-31 17:41:03
## Thread
**1/** **@SebAaltonen** ^1322594445548802050
This is how you generate a cube in vertex shader. Works with any amount of cubes. Also includes the backface culling trick (only include the positive cube faces to index buffer).
Backface culling trick relies on the fact that only 3 faces of a cube can be visible at once.
![](https://pbs.twimg.com/media/ElrMOuxXIAMu09A?format=jpg&name=orig)
**2/** **@SebAaltonen** ^1322594883757027329
Measured performance advantage of the backface culling trick. On Intel Gen 11 GPU. 1 million untextured cubes.
6 face cube = 16.1 ms
3 face cube (mirror faces at runtime) = 10.5 ms
53% performance increase!
**3/** **@SebAaltonen** ^1322595624714407942
If you use the mirroring trick, you need to disable the backface culling from the rasterizer state. Mirroring also flips the faces (except when mirrored even times as that brings the determinant back to positive).
**4/** **@SebAaltonen** ^1322599526318964736
Shader Playground link to my vertex shader:
http://shader-playground.timjones.io/efcd86ce6a954d91ac0a4355f38bb7d4
**5/** **@SebAaltonen** ^1322599989336514561
The cost of the backface mirroring:
9 full rate instructions in the box vertex shader.
I think I can optimize this further if needed. Let's try...
![](https://pbs.twimg.com/media/ElrRUwzX0AEbs_1?format=png&name=orig)
**6/** **@SebAaltonen** ^1322605838624792576
If you are scared that the compiler can't get rid of the branches. Try this. On AMD compiler it results in 1 full rate ALU more than the trivial implementation. On Intel Gen 11 the frame time is identical with 1M cubes. So yeah.
![](https://pbs.twimg.com/media/ElrWr01WoAEzOxF?format=png&name=orig)
**7/** **@SebAaltonen** ^1322819025047605248
For completeness: This is the index buffer I use. Repeat the same 3 or 6 faces for max cubes supported (add 8 for each iteration).
Full index buffer generation code also included...
![](https://pbs.twimg.com/media/EluYJ2SXUAAjwOb?format=png&name=orig)
![](https://pbs.twimg.com/media/EluY0_LW0AENiLp?format=jpg&name=orig)
**8/** **@SebAaltonen** ^1322821076448124928
ARM Mali compiler results: 11.5 ALU cycles. 12 L/S cycles. Thus ALU is free. Without backface culling trick, it's 10.5 ALU cycles. Insignificant difference.
http://shader-playground.timjones.io/2b3fd2d6a2e6f6bd1100283fbe956677
![](https://pbs.twimg.com/media/EluaZUTX0AY0IK6?format=png&name=orig)
**9/** **@SebAaltonen** ^1322822548137062400
Image of the cube is here. The Y and Z arrows should actually point to the other direction. Oops :)
https://x.com/SebAaltonen/status/1315982782439591938?s=20
**10/** **@SebAaltonen** ^1335872884464640000
If you are using this cube rendering trick to render actual concrete cube faces (with normals), you need to use SV_IsFrontFace input in pixel shader to detect whether a backface is rendered and flip the normal.
Branches: [[archive/threads/SebAaltonen/2020-10-31-this-is-how-you-generate-a-cube-in-vertex-shader/2020-12-07-Wunkolo-i-ended-up-going-with-an-approach-where-i-read]]
@@ -0,0 +1,38 @@
---
title: "@SebAaltonen agreed "
type: archive
source: twitter
source_url: "https://x.com/JosephLaurino/status/1514229496861188101"
author: "Joseph Laurino"
handle: JosephLaurino
post_id: "1514229496861188101"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen agreed "
in_reply_to: ""
parent_post_id: "1514228491063078918"
---
## Source
- URL: https://x.com/JosephLaurino/status/1514229496861188101
- Author: Joseph Laurino (@JosephLaurino)
- Posted: 2022-04-13 13:10:19
## Branch
**1/** **@JosephLaurino** ^1514229496861188101
**@SebAaltonen**
agreed
Toolkits/Libraries/APIs over Frameworks
## Related
- Spine: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
@@ -0,0 +1,41 @@
---
title: "@SebAaltonen YEEEEES!"
type: archive
source: twitter
source_url: "https://x.com/ZPostFacto/status/1514300772153905154"
author: "Fletcher Dunn"
handle: ZPostFacto
post_id: "1514300772153905154"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen YEEEEES!"
in_reply_to: ""
parent_post_id: "1514228491063078918"
---
## Source
- URL: https://x.com/ZPostFacto/status/1514300772153905154
- Author: Fletcher Dunn (@ZPostFacto)
- Posted: 2022-04-13 17:53:33
## Branch
**1/** **@ZPostFacto** ^1514300772153905154
**@SebAaltonen**
YEEEEES!
"Toolkit" > "framework".
I want to be in the drivers seat and use your stuff, not "plug in" at the few spots you have deigned to give me access.
## Related
- Spine: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
@@ -0,0 +1,43 @@
---
title: "@SebAaltonen While I agree when it comes to stuff built for game engines."
type: archive
source: twitter
source_url: "https://x.com/bartlomiej_pohl/status/1514297017090068481"
author: "Bartlomiej Pohl"
handle: bartlomiej_pohl
post_id: "1514297017090068481"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen While I agree when it comes to stuff built for game engines."
in_reply_to: ""
parent_post_id: "1514228491063078918"
---
## Source
- URL: https://x.com/bartlomiej_pohl/status/1514297017090068481
- Author: Bartlomiej Pohl (@bartlomiej_pohl)
- Posted: 2022-04-13 17:38:37
## Branch
**1/** **@bartlomiej_pohl** ^1514297017090068481
**@SebAaltonen**
While I agree when it comes to stuff built for game engines. When it comes to Business Software I think this is a different story. In that context frameworks play a similar role that engines do in games.
**2/** **@SebAaltonen** ^1514297209587654658
**@bartlomiej_pohl**
Unpopular opinion: Game engines should not be frameworks either. Same applies for business software frameworks.
## Related
- Spine: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
@@ -0,0 +1,49 @@
---
title: "@SebAaltonen Oh, is that what ECS does? Give me control over execution flow?"
type: archive
source: twitter
source_url: "https://x.com/bodowens86/status/1514330430102769671"
author: "Jan Milík"
handle: bodowens86
post_id: "1514330430102769671"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Oh, is that what ECS does? Give me control over execution flow?"
in_reply_to: ""
parent_post_id: "1514228491063078918"
---
## Source
- URL: https://x.com/bodowens86/status/1514330430102769671
- Author: Jan Milík (@bodowens86)
- Posted: 2022-04-13 19:51:24
## Branch
**1/** **@bodowens86** ^1514330430102769671
**@SebAaltonen**
Oh, is that what ECS does? Give me control over execution flow?
**2/** **@SebAaltonen** ^1514332717697179655
**@bodowens86**
At Ubisoft/RedLynx we created a ECS that didn't steal your control flow. ECS is all about data. It's not about control flow. Why should ECS steal your control flow?
**3/** **@SebAaltonen** ^1514335939086229518
**@bodowens86**
Components were in arrays and we used sparse bitfields to combine them together. Just standard objects we passed to functions and standard function calls we called to them.
## Related
- Spine: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
@@ -0,0 +1,39 @@
---
title: "@SebAaltonen Code Snippets > Libraries > Frameworks"
type: archive
source: twitter
source_url: "https://x.com/matias__eduardo/status/1514232184957280262"
author: "Matias"
handle: matias__eduardo
post_id: "1514232184957280262"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Code Snippets > Libraries > Frameworks"
in_reply_to: ""
parent_post_id: "1514228491063078918"
---
## Source
- URL: https://x.com/matias__eduardo/status/1514232184957280262
- Author: Matias (@matias__eduardo)
- Posted: 2022-04-13 13:21:00
## Branch
**1/** **@matias__eduardo** ^1514232184957280262
**@SebAaltonen**
Code Snippets > Libraries > Frameworks
Just give me the god damn recipe and I’ll cook it myself.
## Related
- Spine: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
@@ -0,0 +1,36 @@
---
title: "Software should be composable."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1514227321271635970"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1514227321271635970"
date: 2022-04-13
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "Software should be composable."
in_reply_to: ""
---
## Source
- URL: https://x.com/SebAaltonen/status/1514227321271635970
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2022-04-13 13:01:41
## Thread
**1/** **@SebAaltonen** ^1514227321271635970
Software should be composable. Framework-style libraries aren't proper libraries. You can't use multiple of them at the same time. Please design proper composable libraries instead.
**2/** **@SebAaltonen** ^1514228491063078918
The cold truth: Your code is not special. People don't want to give the responsibility of the whole execution flow of their program to your framework. Instead they want libraries that are easy to integrate and easy to call from their code.
Branches: [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable/2022-04-13-JosephLaurino-agreed-toolkits-libraries-apis-over-frameworks]], [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable/2022-04-13-matias__eduardo-code-snippets-libraries-frameworks-just-give-me]], [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable/2022-04-13-bartlomiej_pohl-while-i-agree-when-it-comes-to-stuff-built-for]], [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable/2022-04-13-ZPostFacto-yeeeees-toolkit-framework-i-want-to-be-in-the]], [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable/2022-04-13-bodowens86-oh-is-that-what-ecs-does-give-me-control-over]]
@@ -0,0 +1,39 @@
---
title: "@SebAaltonen Painkiller did that"
type: archive
source: twitter
source_url: "https://x.com/kinjalkishor/status/1555189347062005760"
author: "kinjal kishor"
handle: kinjalkishor
post_id: "1555189347062005760"
date: 2022-08-04
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Painkiller did that"
in_reply_to: ""
parent_post_id: "1555111290787565568"
---
## Source
- URL: https://x.com/kinjalkishor/status/1555189347062005760
- Author: kinjal kishor (@kinjalkishor)
- Posted: 2022-08-04 13:50:09
## Branch
**1/** **@kinjalkishor** ^1555189347062005760
**@SebAaltonen**
Painkiller did that
![](https://pbs.twimg.com/media/FZUkbr4aMAQxPyS?format=jpg&name=orig)
## Related
- Spine: [[archive/threads/SebAaltonen/2022-08-03-tip-of-the-day-if-you-dont-have-the-passion-to]]
@@ -0,0 +1,38 @@
---
title: "Tip of the day: If you don't have the passion to build and the resources to maintain high quality tools for artists, level designers and game developers, don't build your own engine."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1554821487797760000"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1554821487797760000"
date: 2022-08-03
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "Tip of the day: If you don't have the passion to build and the resources to maintain high quality tools for artists, level designers and game developers, don't build your own engine."
in_reply_to: ""
---
## Source
- URL: https://x.com/SebAaltonen/status/1554821487797760000
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2022-08-03 13:28:24
## Thread
**1/** **@SebAaltonen** ^1554821487797760000
Tip of the day: If you don't have the passion to build and the resources to maintain high quality tools for artists, level designers and game developers, don't build your own engine.
These people vastly outnumber the programmers. Their productivity is super important.
**2/** **@SebAaltonen** ^1555111290787565568
Also remember that you don't have to build everything. There's a lot of good DCC tools available with big artist communities behind them. Only compete against them if that's your area of passion. Building a plugin/exporter to add your special needs is often better.
Branches: [[archive/threads/SebAaltonen/2022-08-03-tip-of-the-day-if-you-dont-have-the-passion-to/2022-08-04-kinjalkishor-painkiller-did-that]]
@@ -0,0 +1,39 @@
---
title: "@SebAaltonen Caches work with physical addresses."
type: archive
source: twitter
source_url: "https://x.com/hkultala/status/1611421583574188032"
author: "Heikki Kultala"
handle: hkultala
post_id: "1611421583574188032"
date: 2023-01-06
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Caches work with physical addresses."
in_reply_to: ""
parent_post_id: "1611417779474677799"
---
## Source
- URL: https://x.com/hkultala/status/1611421583574188032
- Author: Heikki Kultala (@hkultala)
- Posted: 2023-01-06 17:56:58
## Branch
**1/** **@hkultala** ^1611421583574188032
**@SebAaltonen**
Caches work with physical addresses. All the code should get shared between processes.
Also read-only parts of data segments of different processes from the same binary should get shared.
## Related
- Spine: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen Seb, for the next gen consoles, what is your AMD CPU wishlist? 16 core CPU? Big cache? 3D V-cache as you said?"
type: archive
source: twitter
source_url: "https://x.com/isotoxin390/status/1611496788569067525"
author: "KJ"
handle: isotoxin390
post_id: "1611496788569067525"
date: 2023-01-06
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Seb, for the next gen consoles, what is your AMD CPU wishlist? 16 core CPU? Big cache? 3D V-cache as you said?"
in_reply_to: ""
parent_post_id: "1611417779474677799"
---
## Source
- URL: https://x.com/isotoxin390/status/1611496788569067525
- Author: KJ (@isotoxin390)
- Posted: 2023-01-06 22:55:49
## Branch
**1/** **@isotoxin390** ^1611496788569067525
**@SebAaltonen**
Seb, for the next gen consoles, what is your AMD CPU wishlist? 16 core CPU? Big cache? 3D V-cache as you said?
## Related
- Spine: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen Compiling translation units (cpp files) don’t benefit generally by large cache."
type: archive
source: twitter
source_url: "https://x.com/Kodiak_73/status/1611773762646736899"
author: "Aaron Coday"
handle: Kodiak_73
post_id: "1611773762646736899"
date: 2023-01-07
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Compiling translation units (cpp files) don’t benefit generally by large cache."
in_reply_to: ""
parent_post_id: "1611417779474677799"
---
## Source
- URL: https://x.com/Kodiak_73/status/1611773762646736899
- Author: Aaron Coday (@Kodiak_73)
- Posted: 2023-01-07 17:16:24
## Branch
**1/** **@Kodiak_73** ^1611773762646736899
**@SebAaltonen**
Compiling translation units (cpp files) don’t benefit generally by large cache. However Linking can benefit, but i would guess that whole program optimization and PGO phases benefit
## Related
- Spine: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen well, this is about to change in llvm at least https://llvm.org/devmtg/2019-10/slides/Ganea-OptimizingBuildesOnWindows.pdf"
type: archive
source: twitter
source_url: "https://x.com/morbidarne2007/status/1611611529362771969"
author: "morbidarne2007"
handle: morbidarne2007
post_id: "1611611529362771969"
date: 2023-01-07
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen well, this is about to change in llvm at least https://llvm.org/devmtg/2019-10/slides/Ganea-OptimizingBuildesOnWindows.pdf"
in_reply_to: ""
parent_post_id: "1611417779474677799"
---
## Source
- URL: https://x.com/morbidarne2007/status/1611611529362771969
- Author: morbidarne2007 (@morbidarne2007)
- Posted: 2023-01-07 06:31:45
## Branch
**1/** **@morbidarne2007** ^1611611529362771969
**@SebAaltonen**
well, this is about to change in llvm at least https://llvm.org/devmtg/2019-10/slides/Ganea-OptimizingBuildesOnWindows.pdf
## Related
- Spine: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen Very nicely put together, but one big omission (imo) is the split of cache on said 144MB SKUs, since they use two CCDs and historically (seen in some benchmarks too) games hate being split, they like a single cache pool for a group of cores they work on and thats more or less it."
type: archive
source: twitter
source_url: "https://x.com/GPUsAreMagic/status/1612156777746907138"
author: "Nemez"
handle: GPUsAreMagic
post_id: "1612156777746907138"
date: 2023-01-08
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Very nicely put together, but one big omission (imo) is the split of cache on said 144MB SKUs, since they use two CCDs and historically (seen in some benchmarks too) games hate being split, they like a single cache pool for a group of cores they work on and thats more or less it."
in_reply_to: ""
parent_post_id: "1611417779474677799"
---
## Source
- URL: https://x.com/GPUsAreMagic/status/1612156777746907138
- Author: Nemez (@GPUsAreMagic)
- Posted: 2023-01-08 18:38:22
## Branch
**1/** **@GPUsAreMagic** ^1612156777746907138
**@SebAaltonen**
Very nicely put together, but one big omission (imo) is the split of cache on said 144MB SKUs, since they use two CCDs and historically (seen in some benchmarks too) games hate being split, they like a single cache pool for a group of cores they work on and thats more or less it.
## Related
- Spine: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
@@ -0,0 +1,58 @@
---
title: "Thread: A simple explanation why AMDs 144MB 3D cache makes games run significantly faster."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1611409453806403586"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1611409453806403586"
date: 2023-01-06
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "Thread: A simple explanation why AMDs 144MB 3D cache makes games run significantly faster."
in_reply_to: ""
---
## Source
- URL: https://x.com/SebAaltonen/status/1611409453806403586
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2023-01-06 17:08:46
## Thread
**1/** **@SebAaltonen** ^1611409453806403586
Thread: A simple explanation why AMDs 144MB 3D cache makes games run significantly faster.
TLDR: The working set of most games fits inside the 3D cache. All cache lines accessed during the previous frame are still present in cache. Sequential frames only differ slightly.
**2/** **@SebAaltonen** ^1611409879226269703
If you look at any recent GPU benchmarks (RTX 4090), you notice that most games run at 240Hz+ if you remove the GPU bottleneck. Run at 1080p or similar without RTX. This is enough info to calculate how much memory we can access per frame.
**3/** **@SebAaltonen** ^1611410295842291728
DDR4-3200 provides us 50GB/s theoretical bandwidth. In reality we get roughly 40GB/s, which is proven by memory benchmarks. Divide this by 240Hz, and we get 170MB/frame. That's how much we can access unique memory cache lines per frame in a game that runs at 240Hz = most games.
**4/** **@SebAaltonen** ^1611410746797080595
AMDs 128MB 3D cache is a victim cache, so it doesn't have the same pages as the smaller cache levels. Thus we can use the 144MB number as our maximum working set limit. 170MB/frame considers that game is 100% mem bound all the time. In reality it's not, thus 144MB is enough.
**5/** **@SebAaltonen** ^1611411278467334144
And this is why AMD 3D cache provides big gains for games. The CPU working set (data accessed in a single frame) fits to the 144MB cache, meaning that the next frame can read most of the data from the cache. The difference between two sequential frames is minimal.
**6/** **@SebAaltonen** ^1611411663218950152
Correction: pages -> cache lines. Victim cache doesn't keep the same cache lines as lower level caches.
**7/** **@SebAaltonen** ^1611417779474677799
Traditional MT workloads such as compiling code doesn't get as big benefits. Each .cpp file is compiled in a separate process. There's zero data sharing between them. If you have a cold start (new process) for every compiled file, there's not much a massive cache can do to help.
Branches: [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d/2023-01-06-hkultala-caches-work-with-physical-addresses-all-the-code]], [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d/2023-01-06-isotoxin390-seb-for-the-next-gen-consoles-what-is-your-amd]], [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d/2023-01-07-morbidarne2007-well-this-is-about-to-change-in-llvm-at-least]], [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d/2023-01-07-Kodiak_73-compiling-translation-units-cpp-files-dont]], [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d/2023-01-08-GPUsAreMagic-very-nicely-put-together-but-one-big-omission-imo]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen You might be interested in https://2022.ecoop.org/details/ecoop-2022-papers/17/What-If-We-Don-t-Pop-the-Stack-The-Return-of-Second-Class-Values"
type: archive
source: twitter
source_url: "https://x.com/RepealTCPA1947/status/1698370292975055248"
author: "Workhouse Overseer 🌐🥑🍌"
handle: RepealTCPA1947
post_id: "1698370292975055248"
date: 2023-09-03
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen You might be interested in https://2022.ecoop.org/details/ecoop-2022-papers/17/What-If-We-Don-t-Pop-the-Stack-The-Return-of-Second-Class-Values"
in_reply_to: ""
parent_post_id: "1698355711422476302"
---
## Source
- URL: https://x.com/RepealTCPA1947/status/1698370292975055248
- Author: Workhouse Overseer 🌐🥑🍌 (@RepealTCPA1947)
- Posted: 2023-09-03 16:20:06
## Branch
**1/** **@RepealTCPA1947** ^1698370292975055248
**@SebAaltonen**
You might be interested in https://2022.ecoop.org/details/ecoop-2022-papers/17/What-If-We-Don-t-Pop-the-Stack-The-Return-of-Second-Class-Values
## Related
- Spine: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
@@ -0,0 +1,43 @@
---
title: "@SebAaltonen I like how Jai solved this."
type: archive
source: twitter
source_url: "https://x.com/SergeyLerg/status/1698365089701642504"
author: "Sergey Lerg"
handle: SergeyLerg
post_id: "1698365089701642504"
date: 2023-09-03
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen I like how Jai solved this."
in_reply_to: ""
parent_post_id: "1698355711422476302"
---
## Source
- URL: https://x.com/SergeyLerg/status/1698365089701642504
- Author: Sergey Lerg (@SergeyLerg)
- Posted: 2023-09-03 15:59:26
## Branch
**1/** **@SergeyLerg** ^1698365089701642504
**@SebAaltonen**
I like how Jai solved this. You can return dynamically allocated data just fine because every function has access to a temporary allocator (linear block of reserved heap memory). Most data is short lived and the temporary storage is cleaned at e.g. the end of a game render frame
**2/** **@SebAaltonen** ^1698366857537794256
**@SergeyLerg**
Yes. That's how C/C++ based game engines tend to do it as well. You just use linear temp allocator (reset at end of frame). But a stack based temp allocator would be even better here. Even better if integrated to the language. Would be easy to use = would be the default for all.
## Related
- Spine: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen Ada does this"
type: archive
source: twitter
source_url: "https://x.com/_Glacia/status/1698421319048528297"
author: "Sergey Polyansky"
handle: _Glacia
post_id: "1698421319048528297"
date: 2023-09-03
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen Ada does this"
in_reply_to: ""
parent_post_id: "1698355711422476302"
---
## Source
- URL: https://x.com/_Glacia/status/1698421319048528297
- Author: Sergey Polyansky (@_Glacia)
- Posted: 2023-09-03 19:42:52
## Branch
**1/** **@_Glacia** ^1698421319048528297
**@SebAaltonen**
Ada does this
## Related
- Spine: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen @threadreaderapp unroll"
type: archive
source: twitter
source_url: "https://x.com/DasGurke/status/1698570792919880110"
author: "Marcus Riemer"
handle: DasGurke
post_id: "1698570792919880110"
date: 2023-09-04
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen @threadreaderapp unroll"
in_reply_to: ""
parent_post_id: "1698355711422476302"
---
## Source
- URL: https://x.com/DasGurke/status/1698570792919880110
- Author: Marcus Riemer (@DasGurke)
- Posted: 2023-09-04 05:36:49
## Branch
**1/** **@DasGurke** ^1698570792919880110
**@SebAaltonen** **@threadreaderapp**
unroll
## Related
- Spine: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
@@ -0,0 +1,37 @@
---
title: "@SebAaltonen What if we had some kind of special syntax sugar, which is later split into two calls."
type: archive
source: twitter
source_url: "https://x.com/iiSatana/status/1698552092376359327"
author: "смертельный порошок извращений"
handle: iiSatana
post_id: "1698552092376359327"
date: 2023-09-04
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "@SebAaltonen What if we had some kind of special syntax sugar, which is later split into two calls."
in_reply_to: ""
parent_post_id: "1698355711422476302"
---
## Source
- URL: https://x.com/iiSatana/status/1698552092376359327
- Author: смертельный порошок извращений (@iiSatana)
- Posted: 2023-09-04 04:22:31
## Branch
**1/** **@iiSatana** ^1698552092376359327
**@SebAaltonen**
What if we had some kind of special syntax sugar, which is later split into two calls. First returns a size, codegens for allocation on a caller stack, then second call writes to that space.
## Related
- Spine: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
@@ -0,0 +1,70 @@
---
title: "Somebody asked why you can't return arrays (dynamic sized data) in C."
type: archive
source: twitter
source_url: "https://x.com/SebAaltonen/status/1698349154106274129"
author: "Sebastian Aaltonen"
handle: SebAaltonen
post_id: "1698349154106274129"
date: 2023-09-03
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- SebAaltonen
description: "Somebody asked why you can't return arrays (dynamic sized data) in C."
in_reply_to: ""
---
## Source
- URL: https://x.com/SebAaltonen/status/1698349154106274129
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2023-09-03 14:56:06
## Thread
**1/** **@SebAaltonen** ^1698349154106274129
Somebody asked why you can't return arrays (dynamic sized data) in C. There's a interesting technical limitation in stack based programming languages that prevents this. It's not possible to return dynamic amount of data using the stack.
Thread...
**2/** **@SebAaltonen** ^1698349426559893546
We all know that alloca exists. This allows you to allocate dynamic amount of data from top of the stack. This works like any static sized stack variable. It dies at return. No issues there. Why is the return then a problem?
**3/** **@SebAaltonen** ^1698349835110277381
The problem is that when you call functions, those functions go on stack on top of you. The stack will be rewinded at function return, so if you want to have storage for return value, you have to allocate it in the caller scope before the function call.
**4/** **@SebAaltonen** ^1698350535290609828
The problem is that the caller doesn't know how many bytes the called function wants to return. That function must run first. And that function's stack variables are on top of the caller's variables. Dynamic sized stack allocations must always be on top of the stack.
**5/** **@SebAaltonen** ^1698351276117901624
What if the called function could immediately call alloca before allocating local variables from the stack? That would actually work. The problem is that that function would need to calculate the return value size without using any temporary variables in the stack. Not easy!
**6/** **@SebAaltonen** ^1698351905229947197
There's no generic way to put a dynamic sized return value to the top of the stack in a way that it remains on top of the stack after the function has returned. That would be equal to alloca and would work, but it's not doable in most situations.
**7/** **@SebAaltonen** ^1698352650775847179
You could also think about reading the return value beyond the stack scope after function has returned with dynamic return size. This works only in case you don't call any other functions, since those would override the return value.
**8/** **@SebAaltonen** ^1698353875978178598
There's a way to make dynamic sized stack return work. You know how the top of the stack of the returned function and you alloca(N) where N is enough to cover that function. Now the dynamic return is safe to access. But you waste extra stack space equal to variables of that func.
**9/** **@SebAaltonen** ^1698354683096563868
The above works for multiple functions too, it's simply equal to calling alloca multiple times inside the same function. The problem of this kind of deferred stack popping is that it continues recursively if the called functions also receive some dynamic sized return values.
**10/** **@SebAaltonen** ^1698355711422476302
I don't know whether any languages have implement this kind of deferred stack popping for dynamic return values. It wastes a lot of stack space if dynamic size return is common, especially in deep chains. But it should never be worse than linear temp allocator.
Branches: [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic/2023-09-03-SergeyLerg-i-like-how-jai-solved-this-you-can-return]], [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic/2023-09-03-RepealTCPA1947-you-might-be-interested-in-https-2022-ecoop-org]], [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic/2023-09-03-_Glacia-ada-does-this]], [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic/2023-09-04-iiSatana-what-if-we-had-some-kind-of-special-syntax-sugar]], [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic/2023-09-04-DasGurke-unroll]]
+5
View File
@@ -13,7 +13,12 @@ tags:
- [[archive/threads/SebAaltonen/2019-01-01-now-that-people-have-already-said-highly]]
- [[archive/threads/SebAaltonen/2019-05-05-this-is-how-you-write-a-good-x64-spinlock-use-two]]
- [[archive/threads/SebAaltonen/2020-10-25-implemented-a-simple-linear-estimator-for]]
- [[archive/threads/SebAaltonen/2020-10-31-this-is-how-you-generate-a-cube-in-vertex-shader]]
- [[archive/threads/SebAaltonen/2022-04-13-software-should-be-composable]]
- [[archive/threads/SebAaltonen/2022-08-03-tip-of-the-day-if-you-dont-have-the-passion-to]]
- [[archive/threads/SebAaltonen/2022-11-22-ive-long-time-talked-about-killing-the-graphics]]
- [[archive/threads/SebAaltonen/2023-01-06-thread-a-simple-explanation-why-amds-144mb-3d]]
- [[archive/threads/SebAaltonen/2023-09-03-somebody-asked-why-you-cant-return-arrays-dynamic]]
- [[archive/threads/SebAaltonen/2024-04-04-this-is-how-slow-code-feels-like]]
- [[archive/threads/SebAaltonen/2024-05-03-why-should-one-be-able-to-code-without]]
- [[archive/threads/SebAaltonen/2024-12-18-fixed-all-our-vulkan-bugs]]