mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 22:41:07 +01:00
Cause shader recompilation when changing shader constants in GLES (#8291)
This commit is contained in:
1 parent
702c4ef4da
commit
a7ed7f4f12
3 files changed
+14
No files matched your search
@@ -120,6 +120,7 @@ By @cwfitzgerald in [#8999](https://github.com/gfx-rs/wgpu/pull/8999).
|
||||
|
||||
- `DisplayHandle` should now be passed to `InstanceDescriptor` for correct EGL initialization on Wayland. By @MarijnS95 in [#8012](https://github.com/gfx-rs/wgpu/pull/8012)
|
||||
Note that the existing workaround to create surfaces before the adapter is no longer valid.
|
||||
- Changing shader constants now correctly recompiles the shader. By @DerSchmale in [#8291](https://github.com/gfx-rs/wgpu/pull/8291).
|
||||
|
||||
### Documentation
|
||||
|
||||
|
||||
@@ -331,6 +331,7 @@ impl super::Device {
|
||||
shader_id: stage.module.id,
|
||||
entry_point: stage.entry_point.to_owned(),
|
||||
zero_initialize_workgroup_memory: stage.zero_initialize_workgroup_memory,
|
||||
constant_hash: Self::create_constant_hash(stage),
|
||||
});
|
||||
}
|
||||
let mut guard = self
|
||||
@@ -362,6 +363,17 @@ impl super::Device {
|
||||
Ok(program)
|
||||
}
|
||||
|
||||
fn create_constant_hash(stage: &crate::ProgrammableStage<super::ShaderModule>) -> Vec<u8> {
|
||||
let mut buf: Vec<u8> = Vec::new();
|
||||
|
||||
for (key, value) in stage.constants.iter() {
|
||||
buf.extend_from_slice(key.as_bytes());
|
||||
buf.extend_from_slice(&value.to_ne_bytes());
|
||||
}
|
||||
|
||||
buf
|
||||
}
|
||||
|
||||
unsafe fn create_program<'a>(
|
||||
gl: &glow::Context,
|
||||
shaders: ArrayVec<ShaderStage<'a>, { crate::MAX_CONCURRENT_SHADER_STAGES }>,
|
||||
|
||||
@@ -703,6 +703,7 @@ struct ProgramStage {
|
||||
shader_id: ShaderId,
|
||||
entry_point: String,
|
||||
zero_initialize_workgroup_memory: bool,
|
||||
constant_hash: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
|
||||
Reference in new issue
Block a user