-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branchless sky shader #71
Conversation
cool! |
c7575f1
to
de95ae3
Compare
Maybe starting to become a red dawn on Mars? so a very specific sky shader :) |
Alright, it should look different but I hacked in an up and view vector so it probably looks wrong. What does |
Actually - I think the |
Hacky way to avoid the memcpys - vectors apparently use a different mechanism to copy than structs. I probably won't get to implementing all those bugfixes properly before we opensource - some of them are kind of in-depth. Maybe if I high-priority it, but, there's a lot of other things on my plate. Also yeah, I tried playing around with input values and whatnot, but couldn't get anything other than pure white output and pure black output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like this to either be a pristine example if we're going to put it as the main item in examples/example-shader
, or it to be a second example. If it's the main item, I'd like all the vector/helper stuff to be in spirv-std
(ideally with the same ops defined on f32x4, etc.), and some thought put into the design of the library. Seeing all this boilerplate as a first user experience isn't a great first impression.
The actual mathy bits/implementation look fine, though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be the final implementation
yeah, needs some work, but it's decent for a first hack-together!
implement pow and a few others on f32 directly
could do an extension trait, right?
spirv-std/src/math/mat2.rs
Outdated
|
||
/// A 2x2 column major matrix. | ||
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)] | ||
#[repr(C)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why repr(C) for all of these? why not repr(simd)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was like this in glam - not sure if it matters much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does indeed matter, repr(rust) or repr(c) gets translated to OpTypeStruct, repr(simd) gets translated to OpTypeVector and we really want to do that, right? (all the discussions around nvidia load/store perf and whatnot)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, yeah I figured it'd be fine for now since our final store needs to happen through a f32x4 anyway, which is repr(simd). Let me take a look at a few of these, it might be nicer to remove the repr(C) indeed.
Oh of course. Hold on. |
FYI, filed #81 after seeing the horror that is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice looks good! Will try and run locally also and poke at some more, but think we can get this in.
Added tiny suggestion
This reverts commit ca16454.
These kind of approximations are fairly common in graphics so it might be nice to have a crate later on with a bunch of these, or add them as |
Right now this shader doesn't compile because it outputs a lot of
error: OpCopyMemorySized (memcpy) without OpCapability Addresses
anderror: static_addr_of
. However, this shader is a relatively complex workload that looks nice and doesn't have any branching in it, so it could be a nice show-case for the project.Source: https://github.com/Tw1ddle/Sky-Shader/blob/master/src/shaders/glsl/sky.fragment