mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 05:51:03 +01:00
Add supported caps info to naga backends (#9068)
* Initial commit * 3/5 done I think * Updated naga bin to use new caps * Made clippy shut up * Tried to fix dota2 validation error * HLSL list made, also formatted Cargo.toml * Made stuff work with snapshots * Added changelog and GLSL list * Updated message
This commit is contained in:
1 parent
6432094c9e
commit
fdd903e6e4
24 files changed
+377
-62
No files matched your search
@@ -107,6 +107,7 @@ By @cwfitzgerald in [#8999](https://github.com/gfx-rs/wgpu/pull/8999).
|
||||
#### naga
|
||||
|
||||
- Added support for dual-source blending in SPIR-V shaders. By @andyleiserson in [#8865](https://github.com/gfx-rs/wgpu/pull/8865).
|
||||
- Added `supported_capabilities` to all backends. By @inner-daemons in [#9068](https://github.com/gfx-rs/wgpu/pull/9068).
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
Generated
+1
@@ -5027,6 +5027,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"libtest-mimic",
|
||||
"log",
|
||||
"naga",
|
||||
"nanorand",
|
||||
"nv-flip",
|
||||
"parking_lot",
|
||||
|
||||
+15
-13
@@ -628,19 +628,21 @@ fn run() -> anyhow::Result<()> {
|
||||
let output_paths = files;
|
||||
|
||||
// Decide which capabilities our output formats can support.
|
||||
let validation_caps =
|
||||
output_paths
|
||||
.clone()
|
||||
.fold(naga::valid::Capabilities::all(), |caps, path| {
|
||||
use naga::valid::Capabilities as C;
|
||||
let missing = match Path::new(path).extension().and_then(|ex| ex.to_str()) {
|
||||
Some("wgsl") => C::CLIP_DISTANCE | C::CULL_DISTANCE,
|
||||
Some("metal") => C::CULL_DISTANCE,
|
||||
Some("hlsl") => C::empty(),
|
||||
_ => C::TEXTURE_EXTERNAL,
|
||||
};
|
||||
caps & !missing
|
||||
});
|
||||
let validation_caps = output_paths
|
||||
.clone()
|
||||
.fold(params.capabilities, |caps, path| {
|
||||
use naga::valid::Capabilities as C;
|
||||
let allowed = match Path::new(path).extension().and_then(|ex| ex.to_str()) {
|
||||
Some("wgsl") => naga::back::wgsl::supported_capabilities(),
|
||||
Some("metal") => naga::back::msl::supported_capabilities(),
|
||||
Some("hlsl") => naga::back::hlsl::supported_capabilities(),
|
||||
Some("spv") | Some("spirv") => naga::back::spv::supported_capabilities(),
|
||||
Some("glsl") | Some("frag") | Some("vert") | Some("comp") | Some("task")
|
||||
| Some("mesh") => naga::back::glsl::supported_capabilities(),
|
||||
_ => C::all() - C::TEXTURE_EXTERNAL,
|
||||
};
|
||||
caps & allowed
|
||||
});
|
||||
|
||||
// Validate the IR before compaction.
|
||||
let info = match naga::valid::Validator::new(params.validation_flags, validation_caps)
|
||||
|
||||
@@ -616,3 +616,29 @@ fn is_value_init_supported(module: &crate::Module, ty: Handle<crate::Type>) -> b
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supported_capabilities() -> valid::Capabilities {
|
||||
use valid::Capabilities as Caps;
|
||||
|
||||
// Lots of these aren't supported on GLES in general, but naga is able to write them without panicking.
|
||||
|
||||
Caps::IMMEDIATES
|
||||
| Caps::FLOAT64
|
||||
| Caps::PRIMITIVE_INDEX
|
||||
| Caps::CLIP_DISTANCE
|
||||
| Caps::MULTIVIEW
|
||||
| Caps::EARLY_DEPTH_TEST
|
||||
| Caps::MULTISAMPLED_SHADING
|
||||
| Caps::DUAL_SOURCE_BLENDING
|
||||
| Caps::CUBE_ARRAY_TEXTURES
|
||||
| Caps::SHADER_INT64
|
||||
| Caps::SHADER_INT64_ATOMIC_ALL_OPS
|
||||
| Caps::TEXTURE_ATOMIC
|
||||
| Caps::TEXTURE_INT64_ATOMIC
|
||||
| Caps::SUBGROUP
|
||||
| Caps::SUBGROUP_BARRIER
|
||||
| Caps::SHADER_FLOAT16
|
||||
| Caps::SHADER_FLOAT16_IN_FLOAT32
|
||||
| Caps::SHADER_BARYCENTRICS
|
||||
| Caps::DRAW_INDEX
|
||||
}
|
||||
@@ -760,3 +760,47 @@ pub struct Writer<'a, W> {
|
||||
temp_access_chain: Vec<storage::SubAccess>,
|
||||
need_bake_expressions: back::NeedBakeExpressions,
|
||||
}
|
||||
|
||||
pub fn supported_capabilities() -> crate::valid::Capabilities {
|
||||
use crate::valid::Capabilities as Caps;
|
||||
Caps::IMMEDIATES
|
||||
| Caps::FLOAT64 // Unsupported by wgpu but supported by naga
|
||||
| Caps::PRIMITIVE_INDEX
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY
|
||||
// No BUFFER_BINDING_ARRAY
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY
|
||||
// No STORAGE_BUFFER_BINDING_ARRAY
|
||||
// No CLIP_DISTANCE
|
||||
// No CULL_DISTANCE
|
||||
| Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS
|
||||
| Caps::MULTIVIEW
|
||||
// No EARLY_DEPTH_TEST
|
||||
| Caps::MULTISAMPLED_SHADING
|
||||
| Caps::RAY_QUERY
|
||||
| Caps::DUAL_SOURCE_BLENDING
|
||||
| Caps::CUBE_ARRAY_TEXTURES
|
||||
| Caps::SHADER_INT64
|
||||
| Caps::SUBGROUP
|
||||
// No SUBGROUP_BARRIER
|
||||
// No SUBGROUP_VERTEX_STAGE
|
||||
| Caps::SHADER_INT64_ATOMIC_MIN_MAX
|
||||
| Caps::SHADER_INT64_ATOMIC_ALL_OPS
|
||||
// No SHADER_FLOAT32_ATOMIC
|
||||
| Caps::TEXTURE_ATOMIC
|
||||
| Caps::TEXTURE_INT64_ATOMIC
|
||||
// No RAY_HIT_VERTEX_POSITION
|
||||
| Caps::SHADER_FLOAT16
|
||||
| Caps::TEXTURE_EXTERNAL
|
||||
| Caps::SHADER_FLOAT16_IN_FLOAT32
|
||||
| Caps::SHADER_BARYCENTRICS
|
||||
// No MESH_SHADER
|
||||
// No MESH_SHADER_POINT_TOPOLOGY
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
// No BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
// No COOPERATIVE_MATRIX
|
||||
// No PER_VERTEX
|
||||
// No RAY_TRACING_PIPELINE
|
||||
// No DRAW_INDEX
|
||||
}
|
||||
@@ -832,6 +832,50 @@ pub fn write_string(
|
||||
Ok((w.finish(), info))
|
||||
}
|
||||
|
||||
pub fn supported_capabilities() -> crate::valid::Capabilities {
|
||||
use crate::valid::Capabilities as Caps;
|
||||
Caps::IMMEDIATES
|
||||
// No FLOAT64
|
||||
| Caps::PRIMITIVE_INDEX
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY
|
||||
// No BUFFER_BINDING_ARRAY
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY
|
||||
| Caps::STORAGE_BUFFER_BINDING_ARRAY
|
||||
| Caps::CLIP_DISTANCE // CLIP_DISTANCE isn't supported by metal backend? But is supported by MSL writer
|
||||
// No CULL_DISTANCE
|
||||
| Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS
|
||||
| Caps::MULTIVIEW
|
||||
// No EARLY_DEPTH_TEST
|
||||
| Caps::MULTISAMPLED_SHADING
|
||||
| Caps::RAY_QUERY
|
||||
| Caps::DUAL_SOURCE_BLENDING
|
||||
| Caps::CUBE_ARRAY_TEXTURES
|
||||
| Caps::SHADER_INT64
|
||||
| Caps::SUBGROUP
|
||||
| Caps::SUBGROUP_BARRIER
|
||||
// No SUBGROUP_VERTEX_STAGE
|
||||
| Caps::SHADER_INT64_ATOMIC_MIN_MAX
|
||||
// No SHADER_INT64_ATOMIC_ALL_OPS
|
||||
| Caps::SHADER_FLOAT32_ATOMIC
|
||||
| Caps::TEXTURE_ATOMIC
|
||||
| Caps::TEXTURE_INT64_ATOMIC
|
||||
// No RAY_HIT_VERTEX_POSITION
|
||||
| Caps::SHADER_FLOAT16
|
||||
| Caps::TEXTURE_EXTERNAL
|
||||
| Caps::SHADER_FLOAT16_IN_FLOAT32
|
||||
| Caps::SHADER_BARYCENTRICS
|
||||
// No MESH_SHADER
|
||||
// No MESH_SHADER_POINT_TOPOLOGY
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
// No BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::COOPERATIVE_MATRIX
|
||||
// No PER_VERTEX
|
||||
// No RAY_TRACING_PIPELINE
|
||||
// No DRAW_INDEX
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_size() {
|
||||
assert_eq!(size_of::<Error>(), 40);
|
||||
|
||||
@@ -1146,3 +1146,48 @@ pub fn write_vec(
|
||||
)?;
|
||||
Ok(words)
|
||||
}
|
||||
|
||||
pub fn supported_capabilities() -> crate::valid::Capabilities {
|
||||
use crate::valid::Capabilities as Caps;
|
||||
|
||||
Caps::IMMEDIATES
|
||||
| Caps::FLOAT64
|
||||
| Caps::PRIMITIVE_INDEX
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY
|
||||
| Caps::BUFFER_BINDING_ARRAY
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY
|
||||
| Caps::STORAGE_BUFFER_BINDING_ARRAY
|
||||
| Caps::CLIP_DISTANCE
|
||||
// No cull distance
|
||||
| Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS
|
||||
| Caps::MULTIVIEW
|
||||
| Caps::EARLY_DEPTH_TEST
|
||||
| Caps::MULTISAMPLED_SHADING
|
||||
| Caps::RAY_QUERY
|
||||
| Caps::DUAL_SOURCE_BLENDING
|
||||
| Caps::CUBE_ARRAY_TEXTURES
|
||||
| Caps::SHADER_INT64
|
||||
| Caps::SUBGROUP
|
||||
| Caps::SUBGROUP_BARRIER
|
||||
| Caps::SUBGROUP_VERTEX_STAGE
|
||||
| Caps::SHADER_INT64_ATOMIC_MIN_MAX
|
||||
| Caps::SHADER_INT64_ATOMIC_ALL_OPS
|
||||
| Caps::SHADER_FLOAT32_ATOMIC
|
||||
| Caps::TEXTURE_ATOMIC
|
||||
| Caps::TEXTURE_INT64_ATOMIC
|
||||
| Caps::RAY_HIT_VERTEX_POSITION
|
||||
| Caps::SHADER_FLOAT16
|
||||
// No TEXTURE_EXTERNAL
|
||||
| Caps::SHADER_FLOAT16_IN_FLOAT32
|
||||
| Caps::SHADER_BARYCENTRICS
|
||||
| Caps::MESH_SHADER
|
||||
| Caps::MESH_SHADER_POINT_TOPOLOGY
|
||||
| Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
// No BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_TEXTURE_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
|
||||
| Caps::COOPERATIVE_MATRIX
|
||||
| Caps::PER_VERTEX
|
||||
// No RAY_TRACING_PIPELINE
|
||||
| Caps::DRAW_INDEX
|
||||
}
|
||||
@@ -88,3 +88,9 @@ impl crate::AtomicFunction {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn supported_capabilities() -> crate::valid::Capabilities {
|
||||
// WGSL regurgitation supports almost everything, though browser webgpu can't parse most of these.
|
||||
use crate::valid::Capabilities as Caps;
|
||||
Caps::all()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
capabilities = "SUBGROUP | SUBGROUP_BARRIER"
|
||||
targets = "WGSL | SPIRV | METAL"
|
||||
|
||||
[msl]
|
||||
fake_missing_bindings = false
|
||||
lang_version = [2, 4]
|
||||
spirv_cross_compatibility = false
|
||||
zero_initialize_workgroup_memory = true
|
||||
|
||||
[hlsl]
|
||||
shader_model = "V6_0"
|
||||
fake_missing_bindings = true
|
||||
restrict_indexing = true
|
||||
zero_initialize_workgroup_memory = true
|
||||
|
||||
[glsl]
|
||||
version.Desktop = 430
|
||||
zero_initialize_workgroup_memory = true
|
||||
|
||||
[spv]
|
||||
version = [1, 3]
|
||||
@@ -0,0 +1,4 @@
|
||||
@compute @workgroup_size(1)
|
||||
fn main() {
|
||||
subgroupBarrier();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
capabilities = "SUBGROUP | SUBGROUP_BARRIER"
|
||||
capabilities = "SUBGROUP"
|
||||
|
||||
[msl]
|
||||
fake_missing_bindings = false
|
||||
|
||||
@@ -9,8 +9,6 @@ fn main(
|
||||
@builtin(subgroup_id) subgroup_id: u32,
|
||||
@builtin(subgroup_invocation_id) subgroup_invocation_id: u32,
|
||||
) {
|
||||
subgroupBarrier();
|
||||
|
||||
_ = subgroupBallot((subgroup_invocation_id & 1u) == 1u);
|
||||
_ = subgroupBallot();
|
||||
|
||||
|
||||
@@ -11,7 +11,36 @@ fn check_targets(input: &Input, module: &mut naga::Module, source_code: Option<&
|
||||
|
||||
let targets = params.targets.unwrap();
|
||||
|
||||
let capabilities = params.capabilities.unwrap_or_default();
|
||||
let mut capabilities = params.capabilities.unwrap_or_default();
|
||||
{
|
||||
let mut allowed_capabilities = naga::valid::Capabilities::all();
|
||||
if targets.contains(Targets::GLSL) {
|
||||
allowed_capabilities &= naga::back::glsl::supported_capabilities();
|
||||
}
|
||||
if targets.contains(Targets::HLSL) {
|
||||
allowed_capabilities &= naga::back::hlsl::supported_capabilities();
|
||||
}
|
||||
if targets.contains(Targets::SPIRV) {
|
||||
allowed_capabilities &= naga::back::spv::supported_capabilities();
|
||||
}
|
||||
if targets.contains(Targets::WGSL) {
|
||||
allowed_capabilities &= naga::back::wgsl::supported_capabilities();
|
||||
}
|
||||
if targets.contains(Targets::METAL) {
|
||||
allowed_capabilities &= naga::back::msl::supported_capabilities();
|
||||
}
|
||||
if capabilities == naga::valid::Capabilities::all() {
|
||||
capabilities = allowed_capabilities;
|
||||
} else {
|
||||
let diff = capabilities - allowed_capabilities;
|
||||
if !diff.is_empty() {
|
||||
panic!(
|
||||
"Invalid capabilities for backends on shader {name}: used {diff:?} which aren't supported by one of the targets.
|
||||
Note: this is an issue with snapshot configuration, not code. If you added a new capability, add it to `supported_capabilities()` in each backend where it is supported"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if targets.contains(Targets::IR) {
|
||||
|
||||
@@ -18,8 +18,6 @@ void main() {
|
||||
Structure sizes = Structure(gl_NumSubgroups, gl_SubgroupSize);
|
||||
uint subgroup_id = gl_SubgroupID;
|
||||
uint subgroup_invocation_id = gl_SubgroupInvocationID;
|
||||
subgroupMemoryBarrier();
|
||||
barrier();
|
||||
uvec4 _e7 = subgroupBallot(((subgroup_invocation_id & 1u) == 1u));
|
||||
uvec4 _e8 = subgroupBallot(true);
|
||||
bool _e11 = subgroupAll((subgroup_invocation_id != 0u));
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// language: metal2.4
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using metal::uint;
|
||||
|
||||
|
||||
kernel void main_(
|
||||
) {
|
||||
metal::simdgroup_barrier(metal::mem_flags::mem_threadgroup);
|
||||
return;
|
||||
}
|
||||
@@ -18,7 +18,6 @@ kernel void main_(
|
||||
, uint subgroup_invocation_id [[thread_index_in_simdgroup]]
|
||||
) {
|
||||
const Structure sizes = { num_subgroups, subgroup_size };
|
||||
metal::simdgroup_barrier(metal::mem_flags::mem_threadgroup);
|
||||
metal::uint4 unnamed = metal::uint4((uint64_t)metal::simd_ballot((subgroup_invocation_id & 1u) == 1u), 0, 0, 0);
|
||||
metal::uint4 unnamed_1 = metal::uint4((uint64_t)metal::simd_ballot(true), 0, 0, 0);
|
||||
bool unnamed_2 = metal::simd_all(subgroup_invocation_id != 0u);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: rspirv
|
||||
; Bound: 10
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %4 "main"
|
||||
OpExecutionMode %4 LocalSize 1 1 1
|
||||
%2 = OpTypeVoid
|
||||
%5 = OpTypeFunction %2
|
||||
%8 = OpTypeInt 32 0
|
||||
%7 = OpConstant %8 3
|
||||
%9 = OpConstant %8 136
|
||||
%4 = OpFunction %2 None %5
|
||||
%3 = OpLabel
|
||||
OpBranch %6
|
||||
%6 = OpLabel
|
||||
OpControlBarrier %7 %7 %9
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: rspirv
|
||||
; Bound: 62
|
||||
; Bound: 61
|
||||
OpCapability Shader
|
||||
OpCapability GroupNonUniform
|
||||
OpCapability GroupNonUniformBallot
|
||||
@@ -33,11 +33,10 @@ OpDecorate %15 BuiltIn SubgroupLocalInvocationId
|
||||
%19 = OpConstant %3 1
|
||||
%20 = OpConstant %3 0
|
||||
%21 = OpConstant %3 4
|
||||
%23 = OpConstant %3 3
|
||||
%24 = OpConstant %3 136
|
||||
%27 = OpTypeVector %3 4
|
||||
%29 = OpConstantTrue %5
|
||||
%61 = OpConstant %3 2
|
||||
%25 = OpTypeVector %3 4
|
||||
%26 = OpConstant %3 3
|
||||
%28 = OpConstantTrue %5
|
||||
%60 = OpConstant %3 2
|
||||
%17 = OpFunction %2 None %18
|
||||
%6 = OpLabel
|
||||
%10 = OpLoad %3 %8
|
||||
@@ -47,40 +46,39 @@ OpDecorate %15 BuiltIn SubgroupLocalInvocationId
|
||||
%16 = OpLoad %3 %15
|
||||
OpBranch %22
|
||||
%22 = OpLabel
|
||||
OpControlBarrier %23 %23 %24
|
||||
%25 = OpBitwiseAnd %3 %16 %19
|
||||
%26 = OpIEqual %5 %25 %19
|
||||
%28 = OpGroupNonUniformBallot %27 %23 %26
|
||||
%30 = OpGroupNonUniformBallot %27 %23 %29
|
||||
%31 = OpINotEqual %5 %16 %20
|
||||
%32 = OpGroupNonUniformAll %5 %23 %31
|
||||
%33 = OpIEqual %5 %16 %20
|
||||
%34 = OpGroupNonUniformAny %5 %23 %33
|
||||
%35 = OpGroupNonUniformIAdd %3 %23 Reduce %16
|
||||
%36 = OpGroupNonUniformIMul %3 %23 Reduce %16
|
||||
%37 = OpGroupNonUniformUMin %3 %23 Reduce %16
|
||||
%38 = OpGroupNonUniformUMax %3 %23 Reduce %16
|
||||
%39 = OpGroupNonUniformBitwiseAnd %3 %23 Reduce %16
|
||||
%40 = OpGroupNonUniformBitwiseOr %3 %23 Reduce %16
|
||||
%41 = OpGroupNonUniformBitwiseXor %3 %23 Reduce %16
|
||||
%42 = OpGroupNonUniformIAdd %3 %23 ExclusiveScan %16
|
||||
%43 = OpGroupNonUniformIMul %3 %23 ExclusiveScan %16
|
||||
%44 = OpGroupNonUniformIAdd %3 %23 InclusiveScan %16
|
||||
%45 = OpGroupNonUniformIMul %3 %23 InclusiveScan %16
|
||||
%46 = OpGroupNonUniformBroadcastFirst %3 %23 %16
|
||||
%47 = OpGroupNonUniformShuffle %3 %23 %16 %21
|
||||
%48 = OpCompositeExtract %3 %7 1
|
||||
%49 = OpISub %3 %48 %19
|
||||
%50 = OpISub %3 %49 %16
|
||||
%51 = OpGroupNonUniformShuffle %3 %23 %16 %50
|
||||
%52 = OpGroupNonUniformShuffleDown %3 %23 %16 %19
|
||||
%53 = OpGroupNonUniformShuffleUp %3 %23 %16 %19
|
||||
%54 = OpCompositeExtract %3 %7 1
|
||||
%55 = OpISub %3 %54 %19
|
||||
%56 = OpGroupNonUniformShuffleXor %3 %23 %16 %55
|
||||
%57 = OpGroupNonUniformQuadBroadcast %3 %23 %16 %21
|
||||
%58 = OpGroupNonUniformQuadSwap %3 %23 %16 %20
|
||||
%59 = OpGroupNonUniformQuadSwap %3 %23 %16 %19
|
||||
%60 = OpGroupNonUniformQuadSwap %3 %23 %16 %61
|
||||
%23 = OpBitwiseAnd %3 %16 %19
|
||||
%24 = OpIEqual %5 %23 %19
|
||||
%27 = OpGroupNonUniformBallot %25 %26 %24
|
||||
%29 = OpGroupNonUniformBallot %25 %26 %28
|
||||
%30 = OpINotEqual %5 %16 %20
|
||||
%31 = OpGroupNonUniformAll %5 %26 %30
|
||||
%32 = OpIEqual %5 %16 %20
|
||||
%33 = OpGroupNonUniformAny %5 %26 %32
|
||||
%34 = OpGroupNonUniformIAdd %3 %26 Reduce %16
|
||||
%35 = OpGroupNonUniformIMul %3 %26 Reduce %16
|
||||
%36 = OpGroupNonUniformUMin %3 %26 Reduce %16
|
||||
%37 = OpGroupNonUniformUMax %3 %26 Reduce %16
|
||||
%38 = OpGroupNonUniformBitwiseAnd %3 %26 Reduce %16
|
||||
%39 = OpGroupNonUniformBitwiseOr %3 %26 Reduce %16
|
||||
%40 = OpGroupNonUniformBitwiseXor %3 %26 Reduce %16
|
||||
%41 = OpGroupNonUniformIAdd %3 %26 ExclusiveScan %16
|
||||
%42 = OpGroupNonUniformIMul %3 %26 ExclusiveScan %16
|
||||
%43 = OpGroupNonUniformIAdd %3 %26 InclusiveScan %16
|
||||
%44 = OpGroupNonUniformIMul %3 %26 InclusiveScan %16
|
||||
%45 = OpGroupNonUniformBroadcastFirst %3 %26 %16
|
||||
%46 = OpGroupNonUniformShuffle %3 %26 %16 %21
|
||||
%47 = OpCompositeExtract %3 %7 1
|
||||
%48 = OpISub %3 %47 %19
|
||||
%49 = OpISub %3 %48 %16
|
||||
%50 = OpGroupNonUniformShuffle %3 %26 %16 %49
|
||||
%51 = OpGroupNonUniformShuffleDown %3 %26 %16 %19
|
||||
%52 = OpGroupNonUniformShuffleUp %3 %26 %16 %19
|
||||
%53 = OpCompositeExtract %3 %7 1
|
||||
%54 = OpISub %3 %53 %19
|
||||
%55 = OpGroupNonUniformShuffleXor %3 %26 %16 %54
|
||||
%56 = OpGroupNonUniformQuadBroadcast %3 %26 %16 %21
|
||||
%57 = OpGroupNonUniformQuadSwap %3 %26 %16 %20
|
||||
%58 = OpGroupNonUniformQuadSwap %3 %26 %16 %19
|
||||
%59 = OpGroupNonUniformQuadSwap %3 %26 %16 %60
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -0,0 +1,5 @@
|
||||
@compute @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
subgroupBarrier();
|
||||
return;
|
||||
}
|
||||
@@ -5,7 +5,6 @@ struct Structure {
|
||||
|
||||
@compute @workgroup_size(1, 1, 1)
|
||||
fn main(sizes: Structure, @builtin(subgroup_id) subgroup_id: u32, @builtin(subgroup_invocation_id) subgroup_invocation_id: u32) {
|
||||
subgroupBarrier();
|
||||
let _e7 = subgroupBallot(((subgroup_invocation_id & 1u) == 1u));
|
||||
let _e8 = subgroupBallot();
|
||||
let _e11 = subgroupAll((subgroup_invocation_id != 0u));
|
||||
|
||||
@@ -47,6 +47,13 @@ wgpu-core = { workspace = true, features = ["trace"] }
|
||||
wgpu-hal = { workspace = true, features = ["validation_canary"] }
|
||||
wgpu-macros.workspace = true
|
||||
wgpu-types.workspace = true
|
||||
naga = { workspace = true, features = [
|
||||
"spv-out",
|
||||
"wgsl-out",
|
||||
"hlsl-out",
|
||||
"msl-out",
|
||||
"glsl-out",
|
||||
] }
|
||||
|
||||
anyhow.workspace = true
|
||||
arrayvec.workspace = true
|
||||
|
||||
@@ -39,6 +39,7 @@ mod life_cycle;
|
||||
mod mem_leaks;
|
||||
mod mesh_shader;
|
||||
mod multiview;
|
||||
mod naga_capabilities;
|
||||
mod occlusion_query;
|
||||
mod oob_indexing;
|
||||
mod oom;
|
||||
@@ -157,6 +158,7 @@ fn all_tests() -> Vec<wgpu_test::GpuTestInitializer> {
|
||||
vertex_state::all_tests(&mut tests);
|
||||
write_texture::all_tests(&mut tests);
|
||||
zero_init_texture_after_discard::all_tests(&mut tests);
|
||||
naga_capabilities::all_tests(&mut tests);
|
||||
|
||||
tests
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
use wgpu_test::{
|
||||
gpu_test, GpuTestConfiguration, GpuTestInitializer, TestParameters, TestingContext,
|
||||
};
|
||||
|
||||
pub fn all_tests(vec: &mut Vec<GpuTestInitializer>) {
|
||||
vec.push(VALIDATE_CAPABILITIES);
|
||||
}
|
||||
|
||||
pub fn validate_capabilities(ctx: TestingContext) {
|
||||
use naga::valid::Capabilities as Caps;
|
||||
let device_caps = wgpu_core::device::features_to_naga_capabilities(
|
||||
ctx.adapter.features(),
|
||||
ctx.adapter.get_downlevel_capabilities().flags,
|
||||
);
|
||||
let max_caps = match ctx.adapter.get_info().backend {
|
||||
wgpu::Backend::Vulkan => naga::back::spv::supported_capabilities(),
|
||||
// TODO: when mesh shaders land, change this
|
||||
wgpu::Backend::Dx12 => naga::back::hlsl::supported_capabilities() | Caps::MESH_SHADER,
|
||||
wgpu::Backend::Metal => naga::back::msl::supported_capabilities() | Caps::MESH_SHADER,
|
||||
wgpu::Backend::Gl => naga::back::glsl::supported_capabilities(),
|
||||
wgpu::Backend::BrowserWebGpu => naga::back::wgsl::supported_capabilities(),
|
||||
wgpu::Backend::Noop => Caps::all(),
|
||||
};
|
||||
let diff = device_caps - max_caps;
|
||||
assert_eq!(diff, Caps::empty());
|
||||
}
|
||||
|
||||
#[gpu_test]
|
||||
static VALIDATE_CAPABILITIES: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
.parameters(
|
||||
TestParameters::default()
|
||||
.downlevel_flags(wgpu::DownlevelFlags::empty())
|
||||
.limits(wgpu::Limits::downlevel_defaults()),
|
||||
)
|
||||
.run_sync(validate_capabilities);
|
||||
@@ -1332,6 +1332,7 @@ bitflags_array! {
|
||||
/// Supported platforms:
|
||||
/// - desktops
|
||||
/// - some mobile chips
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const DEPTH_CLIP_CONTROL = WEBGPU_FEATURE_DEPTH_CLIP_CONTROL;
|
||||
@@ -1343,6 +1344,7 @@ bitflags_array! {
|
||||
/// - DX12
|
||||
/// - Metal
|
||||
/// - OpenGL
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
///
|
||||
@@ -1363,6 +1365,7 @@ bitflags_array! {
|
||||
/// Supported Platforms:
|
||||
/// - desktops
|
||||
/// - Mobile (All Apple9 and some Apple7 and Apple8 devices)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const TEXTURE_COMPRESSION_BC = WEBGPU_FEATURE_TEXTURE_COMPRESSION_BC;
|
||||
@@ -1376,6 +1379,7 @@ bitflags_array! {
|
||||
/// Supported Platforms:
|
||||
/// - desktops
|
||||
/// - Mobile (All Apple9 and some Apple7 and Apple8 devices)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const TEXTURE_COMPRESSION_BC_SLICED_3D = WEBGPU_FEATURE_TEXTURE_COMPRESSION_BC_SLICED_3D;
|
||||
@@ -1392,6 +1396,7 @@ bitflags_array! {
|
||||
/// Supported Platforms:
|
||||
/// - Vulkan on Intel
|
||||
/// - Mobile (some)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const TEXTURE_COMPRESSION_ETC2 = WEBGPU_FEATURE_TEXTURE_COMPRESSION_ETC2;
|
||||
@@ -1411,6 +1416,7 @@ bitflags_array! {
|
||||
/// Supported Platforms:
|
||||
/// - Vulkan on Intel
|
||||
/// - Mobile (some)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const TEXTURE_COMPRESSION_ASTC = WEBGPU_FEATURE_TEXTURE_COMPRESSION_ASTC;
|
||||
@@ -1425,6 +1431,7 @@ bitflags_array! {
|
||||
/// - Vulkan (some)
|
||||
/// - Metal on Apple3+
|
||||
/// - OpenGL/WebGL (some)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// Not Supported:
|
||||
/// - DX12
|
||||
@@ -1452,6 +1459,7 @@ bitflags_array! {
|
||||
/// - Vulkan
|
||||
/// - DX12
|
||||
/// - Metal
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
///
|
||||
@@ -1473,6 +1481,7 @@ bitflags_array! {
|
||||
/// - DX12
|
||||
/// - Metal on Apple3+ or Mac1+
|
||||
/// - OpenGL (Desktop 4.2+ with ARB_shader_draw_parameters only)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// Not Supported:
|
||||
/// - OpenGL ES / WebGL
|
||||
@@ -1490,6 +1499,7 @@ bitflags_array! {
|
||||
/// - Vulkan
|
||||
/// - Metal
|
||||
/// - DX12
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const SHADER_F16 = WEBGPU_FEATURE_SHADER_F16;
|
||||
@@ -1500,6 +1510,7 @@ bitflags_array! {
|
||||
/// - Vulkan
|
||||
/// - DX12
|
||||
/// - Metal
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
///
|
||||
@@ -1512,6 +1523,7 @@ bitflags_array! {
|
||||
/// - Vulkan
|
||||
/// - DX12
|
||||
/// - Metal
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
///
|
||||
@@ -1527,6 +1539,7 @@ bitflags_array! {
|
||||
/// - DX12
|
||||
/// - Metal on macOS or Apple9+ GPUs, optional on iOS/iPadOS with Apple7/8 GPUs
|
||||
/// - GL with one of `GL_ARB_color_buffer_float`/`GL_EXT_color_buffer_float`/`OES_texture_float_linear`
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const FLOAT32_FILTERABLE = WEBGPU_FEATURE_FLOAT32_FILTERABLE;
|
||||
@@ -1535,6 +1548,7 @@ bitflags_array! {
|
||||
///
|
||||
/// Supported Platforms:
|
||||
/// - Vulkan
|
||||
/// - WebGPU
|
||||
const FLOAT32_BLENDABLE = WEBGPU_FEATURE_FLOAT32_BLENDABLE;
|
||||
|
||||
/// Allows two outputs from a shader to be used for blending.
|
||||
@@ -1547,6 +1561,7 @@ bitflags_array! {
|
||||
/// - Metal (with MSL 1.2+)
|
||||
/// - Vulkan (with dualSrcBlend)
|
||||
/// - DX12
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const DUAL_SOURCE_BLENDING = WEBGPU_FEATURE_DUAL_SOURCE_BLENDING;
|
||||
@@ -1555,7 +1570,9 @@ bitflags_array! {
|
||||
///
|
||||
/// Supported platforms:
|
||||
/// - Vulkan (mainly on Desktop GPUs)
|
||||
/// - Metal
|
||||
/// - GL (Desktop or `GL_EXT_clip_cull_distance`)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// This is a web and native feature.
|
||||
const CLIP_DISTANCES = WEBGPU_FEATURE_CLIP_DISTANCES;
|
||||
@@ -1580,6 +1597,7 @@ bitflags_array! {
|
||||
/// - Vulkan
|
||||
/// - Metal
|
||||
/// - OpenGL (emulated with uniforms)
|
||||
/// - WebGPU
|
||||
///
|
||||
/// WebGPU support is currently a proposal and will be available in browsers in the future.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user