Fix workgroup_storage_size computation
The WebGPU spec says:
> Let workgroupStorageUsed be the sum of roundUp(16, SizeOf(T))
> over each type T of all variables with address space "workgroup"
> statically used by descriptor.compute.
Bug: tint:2157
Change-Id: I55a80b6afb601e72e25e0b6aa99e34b42a0a507c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/172680
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Gregg Tavares <gman@chromium.org>
diff --git a/src/tint/lang/wgsl/inspector/inspector.cc b/src/tint/lang/wgsl/inspector/inspector.cc
index 5784734..e6c2b44 100644
--- a/src/tint/lang/wgsl/inspector/inspector.cc
+++ b/src/tint/lang/wgsl/inspector/inspector.cc
@@ -920,7 +920,7 @@
// turn specified as an upper bound for Vulkan layout sizing. Since D3D
// and Metal are even less specific, we assume Vulkan behavior as a
// good-enough approximation everywhere.
- total_size += tint::RoundUp(align, size);
+ total_size += tint::RoundUp(16u, tint::RoundUp(align, size));
}
}
diff --git a/src/tint/lang/wgsl/inspector/inspector_test.cc b/src/tint/lang/wgsl/inspector/inspector_test.cc
index 76d514e..e3d97bb 100644
--- a/src/tint/lang/wgsl/inspector/inspector_test.cc
+++ b/src/tint/lang/wgsl/inspector/inspector_test.cc
@@ -305,7 +305,7 @@
ASSERT_FALSE(inspector.has_error()) << inspector.error();
ASSERT_EQ(1u, result.size());
- EXPECT_EQ(4u, result[0].workgroup_storage_size);
+ EXPECT_EQ(16u, result[0].workgroup_storage_size);
}
TEST_F(InspectorGetEntryPointTest, WorkgroupStorageSizeCompoundTypes) {
@@ -338,7 +338,7 @@
ASSERT_FALSE(inspector.has_error()) << inspector.error();
ASSERT_EQ(1u, result.size());
- EXPECT_EQ(72u, result[0].workgroup_storage_size);
+ EXPECT_EQ(96u, result[0].workgroup_storage_size);
}
TEST_F(InspectorGetEntryPointTest, WorkgroupStorageSizeAlignmentPadding) {
diff --git a/webgpu-cts/compat-expectations.txt b/webgpu-cts/compat-expectations.txt
index 0ba914a..a16040e 100644
--- a/webgpu-cts/compat-expectations.txt
+++ b/webgpu-cts/compat-expectations.txt
@@ -274,6 +274,34 @@
### This section represents tests which may require CTS changes.
+# Workgroup size calculation issue.
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atDefault";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atDefault";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="mat2x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Ci32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Cu32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="mat2x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Ci32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Cu32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="overLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="overLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="betweenDefaultAndMaximum";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="betweenDefaultAndMaximum";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+
# ANGLETextureSharing is not supported
crbug.com/dawn/2086 webgpu:api,operation,adapter,requestAdapter:requestAdapter:powerPreference="_undef_";forceFallbackAdapter=true [ Failure ]
crbug.com/dawn/2086 webgpu:api,operation,adapter,requestAdapter:requestAdapter:powerPreference="high-performance";forceFallbackAdapter=true [ Failure ]
diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt
index 6f92384..7f06a82 100644
--- a/webgpu-cts/expectations.txt
+++ b/webgpu-cts/expectations.txt
@@ -771,6 +771,34 @@
crbug.com/dawn/1991 [ android-t ] webgpu:shader,execution,memory_model,coherence:corr:memType="atomic_storage";testType="inter_workgroup";extraFlags="rmw_variant" [ RetryOnFailure ]
################################################################################
+# Workgroup size calculation issue.
+################################################################################
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atDefault";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atDefault";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="mat2x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Ci32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=false;wgslType="vec2%3Cu32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="mat2x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Ci32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="atLimit";async=true;wgslType="vec2%3Cu32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="overLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="underDefault";testValueName="overLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=false;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x3%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x4%3Cf16%3E" [ Failure ]
+crbug.com/tint/2157 webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:limitTest="atMaximum";testValueName="atLimit";async=true;wgslType="mat3x2%3Cf32%3E" [ Failure ]
+
+################################################################################
# Tint unimplemented feature
################################################################################
crbug.com/tint/1864 webgpu:shader,validation,parse,identifiers:alias_name:ident="bitcast" [ Failure ]