mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Implement experimental WebGPU support (#1238)
* Web gpu execution MVP Ready infrastructure for wgpu experimentation Start implementing simple gpu test case Fix Extract Node not working with nested networks Convert inputs for extracted node to network inputs Fix missing cors headers Feature gate gcore to make it once again no-std compatible Add skeleton structure gpu shader Work on gpu node graph output saving Fix Get and Set nodes Fix storage nodes Fix shader construction errors -> spirv errors Add unsafe version Add once cell node Web gpu execution MVP
This commit is contained in:
committed by
Keavon Chambers
parent
4bd9fbd073
commit
0586d52f3a
@@ -192,6 +192,14 @@ pub trait Sample {
|
||||
fn sample(&self, pos: DVec2, area: DVec2) -> Option<Self::Pixel>;
|
||||
}
|
||||
|
||||
impl<'i, T: Sample> Sample for &'i T {
|
||||
type Pixel = T::Pixel;
|
||||
|
||||
fn sample(&self, pos: DVec2, area: DVec2) -> Option<Self::Pixel> {
|
||||
(**self).sample(pos, area)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: We might rename this to Bitmap at some point
|
||||
pub trait Raster {
|
||||
type Pixel: Pixel;
|
||||
@@ -200,6 +208,38 @@ pub trait Raster {
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<Self::Pixel>;
|
||||
}
|
||||
|
||||
impl<'i, T: Raster> Raster for &'i T {
|
||||
type Pixel = T::Pixel;
|
||||
|
||||
fn width(&self) -> u32 {
|
||||
(**self).width()
|
||||
}
|
||||
|
||||
fn height(&self) -> u32 {
|
||||
(**self).height()
|
||||
}
|
||||
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<Self::Pixel> {
|
||||
(**self).get_pixel(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i, T: Raster> Raster for &'i mut T {
|
||||
type Pixel = T::Pixel;
|
||||
|
||||
fn width(&self) -> u32 {
|
||||
(**self).width()
|
||||
}
|
||||
|
||||
fn height(&self) -> u32 {
|
||||
(**self).height()
|
||||
}
|
||||
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<Self::Pixel> {
|
||||
(**self).get_pixel(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RasterMut: Raster {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel>;
|
||||
fn set_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel) {
|
||||
@@ -215,6 +255,12 @@ pub trait RasterMut: Raster {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'i, T: RasterMut + Raster> RasterMut for &'i mut T {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel> {
|
||||
(*self).get_pixel_mut(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MapNode<MapFn> {
|
||||
map_fn: MapFn,
|
||||
|
||||
Reference in New Issue
Block a user