-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
339 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
use crate::{FilterMode, ImageFormat, Size, WrapMode}; | ||
|
||
impl From<ImageFormat> for Option<wgpu_types::TextureFormat> { | ||
fn from(format: ImageFormat) -> Self { | ||
match format { | ||
ImageFormat::Unknown => None, | ||
ImageFormat::R8Unorm => Some(wgpu_types::TextureFormat::R8Unorm), | ||
ImageFormat::R8Uint => Some(wgpu_types::TextureFormat::R8Uint), | ||
ImageFormat::R8Sint => Some(wgpu_types::TextureFormat::R8Sint), | ||
ImageFormat::R8G8Unorm => Some(wgpu_types::TextureFormat::Rg8Unorm), | ||
ImageFormat::R8G8Uint => Some(wgpu_types::TextureFormat::Rg8Uint), | ||
ImageFormat::R8G8Sint => Some(wgpu_types::TextureFormat::Rg8Sint), | ||
ImageFormat::R8G8B8A8Unorm => Some(wgpu_types::TextureFormat::Rgba8Unorm), | ||
ImageFormat::R8G8B8A8Uint => Some(wgpu_types::TextureFormat::Rgba8Uint), | ||
ImageFormat::R8G8B8A8Sint => Some(wgpu_types::TextureFormat::Rgba8Sint), | ||
ImageFormat::R8G8B8A8Srgb => Some(wgpu_types::TextureFormat::Rgba8UnormSrgb), | ||
ImageFormat::A2B10G10R10UnormPack32 => Some(wgpu_types::TextureFormat::Rgb10a2Unorm), | ||
ImageFormat::A2B10G10R10UintPack32 => Some(wgpu_types::TextureFormat::Rgb10a2Uint), | ||
ImageFormat::R16Uint => Some(wgpu_types::TextureFormat::R16Uint), | ||
ImageFormat::R16Sint => Some(wgpu_types::TextureFormat::R16Sint), | ||
ImageFormat::R16Sfloat => Some(wgpu_types::TextureFormat::R16Float), | ||
ImageFormat::R16G16Uint => Some(wgpu_types::TextureFormat::Rg16Uint), | ||
ImageFormat::R16G16Sint => Some(wgpu_types::TextureFormat::Rg16Sint), | ||
ImageFormat::R16G16Sfloat => Some(wgpu_types::TextureFormat::Rg16Float), | ||
ImageFormat::R16G16B16A16Uint => Some(wgpu_types::TextureFormat::Rgba16Uint), | ||
ImageFormat::R16G16B16A16Sint => Some(wgpu_types::TextureFormat::Rgba16Sint), | ||
ImageFormat::R16G16B16A16Sfloat => Some(wgpu_types::TextureFormat::Rgba16Float), | ||
ImageFormat::R32Uint => Some(wgpu_types::TextureFormat::R32Uint), | ||
ImageFormat::R32Sint => Some(wgpu_types::TextureFormat::R32Sint), | ||
ImageFormat::R32Sfloat => Some(wgpu_types::TextureFormat::R32Float), | ||
ImageFormat::R32G32Uint => Some(wgpu_types::TextureFormat::Rg32Uint), | ||
ImageFormat::R32G32Sint => Some(wgpu_types::TextureFormat::Rg32Sint), | ||
ImageFormat::R32G32Sfloat => Some(wgpu_types::TextureFormat::Rg32Float), | ||
ImageFormat::R32G32B32A32Uint => Some(wgpu_types::TextureFormat::Rgba32Uint), | ||
ImageFormat::R32G32B32A32Sint => Some(wgpu_types::TextureFormat::Rgba32Sint), | ||
ImageFormat::R32G32B32A32Sfloat => Some(wgpu_types::TextureFormat::Rgba32Float), | ||
} | ||
} | ||
} | ||
|
||
impl From<wgpu_types::TextureFormat> for ImageFormat { | ||
fn from(format: wgpu_types::TextureFormat) -> Self { | ||
match format { | ||
wgpu_types::TextureFormat::R8Unorm => ImageFormat::R8Unorm, | ||
wgpu_types::TextureFormat::R8Uint => ImageFormat::R8Uint, | ||
wgpu_types::TextureFormat::R8Sint => ImageFormat::R8Sint, | ||
wgpu_types::TextureFormat::Rg8Unorm => ImageFormat::R8G8Unorm, | ||
wgpu_types::TextureFormat::Rg8Uint => ImageFormat::R8G8Uint, | ||
wgpu_types::TextureFormat::Rg8Sint => ImageFormat::R8G8Sint, | ||
wgpu_types::TextureFormat::Rgba8Unorm => ImageFormat::R8G8B8A8Unorm, | ||
wgpu_types::TextureFormat::Rgba8Uint => ImageFormat::R8G8B8A8Uint, | ||
wgpu_types::TextureFormat::Rgba8Sint => ImageFormat::R8G8B8A8Sint, | ||
wgpu_types::TextureFormat::Rgba8UnormSrgb => ImageFormat::R8G8B8A8Srgb, | ||
wgpu_types::TextureFormat::Rgb10a2Unorm => ImageFormat::A2B10G10R10UnormPack32, | ||
wgpu_types::TextureFormat::Rgb10a2Uint => ImageFormat::A2B10G10R10UintPack32, | ||
wgpu_types::TextureFormat::R16Uint => ImageFormat::R16Uint, | ||
wgpu_types::TextureFormat::R16Sint => ImageFormat::R16Sint, | ||
wgpu_types::TextureFormat::R16Float => ImageFormat::R16Sfloat, | ||
wgpu_types::TextureFormat::Rg16Uint => ImageFormat::R16G16Uint, | ||
wgpu_types::TextureFormat::Rg16Sint => ImageFormat::R16G16Sint, | ||
wgpu_types::TextureFormat::Rg16Float => ImageFormat::R16G16Sfloat, | ||
wgpu_types::TextureFormat::Rgba16Uint => ImageFormat::R16G16B16A16Uint, | ||
wgpu_types::TextureFormat::Rgba16Sint => ImageFormat::R16G16B16A16Sint, | ||
wgpu_types::TextureFormat::Rgba16Float => ImageFormat::R16G16B16A16Sfloat, | ||
wgpu_types::TextureFormat::R32Uint => ImageFormat::R32Uint, | ||
wgpu_types::TextureFormat::R32Sint => ImageFormat::R32Sint, | ||
wgpu_types::TextureFormat::R32Float => ImageFormat::R32Sfloat, | ||
wgpu_types::TextureFormat::Rg32Uint => ImageFormat::R32G32Uint, | ||
wgpu_types::TextureFormat::Rg32Sint => ImageFormat::R32G32Sint, | ||
wgpu_types::TextureFormat::Rg32Float => ImageFormat::R32G32Sfloat, | ||
wgpu_types::TextureFormat::Rgba32Uint => ImageFormat::R32G32B32A32Uint, | ||
wgpu_types::TextureFormat::Rgba32Sint => ImageFormat::R32G32B32A32Sint, | ||
wgpu_types::TextureFormat::Rgba32Float => ImageFormat::R32G32B32A32Sfloat, | ||
_ => ImageFormat::Unknown | ||
} | ||
} | ||
} | ||
|
||
impl From<Option<wgpu_types::TextureFormat>> for ImageFormat { | ||
fn from(format: Option<wgpu_types::TextureFormat>) -> Self { | ||
let Some(format) = format else { | ||
return ImageFormat::Unknown; | ||
}; | ||
ImageFormat::from(format) | ||
} | ||
} | ||
|
||
// | ||
// impl From<Size<u32>> for vk::Extent3D { | ||
// fn from(value: Size<u32>) -> Self { | ||
// vk::Extent3D { | ||
// width: value.width, | ||
// height: value.height, | ||
// depth: 1, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<Size<u32>> for vk::Extent2D { | ||
// fn from(value: Size<u32>) -> Self { | ||
// vk::Extent2D { | ||
// width: value.width, | ||
// height: value.height, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<vk::Extent3D> for Size<u32> { | ||
// fn from(value: vk::Extent3D) -> Self { | ||
// Size { | ||
// width: value.width, | ||
// height: value.height, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<vk::Extent2D> for Size<u32> { | ||
// fn from(value: vk::Extent2D) -> Self { | ||
// Size { | ||
// width: value.width, | ||
// height: value.height, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<vk::Viewport> for Size<u32> { | ||
// fn from(value: vk::Viewport) -> Self { | ||
// Size { | ||
// width: value.width as u32, | ||
// height: value.height as u32, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<&vk::Viewport> for Size<u32> { | ||
// fn from(value: &vk::Viewport) -> Self { | ||
// Size { | ||
// width: value.width as u32, | ||
// height: value.height as u32, | ||
// } | ||
// } | ||
// } | ||
// | ||
// impl From<Size<u32>> for vk::Viewport { | ||
// fn from(value: Size<u32>) -> Self { | ||
// vk::Viewport { | ||
// x: 0.0, | ||
// y: 0.0, | ||
// width: value.width as f32, | ||
// height: value.height as f32, | ||
// min_depth: 0.0, | ||
// max_depth: 1.0, | ||
// } | ||
// } | ||
// } | ||
|
||
impl From<FilterMode> for wgpu_types::FilterMode { | ||
fn from(value: FilterMode) -> Self { | ||
match value { | ||
FilterMode::Linear => wgpu_types::FilterMode::Linear, | ||
FilterMode::Nearest => wgpu_types::FilterMode::Nearest, | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
impl From<WrapMode> for wgpu_types::AddressMode { | ||
fn from(value: WrapMode) -> Self { | ||
match value { | ||
WrapMode::ClampToBorder => wgpu_types::AddressMode::ClampToBorder, | ||
WrapMode::ClampToEdge => wgpu_types::AddressMode::ClampToEdge, | ||
WrapMode::Repeat => wgpu_types::AddressMode::Repeat, | ||
WrapMode::MirroredRepeat => wgpu_types::AddressMode::MirrorRepeat, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "librashader-runtime-wgpu" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.1.4" } | ||
librashader-presets = { path = "../librashader-presets", version = "0.1.4" } | ||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.4" } | ||
librashader-reflect = { path = "../librashader-reflect", version = "0.1.4", features = [] } | ||
librashader-runtime = { path = "../librashader-runtime" , version = "0.1.4" } | ||
librashader-cache = { path = "../librashader-cache", version = "0.1.4" } | ||
|
||
wgpu = { version = "0.18.0", features = ["spirv"] } | ||
rustc-hash = "1.1.0" | ||
image = "0.24.7" | ||
thiserror = "1.0.50" | ||
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" } | ||
parking_lot = "0.12.1" | ||
rayon = "1.8.0" | ||
bytemuck = { version = "1.14.0", features = ["derive"] } | ||
|
||
|
||
|
||
[dev-dependencies] | ||
config = { version = "0.13.4", features = [] } | ||
env_logger = "0.10.1" | ||
raw-window-handle = "0.5" | ||
winit = "0.28.7" | ||
pollster = "0.3" | ||
log = "0.4.20" | ||
|
||
|
||
[[test]] | ||
name = "triangle" |
Oops, something went wrong.