pub struct PipelineCacheKey {
pub shader_hash: u64,
pub entry_point: String,
pub layout_tag: String,
}Expand description
Unique key identifying a compiled compute pipeline.
Two pipelines are considered identical — and therefore candidates for
sharing a cached wgpu::ComputePipeline — when all three fields match.
§Layout tag conventions
The layout_tag is an opaque caller-supplied string. A suggested
convention is to encode the binding types in declaration order, e.g.:
| Binding pattern | layout_tag |
|---|---|
| read ⟶ read_write | "r-w" |
| read ⟶ read ⟶ read_write | "r-r-w" |
| uniform ⟶ read ⟶ read_write | "u-r-w" |
Any unambiguous scheme works as long as it is applied consistently within a project.
Fields§
§shader_hash: u64FNV-1a 64-bit hash of the WGSL shader source text.
Using a hash keeps the key small; the probability of a collision for distinct shaders in a typical project is negligible (< 2⁻⁶⁰).
entry_point: StringThe @compute function name used as the pipeline entry point.
layout_tag: StringAn opaque string describing the bind-group layout structure.
Implementations§
Source§impl PipelineCacheKey
impl PipelineCacheKey
Sourcepub fn new(shader_source: &str, entry_point: &str, layout_tag: &str) -> Self
pub fn new(shader_source: &str, entry_point: &str, layout_tag: &str) -> Self
Construct a key from raw shader source, entry point, and layout tag.
The shader source is hashed with fnv1a_64; the raw text is not
stored in the key.
§Examples
use oxigdal_gpu::pipeline_cache::{PipelineCacheKey, fnv1a_64};
let src = "// wgsl shader source";
let key = PipelineCacheKey::new(src, "main", "r-w");
assert_eq!(key.shader_hash, fnv1a_64(src.as_bytes()));
assert_eq!(key.entry_point, "main");
assert_eq!(key.layout_tag, "r-w");Trait Implementations§
Source§impl Clone for PipelineCacheKey
impl Clone for PipelineCacheKey
Source§fn clone(&self) -> PipelineCacheKey
fn clone(&self) -> PipelineCacheKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PipelineCacheKey
impl Debug for PipelineCacheKey
Source§impl Display for PipelineCacheKey
impl Display for PipelineCacheKey
impl Eq for PipelineCacheKey
Source§impl Hash for PipelineCacheKey
impl Hash for PipelineCacheKey
Source§impl PartialEq for PipelineCacheKey
impl PartialEq for PipelineCacheKey
Source§fn eq(&self, other: &PipelineCacheKey) -> bool
fn eq(&self, other: &PipelineCacheKey) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PipelineCacheKey
Auto Trait Implementations§
impl Freeze for PipelineCacheKey
impl RefUnwindSafe for PipelineCacheKey
impl Send for PipelineCacheKey
impl Sync for PipelineCacheKey
impl Unpin for PipelineCacheKey
impl UnsafeUnpin for PipelineCacheKey
impl UnwindSafe for PipelineCacheKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.