Skip to content

Commit

Permalink
Update naga to 0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Jan 17, 2024
1 parent 9958fea commit 4e97679
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ prune = []
allow_deprecated = []

[dependencies]
naga = { version = "0.14.1", features = ["wgsl-in", "wgsl-out", "clone", "span"] }
naga = { version = "0.19.0", features = ["wgsl-in", "wgsl-out", "clone"] }
tracing = "0.1"
regex = "1.8"
regex-syntax = "0.7"
Expand All @@ -31,6 +31,6 @@ once_cell = "1.17.0"
indexmap = "2"

[dev-dependencies]
wgpu = { version = "0.18", features = ["naga"] }
wgpu = { version = "0.19.0", features = ["naga-ir"] }
futures-lite = "1"
tracing-subscriber = { version = "0.3", features = ["std", "fmt"] }
2 changes: 2 additions & 0 deletions examples/pbr_compose_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fn test_wgsl_string_compile(n: usize) {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
let adapter = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter()
.next()
.unwrap();
let device = futures_lite::future::block_on(
Expand All @@ -165,6 +166,7 @@ fn test_composer_compile(n: usize, composer: &mut Composer) {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
let adapter = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter()
.next()
.unwrap();
let device = futures_lite::future::block_on(
Expand Down
3 changes: 1 addition & 2 deletions src/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ impl Composer {
name: None,
inner: naga::TypeInner::Vector {
size: naga::VectorSize::Quad,
kind: naga::ScalarKind::Float,
width: 4,
scalar: naga::Scalar::F32,
},
},
naga::Span::UNDEFINED,
Expand Down
27 changes: 17 additions & 10 deletions src/compose/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,11 +1423,12 @@ mod test {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
let adapter = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter()
.next()
.unwrap();
let (device, queue) = futures_lite::future::block_on(adapter.request_device(
&wgpu::DeviceDescriptor {
features: Features::MAPPABLE_PRIMARY_BUFFERS,
required_features: Features::MAPPABLE_PRIMARY_BUFFERS,
..Default::default()
},
None,
Expand All @@ -1439,13 +1440,6 @@ mod test {
label: None,
});

let pipeline = device.create_compute_pipeline(&ComputePipelineDescriptor {
label: None,
layout: None,
module: &shader_module,
entry_point: "run_test",
});

let output_buffer = device.create_buffer(&BufferDescriptor {
label: None,
size: 4,
Expand All @@ -1467,6 +1461,19 @@ mod test {
}],
});

let pipeline = device.create_compute_pipeline(&ComputePipelineDescriptor {
label: None,
layout: Some(
&device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[&layout],
push_constant_ranges: &[],
}),
),
module: &shader_module,
entry_point: "run_test",
});

let bindgroup = device.create_bind_group(&BindGroupDescriptor {
label: None,
layout: &layout,
Expand All @@ -1493,15 +1500,15 @@ mod test {

queue.submit([buffer]);

while !device.poll(wgpu::MaintainBase::Wait) {
while !device.poll(wgpu::MaintainBase::Wait).is_queue_empty() {
println!("waiting...");
}

output_buffer
.slice(..)
.map_async(wgpu::MapMode::Read, |_| ());

while !device.poll(wgpu::MaintainBase::Wait) {
while !device.poll(wgpu::MaintainBase::Wait).is_queue_empty() {
println!("waiting...");
}

Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/additional_import.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
fn funcX_naga_oil_mod_XN53GK4TSNFSGCYTMMUX() -> f32 {
return 1.0;
return 1f;
}

fn funcX_naga_oil_vrt_XN53GK4TSNFSGCYTMMUXX_naga_oil_mod_XOBWHKZ3JNYX() -> f32 {
let _e0: f32 = funcX_naga_oil_mod_XN53GK4TSNFSGCYTMMUX();
return (_e0 + 1.0);
return (_e0 + 1f);
}

fn entry_point() -> f32 {
Expand Down
18 changes: 9 additions & 9 deletions src/compose/tests/expected/bad_identifiers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@



d.fine = 3.0;
e.fine_member = 4.0;
d.fine = 3f;
e.fine_member = 4f;
fine: f32,
fine_member: f32,
let _e1: f32 = fineX_naga_oil_mod_XMZXHGX(1.0);
let _e1: f32 = fineX_naga_oil_mod_XMZXHGX(1f);
let _e20: f32 = d.fine;
let _e23: f32 = e.fine_member;
let _e3: f32 = bad_X_naga_oil_mod_XMZXHGX(2.0);
let _e3: f32 = bad_X_naga_oil_mod_XMZXHGX(2f);
let _e6: f32 = fineX_naga_oil_mod_XM5WG6YTBNRZQX;
let _e8: f32 = bad_X_naga_oil_mod_XM5WG6YTBNRZQX;
let b: f32 = (_e1 + _e3);
let c: f32 = (_e6 + _e8);
return ((((2.0 + b) + c) + _e20) + _e23);
return ((((2f + b) + c) + _e20) + _e23);
return in;
return in_1;
var d: IsFineX_naga_oil_mod_XON2HE5LDORZQX;
var e: Isbad_X_naga_oil_mod_XON2HE5LDORZQX;
const bad_X_naga_oil_mod_XMNXW443UOMX: f32 = 1.0;
const fineX_naga_oil_mod_XMNXW443UOMX: f32 = 1.0;
const bad_X_naga_oil_mod_XMNXW443UOMX: f32 = 1f;
const fineX_naga_oil_mod_XMNXW443UOMX: f32 = 1f;
fn bad_X_naga_oil_mod_XMZXHGX(in_1: f32) -> f32 {
fn fineX_naga_oil_mod_XMZXHGX(in: f32) -> f32 {
fn main() -> f32 {
struct IsFineX_naga_oil_mod_XON2HE5LDORZQX {
struct Isbad_X_naga_oil_mod_XON2HE5LDORZQX {
var<private> bad_X_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1.0;
var<private> fineX_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1.0;
var<private> bad_X_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1f;
var<private> fineX_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1f;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/big_shaderdefs.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn fX_naga_oil_mod_XNVXWIX() -> f32 {
var x: f32 = 0.0;
var x: f32 = 0f;

x = 1.0;
x = 1f;
let _e3: f32 = x;
return _e3;
}
Expand Down
6 changes: 3 additions & 3 deletions src/compose/tests/expected/dup_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
let _e0: f32 = fX_naga_oil_mod_XMEX();
let _e1: f32 = fX_naga_oil_mod_XMIX();
return (_e0 * _e1);
return 3.1;
return 6.2;
const PIX_naga_oil_mod_XMNXW443UOMX: f32 = 3.1;
return 3.1f;
return 6.2f;
const PIX_naga_oil_mod_XMNXW443UOMX: f32 = 3.1f;
fn fX_naga_oil_mod_XMEX() -> f32 {
fn fX_naga_oil_mod_XMIX() -> f32 {
fn main() -> f32 {
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/dup_struct_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
return (_e0.value / _e1.value);
return _e3;
return _e3;
s_a.value = 1.0;
s_b.value = 2.0;
s_a.value = 1f;
s_b.value = 2f;
value: f32,
var s_a: MyStructX_naga_oil_mod_XON2HE5LDOQX;
var s_b: MyStructX_naga_oil_mod_XON2HE5LDOQX;
Expand Down
2 changes: 1 addition & 1 deletion src/compose/tests/expected/glsl_call_wgsl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct VertexOutput {
var<private> gl_Position: vec4<f32>;

fn wgsl_funcX_naga_oil_mod_XO5TXG3C7NVXWI5LMMUX() -> f32 {
return 53.0;
return 53f;
}

fn main_1() {
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/glsl_const_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ struct FragmentOutput {
@location(0) out_color: vec4<f32>,
}

const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5;
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;

var<private> out_color: vec4<f32>;

fn main_1() {
out_color = vec4<f32>(1.0, 0.5, 0.0, 1.0);
out_color = vec4<f32>(1f, 0.5f, 0f, 1f);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/glsl_wgsl_const_import.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5;
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;

fn main() -> vec4<f32> {
return vec4<f32>(1.0, 0.5, 0.0, 1.0);
return vec4<f32>(1f, 0.5f, 0f, 1f);
}

4 changes: 2 additions & 2 deletions src/compose/tests/expected/item_sub_point.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ struct FragX_naga_oil_mod_XNVXWIX {
}

fn fragmentX_naga_oil_mod_XNVXWIX(f_1: FragX_naga_oil_mod_XNVXWIX) -> f32 {
return (f_1.fragment * 2.0);
return (f_1.fragment * 2f);
}

@fragment
fn main() -> @location(0) f32 {
var f: FragX_naga_oil_mod_XNVXWIX;

f.fragment = 3.0;
f.fragment = 3f;
let _e3: FragX_naga_oil_mod_XNVXWIX = f;
let _e4: f32 = fragmentX_naga_oil_mod_XNVXWIX(_e3);
return _e4;
Expand Down
2 changes: 1 addition & 1 deletion src/compose/tests/expected/simple_compose.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn helloX_naga_oil_mod_XNFXGGX() -> f32 {
return 1.0;
return 1f;
}

fn main() -> f32 {
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/test_quoted_import_dup_name.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fn fooX_naga_oil_mod_XEJYXK33UMVSF63LPMR2WYZJCX() -> f32 {
return 3.0;
return 3f;
}

fn myfunc(foo: u32) -> f32 {
return (f32(foo) * 2.0);
return (f32(foo) * 2f);
}

fn main() -> f32 {
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/use_shared_global.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var<private> aX_naga_oil_mod_XNVXWIX: f32 = 0.0;
var<private> aX_naga_oil_mod_XNVXWIX: f32 = 0f;

fn add() {
let _e2: f32 = aX_naga_oil_mod_XNVXWIX;
aX_naga_oil_mod_XNVXWIX = (_e2 + 1.0);
aX_naga_oil_mod_XNVXWIX = (_e2 + 1f);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compose/tests/expected/wgsl_call_entrypoint.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn fragmentX_naga_oil_mod_XNFXGG3DVMRSQX(frag_coord_1: vec4<f32>) -> vec4<f32> {
return vec4<f32>((1.5 * frag_coord_1));
return vec4<f32>((1.5f * frag_coord_1));
}

@fragment
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/wgsl_glsl_const_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ struct FragmentOutput {
@location(0) out_color: vec4<f32>,
}

const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5;
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;

var<private> out_color: vec4<f32>;

fn main_1() {
out_color = vec4<f32>(1.0, 0.5, 0.0, 1.0);
out_color = vec4<f32>(1f, 0.5f, 0f, 1f);
return;
}

Expand Down

0 comments on commit 4e97679

Please sign in to comment.