mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
tint: Add basic support for chromium_experimental_push_constant.
This extension adds support for the push_constant storage class such
that it can be tested with WGSL test files. The real goal is to allow
future transforms that will add push constants that the SPIRV writer
will output.
The extension:
- Adds the `chromium_experimental_push_constant` enable.
- Allows the push_constant storage class for global variables.
- Adds validation that the types are host-shareable for push_constant
variables, and that they don't contain f16 (must be 32bit types
only).
- Validates that at most one push_constant variable is statically used
per entry-point.
- Skips validation that the extension has been enabled if
kIgnoreStorageClass is used.
Tests are added:
- For parsing of var<push_constant>
- Caught a missing conversion.
- For each of the validation rules.
- For the wrapping of push constants in structs if needed by
AddSpirvBlockAttribute.
- For the layout and type rules of the storage class.
- For a shader with multiple entry-points using various push constants.
- Caught a missing reset of the previous push constant variable in
the validation check that at most one is used.
- Caught the missing wrapping in structs that had to be added to
AddSpirvBlockAttribute.
- Caught incorrect logic when adding diagnostics about the call
graph leading to the reference to push constants.
Bug: tint:1620
Change-Id: I04a5d8e5188c0dcef077f2233ba1359d1575bf51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96682
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
24d36b0227
commit
4abf28e29b
36
test/tint/var/uses/push_constant.wgsl
Normal file
36
test/tint/var/uses/push_constant.wgsl
Normal file
@@ -0,0 +1,36 @@
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
var<push_constant> b : i32;
|
||||
var<push_constant> c : i32; // unused
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
43
test/tint/var/uses/push_constant.wgsl.expected.dxc.hlsl
Normal file
43
test/tint/var/uses/push_constant.wgsl.expected.dxc.hlsl
Normal file
@@ -0,0 +1,43 @@
|
||||
SKIP: FAILED
|
||||
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled storage class push_constant
|
||||
43
test/tint/var/uses/push_constant.wgsl.expected.fxc.hlsl
Normal file
43
test/tint/var/uses/push_constant.wgsl.expected.fxc.hlsl
Normal file
@@ -0,0 +1,43 @@
|
||||
SKIP: FAILED
|
||||
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled storage class push_constant
|
||||
135
test/tint/var/uses/push_constant.wgsl.expected.glsl
Normal file
135
test/tint/var/uses/push_constant.wgsl.expected.glsl
Normal file
@@ -0,0 +1,135 @@
|
||||
SKIP: FAILED
|
||||
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled storage class push_constant
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled storage class push_constant
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled storage class push_constant
|
||||
#version 310 es
|
||||
|
||||
void main4() {
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void main() {
|
||||
main4();
|
||||
return;
|
||||
}
|
||||
48
test/tint/var/uses/push_constant.wgsl.expected.msl
Normal file
48
test/tint/var/uses/push_constant.wgsl.expected.msl
Normal file
@@ -0,0 +1,48 @@
|
||||
SKIP: FAILED
|
||||
|
||||
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
|
||||
Failed to generate: error: unhandled module-scope storage class (push_constant)
|
||||
error: unhandled module-scope storage class (push_constant)
|
||||
error: unhandled module-scope storage class (push_constant)
|
||||
error: unhandled module-scope storage class (push_constant)
|
||||
error: unhandled module-scope storage class (push_constant)
|
||||
error: unhandled module-scope storage class (push_constant)
|
||||
76
test/tint/var/uses/push_constant.wgsl.expected.spvasm
Normal file
76
test/tint/var/uses/push_constant.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,76 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main1 "main1"
|
||||
OpEntryPoint GLCompute %main2 "main2"
|
||||
OpEntryPoint GLCompute %main3 "main3"
|
||||
OpEntryPoint GLCompute %main4 "main4"
|
||||
OpExecutionMode %main1 LocalSize 1 1 1
|
||||
OpExecutionMode %main2 LocalSize 1 1 1
|
||||
OpExecutionMode %main3 LocalSize 1 1 1
|
||||
OpExecutionMode %main4 LocalSize 1 1 1
|
||||
OpName %a_block "a_block"
|
||||
OpMemberName %a_block 0 "inner"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
OpName %uses_a "uses_a"
|
||||
OpName %uses_uses_a "uses_uses_a"
|
||||
OpName %uses_b "uses_b"
|
||||
OpName %main1 "main1"
|
||||
OpName %main2 "main2"
|
||||
OpName %main3 "main3"
|
||||
OpName %main4 "main4"
|
||||
OpDecorate %a_block Block
|
||||
OpMemberDecorate %a_block 0 Offset 0
|
||||
%int = OpTypeInt 32 1
|
||||
%a_block = OpTypeStruct %int
|
||||
%_ptr_PushConstant_a_block = OpTypePointer PushConstant %a_block
|
||||
%a = OpVariable %_ptr_PushConstant_a_block PushConstant
|
||||
%b = OpVariable %_ptr_PushConstant_a_block PushConstant
|
||||
%c = OpVariable %_ptr_PushConstant_a_block PushConstant
|
||||
%void = OpTypeVoid
|
||||
%7 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_PushConstant_int = OpTypePointer PushConstant %int
|
||||
%uses_a = OpFunction %void None %7
|
||||
%10 = OpLabel
|
||||
%14 = OpAccessChain %_ptr_PushConstant_int %a %uint_0
|
||||
%15 = OpLoad %int %14
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_uses_a = OpFunction %void None %7
|
||||
%17 = OpLabel
|
||||
%18 = OpFunctionCall %void %uses_a
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_b = OpFunction %void None %7
|
||||
%20 = OpLabel
|
||||
%21 = OpAccessChain %_ptr_PushConstant_int %b %uint_0
|
||||
%22 = OpLoad %int %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main1 = OpFunction %void None %7
|
||||
%24 = OpLabel
|
||||
%25 = OpFunctionCall %void %uses_a
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main2 = OpFunction %void None %7
|
||||
%27 = OpLabel
|
||||
%28 = OpFunctionCall %void %uses_uses_a
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main3 = OpFunction %void None %7
|
||||
%30 = OpLabel
|
||||
%31 = OpFunctionCall %void %uses_b
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main4 = OpFunction %void None %7
|
||||
%33 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
38
test/tint/var/uses/push_constant.wgsl.expected.wgsl
Normal file
38
test/tint/var/uses/push_constant.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,38 @@
|
||||
enable chromium_experimental_push_constant;
|
||||
|
||||
var<push_constant> a : i32;
|
||||
|
||||
var<push_constant> b : i32;
|
||||
|
||||
var<push_constant> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
let foo = a;
|
||||
}
|
||||
|
||||
fn uses_uses_a() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
let foo = b;
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main1() {
|
||||
uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main2() {
|
||||
uses_uses_a();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main3() {
|
||||
uses_b();
|
||||
}
|
||||
|
||||
@compute @workgroup_size(1)
|
||||
fn main4() {
|
||||
}
|
||||
Reference in New Issue
Block a user