Readit News logoReadit News
lightingthedark commented on Zig's new LinkedList API (it's time to learn fieldParentPtr)   openmymind.net/Zigs-New-L... · Posted by u/todsacerdoti
lightingthedark · 8 months ago
Technically that should be possible the other way by using a Node<T> so the type of the second list ends up being a Node<Node<T>> but I can see why an intrusive list would be preferred to that, and also the linked list API might prevent that pattern.

Usually if I have multiple lists holding something I have one that's the 'owner' and then the secondary data structures would have a non-owning pointer to it. Is that the case where the performance would be better with an intrusive list? My intuition would be that having multiple Node members would pollute the cache and not actually be a performance win but maybe it is still better off because it's all colocated? Seems like the kind of thing I'd have to benchmark to know since it would depend on the number of lists and the size of the actual data.

lightingthedark · 8 months ago
Okay so in the multiple list case performance would actually be worse because you'd have a double pointer dereference. I was thinking you'd have the list nodes contiguous in memory so the first dereference would always hit cache but that's a bad assumption for a linked list.

Since you shouldn't reach for a linked list as a default data structure modern hardware anyway, I actually do see how this change makes sense for Zig. Neat!

lightingthedark commented on Zig's new LinkedList API (it's time to learn fieldParentPtr)   openmymind.net/Zigs-New-L... · Posted by u/todsacerdoti
ashdnazg · 8 months ago
I don't understand the higher performance either. What I know as the significant advantage is that you can have one object in multiple lists.
lightingthedark · 8 months ago
Technically that should be possible the other way by using a Node<T> so the type of the second list ends up being a Node<Node<T>> but I can see why an intrusive list would be preferred to that, and also the linked list API might prevent that pattern.

Usually if I have multiple lists holding something I have one that's the 'owner' and then the secondary data structures would have a non-owning pointer to it. Is that the case where the performance would be better with an intrusive list? My intuition would be that having multiple Node members would pollute the cache and not actually be a performance win but maybe it is still better off because it's all colocated? Seems like the kind of thing I'd have to benchmark to know since it would depend on the number of lists and the size of the actual data.

lightingthedark commented on Zig's new LinkedList API (it's time to learn fieldParentPtr)   openmymind.net/Zigs-New-L... · Posted by u/todsacerdoti
lightingthedark · 8 months ago
Can someone explain how the claim of higher performance works here? In C, which lacks generics, an intrusive list is preferred because otherwise you end up with each node having a void pointer to the data it holds. The previous Zig version was a generic, so the data type could easily be a value type. Given that the compiler is allowed to rearrange the layout of both structs unless data is packed or extern (in which case it almost certainly won't want to have a linked list node in the middle anyway) isn't the resulting type exactly the same in memory unless you intentionally made T a pointer type?
lightingthedark commented on Web Server for AoE 1, 2 and 3 DE supporting LAN multiplayer 100% offline   github.com/luskaner/ageLA... · Posted by u/apitman
cheeseomlit · 9 months ago
I'm sure the answer could be found in this repo somewhere but its above my head- does aoe2 DE rely mostly on p2p for multiplayer? I assume it does and the regional servers are just used for matchmaking, and all the actual game logic is running on the clients. I base that on the fact that map hacks are possible and that one player lagging lags the game for everyone, but there are often conflicting claims when it's brought up on aoe forums
lightingthedark · 9 months ago
If you haven't read it, there's a great paper on the netcode of the originals: https://zoo.cs.yale.edu/classes/cs538/readings/papers/terran...

I'd be surprised if the definitive editions changed the design significantly enough to move the netcode away from P2P, but I don't know of any actual information on it.

lightingthedark commented on Web Server for AoE 1, 2 and 3 DE supporting LAN multiplayer 100% offline   github.com/luskaner/ageLA... · Posted by u/apitman
CursedSilicon · 9 months ago
Does anything like this exist for the original Age of Empires games?

Battle.Net has "PVPGN" that covers Diablo 2 up through Warcraft 3, and the Westwood Online games (ish) but searching for an AoE equivalent turned up nothing

lightingthedark · 9 months ago
I believe the originals just supported offline LAN play. I remember getting my friend to have his modem dial my modem so we could play together, no Internet connection required.
lightingthedark commented on Nvidia emulation journey, part 1: RIVA 128/NV3 architecture history and overview   86box.net/2025/02/25/riva... · Posted by u/davikr
msk-lywenn · 10 months ago
I doubt it required floating point rgb and, iirc, it came (for real) much later. GPUs used fixed point math behind the scenes for a long time. The only thing you need to get proper additive blending is saturation, so that you don't overflow, like on the N64.
lightingthedark · 10 months ago
You don't need floating point RGB for additive blending, but to get correct behavior when using additive blending for your light sources, you must use linear buffers and if you do that, the dynamic range of the scene won't fit in eight bits.
lightingthedark commented on Exploring ways to mipmap alpha-tested textures   lisyarus.github.io/blog/p... · Posted by u/ibobev
koolala · a year ago
>Top row: mipmaps generated with premultiplied alpha. Bottom row: mipmaps generated without premultiplied alpha.

I couldn't see a difference in this first comparison.

lightingthedark · a year ago
Look at the fourth one on the bottom, you can see the black splotches. It's not the best example I've seen, a quick search turned up this better example, notice how the edges become all dark: https://forum.shotcut.org/uploads/default/original/2X/e/edb3...
lightingthedark commented on Great things about Rust that aren't just performance   ntietz.com/blog/great-thi... · Posted by u/vortex_ape
dataflow · a year ago
> Move by default. If you came from c++, I think this makes a lot of sense.

> Immutable by default.

In C++, these two fight each other. You can't (for the most part) move from something that's immutable.

How does Rust handle this? I assume it drops immutability upon the move, and that doesn't affect optimizations because the variable is unused thereafter?

lightingthedark · a year ago
Rust moves aren't quite the same as C++ moves, you can think of them more like a memcpy where the destructor (if there is one) doesn't get run on the original location. This means you can move an immutable object, the object itself doesn't have to do anything to be moved.

u/lightingthedark

KarmaCake day11January 12, 2025View Original