Details
-
AboutAAAAAAAAAAAAAAAAAAA
-
SkillsRust and other things
-
Locationhere
-
Website
Joined devRant on 12/8/2018
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
-
Oh man, reminds me of this critique of an offical blog post for the hare language (anyone remember hare?) about how to implement hashmaps
https://ayende.com/blog/197185-B/... -
@jestdotty For the request enum: It's mostly the idea of making invalid states unrepresentable. In your code, calling send on the request enum gives back potentially any response even though each request has exactly one response "type" it returns.
Now you have to match against that response enum to extract out the actual variant you want, resulting in a runtime panic if there is a bug. Using the type system such a bug could have been caught at compile time
In your case just having three different concrete request and response types with three different send methods is probably the easiest way.
For more complex scenarios you could define a trait with an associated type denoting the response type:
pub trait Request {
type Response;
fn send(self) -> Self::Response;
} -
@jestdotty You don't /have/ to wrap errors into enums, only if you want to programatically handle them. For very simple error handling check out the anyhow crate which gives you an opaque "Error" type which any other error can be converted into and which captures a stack trace, etc. Then you can still use the ? operator but not worry about defining your own error enum
Trying to avoid dependencies makes sense but Rust has a lot of really high quality libraries, so don't feel to bad about using
The feature flag on ureq has actually a good reason: They don't want to force you to also depend on serde_json, so all that code is optional and has to be enabled with the feature flag should you want it (in this case you do to use Response::into_json()) -
Update: Actually I'm kinda wrong. I have some fullscreen workload and that is fastest with 8*8*1 workgroups. Both 8*4*1 (wave sized) and 16*16*1 are noticibly slower...
Guess if you're reading from an image per globalInvocationId, cache also plays a big role and having 64 threads closer together in terms of cache access outweighs some of the gains of smaller workgroup sizes? -
@jestdotty Something approximately like this should work (haven't tested since I can't compile it): https://play.rust-lang.org//...
This relies heavily on the try operator which is awesome for error handling and the thiserror crate for defining an error enum. (you might also have to turn on the json feature of ureq)
Apart from that the code looks pretty good, maybe some small nitpicks:
* you use a lot of inline defined structs, there is nothing wrong with that but it does harm readibility a bit imo
* I'm not too hot on making Request an enum and having send return an "untyped" Response, I would rather have concrete structs, but it's not that bad -
Thr joy of vulkan synchronization
Turns out I didn't insert a pipeline barrier between writing dispatch indirect params and the dispatch indirect itself
RenderDoc seems to insert some barriers, so it was visible there, but in reality the two dispatches where racing so the dispatch indirect still saw the cleared buffer (and thus 0*0*0 dispatch dims) -
@cuddlyogre Yeah but what have some randos to do with the rust project? Most of the hype bros can't even write Rust
If it was the core maintainers I would understand, but no, there all chill
You're limiting yourself from a potentially great language because some idiots somewhere say something... come on -
@jestdotty Sure, im up for it
-
@jestdotty Not sure how your code looks like but there is probably a better approach than these complex matches
What are you matching anyways? If it's just for "normal" error handling / detecting absent values you can use the try operator, which is a form of early return
By default it's for the entire function call though (returns from the function), else you need to unstable try_blocks feature:
https://play.rust-lang.org//...
Of course when you're dealing with Results its a bit more complex than Option since the error types have to be compatible. The cool thing is, the try/? operator calls .into() on the error to try to make it compatible with the target error type of the function / try block, so if you are frequently turning a ParseError into RequestError, you can just implement From<ParseError> for RequestError instead of having to call .map_err() all over the place -
@jestdotty Or if you REALLY want the nested if, you can do it like this:
Ok(match x {
Thing::A => Some(12),
Thing::B(value) => {
if let Some(value) = value {
Some(value * 36464)
} else {
None
}
}
}) -
@jestdotty No, theres no early "return" from within a match arm
In your specific case you can either solve this with a nested pattern or by mapping the option:
(or traditionally with a mut variable and an if, if youre feeling old school)
// Using nested pattern
Ok(match x {
Thing::A => Some(12),
Thing::B(Some(value)) => {
Some(value * 36464)
}
Thing::B(None) => None,
})
// Mapping the option
Ok(match x {
Thing::A => Some(12),
Thing::B(maybe) => {
maybe.map(|v| v * 36464)
}
}) -
@devRancid @cuddlyogre I don't get why people get their panties in a twist about internet idiots so much
I mean, literally just don't look at it. Don't consume low quality hype videos and don't read clueless reddit comments
Rust is just a tool. And its a good one so I use it. Evaluate for yourself instead of listening to coding bros -
The book is pretty boring, but you can always just do your own project
Rust is great, but it forces you to actually think about your code architecture beforehand which feels like a massive pain if you're not used to it -
Hmmm yes, let me download and run some sketchy chinese shell script. Surely nothing will go wrong
-
I'm mostly writing in Rust. It's pretty nice but comes with it's own set of challenges
Writing a regex engine is pretty cool. I'm not too knowledgable about it but some implementation details I heard sounded pretty insane :D
Hows your progress so far? -
@retoor For am upcoming game of mine. Because trying to make a AAA quality engine from scratch is totally a smart move...
-
@Eklavya *53 seconds, lets be honest
-
Jokes aside, thats kinda what happens when core usecases of your language are not directly encoded into the language itself. Not saying that it's possible and/or wanted that they are (considering how many millions/billions/gazillions there are), but still
It's like with Rust: Beautiful error messages when doing normal stuff the compiler devs thought you would be doing...
And then you're using lifetimes, or async or lifetimes in async...
bruh -
@retoor Turns out I actually dont! Haha, my stubbornness strikes again!
No actually the problem with visibility rendering is that you can't keep vertex positions across your passes meaning that for each pixel you have to transform 3 vertices twice (once for a "prepass" generating normals and stuff, and again for the actual shade pass), plus calculating barycentric coordinates twice plus transforming all vertices again in the vis pass
With a gbuffer you would only need to do it once, since your shading only cares about the gbuffer parameters, also good for dynamic geometry since you can render that directly into your gbuffer with traditional vertex/fragment shaders...
Well whatever, as far as I can tell doing the vertex transforms per pixel is more or less free (yeah really) taking only about 15 micros, most of which is the overhead of just launching the compute shader invocations themselves lol -
@rantsauce That's the beauty of todays world: It's not limited to country borders anymore. Plenty of europeans also being like this...
-
@LLAMS Thats a good point. Still kinda annoying as an end user though
-
@electrineer I mean... Google Calender exists
-
@atheist Game dev notes lol
-
@spoiledgoods What limitation? Can't be storage size if converting the note into a doc solves the issue
-
gz, hope you have prepared some coke and hookers
-
@Demolishun Really though, it's pretty tough. Even finding a used 4000 series card for retail price is challenging enough... I would say just go for AMD but unfortunately DLSS and co shenanigans are just too good to pass up on. At the end of the day there isn't much you can do besides bite the bullet and begrudgingly give nvidia your money
-
Nvidia says fuck you thats why
-
Just use a regex to get the correct regex capture group *facepalm*
-
Racism hell yeah
-
kiki be like https://youtu.be/mjWqhCWd4cI/...