mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
writer/msl: Handle private and workgroup variables
Add a transform that pushes these into the entry point and then passes them by pointer to any functions that need them. Since WGSL does not allow non-function storage class at function-scope, add a DisableValidation attribute to bypass this check. Fixed: tint/726 Change-Id: Ic1f4cd691a54c19e77a60e8ba178508e4249bfd9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51962 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
61e573663d
commit
7a47fa8495
@@ -1 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
SKIP: crbug.com/tint/831
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
thread int tint_symbol_2 = 0;
|
||||
thread int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
int const x_9 = *(tint_symbol_1);
|
||||
int const x_11 = (x_9 + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
thread int tint_symbol_2 = 0;
|
||||
thread int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
int const i = *(tint_symbol_1);
|
||||
int const use = (i + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
SKIP: crbug.com/tint/831
|
||||
|
||||
@@ -1 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
SKIP: crbug.com/tint/831
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
thread int tint_symbol_2 = 123;
|
||||
thread int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
thread int* const p = &(*(tint_symbol_1));
|
||||
int const use = (*(p) + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
threadgroup int tint_symbol_2 = 0;
|
||||
threadgroup int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
*(tint_symbol_1) = 123;
|
||||
threadgroup int* const p = &(*(tint_symbol_1));
|
||||
int const use = (*(p) + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
thread int tint_symbol_2 = 0;
|
||||
thread int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
*(tint_symbol_1) = 123;
|
||||
*(tint_symbol_1) = ((100 + 20) + 3);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
thread int tint_symbol_2 = 0;
|
||||
thread int* const tint_symbol_1 = &(tint_symbol_2);
|
||||
*(tint_symbol_1) = 123;
|
||||
*(tint_symbol_1) = ((100 + 20) + 3);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
SKIP: crbug.com/tint/831
|
||||
@@ -1 +0,0 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
17
test/types/module_scope_let.wgsl
Normal file
17
test/types/module_scope_let.wgsl
Normal file
@@ -0,0 +1,17 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
let bool_let : bool = bool();
|
||||
let i32_let : i32 = i32();
|
||||
let u32_let : u32 = u32();
|
||||
let f32_let : f32 = f32();
|
||||
let v2i32_let : vec2<i32> = vec2<i32>();
|
||||
let v3u32_let : vec3<u32> = vec3<u32>();
|
||||
let v4f32_let : vec4<f32> = vec4<f32>();
|
||||
let m3x4_let : mat3x4<f32> = mat3x4<f32>();
|
||||
let arr_let : array<f32, 4> = array<f32, 4>();
|
||||
let struct_let : S = S();
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
}
|
||||
20
test/types/module_scope_let.wgsl.expected.msl
Normal file
20
test/types/module_scope_let.wgsl.expected.msl
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct S {
|
||||
};
|
||||
|
||||
constant bool bool_let = bool();
|
||||
constant int i32_let = int();
|
||||
constant uint u32_let = uint();
|
||||
constant float f32_let = float();
|
||||
constant int2 v2i32_let = int2();
|
||||
constant uint3 v3u32_let = uint3();
|
||||
constant float4 v4f32_let = float4();
|
||||
constant float3x4 m3x4_let = float3x4();
|
||||
constant float arr_let[4] = {};
|
||||
constant S struct_let = {};
|
||||
kernel void tint_symbol() {
|
||||
return;
|
||||
}
|
||||
|
||||
49
test/types/module_scope_let.wgsl.expected.spvasm
Normal file
49
test/types/module_scope_let.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,49 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %bool_let "bool_let"
|
||||
OpName %i32_let "i32_let"
|
||||
OpName %u32_let "u32_let"
|
||||
OpName %f32_let "f32_let"
|
||||
OpName %v2i32_let "v2i32_let"
|
||||
OpName %v3u32_let "v3u32_let"
|
||||
OpName %v4f32_let "v4f32_let"
|
||||
OpName %m3x4_let "m3x4_let"
|
||||
OpName %arr_let "arr_let"
|
||||
OpName %S "S"
|
||||
OpName %struct_let "struct_let"
|
||||
OpName %main "main"
|
||||
OpDecorate %_arr_float_uint_4 ArrayStride 4
|
||||
%bool = OpTypeBool
|
||||
%bool_let = OpConstantNull %bool
|
||||
%int = OpTypeInt 32 1
|
||||
%i32_let = OpConstantNull %int
|
||||
%uint = OpTypeInt 32 0
|
||||
%u32_let = OpConstantNull %uint
|
||||
%float = OpTypeFloat 32
|
||||
%f32_let = OpConstantNull %float
|
||||
%v2int = OpTypeVector %int 2
|
||||
%v2i32_let = OpConstantNull %v2int
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%v3u32_let = OpConstantNull %v3uint
|
||||
%v4float = OpTypeVector %float 4
|
||||
%v4f32_let = OpConstantNull %v4float
|
||||
%mat3v4float = OpTypeMatrix %v4float 3
|
||||
%m3x4_let = OpConstantNull %mat3v4float
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%_arr_float_uint_4 = OpTypeArray %float %uint_4
|
||||
%arr_let = OpConstantNull %_arr_float_uint_4
|
||||
%S = OpTypeStruct
|
||||
%struct_let = OpConstantNull %S
|
||||
%void = OpTypeVoid
|
||||
%22 = OpTypeFunction %void
|
||||
%main = OpFunction %void None %22
|
||||
%25 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
26
test/types/module_scope_let.wgsl.expected.wgsl
Normal file
26
test/types/module_scope_let.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,26 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
let bool_let : bool = bool();
|
||||
|
||||
let i32_let : i32 = i32();
|
||||
|
||||
let u32_let : u32 = u32();
|
||||
|
||||
let f32_let : f32 = f32();
|
||||
|
||||
let v2i32_let : vec2<i32> = vec2<i32>();
|
||||
|
||||
let v3u32_let : vec3<u32> = vec3<u32>();
|
||||
|
||||
let v4f32_let : vec4<f32> = vec4<f32>();
|
||||
|
||||
let m3x4_let : mat3x4<f32> = mat3x4<f32>();
|
||||
|
||||
let arr_let : array<f32, 4> = array<f32, 4>();
|
||||
|
||||
let struct_let : S = S();
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
}
|
||||
28
test/types/module_scope_var.wgsl
Normal file
28
test/types/module_scope_var.wgsl
Normal file
@@ -0,0 +1,28 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
var<private> bool_var : bool;
|
||||
var<private> i32_var : i32;
|
||||
var<private> u32_var : u32;
|
||||
var<private> f32_var : f32;
|
||||
var<private> v2i32_var : vec2<i32>;
|
||||
var<private> v3u32_var : vec3<u32>;
|
||||
var<private> v4f32_var : vec4<f32>;
|
||||
var<private> m2x3_var : mat2x3<f32>;
|
||||
var<private> arr_var : array<f32, 4>;
|
||||
var<private> struct_var : S;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
// Reference the module-scope variables to stop them from being removed.
|
||||
bool_var = bool();
|
||||
i32_var = i32();
|
||||
u32_var = u32();
|
||||
f32_var = f32();
|
||||
v2i32_var = vec2<i32>();
|
||||
v3u32_var = vec3<u32>();
|
||||
v4f32_var = vec4<f32>();
|
||||
m2x3_var = mat2x3<f32>();
|
||||
arr_var = array<f32, 4>();
|
||||
struct_var = S();
|
||||
}
|
||||
31
test/types/module_scope_var.wgsl.expected.hlsl
Normal file
31
test/types/module_scope_var.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,31 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
static bool bool_var;
|
||||
static int i32_var;
|
||||
static uint u32_var;
|
||||
static float f32_var;
|
||||
static int2 v2i32_var;
|
||||
static uint3 v3u32_var;
|
||||
static float4 v4f32_var;
|
||||
static float2x3 m2x3_var;
|
||||
static float arr_var[4];
|
||||
static S struct_var;
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
bool_var = false;
|
||||
i32_var = 0;
|
||||
u32_var = 0u;
|
||||
f32_var = 0.0f;
|
||||
v2i32_var = int2(0, 0);
|
||||
v3u32_var = uint3(0u, 0u, 0u);
|
||||
v4f32_var = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
const float tint_symbol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
arr_var = tint_symbol;
|
||||
const S tint_symbol_1 = {};
|
||||
struct_var = tint_symbol_1;
|
||||
return;
|
||||
}
|
||||
|
||||
1
test/types/module_scope_var.wgsl.expected.msl
Normal file
1
test/types/module_scope_var.wgsl.expected.msl
Normal file
@@ -0,0 +1 @@
|
||||
SKIP: crbug.com/tint/814
|
||||
80
test/types/module_scope_var.wgsl.expected.spvasm
Normal file
80
test/types/module_scope_var.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,80 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 47
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %bool_var "bool_var"
|
||||
OpName %i32_var "i32_var"
|
||||
OpName %u32_var "u32_var"
|
||||
OpName %f32_var "f32_var"
|
||||
OpName %v2i32_var "v2i32_var"
|
||||
OpName %v3u32_var "v3u32_var"
|
||||
OpName %v4f32_var "v4f32_var"
|
||||
OpName %m2x3_var "m2x3_var"
|
||||
OpName %arr_var "arr_var"
|
||||
OpName %S "S"
|
||||
OpName %struct_var "struct_var"
|
||||
OpName %main "main"
|
||||
OpDecorate %_arr_float_uint_4 ArrayStride 4
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Private_bool = OpTypePointer Private %bool
|
||||
%4 = OpConstantNull %bool
|
||||
%bool_var = OpVariable %_ptr_Private_bool Private %4
|
||||
%int = OpTypeInt 32 1
|
||||
%_ptr_Private_int = OpTypePointer Private %int
|
||||
%8 = OpConstantNull %int
|
||||
%i32_var = OpVariable %_ptr_Private_int Private %8
|
||||
%uint = OpTypeInt 32 0
|
||||
%_ptr_Private_uint = OpTypePointer Private %uint
|
||||
%12 = OpConstantNull %uint
|
||||
%u32_var = OpVariable %_ptr_Private_uint Private %12
|
||||
%float = OpTypeFloat 32
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%16 = OpConstantNull %float
|
||||
%f32_var = OpVariable %_ptr_Private_float Private %16
|
||||
%v2int = OpTypeVector %int 2
|
||||
%_ptr_Private_v2int = OpTypePointer Private %v2int
|
||||
%20 = OpConstantNull %v2int
|
||||
%v2i32_var = OpVariable %_ptr_Private_v2int Private %20
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%_ptr_Private_v3uint = OpTypePointer Private %v3uint
|
||||
%24 = OpConstantNull %v3uint
|
||||
%v3u32_var = OpVariable %_ptr_Private_v3uint Private %24
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Private_v4float = OpTypePointer Private %v4float
|
||||
%28 = OpConstantNull %v4float
|
||||
%v4f32_var = OpVariable %_ptr_Private_v4float Private %28
|
||||
%v3float = OpTypeVector %float 3
|
||||
%mat2v3float = OpTypeMatrix %v3float 2
|
||||
%_ptr_Private_mat2v3float = OpTypePointer Private %mat2v3float
|
||||
%33 = OpConstantNull %mat2v3float
|
||||
%m2x3_var = OpVariable %_ptr_Private_mat2v3float Private %33
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%_arr_float_uint_4 = OpTypeArray %float %uint_4
|
||||
%_ptr_Private__arr_float_uint_4 = OpTypePointer Private %_arr_float_uint_4
|
||||
%38 = OpConstantNull %_arr_float_uint_4
|
||||
%arr_var = OpVariable %_ptr_Private__arr_float_uint_4 Private %38
|
||||
%S = OpTypeStruct
|
||||
%_ptr_Private_S = OpTypePointer Private %S
|
||||
%42 = OpConstantNull %S
|
||||
%struct_var = OpVariable %_ptr_Private_S Private %42
|
||||
%void = OpTypeVoid
|
||||
%43 = OpTypeFunction %void
|
||||
%main = OpFunction %void None %43
|
||||
%46 = OpLabel
|
||||
OpStore %bool_var %4
|
||||
OpStore %i32_var %8
|
||||
OpStore %u32_var %12
|
||||
OpStore %f32_var %16
|
||||
OpStore %v2i32_var %20
|
||||
OpStore %v3u32_var %24
|
||||
OpStore %v4f32_var %28
|
||||
OpStore %m2x3_var %33
|
||||
OpStore %arr_var %38
|
||||
OpStore %struct_var %42
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
36
test/types/module_scope_var.wgsl.expected.wgsl
Normal file
36
test/types/module_scope_var.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,36 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
var<private> bool_var : bool;
|
||||
|
||||
var<private> i32_var : i32;
|
||||
|
||||
var<private> u32_var : u32;
|
||||
|
||||
var<private> f32_var : f32;
|
||||
|
||||
var<private> v2i32_var : vec2<i32>;
|
||||
|
||||
var<private> v3u32_var : vec3<u32>;
|
||||
|
||||
var<private> v4f32_var : vec4<f32>;
|
||||
|
||||
var<private> m2x3_var : mat2x3<f32>;
|
||||
|
||||
var<private> arr_var : array<f32, 4>;
|
||||
|
||||
var<private> struct_var : S;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
bool_var = bool();
|
||||
i32_var = i32();
|
||||
u32_var = u32();
|
||||
f32_var = f32();
|
||||
v2i32_var = vec2<i32>();
|
||||
v3u32_var = vec3<u32>();
|
||||
v4f32_var = vec4<f32>();
|
||||
m2x3_var = mat2x3<f32>();
|
||||
arr_var = array<f32, 4>();
|
||||
struct_var = S();
|
||||
}
|
||||
@@ -2,26 +2,27 @@ struct S {
|
||||
};
|
||||
|
||||
var<private> bool_var : bool = bool();
|
||||
let bool_let : bool = bool();
|
||||
var<private> i32_var : i32 = i32();
|
||||
let i32_let : i32 = i32();
|
||||
var<private> u32_var : u32 = u32();
|
||||
let u32_let : u32 = u32();
|
||||
var<private> f32_var : f32 = f32();
|
||||
let f32_let : f32 = f32();
|
||||
var<private> v2i32_var : vec2<i32> = vec2<i32>();
|
||||
let v2i32_let : vec2<i32> = vec2<i32>();
|
||||
var<private> v3u32_var : vec3<u32> = vec3<u32>();
|
||||
let v3u32_let : vec3<u32> = vec3<u32>();
|
||||
var<private> v4f32_var : vec4<f32> = vec4<f32>();
|
||||
let v4f32_let : vec4<f32> = vec4<f32>();
|
||||
var<private> m2x3_var : mat2x3<f32> = mat2x3<f32>();
|
||||
let m3x4_let : mat3x4<f32> = mat3x4<f32>();
|
||||
var<private> arr_var : array<f32, 4> = array<f32, 4>();
|
||||
let arr_let : array<f32, 4> = array<f32, 4>();
|
||||
var<private> struct_var : S = S();
|
||||
let struct_let : S = S();
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
// Reference the module-scope variables to stop them from being removed.
|
||||
bool_var = bool();
|
||||
i32_var = i32();
|
||||
u32_var = u32();
|
||||
f32_var = f32();
|
||||
v2i32_var = vec2<i32>();
|
||||
v3u32_var = vec3<u32>();
|
||||
v4f32_var = vec4<f32>();
|
||||
m2x3_var = mat2x3<f32>();
|
||||
arr_var = array<f32, 4>();
|
||||
struct_var = S();
|
||||
}
|
||||
31
test/types/module_scope_var_initializers.wgsl.expected.hlsl
Normal file
31
test/types/module_scope_var_initializers.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,31 @@
|
||||
struct S {
|
||||
};
|
||||
|
||||
static bool bool_var = false;
|
||||
static int i32_var = 0;
|
||||
static uint u32_var = 0u;
|
||||
static float f32_var = 0.0f;
|
||||
static int2 v2i32_var = int2(0, 0);
|
||||
static uint3 v3u32_var = uint3(0u, 0u, 0u);
|
||||
static float4 v4f32_var = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
static float2x3 m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
static float arr_var[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
static S struct_var = {};
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
bool_var = false;
|
||||
i32_var = 0;
|
||||
u32_var = 0u;
|
||||
f32_var = 0.0f;
|
||||
v2i32_var = int2(0, 0);
|
||||
v3u32_var = uint3(0u, 0u, 0u);
|
||||
v4f32_var = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
const float tint_symbol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
arr_var = tint_symbol;
|
||||
const S tint_symbol_1 = {};
|
||||
struct_var = tint_symbol_1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
SKIP: crbug.com/tint/814
|
||||
@@ -1,82 +1,80 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 49
|
||||
; Bound: 47
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %bool_var "bool_var"
|
||||
OpName %bool_let "bool_let"
|
||||
OpName %i32_var "i32_var"
|
||||
OpName %i32_let "i32_let"
|
||||
OpName %u32_var "u32_var"
|
||||
OpName %u32_let "u32_let"
|
||||
OpName %f32_var "f32_var"
|
||||
OpName %f32_let "f32_let"
|
||||
OpName %v2i32_var "v2i32_var"
|
||||
OpName %v2i32_let "v2i32_let"
|
||||
OpName %v3u32_var "v3u32_var"
|
||||
OpName %v3u32_let "v3u32_let"
|
||||
OpName %v4f32_var "v4f32_var"
|
||||
OpName %v4f32_let "v4f32_let"
|
||||
OpName %m2x3_var "m2x3_var"
|
||||
OpName %m3x4_let "m3x4_let"
|
||||
OpName %arr_var "arr_var"
|
||||
OpName %arr_let "arr_let"
|
||||
OpName %S "S"
|
||||
OpName %struct_var "struct_var"
|
||||
OpName %struct_let "struct_let"
|
||||
OpName %main "main"
|
||||
OpDecorate %_arr_float_uint_4 ArrayStride 4
|
||||
%bool = OpTypeBool
|
||||
%bool_let = OpConstantNull %bool
|
||||
%2 = OpConstantNull %bool
|
||||
%_ptr_Private_bool = OpTypePointer Private %bool
|
||||
%bool_var = OpVariable %_ptr_Private_bool Private %bool_let
|
||||
%bool_var = OpVariable %_ptr_Private_bool Private %2
|
||||
%int = OpTypeInt 32 1
|
||||
%i32_let = OpConstantNull %int
|
||||
%6 = OpConstantNull %int
|
||||
%_ptr_Private_int = OpTypePointer Private %int
|
||||
%i32_var = OpVariable %_ptr_Private_int Private %i32_let
|
||||
%i32_var = OpVariable %_ptr_Private_int Private %6
|
||||
%uint = OpTypeInt 32 0
|
||||
%u32_let = OpConstantNull %uint
|
||||
%10 = OpConstantNull %uint
|
||||
%_ptr_Private_uint = OpTypePointer Private %uint
|
||||
%u32_var = OpVariable %_ptr_Private_uint Private %u32_let
|
||||
%u32_var = OpVariable %_ptr_Private_uint Private %10
|
||||
%float = OpTypeFloat 32
|
||||
%f32_let = OpConstantNull %float
|
||||
%14 = OpConstantNull %float
|
||||
%_ptr_Private_float = OpTypePointer Private %float
|
||||
%f32_var = OpVariable %_ptr_Private_float Private %f32_let
|
||||
%f32_var = OpVariable %_ptr_Private_float Private %14
|
||||
%v2int = OpTypeVector %int 2
|
||||
%v2i32_let = OpConstantNull %v2int
|
||||
%18 = OpConstantNull %v2int
|
||||
%_ptr_Private_v2int = OpTypePointer Private %v2int
|
||||
%v2i32_var = OpVariable %_ptr_Private_v2int Private %v2i32_let
|
||||
%v2i32_var = OpVariable %_ptr_Private_v2int Private %18
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%v3u32_let = OpConstantNull %v3uint
|
||||
%22 = OpConstantNull %v3uint
|
||||
%_ptr_Private_v3uint = OpTypePointer Private %v3uint
|
||||
%v3u32_var = OpVariable %_ptr_Private_v3uint Private %v3u32_let
|
||||
%v3u32_var = OpVariable %_ptr_Private_v3uint Private %22
|
||||
%v4float = OpTypeVector %float 4
|
||||
%v4f32_let = OpConstantNull %v4float
|
||||
%26 = OpConstantNull %v4float
|
||||
%_ptr_Private_v4float = OpTypePointer Private %v4float
|
||||
%v4f32_var = OpVariable %_ptr_Private_v4float Private %v4f32_let
|
||||
%v4f32_var = OpVariable %_ptr_Private_v4float Private %26
|
||||
%v3float = OpTypeVector %float 3
|
||||
%mat2v3float = OpTypeMatrix %v3float 2
|
||||
%31 = OpConstantNull %mat2v3float
|
||||
%_ptr_Private_mat2v3float = OpTypePointer Private %mat2v3float
|
||||
%m2x3_var = OpVariable %_ptr_Private_mat2v3float Private %31
|
||||
%mat3v4float = OpTypeMatrix %v4float 3
|
||||
%m3x4_let = OpConstantNull %mat3v4float
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%_arr_float_uint_4 = OpTypeArray %float %uint_4
|
||||
%arr_let = OpConstantNull %_arr_float_uint_4
|
||||
%36 = OpConstantNull %_arr_float_uint_4
|
||||
%_ptr_Private__arr_float_uint_4 = OpTypePointer Private %_arr_float_uint_4
|
||||
%arr_var = OpVariable %_ptr_Private__arr_float_uint_4 Private %arr_let
|
||||
%arr_var = OpVariable %_ptr_Private__arr_float_uint_4 Private %36
|
||||
%S = OpTypeStruct
|
||||
%struct_let = OpConstantNull %S
|
||||
%40 = OpConstantNull %S
|
||||
%_ptr_Private_S = OpTypePointer Private %S
|
||||
%struct_var = OpVariable %_ptr_Private_S Private %struct_let
|
||||
%struct_var = OpVariable %_ptr_Private_S Private %40
|
||||
%void = OpTypeVoid
|
||||
%45 = OpTypeFunction %void
|
||||
%main = OpFunction %void None %45
|
||||
%48 = OpLabel
|
||||
%43 = OpTypeFunction %void
|
||||
%main = OpFunction %void None %43
|
||||
%46 = OpLabel
|
||||
OpStore %bool_var %2
|
||||
OpStore %i32_var %6
|
||||
OpStore %u32_var %10
|
||||
OpStore %f32_var %14
|
||||
OpStore %v2i32_var %18
|
||||
OpStore %v3u32_var %22
|
||||
OpStore %v4f32_var %26
|
||||
OpStore %m2x3_var %31
|
||||
OpStore %arr_var %36
|
||||
OpStore %struct_var %40
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -3,44 +3,34 @@ struct S {
|
||||
|
||||
var<private> bool_var : bool = bool();
|
||||
|
||||
let bool_let : bool = bool();
|
||||
|
||||
var<private> i32_var : i32 = i32();
|
||||
|
||||
let i32_let : i32 = i32();
|
||||
|
||||
var<private> u32_var : u32 = u32();
|
||||
|
||||
let u32_let : u32 = u32();
|
||||
|
||||
var<private> f32_var : f32 = f32();
|
||||
|
||||
let f32_let : f32 = f32();
|
||||
|
||||
var<private> v2i32_var : vec2<i32> = vec2<i32>();
|
||||
|
||||
let v2i32_let : vec2<i32> = vec2<i32>();
|
||||
|
||||
var<private> v3u32_var : vec3<u32> = vec3<u32>();
|
||||
|
||||
let v3u32_let : vec3<u32> = vec3<u32>();
|
||||
|
||||
var<private> v4f32_var : vec4<f32> = vec4<f32>();
|
||||
|
||||
let v4f32_let : vec4<f32> = vec4<f32>();
|
||||
|
||||
var<private> m2x3_var : mat2x3<f32> = mat2x3<f32>();
|
||||
|
||||
let m3x4_let : mat3x4<f32> = mat3x4<f32>();
|
||||
|
||||
var<private> arr_var : array<f32, 4> = array<f32, 4>();
|
||||
|
||||
let arr_let : array<f32, 4> = array<f32, 4>();
|
||||
|
||||
var<private> struct_var : S = S();
|
||||
|
||||
let struct_let : S = S();
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main() {
|
||||
bool_var = bool();
|
||||
i32_var = i32();
|
||||
u32_var = u32();
|
||||
f32_var = f32();
|
||||
v2i32_var = vec2<i32>();
|
||||
v3u32_var = vec3<u32>();
|
||||
v4f32_var = vec4<f32>();
|
||||
m2x3_var = mat2x3<f32>();
|
||||
arr_var = array<f32, 4>();
|
||||
struct_var = S();
|
||||
}
|
||||
49
test/var/private.wgsl
Normal file
49
test/var/private.wgsl
Normal file
@@ -0,0 +1,49 @@
|
||||
var<private> a : i32;
|
||||
var<private> b : i32;
|
||||
var<private> c : i32; // unused
|
||||
|
||||
fn uses_a() {
|
||||
a = a + 1;
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
b = b * 2;
|
||||
}
|
||||
|
||||
fn uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main4() {
|
||||
no_uses();
|
||||
}
|
||||
54
test/var/private.wgsl.expected.hlsl
Normal file
54
test/var/private.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,54 @@
|
||||
static int a;
|
||||
|
||||
static int b;
|
||||
|
||||
void uses_a() {
|
||||
a = (a + 1);
|
||||
}
|
||||
|
||||
void uses_b() {
|
||||
b = (b * 2);
|
||||
}
|
||||
|
||||
void uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
void no_uses() {
|
||||
}
|
||||
|
||||
void outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main4() {
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
57
test/var/private.wgsl.expected.msl
Normal file
57
test/var/private.wgsl.expected.msl
Normal file
@@ -0,0 +1,57 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void uses_a(thread int* const tint_symbol) {
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
}
|
||||
|
||||
void uses_b(thread int* const tint_symbol_1) {
|
||||
*(tint_symbol_1) = (*(tint_symbol_1) * 2);
|
||||
}
|
||||
|
||||
void uses_a_and_b(thread int* const tint_symbol_2, thread int* const tint_symbol_3) {
|
||||
*(tint_symbol_2) = *(tint_symbol_3);
|
||||
}
|
||||
|
||||
void no_uses() {
|
||||
}
|
||||
|
||||
void outer(thread int* const tint_symbol_4, thread int* const tint_symbol_5) {
|
||||
*(tint_symbol_4) = 0;
|
||||
uses_a(tint_symbol_4);
|
||||
uses_a_and_b(tint_symbol_5, tint_symbol_4);
|
||||
uses_b(tint_symbol_5);
|
||||
no_uses();
|
||||
}
|
||||
|
||||
kernel void main1() {
|
||||
thread int tint_symbol_7 = 0;
|
||||
thread int* const tint_symbol_6 = &(tint_symbol_7);
|
||||
*(tint_symbol_6) = 42;
|
||||
uses_a(tint_symbol_6);
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main2() {
|
||||
thread int tint_symbol_9 = 0;
|
||||
thread int* const tint_symbol_8 = &(tint_symbol_9);
|
||||
*(tint_symbol_8) = 7;
|
||||
uses_b(tint_symbol_8);
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main3() {
|
||||
thread int tint_symbol_11 = 0;
|
||||
thread int* const tint_symbol_10 = &(tint_symbol_11);
|
||||
thread int tint_symbol_13 = 0;
|
||||
thread int* const tint_symbol_12 = &(tint_symbol_13);
|
||||
outer(tint_symbol_10, tint_symbol_12);
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main4() {
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
96
test/var/private.wgsl.expected.spvasm
Normal file
96
test/var/private.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,96 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 46
|
||||
; 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 "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
OpName %uses_a "uses_a"
|
||||
OpName %uses_b "uses_b"
|
||||
OpName %uses_a_and_b "uses_a_and_b"
|
||||
OpName %no_uses "no_uses"
|
||||
OpName %outer "outer"
|
||||
OpName %main1 "main1"
|
||||
OpName %main2 "main2"
|
||||
OpName %main3 "main3"
|
||||
OpName %main4 "main4"
|
||||
%int = OpTypeInt 32 1
|
||||
%_ptr_Private_int = OpTypePointer Private %int
|
||||
%4 = OpConstantNull %int
|
||||
%a = OpVariable %_ptr_Private_int Private %4
|
||||
%b = OpVariable %_ptr_Private_int Private %4
|
||||
%c = OpVariable %_ptr_Private_int Private %4
|
||||
%void = OpTypeVoid
|
||||
%7 = OpTypeFunction %void
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_42 = OpConstant %int 42
|
||||
%int_7 = OpConstant %int 7
|
||||
%uses_a = OpFunction %void None %7
|
||||
%10 = OpLabel
|
||||
%11 = OpLoad %int %a
|
||||
%13 = OpIAdd %int %11 %int_1
|
||||
OpStore %a %13
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_b = OpFunction %void None %7
|
||||
%15 = OpLabel
|
||||
%16 = OpLoad %int %b
|
||||
%18 = OpIMul %int %16 %int_2
|
||||
OpStore %b %18
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_a_and_b = OpFunction %void None %7
|
||||
%20 = OpLabel
|
||||
%21 = OpLoad %int %a
|
||||
OpStore %b %21
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%no_uses = OpFunction %void None %7
|
||||
%23 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%outer = OpFunction %void None %7
|
||||
%25 = OpLabel
|
||||
OpStore %a %int_0
|
||||
%27 = OpFunctionCall %void %uses_a
|
||||
%28 = OpFunctionCall %void %uses_a_and_b
|
||||
%29 = OpFunctionCall %void %uses_b
|
||||
%30 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main1 = OpFunction %void None %7
|
||||
%32 = OpLabel
|
||||
OpStore %a %int_42
|
||||
%34 = OpFunctionCall %void %uses_a
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main2 = OpFunction %void None %7
|
||||
%36 = OpLabel
|
||||
OpStore %b %int_7
|
||||
%38 = OpFunctionCall %void %uses_b
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main3 = OpFunction %void None %7
|
||||
%40 = OpLabel
|
||||
%41 = OpFunctionCall %void %outer
|
||||
%42 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main4 = OpFunction %void None %7
|
||||
%44 = OpLabel
|
||||
%45 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
51
test/var/private.wgsl.expected.wgsl
Normal file
51
test/var/private.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,51 @@
|
||||
var<private> a : i32;
|
||||
|
||||
var<private> b : i32;
|
||||
|
||||
var<private> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
a = (a + 1);
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
b = (b * 2);
|
||||
}
|
||||
|
||||
fn uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main4() {
|
||||
no_uses();
|
||||
}
|
||||
49
test/var/workgroup.wgsl
Normal file
49
test/var/workgroup.wgsl
Normal file
@@ -0,0 +1,49 @@
|
||||
var<workgroup> a : i32;
|
||||
var<workgroup> b : i32;
|
||||
var<workgroup> c : i32; // unused
|
||||
|
||||
fn uses_a() {
|
||||
a = a + 1;
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
b = b * 2;
|
||||
}
|
||||
|
||||
fn uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main4() {
|
||||
no_uses();
|
||||
}
|
||||
54
test/var/workgroup.wgsl.expected.hlsl
Normal file
54
test/var/workgroup.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,54 @@
|
||||
groupshared int a;
|
||||
|
||||
groupshared int b;
|
||||
|
||||
void uses_a() {
|
||||
a = (a + 1);
|
||||
}
|
||||
|
||||
void uses_b() {
|
||||
b = (b * 2);
|
||||
}
|
||||
|
||||
void uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
void no_uses() {
|
||||
}
|
||||
|
||||
void outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main4() {
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
57
test/var/workgroup.wgsl.expected.msl
Normal file
57
test/var/workgroup.wgsl.expected.msl
Normal file
@@ -0,0 +1,57 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void uses_a(threadgroup int* const tint_symbol) {
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
}
|
||||
|
||||
void uses_b(threadgroup int* const tint_symbol_1) {
|
||||
*(tint_symbol_1) = (*(tint_symbol_1) * 2);
|
||||
}
|
||||
|
||||
void uses_a_and_b(threadgroup int* const tint_symbol_2, threadgroup int* const tint_symbol_3) {
|
||||
*(tint_symbol_2) = *(tint_symbol_3);
|
||||
}
|
||||
|
||||
void no_uses() {
|
||||
}
|
||||
|
||||
void outer(threadgroup int* const tint_symbol_4, threadgroup int* const tint_symbol_5) {
|
||||
*(tint_symbol_4) = 0;
|
||||
uses_a(tint_symbol_4);
|
||||
uses_a_and_b(tint_symbol_5, tint_symbol_4);
|
||||
uses_b(tint_symbol_5);
|
||||
no_uses();
|
||||
}
|
||||
|
||||
kernel void main1() {
|
||||
threadgroup int tint_symbol_7 = 0;
|
||||
threadgroup int* const tint_symbol_6 = &(tint_symbol_7);
|
||||
*(tint_symbol_6) = 42;
|
||||
uses_a(tint_symbol_6);
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main2() {
|
||||
threadgroup int tint_symbol_9 = 0;
|
||||
threadgroup int* const tint_symbol_8 = &(tint_symbol_9);
|
||||
*(tint_symbol_8) = 7;
|
||||
uses_b(tint_symbol_8);
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main3() {
|
||||
threadgroup int tint_symbol_11 = 0;
|
||||
threadgroup int* const tint_symbol_10 = &(tint_symbol_11);
|
||||
threadgroup int tint_symbol_13 = 0;
|
||||
threadgroup int* const tint_symbol_12 = &(tint_symbol_13);
|
||||
outer(tint_symbol_10, tint_symbol_12);
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
kernel void main4() {
|
||||
no_uses();
|
||||
return;
|
||||
}
|
||||
|
||||
95
test/var/workgroup.wgsl.expected.spvasm
Normal file
95
test/var/workgroup.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,95 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 45
|
||||
; 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 "a"
|
||||
OpName %b "b"
|
||||
OpName %c "c"
|
||||
OpName %uses_a "uses_a"
|
||||
OpName %uses_b "uses_b"
|
||||
OpName %uses_a_and_b "uses_a_and_b"
|
||||
OpName %no_uses "no_uses"
|
||||
OpName %outer "outer"
|
||||
OpName %main1 "main1"
|
||||
OpName %main2 "main2"
|
||||
OpName %main3 "main3"
|
||||
OpName %main4 "main4"
|
||||
%int = OpTypeInt 32 1
|
||||
%_ptr_Workgroup_int = OpTypePointer Workgroup %int
|
||||
%a = OpVariable %_ptr_Workgroup_int Workgroup
|
||||
%b = OpVariable %_ptr_Workgroup_int Workgroup
|
||||
%c = OpVariable %_ptr_Workgroup_int Workgroup
|
||||
%void = OpTypeVoid
|
||||
%6 = OpTypeFunction %void
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_42 = OpConstant %int 42
|
||||
%int_7 = OpConstant %int 7
|
||||
%uses_a = OpFunction %void None %6
|
||||
%9 = OpLabel
|
||||
%10 = OpLoad %int %a
|
||||
%12 = OpIAdd %int %10 %int_1
|
||||
OpStore %a %12
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_b = OpFunction %void None %6
|
||||
%14 = OpLabel
|
||||
%15 = OpLoad %int %b
|
||||
%17 = OpIMul %int %15 %int_2
|
||||
OpStore %b %17
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%uses_a_and_b = OpFunction %void None %6
|
||||
%19 = OpLabel
|
||||
%20 = OpLoad %int %a
|
||||
OpStore %b %20
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%no_uses = OpFunction %void None %6
|
||||
%22 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%outer = OpFunction %void None %6
|
||||
%24 = OpLabel
|
||||
OpStore %a %int_0
|
||||
%26 = OpFunctionCall %void %uses_a
|
||||
%27 = OpFunctionCall %void %uses_a_and_b
|
||||
%28 = OpFunctionCall %void %uses_b
|
||||
%29 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main1 = OpFunction %void None %6
|
||||
%31 = OpLabel
|
||||
OpStore %a %int_42
|
||||
%33 = OpFunctionCall %void %uses_a
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main2 = OpFunction %void None %6
|
||||
%35 = OpLabel
|
||||
OpStore %b %int_7
|
||||
%37 = OpFunctionCall %void %uses_b
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main3 = OpFunction %void None %6
|
||||
%39 = OpLabel
|
||||
%40 = OpFunctionCall %void %outer
|
||||
%41 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main4 = OpFunction %void None %6
|
||||
%43 = OpLabel
|
||||
%44 = OpFunctionCall %void %no_uses
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
51
test/var/workgroup.wgsl.expected.wgsl
Normal file
51
test/var/workgroup.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,51 @@
|
||||
var<workgroup> a : i32;
|
||||
|
||||
var<workgroup> b : i32;
|
||||
|
||||
var<workgroup> c : i32;
|
||||
|
||||
fn uses_a() {
|
||||
a = (a + 1);
|
||||
}
|
||||
|
||||
fn uses_b() {
|
||||
b = (b * 2);
|
||||
}
|
||||
|
||||
fn uses_a_and_b() {
|
||||
b = a;
|
||||
}
|
||||
|
||||
fn no_uses() {
|
||||
}
|
||||
|
||||
fn outer() {
|
||||
a = 0;
|
||||
uses_a();
|
||||
uses_a_and_b();
|
||||
uses_b();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main1() {
|
||||
a = 42;
|
||||
uses_a();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main2() {
|
||||
b = 7;
|
||||
uses_b();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main3() {
|
||||
outer();
|
||||
no_uses();
|
||||
}
|
||||
|
||||
[[stage(compute)]]
|
||||
fn main4() {
|
||||
no_uses();
|
||||
}
|
||||
Reference in New Issue
Block a user