mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Merge #1078
1078: Switch paytests to WGSL r=grovesNL a=kvark **Connections** Closes #1073 Updates naga to "gfx-4" tag. Updates gfx to https://github.com/gfx-rs/gfx/pull/3518 **Description** This is the first use of WGSL in our codebase! Much nicer to have WGSL for tests than keeping GLSL+SPV pairs. Interestingly, the tests go through Naga without ever touching SPIR-V now, unless running on Vulkan. **Testing** Tests itself - this change applies to testing infra. Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
24
Cargo.lock
generated
24
Cargo.lock
generated
@@ -441,7 +441,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-auxil"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"gfx-hal",
|
||||
@@ -451,7 +451,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-dx11"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@@ -472,7 +472,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-dx12"
|
||||
version = "0.6.2"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
@@ -492,7 +492,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-empty"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"gfx-hal",
|
||||
"log",
|
||||
@@ -502,7 +502,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-gl"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@@ -524,7 +524,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@@ -549,7 +549,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.6.5"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"ash",
|
||||
@@ -568,7 +568,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"naga",
|
||||
@@ -735,9 +735,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "khronos-egl"
|
||||
version = "2.1.1"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ba35280f59eaad0529951ae6ce84357cc954af38c6c74319884f7bdda4df53d"
|
||||
checksum = "e99a569e2016510b4d6001b8049a377dabbcc00f88b20337641de351bc22edca"
|
||||
dependencies = [
|
||||
"khronos",
|
||||
"libc 0.2.80",
|
||||
@@ -927,7 +927,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/gfx-rs/naga?tag=gfx-2#0d81b1f78c763a2f564194ec108bcb8ead10ea2e"
|
||||
source = "git+https://github.com/gfx-rs/naga?tag=gfx-4#4f958bf658de7ee4e285bd40a5975136582e1113"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"fxhash",
|
||||
@@ -1217,7 +1217,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "range-alloc"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=654ad48ee39ce2a341407ae2857ddf4db639ea54#654ad48ee39ce2a341407ae2857ddf4db639ea54"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=f1398d29c7ad726968723a37187bd3932c539783#f1398d29c7ad726968723a37187bd3932c539783"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
|
||||
@@ -34,6 +34,11 @@ package = "wgpu-core"
|
||||
version = "0.6"
|
||||
features = ["replay", "raw-window-handle"]
|
||||
|
||||
#[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies.gfx-backend-metal]
|
||||
#git = "https://github.com/gfx-rs/gfx"
|
||||
#rev = "f1398d29c7ad726968723a37187bd3932c539783"
|
||||
#features = ["auto-capture"]
|
||||
|
||||
[dependencies.wgpu-subscriber]
|
||||
git = "https://github.com/gfx-rs/subscriber.git"
|
||||
rev = "cdc9feb53f152f9c41905ed9efeff2c1ed214361"
|
||||
|
||||
@@ -209,16 +209,13 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
|
||||
A::DestroyBindGroup(id) => {
|
||||
self.bind_group_drop::<B>(id);
|
||||
}
|
||||
A::CreateShaderModule { id, label, data } => {
|
||||
let desc = wgc::pipeline::ShaderModuleDescriptor {
|
||||
label,
|
||||
experimental_translation: false,
|
||||
};
|
||||
A::CreateShaderModule { id, desc, data } => {
|
||||
let source = if data.ends_with(".wgsl") {
|
||||
let code = fs::read_to_string(dir.join(data)).unwrap();
|
||||
wgc::pipeline::ShaderModuleSource::Wgsl(Cow::Owned(code))
|
||||
} else {
|
||||
let byte_vec = fs::read(dir.join(data)).unwrap();
|
||||
let byte_vec = fs::read(dir.join(&data))
|
||||
.unwrap_or_else(|e| panic!("Unable to open '{}': {:?}", data, e));
|
||||
let spv = byte_vec
|
||||
.chunks(4)
|
||||
.map(|c| u32::from_le_bytes([c[0], c[1], c[2], c[3]]))
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
)),
|
||||
CreateShaderModule(
|
||||
id: Id(0, 1, Empty),
|
||||
label: None,
|
||||
data: "empty.comp.spv",
|
||||
desc: (
|
||||
label: None,
|
||||
experimental_translation: true,
|
||||
),
|
||||
data: "empty.wgsl",
|
||||
),
|
||||
CreateComputePipeline(Id(0, 1, Empty), (
|
||||
label: None,
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
void main() {
|
||||
}
|
||||
Binary file not shown.
3
player/tests/data/empty.wgsl
Normal file
3
player/tests/data/empty.wgsl
Normal file
@@ -0,0 +1,3 @@
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main() {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
outColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
Binary file not shown.
@@ -11,11 +11,11 @@
|
||||
actions: [
|
||||
CreateShaderModule(
|
||||
id: Id(0, 1, Empty),
|
||||
data: "quad.vert.spv",
|
||||
),
|
||||
CreateShaderModule(
|
||||
id: Id(1, 1, Empty),
|
||||
data: "quad.frag.spv",
|
||||
desc: (
|
||||
label: None,
|
||||
experimental_translation: true,
|
||||
),
|
||||
data: "quad.wgsl",
|
||||
),
|
||||
CreateTexture(Id(0, 1, Empty), (
|
||||
label: Some("Output Texture"),
|
||||
@@ -58,11 +58,11 @@
|
||||
layout: Some(Id(0, 1, Empty)),
|
||||
vertex_stage: (
|
||||
module: Id(0, 1, Empty),
|
||||
entry_point: "main",
|
||||
entry_point: "vs_main",
|
||||
),
|
||||
fragment_stage: Some((
|
||||
module: Id(1, 1, Empty),
|
||||
entry_point: "main",
|
||||
module: Id(0, 1, Empty),
|
||||
entry_point: "fs_main",
|
||||
)),
|
||||
rasterization_state: None,
|
||||
primitive_topology: TriangleList,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#version 450
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main() {
|
||||
vec2 pos = vec2(gl_VertexIndex == 2 ? 3.0 : -1.0, gl_VertexIndex == 1 ? 3.0 : -1.0);
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
||||
Binary file not shown.
24
player/tests/data/quad.wgsl
Normal file
24
player/tests/data/quad.wgsl
Normal file
@@ -0,0 +1,24 @@
|
||||
[[builtin(vertex_index)]]
|
||||
var<in> in_vertex_index: u32;
|
||||
[[builtin(position)]]
|
||||
var<out> out_pos: vec4<f32>;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vs_main() {
|
||||
# hacky way to draw a large triangle
|
||||
var tmp1: i32 = i32(in_vertex_index) / 2;
|
||||
var tmp2: i32 = i32(in_vertex_index) & 1;
|
||||
var pos: vec2<f32> = vec2<f32>(
|
||||
f32(tmp1) * 4.0 - 1.0,
|
||||
f32(tmp2) * 4.0 - 1.0
|
||||
);
|
||||
out_pos = vec4<f32>(pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[location(0)]]
|
||||
var<out> out_color: vec4<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main() {
|
||||
out_color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
@@ -144,7 +144,9 @@ impl Test<'_> {
|
||||
}
|
||||
};
|
||||
|
||||
assert_eq!(&expected_data[..], contents);
|
||||
if &expected_data[..] != contents {
|
||||
panic!("Test expectation is not met!");
|
||||
}
|
||||
}
|
||||
|
||||
wgc::gfx_select!(device => global.clear_backend(()));
|
||||
|
||||
@@ -35,25 +35,25 @@ thiserror = "1"
|
||||
gpu-alloc = { git = "https://github.com/zakarumych/gpu-alloc", rev = "d07be73f9439a37c89f5b72f2500cbf0eb4ff613" }
|
||||
gpu-descriptor = { git = "https://github.com/zakarumych/gpu-descriptor", rev = "df74fd8c7bea03149058a41aab0e4fe04077b266"}
|
||||
|
||||
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
|
||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54", features = ["naga"] }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54", optional = true }
|
||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783", features = ["naga"] }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783", optional = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "654ad48ee39ce2a341407ae2857ddf4db639ea54" }
|
||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "f1398d29c7ad726968723a37187bd3932c539783" }
|
||||
|
||||
[dependencies.naga]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
tag = "gfx-2"
|
||||
tag = "gfx-4"
|
||||
features = ["spv-in", "spv-out", "wgsl-in"]
|
||||
|
||||
[dependencies.wgt]
|
||||
|
||||
@@ -3314,11 +3314,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref trace) = device.trace {
|
||||
let mut trace = trace.lock();
|
||||
let label = desc.label.clone();
|
||||
trace.add(trace::Action::CreateShaderModule {
|
||||
id: id.0,
|
||||
desc: desc.clone(),
|
||||
data,
|
||||
label,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ pub enum Action<'a> {
|
||||
DestroyBindGroup(id::BindGroupId),
|
||||
CreateShaderModule {
|
||||
id: id::ShaderModuleId,
|
||||
label: crate::Label<'a>,
|
||||
desc: crate::pipeline::ShaderModuleDescriptor<'a>,
|
||||
data: FileName,
|
||||
},
|
||||
DestroyShaderModule(id::ShaderModuleId),
|
||||
|
||||
@@ -20,12 +20,15 @@ pub enum ShaderModuleSource<'a> {
|
||||
Naga(naga::Module),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
|
||||
pub struct ShaderModuleDescriptor<'a> {
|
||||
pub label: Label<'a>,
|
||||
/// If enabled, `wgpu` will attempt to operate on `Naga` representation
|
||||
/// of the shader module for both validation and translation into the
|
||||
/// backend shader languages, where `gfx-hal` supports this.
|
||||
#[cfg_attr(any(feature = "replay", feature = "trace"), serde(default))]
|
||||
pub experimental_translation: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ pub enum StageError {
|
||||
#[error("shader module is invalid")]
|
||||
InvalidModule,
|
||||
#[error("unable to find an entry point at {0:?} stage")]
|
||||
MissingEntryPoint(wgt::ShaderStage),
|
||||
MissingEntryPoint(String),
|
||||
#[error("error matching global binding at index {binding} in group {group} against the pipeline layout: {error}")]
|
||||
Binding {
|
||||
group: u32,
|
||||
@@ -792,10 +792,11 @@ impl Interface {
|
||||
wgt::ShaderStage::COMPUTE => naga::ShaderStage::Compute,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let pair = (shader_stage, entry_point_name.to_string());
|
||||
let entry_point = self
|
||||
.entry_points
|
||||
.get(&(shader_stage, entry_point_name.to_string()))
|
||||
.ok_or(StageError::MissingEntryPoint(stage_bit))?;
|
||||
.get(&pair)
|
||||
.ok_or(StageError::MissingEntryPoint(pair.1))?;
|
||||
|
||||
for &(handle, usage) in entry_point.resources.iter() {
|
||||
let res = &self.resources[handle];
|
||||
|
||||
Reference in New Issue
Block a user