Skip to content

Commit 1fa2c5d

Browse files
LPGhatguyozkriff
andauthored
N14: Add Crevice and Thunderdome (rust-gamedev#283)
* First draft * N14: Thunderdome: Fix fmt Co-authored-by: Andrey Lesnikov <ozkriff@gmail.com>
1 parent 91f4db5 commit 1fa2c5d

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

content/posts/newsletter-014/index.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,83 @@ prior to Jan 1, 2021.
129129

130130
## Library & Tooling Updates
131131

132+
### [Thunderdome]
133+
134+
[Thunderdome] is a ~~gladitorial~~ generational arena library inspired by
135+
[generational-arena], [slotmap], and [slab]. It provides constant time
136+
insertion, lookup, and removal via small (8 byte) keys that stay 8 bytes when
137+
wrapped in `Option<T>`.
138+
139+
Data structures like Thunderdome's `Arena` store values and return keys that can
140+
be later used to access those values. These keys are stable across removals and
141+
have a generation counter to solve the [ABA Problem].
142+
143+
```rust
144+
let mut arena = Arena::new();
145+
146+
let foo = arena.insert("Foo");
147+
let bar = arena.insert("Bar");
148+
149+
assert_eq!(arena[foo], "Foo");
150+
assert_eq!(arena[bar], "Bar");
151+
152+
arena[bar] = "Replaced";
153+
assert_eq!(arena[bar], "Replaced");
154+
155+
let foo_value = arena.remove(foo);
156+
assert_eq!(foo_value, Some("Foo"));
157+
158+
// The slot previously used by foo will be reused for baz.
159+
let baz = arena.insert("Baz");
160+
assert_eq!(arena[baz], "Baz");
161+
162+
// foo is no longer a valid key.
163+
assert_eq!(arena.get(foo), None);
164+
```
165+
166+
_Discussions:
167+
[twitter](https://twitter.com/LPGhatguy/status/1303375906493276160)_
168+
169+
[Thunderdome]: https://github.com/LPGhatguy/thunderdome
170+
[generational-arena]: https://crates.io/crates/generational-arena
171+
[slotmap]: https://crates.io/crates/slotmap
172+
[slab]: https://crates.io/crates/slab
173+
[ABA Problem]: https://en.wikipedia.org/wiki/ABA_problem
174+
175+
### [Crevice]
176+
177+
[Crevice] is a library that helps define GLSL-compatible (std140) structs for
178+
use in uniform and storage buffers. It uses new `const fn` capabilities
179+
stabilized in [Rust 1.46.0] to align types with explicitly zeroed padding.
180+
181+
Crevice depends heavily on [mint] to support almost any Rust math library. It
182+
also contains helpers for safely sizing and writing buffers, making dynamic
183+
buffer layout a breeze.
184+
185+
```rust
186+
#[derive(AsStd140)]
187+
struct MainUniform {
188+
orientation: mint::ColumnMatrix3<f32>,
189+
position: mint::Vector3<f32>,
190+
scale: f32,
191+
}
192+
193+
let value = MainUniform {
194+
orientation: cgmath::Matrix3::identity().into(),
195+
position: [1.0, 2.0, 3.0].into(),
196+
scale: 4.0,
197+
};
198+
199+
upload_data_to_gpu(value.as_std140().as_bytes());
200+
```
201+
202+
_Discussions:
203+
[twitter](https://twitter.com/LPGhatguy/status/1308499131212599296)_
204+
205+
[Crevice]: https://github.com/LPGhatguy/crevice
206+
[Rust 1.46.0]: https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html
207+
[mint]: https://github.com/kvark/mint
208+
132209
### [gfx-rs] and [gfx-portability]
133210

134211
![gfx-rs logo](gfx-logo.png)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy