mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 17:44:09 +01:00
fix(naga wgsl-in): Add checks for wgpu_cooperative_matrix extension
This commit is contained in:
1 parent
b1bdabda53
commit
b40c01a018
4 files changed
+106
-20
No files matched your search
@@ -663,14 +663,26 @@ impl Parser {
|
||||
ty_span: Span::UNDEFINED,
|
||||
}))
|
||||
}
|
||||
"coop_mat8x8" => ast::ConstructorType::PartialCooperativeMatrix {
|
||||
columns: crate::CooperativeSize::Eight,
|
||||
rows: crate::CooperativeSize::Eight,
|
||||
},
|
||||
"coop_mat16x16" => ast::ConstructorType::PartialCooperativeMatrix {
|
||||
columns: crate::CooperativeSize::Sixteen,
|
||||
rows: crate::CooperativeSize::Sixteen,
|
||||
},
|
||||
"coop_mat8x8" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuCooperativeMatrix,
|
||||
span,
|
||||
)?;
|
||||
ast::ConstructorType::PartialCooperativeMatrix {
|
||||
columns: crate::CooperativeSize::Eight,
|
||||
rows: crate::CooperativeSize::Eight,
|
||||
}
|
||||
}
|
||||
"coop_mat16x16" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuCooperativeMatrix,
|
||||
span,
|
||||
)?;
|
||||
ast::ConstructorType::PartialCooperativeMatrix {
|
||||
columns: crate::CooperativeSize::Sixteen,
|
||||
rows: crate::CooperativeSize::Sixteen,
|
||||
}
|
||||
}
|
||||
"array" => ast::ConstructorType::PartialArray,
|
||||
"atomic"
|
||||
| "binding_array"
|
||||
@@ -1744,18 +1756,30 @@ impl Parser {
|
||||
ty: ctx.new_scalar(Scalar::F16),
|
||||
ty_span: Span::UNDEFINED,
|
||||
},
|
||||
"coop_mat8x8" => self.cooperative_matrix_with_type(
|
||||
lexer,
|
||||
ctx,
|
||||
crate::CooperativeSize::Eight,
|
||||
crate::CooperativeSize::Eight,
|
||||
)?,
|
||||
"coop_mat16x16" => self.cooperative_matrix_with_type(
|
||||
lexer,
|
||||
ctx,
|
||||
crate::CooperativeSize::Sixteen,
|
||||
crate::CooperativeSize::Sixteen,
|
||||
)?,
|
||||
"coop_mat8x8" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuCooperativeMatrix,
|
||||
span,
|
||||
)?;
|
||||
self.cooperative_matrix_with_type(
|
||||
lexer,
|
||||
ctx,
|
||||
crate::CooperativeSize::Eight,
|
||||
crate::CooperativeSize::Eight,
|
||||
)?
|
||||
}
|
||||
"coop_mat16x16" => {
|
||||
lexer.require_enable_extension(
|
||||
ImplementedEnableExtension::WgpuCooperativeMatrix,
|
||||
span,
|
||||
)?;
|
||||
self.cooperative_matrix_with_type(
|
||||
lexer,
|
||||
ctx,
|
||||
crate::CooperativeSize::Sixteen,
|
||||
crate::CooperativeSize::Sixteen,
|
||||
)?
|
||||
}
|
||||
"atomic" => {
|
||||
let scalar = lexer.next_scalar_generic()?;
|
||||
ast::Type::Atomic(scalar)
|
||||
|
||||
@@ -224,6 +224,7 @@ impl Capabilities {
|
||||
Self::MESH_SHADER => Some(Ext::WgpuMeshShader),
|
||||
Self::RAY_QUERY => Some(Ext::WgpuRayQuery),
|
||||
Self::RAY_HIT_VERTEX_POSITION => Some(Ext::WgpuRayQueryVertexReturn),
|
||||
Self::COOPERATIVE_MATRIX => Some(Ext::WgpuCooperativeMatrix),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
enable wgpu_cooperative_matrix;
|
||||
|
||||
// type declarations with different roles
|
||||
var<private> a: coop_mat8x8<f32, A>;
|
||||
var<private> b: coop_mat8x8<f32, B>;
|
||||
|
||||
@@ -4535,3 +4535,62 @@ fn binding_array_requires_capability() {
|
||||
Capabilities::all()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cooperative_matrix_enable_extension() {
|
||||
for ty in ["coop_mat8x8", "coop_mat16x16"] {
|
||||
let carets = "^".repeat(ty.len());
|
||||
|
||||
check_extension_validation!(
|
||||
// Used in type declaration
|
||||
Capabilities::COOPERATIVE_MATRIX,
|
||||
&format!(
|
||||
r#"fn foo() {{
|
||||
var a: {ty}<f32, A>;
|
||||
}}
|
||||
"#
|
||||
),
|
||||
&format!(
|
||||
r#"error: the `wgpu_cooperative_matrix` enable extension is not enabled
|
||||
┌─ wgsl:2:12
|
||||
│
|
||||
2 │ var a: {ty}<f32, A>;
|
||||
│ {carets} the `wgpu_cooperative_matrix` "Enable Extension" is needed for this functionality, but it is not currently enabled.
|
||||
│
|
||||
= note: You can enable this extension by adding `enable wgpu_cooperative_matrix;` at the top of the shader, before any other items.
|
||||
|
||||
"#,
|
||||
),
|
||||
Err(naga::valid::ValidationError::Type {
|
||||
source: naga::valid::TypeError::MissingCapability(Capabilities::COOPERATIVE_MATRIX),
|
||||
..
|
||||
})
|
||||
);
|
||||
|
||||
// Used as constructor
|
||||
check_extension_validation!(
|
||||
Capabilities::COOPERATIVE_MATRIX,
|
||||
&format!(
|
||||
r#"fn foo() {{
|
||||
let a = {ty}<f32, A>();
|
||||
}}
|
||||
"#,
|
||||
),
|
||||
&format!(
|
||||
r#"error: the `wgpu_cooperative_matrix` enable extension is not enabled
|
||||
┌─ wgsl:2:13
|
||||
│
|
||||
2 │ let a = {ty}<f32, A>();
|
||||
│ {carets} the `wgpu_cooperative_matrix` "Enable Extension" is needed for this functionality, but it is not currently enabled.
|
||||
│
|
||||
= note: You can enable this extension by adding `enable wgpu_cooperative_matrix;` at the top of the shader, before any other items.
|
||||
|
||||
"#,
|
||||
),
|
||||
Err(naga::valid::ValidationError::Type {
|
||||
source: naga::valid::TypeError::MissingCapability(Capabilities::COOPERATIVE_MATRIX),
|
||||
..
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user