mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Upgrade wgpu to git
This commit is contained in:
parent
dd2b88e2db
commit
07bddd2a8c
@ -12,7 +12,7 @@ readme = "../README.md"
|
|||||||
sqlite = ["rusqlite"]
|
sqlite = ["rusqlite"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
naga = { version = "0.8", features = ["wgsl-in"] }
|
naga = { git = "https://github.com/gfx-rs/naga", branch = "master", features = ["wgsl-in"] }
|
||||||
walkdir = "2.3"
|
walkdir = "2.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rusqlite = {version= "0.26", optional=true}
|
rusqlite = {version= "0.26", optional=true}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use std::process::exit;
|
|||||||
|
|
||||||
use naga::front::wgsl;
|
use naga::front::wgsl;
|
||||||
use naga::valid::{Capabilities, ValidationFlags, Validator};
|
use naga::valid::{Capabilities, ValidationFlags, Validator};
|
||||||
use naga::{front::wgsl::ParseError, valid::ValidationError};
|
use naga::{front::wgsl::ParseError, valid::ValidationError, SourceLocation};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -12,8 +12,7 @@ pub enum WgslError {
|
|||||||
ValidationErr(ValidationError),
|
ValidationErr(ValidationError),
|
||||||
ParserErr {
|
ParserErr {
|
||||||
error: String,
|
error: String,
|
||||||
line: usize,
|
location: Option<SourceLocation>,
|
||||||
pos: usize,
|
|
||||||
},
|
},
|
||||||
IoErr(std::io::Error),
|
IoErr(std::io::Error),
|
||||||
}
|
}
|
||||||
@ -26,9 +25,9 @@ impl From<std::io::Error> for WgslError {
|
|||||||
|
|
||||||
impl WgslError {
|
impl WgslError {
|
||||||
pub fn from_parse_err(err: ParseError, src: &str) -> Self {
|
pub fn from_parse_err(err: ParseError, src: &str) -> Self {
|
||||||
let (line, pos) = err.location(src);
|
let location = err.location(src);
|
||||||
let error = err.emit_to_string(src);
|
let error = err.emit_to_string(src);
|
||||||
Self::ParserErr { error, line, pos }
|
Self::ParserErr { error, location }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +71,17 @@ pub fn validate_project_wgsl() {
|
|||||||
path.to_str().unwrap(),
|
path.to_str().unwrap(),
|
||||||
match err {
|
match err {
|
||||||
WgslError::ValidationErr(error) => format!(": {:?}", error),
|
WgslError::ValidationErr(error) => format!(": {:?}", error),
|
||||||
WgslError::ParserErr { error, line, pos } =>
|
WgslError::ParserErr { error, location } =>
|
||||||
format!(":{}:{} {}", line, pos, error),
|
if let Some(SourceLocation {
|
||||||
|
line_number,
|
||||||
|
line_position,
|
||||||
|
..
|
||||||
|
}) = location
|
||||||
|
{
|
||||||
|
format!(":{}:{} {}", line_number, line_position, error)
|
||||||
|
} else {
|
||||||
|
format!("{}", error)
|
||||||
|
},
|
||||||
WgslError::IoErr(error) => format!(": {:?}", error),
|
WgslError::IoErr(error) => format!(": {:?}", error),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -50,7 +50,9 @@ geozero = { version = "0.9.4", default-features = false, features = ["with-mvt",
|
|||||||
tile-grid = "0.3"
|
tile-grid = "0.3"
|
||||||
|
|
||||||
# Rendering
|
# Rendering
|
||||||
wgpu = { version = "0.12" }
|
wgpu = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
|
||||||
|
wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
|
||||||
|
wgpu-hal = { git = "https://github.com/gfx-rs/wgpu.git", branch = "master" }
|
||||||
lyon = { version = "0.17", features = [] }
|
lyon = { version = "0.17", features = [] }
|
||||||
raw-window-handle = "0.4"
|
raw-window-handle = "0.4"
|
||||||
|
|
||||||
|
|||||||
@ -71,42 +71,40 @@ impl BufferedTextureHead {
|
|||||||
) {
|
) {
|
||||||
// Note that we're not calling `.await` here.
|
// Note that we're not calling `.await` here.
|
||||||
let buffer_slice = self.output_buffer.slice(..);
|
let buffer_slice = self.output_buffer.slice(..);
|
||||||
let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read);
|
let buffer_future = buffer_slice.map_async(wgpu::MapMode::Read, |_| ());
|
||||||
|
|
||||||
// Poll the device in a blocking manner so that our future resolves.
|
// Poll the device in a blocking manner so that our future resolves.
|
||||||
// In an actual application, `device.poll(...)` should
|
// In an actual application, `device.poll(...)` should
|
||||||
// be called in an event loop or on another thread.
|
// be called in an event loop or on another thread.
|
||||||
device.poll(wgpu::Maintain::Wait);
|
device.poll(wgpu::Maintain::Wait);
|
||||||
if let Ok(()) = buffer_future.await {
|
let padded_buffer = buffer_slice.get_mapped_range();
|
||||||
let padded_buffer = buffer_slice.get_mapped_range();
|
|
||||||
|
|
||||||
let mut png_encoder = png::Encoder::new(
|
let mut png_encoder = png::Encoder::new(
|
||||||
File::create(png_output_path).unwrap(),
|
File::create(png_output_path).unwrap(),
|
||||||
self.buffer_dimensions.width as u32,
|
self.buffer_dimensions.width as u32,
|
||||||
self.buffer_dimensions.height as u32,
|
self.buffer_dimensions.height as u32,
|
||||||
);
|
);
|
||||||
png_encoder.set_depth(png::BitDepth::Eight);
|
png_encoder.set_depth(png::BitDepth::Eight);
|
||||||
png_encoder.set_color(png::ColorType::Rgba);
|
png_encoder.set_color(png::ColorType::Rgba);
|
||||||
let mut png_writer = png_encoder
|
let mut png_writer = png_encoder
|
||||||
.write_header()
|
.write_header()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row)
|
.into_stream_writer_with_size(self.buffer_dimensions.unpadded_bytes_per_row)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// from the padded_buffer we write just the unpadded bytes into the image
|
||||||
|
for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) {
|
||||||
|
png_writer
|
||||||
|
.write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// from the padded_buffer we write just the unpadded bytes into the image
|
|
||||||
for chunk in padded_buffer.chunks(self.buffer_dimensions.padded_bytes_per_row) {
|
|
||||||
png_writer
|
|
||||||
.write_all(&chunk[..self.buffer_dimensions.unpadded_bytes_per_row])
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
png_writer.finish().unwrap();
|
|
||||||
|
|
||||||
// With the current interface, we have to make sure all mapped views are
|
|
||||||
// dropped before we unmap the buffer.
|
|
||||||
drop(padded_buffer);
|
|
||||||
|
|
||||||
self.output_buffer.unmap();
|
|
||||||
}
|
}
|
||||||
|
png_writer.finish().unwrap();
|
||||||
|
|
||||||
|
// With the current interface, we have to make sure all mapped views are
|
||||||
|
// dropped before we unmap the buffer.
|
||||||
|
drop(padded_buffer);
|
||||||
|
|
||||||
|
self.output_buffer.unmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
struct Output {
|
struct Output {
|
||||||
[[location(0)]] out_color: vec4<f32>;
|
@location(0) out_color: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[stage(fragment)]]
|
@fragment
|
||||||
fn main([[location(0)]] v_color: vec4<f32>) -> Output {
|
fn main(@location(0) v_color: vec4<f32>) -> Output {
|
||||||
return Output(v_color);
|
return Output(v_color);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,31 @@
|
|||||||
struct ShaderCamera {
|
struct ShaderCamera {
|
||||||
view_proj: mat4x4<f32>;
|
view_proj: mat4x4<f32>,
|
||||||
view_position: vec4<f32>;
|
view_position: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderGlobals {
|
struct ShaderGlobals {
|
||||||
camera: ShaderCamera;
|
camera: ShaderCamera,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[group(0), binding(0)]] var<uniform> globals: ShaderGlobals;
|
@group(0) @binding(0) var<uniform> globals: ShaderGlobals;
|
||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
[[location(0)]] v_color: vec4<f32>;
|
@location(0) v_color: vec4<f32>,
|
||||||
[[builtin(position)]] position: vec4<f32>;
|
@builtin(position) position: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[stage(vertex)]]
|
@vertex
|
||||||
fn main(
|
fn main(
|
||||||
[[location(0)]] position: vec2<f32>,
|
@location(0) position: vec2<f32>,
|
||||||
[[location(1)]] normal: vec2<f32>,
|
@location(1) normal: vec2<f32>,
|
||||||
[[location(4)]] translate1: vec4<f32>,
|
@location(4) translate1: vec4<f32>,
|
||||||
[[location(5)]] translate2: vec4<f32>,
|
@location(5) translate2: vec4<f32>,
|
||||||
[[location(6)]] translate3: vec4<f32>,
|
@location(6) translate3: vec4<f32>,
|
||||||
[[location(7)]] translate4: vec4<f32>,
|
@location(7) translate4: vec4<f32>,
|
||||||
[[location(8)]] color: vec4<f32>,
|
@location(8) color: vec4<f32>,
|
||||||
[[location(9)]] zoom_factor: f32,
|
@location(9) zoom_factor: f32,
|
||||||
[[location(10)]] z_index: f32,
|
@location(10) z_index: f32,
|
||||||
[[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
|
@builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
let z = 0.0;
|
let z = 0.0;
|
||||||
let width = 3.0 * zoom_factor;
|
let width = 3.0 * zoom_factor;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
struct Output {
|
struct Output {
|
||||||
[[location(0)]] out_color: vec4<f32>;
|
@location(0) out_color: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[stage(fragment)]]
|
@fragment
|
||||||
fn main([[location(0)]] v_color: vec4<f32>) -> Output {
|
fn main(@location(0) v_color: vec4<f32>) -> Output {
|
||||||
return Output(v_color);
|
return Output(v_color);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
struct ShaderCamera {
|
struct ShaderCamera {
|
||||||
view_proj: mat4x4<f32>;
|
view_proj: mat4x4<f32>,
|
||||||
view_position: vec4<f32>;
|
view_position: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderGlobal {
|
struct ShaderGlobal {
|
||||||
camera: ShaderCamera;
|
camera: ShaderCamera,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[group(0), binding(0)]] var<uniform> globals: ShaderGlobal;
|
@group(0) @binding(0) var<uniform> globals: ShaderGlobal;
|
||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
[[location(0)]] v_color: vec4<f32>;
|
@location(0) v_color: vec4<f32>,
|
||||||
[[builtin(position)]] position: vec4<f32>;
|
@builtin(position) position: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
let EXTENT = 4096.0;
|
let EXTENT = 4096.0;
|
||||||
|
|
||||||
[[stage(vertex)]]
|
@vertex
|
||||||
fn main(
|
fn main(
|
||||||
[[location(4)]] translate1: vec4<f32>,
|
@location(4) translate1: vec4<f32>,
|
||||||
[[location(5)]] translate2: vec4<f32>,
|
@location(5) translate2: vec4<f32>,
|
||||||
[[location(6)]] translate3: vec4<f32>,
|
@location(6) translate3: vec4<f32>,
|
||||||
[[location(7)]] translate4: vec4<f32>,
|
@location(7) translate4: vec4<f32>,
|
||||||
[[builtin(vertex_index)]] vertex_idx: u32,
|
@builtin(vertex_index) vertex_idx: u32,
|
||||||
[[builtin(instance_index)]] instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
|
@builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object"
|
||||||
) -> VertexOutput {
|
) -> VertexOutput {
|
||||||
let z = 0.0;
|
let z = 0.0;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user