mirror of
https://github.com/guilhermewerner/wgpu-renderer
synced 2025-06-16 13:54:21 +00:00
Initial wgpu abstraction
This commit is contained in:
22
Source/Shader/ShaderSource.rs
Normal file
22
Source/Shader/ShaderSource.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ShaderSource {
|
||||
Glsl(String),
|
||||
Spirv(Vec<u8>),
|
||||
Wgsl(String),
|
||||
}
|
||||
|
||||
impl ShaderSource {
|
||||
pub fn SpirvFromBytes(bytes: &[u8]) -> ShaderSource {
|
||||
ShaderSource::Spirv(Vec::from(bytes))
|
||||
}
|
||||
|
||||
pub fn WgslToString(&self) -> Option<&String> {
|
||||
if let ShaderSource::Wgsl(s) = &self {
|
||||
Some(s)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user