Skip to content

Commit

Permalink
Merge #89
Browse files Browse the repository at this point in the history
89: Update gfx and naga to gfx-22 r=kvark a=Sineaggi

In order to support cases where enums in webgpu-headers and wgpu might diverge, I've added a new match for more direct mapping between two variants.

Co-authored-by: Clayton Walker <cwalker@sofi.org>
  • Loading branch information
bors[bot] and Clayton Walker authored Apr 20, 2021
2 parents 6072feb + 7185a94 commit bb333ca
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 35 deletions.
33 changes: 17 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"]
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
rev = "41f106d7fc8e2ca49b21aed0919fa6cc67317f7f"
rev = "523ef2dfec0bf18c696bc53fea252fd6fa7350c6"
# path = "../wgpu/wgpu-core"
version = "0.7"
features = ["raw-window-handle", "trace", "cross"]

[dependencies.wgt]
package = "wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
rev = "41f106d7fc8e2ca49b21aed0919fa6cc67317f7f"
rev = "523ef2dfec0bf18c696bc53fea252fd6fa7350c6"
# path = "../wgpu/wgpu-types"
version = "0.7"

Expand Down
2 changes: 1 addition & 1 deletion examples/compute/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main()
},
.maxBindGroups = 1,
.label = "Device",
.tracePath = "build/",
.tracePath = NULL,
},
},
request_device_callback, (void*)&device);
Expand Down
4 changes: 2 additions & 2 deletions examples/triangle/shader.wgsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[stage(vertex)]]
fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> {
const x = f32(i32(in_vertex_index) - 1);
const y = f32(i32(in_vertex_index & 1u) * 2 - 1);
let x = f32(i32(in_vertex_index) - 1);
let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
return vec4<f32>(x, y, 0.0, 1.0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetBlendColor(
color: &native::WGPUColor,
) {
let pass = pass.as_mut().expect("Render pass invalid");
render_ffi::wgpu_render_pass_set_blend_color(pass, &map_color(color));
render_ffi::wgpu_render_pass_set_blend_constant(pass, &map_color(color));
}

#[no_mangle]
Expand Down
26 changes: 14 additions & 12 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline(
native::WGPUCullMode_Back => Some(wgt::Face::Back),
_ => None,
},
clamp_depth: false, // todo: fill this via extras
polygon_mode: wgt::PolygonMode::Fill,
conservative: false,
},
Expand Down Expand Up @@ -643,18 +644,19 @@ map_enum!(
WGPUBlendFactor,
wgt::BlendFactor,
"Unknown blend factor",
Zero,
One,
SrcColor,
OneMinusSrcColor,
SrcAlpha,
OneMinusSrcAlpha,
DstColor,
OneMinusDstColor,
DstAlpha,
OneMinusDstAlpha,
SrcAlphaSaturated,
BlendColor
Zero:Zero,
One:One,
SrcColor:Src,
OneMinusSrcColor:OneMinusSrc,
SrcAlpha:SrcAlpha,
OneMinusSrcAlpha:OneMinusSrcAlpha,
DstColor:Dst,
OneMinusDstColor:OneMinusDst,
DstAlpha:DstAlpha,
OneMinusDstAlpha:OneMinusDstAlpha,
SrcAlphaSaturated:SrcAlphaSaturated,
BlendColor:Constant,
OneMinusBlendColor:OneMinusConstant
);
map_enum!(
map_blend_operation,
Expand Down
17 changes: 16 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,22 @@ macro_rules! map_enum {

map_fn(value).expect($err_msg)
}
}
};
($name:ident, $c_name:ident, $rs_type:ty, $($native_variant:ident:$variant2:ident),+) => {
pub fn $name(value: crate::EnumConstant) -> Result<$rs_type, crate::EnumConstant> {
match value {
$(paste::paste!(native::[<$c_name _ $native_variant>]) => Ok(<$rs_type>::$variant2)),+,
x => Err(x),
}
}
};
($name:ident, $c_name:ident, $rs_type:ty, $err_msg:literal, $($native_variant:ident:$variant2:ident),+) => {
pub fn $name(value: crate::EnumConstant) -> $rs_type {
map_enum!(map_fn, $c_name, $rs_type, $($native_variant:$variant2),+);

map_fn(value).expect($err_msg)
}
};
}

// see https://github.com/rust-windowing/raw-window-handle/issues/49
Expand Down

0 comments on commit bb333ca

Please sign in to comment.