-
Notifications
You must be signed in to change notification settings - Fork 968
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
[BREAKING] Wrap ShaderSource::Naga
in Cow<'static>
#2903
[BREAKING] Wrap ShaderSource::Naga
in Cow<'static>
#2903
Conversation
88792c2
to
7246ad7
Compare
78cbb02
to
d100286
Compare
Could you provide an example that this change fixes? Is there another way to handle it without changing this type? |
// I'm hiding some stuff here, but I've done this with a proc-macro
// and using `serde` to deserialize the `Module` in a `Lazy`.
const MODULE: &'static Module = ...;
// With the PR.
let source = ShaderModuleDescriptor {
label: None,
source: ShaderSource::Naga(Cow::Borrowed(MODULE)),
};
// Without the PR.
let source = ShaderModuleDescriptor {
label: None,
source: ShaderSource::Naga(MODULE.clone()),
};
// With the PR, I can now keep re-using the `Module` without having to clone it unnecessarily.
device.create_shader_module(source); I hope this explains it.
Not that I'm aware of, unless we want to carry around a lifetime I guess. |
Probably related: #2801. |
d100286
to
92f4db5
Compare
Now that gfx-rs/naga#2013 was merged, I updated the relevant parts to depend on it. |
I think CI isn't failing because of this PR, it fails with the same errors in the latest commit on master too. |
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'm game, small comment
92f4db5
to
0e531a5
Compare
96056e3
to
deed644
Compare
Added CHANGELOG entry and rebased, not sure why CI fails now, but it doesn't look like it's because of this PR. |
deed644
to
7b1abf8
Compare
Rebased after #3008. |
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.
Hopefully this doesn't start another cowpocolypse 🐄 😆
Checklist
cargo clippy
.RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown
if applicable.Connections
Depends on gfx-rs/naga#2013.
Description
I'm currently pre-compiling shaders and storing them as
const
, butShaderSource::Naga
wants to ownnaga::Module
s, as far as I understand, for good reasons, because it stores them, so not owning them would be problematic. UsingCow<'static, Module>
, solves this, even if it looks strange.Testing
None.