Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naga 0.14 #63

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "naga_oil"
version = "0.10.1"
version = "0.11.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "a crate for combining and manipulating shaders using naga IR"
Expand All @@ -17,7 +17,7 @@ prune = []
allow_deprecated = []

[dependencies]
naga = { version = "0.13", features = ["wgsl-in", "wgsl-out", "clone", "span"] }
naga = { version = "0.14.1", features = ["wgsl-in", "wgsl-out", "clone", "span"] }
tracing = "0.1"
regex = "1.8"
regex-syntax = "0.7"
Expand All @@ -28,9 +28,9 @@ bit-set = "0.5"
rustc-hash = "1.1.0"
unicode-ident = "1"
once_cell = "1.17.0"
indexmap = "1.9.3"
indexmap = "2"

[dev-dependencies]
wgpu = { version = "0.17", features = ["naga"] }
wgpu = { version = "0.18", features = ["naga"] }
futures-lite = "1"
tracing-subscriber = { version = "0.3", features = ["std", "fmt"] }
5 changes: 4 additions & 1 deletion src/compose/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,10 @@ mod test {

let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor { label: None });

let mut pass = encoder.begin_compute_pass(&ComputePassDescriptor { label: None });
let mut pass = encoder.begin_compute_pass(&ComputePassDescriptor {
label: None,
timestamp_writes: None,
});

pass.set_pipeline(&pipeline);
pass.set_bind_group(0, &bindgroup, &[]);
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/compute_test.wgsl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import test_module

@group(0) @binding(0)
var<storage, write> buffer: f32;
var<storage, read_write> buffer: f32;

@compute @workgroup_size(1, 1, 1)
fn run_test() {
let res = test_module::entry_point();
buffer = res;
}
}
4 changes: 2 additions & 2 deletions src/compose/tests/expected/atomics.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct gen___atomic_compare_exchange_resultUint4_ {
struct _atomic_compare_exchange_resultUint4_ {
old_value: u32,
exchanged: bool,
}
Expand Down Expand Up @@ -27,7 +27,7 @@ fn entry_pointX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX() -> f32 {
let _e27: u32 = atomicExchange((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), _e25);
let _e28: u32 = y;
y = (_e28 + _e27);
let _e33: gen___atomic_compare_exchange_resultUint4_ = atomicCompareExchangeWeak((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 12u, 0u);
let _e33: _atomic_compare_exchange_resultUint4_ = atomicCompareExchangeWeak((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 12u, 0u);
if _e33.exchanged {
let _e36: u32 = y;
y = (_e36 + _e33.old_value);
Expand Down
19 changes: 9 additions & 10 deletions src/compose/tests/expected/bad_identifiers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
e.fine_member = 4.0;
fine: f32,
fine_member: f32,
let _e11: f32 = bad_X_naga_oil_mod_XM5WG6YTBNRZQX;
let _e22: f32 = d.fine;
let _e25: f32 = e.fine_member;
let _e4: f32 = fineX_naga_oil_mod_XMZXHGX(1.0);
let _e6: f32 = bad_X_naga_oil_mod_XMZXHGX(2.0);
let _e9: f32 = fineX_naga_oil_mod_XM5WG6YTBNRZQX;
let a: f32 = (fineX_naga_oil_mod_XMNXW443UOMX + bad_X_naga_oil_mod_XMNXW443UOMX);
let b: f32 = (_e4 + _e6);
let c: f32 = (_e9 + _e11);
return ((((a + b) + c) + _e22) + _e25);
let _e1: f32 = fineX_naga_oil_mod_XMZXHGX(1.0);
let _e20: f32 = d.fine;
let _e23: f32 = e.fine_member;
let _e3: f32 = bad_X_naga_oil_mod_XMZXHGX(2.0);
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 in;
return in_1;
var d: IsFineX_naga_oil_mod_XON2HE5LDORZQX;
Expand Down
3 changes: 1 addition & 2 deletions src/compose/tests/expected/big_shaderdefs.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fn fX_naga_oil_mod_XNVXWIX() -> f32 {
var x: f32;
var x: f32 = 0.0;

x = 0.0;
x = 1.0;
let _e3: f32 = x;
return _e3;
Expand Down
4 changes: 2 additions & 2 deletions src/compose/tests/expected/dup_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

let _e0: f32 = fX_naga_oil_mod_XMEX();
let _e1: f32 = fX_naga_oil_mod_XMIX();
return (PIX_naga_oil_mod_XMNXW443UOMX * 1.0);
return (PIX_naga_oil_mod_XMNXW443UOMX * 2.0);
return (_e0 * _e1);
return 3.1;
return 6.2;
const PIX_naga_oil_mod_XMNXW443UOMX: f32 = 3.1;
fn fX_naga_oil_mod_XMEX() -> f32 {
fn fX_naga_oil_mod_XMIX() -> f32 {
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 @@ -10,7 +10,7 @@ fn wgsl_funcX_naga_oil_mod_XO5TXG3C7NVXWI5LMMUX() -> f32 {

fn main_1() {
let _e0: f32 = wgsl_funcX_naga_oil_mod_XO5TXG3C7NVXWI5LMMUX();
gl_Position = vec4<f32>(_e0);
gl_Position = vec4(_e0);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compose/tests/expected/glsl_const_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5;
var<private> out_color: vec4<f32>;

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

Expand Down
2 changes: 1 addition & 1 deletion 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;

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

2 changes: 1 addition & 1 deletion src/compose/tests/expected/wgsl_glsl_const_import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5;
var<private> out_color: vec4<f32>;

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

Expand Down
17 changes: 13 additions & 4 deletions src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,21 +634,30 @@ impl<'a> DerivedModule<'a> {
binding: r.binding.clone(),
});

let expressions = Rc::new(RefCell::new(Arena::new()));
let expr_map = Rc::new(RefCell::new(HashMap::new()));

let mut local_variables = Arena::new();
for (h_l, l) in func.local_variables.iter() {
let new_local = LocalVariable {
name: l.name.clone(),
ty: self.import_type(&l.ty),
init: l.init.map(|c| self.import_const_expression(c)),
init: l.init.map(|c| {
self.import_expression(
c,
&func.expressions,
expr_map.clone(),
expressions.clone(),
false,
true,
)
}),
};
let span = func.local_variables.get_span(h_l);
let new_h = local_variables.append(new_local, self.map_span(span));
assert_eq!(h_l, new_h);
}

let expressions = Rc::new(RefCell::new(Arena::new()));
let expr_map = Rc::new(RefCell::new(HashMap::new()));

let body = self.import_block(
&func.body,
&func.expressions,
Expand Down
Loading