Allow non-struct buffer store types

For SPIR-V, wrap non-struct types in structs in the
AddSpirvBlockDecoration transform.

For MSL, wrap runtime-sized arrays in structs in the
ModuleScopeVarToEntryPointParam transform.

Bug: tint:1372
Change-Id: Icced5d77b4538e816aa9fab57a634a9f4c52fdab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/76162
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price
2022-01-19 15:55:56 +00:00
parent c3cec4d901
commit 7395e29e70
132 changed files with 2309 additions and 143 deletions

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : array<vec4<f32>, 4>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,21 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
typedef float4 tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
float4 arr[4] = (float4[4])0;
{
[loop] for(uint i = 0u; (i < 4u); i = (i + 1u)) {
const uint scalar_offset = ((offset + (i * 16u))) / 4;
arr[i] = asfloat(buffer[scalar_offset / 4]);
}
}
return arr;
}
[numthreads(1, 1, 1)]
void main() {
const float4 x[4] = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,12 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
/* 0x0000 */ float4 arr[4];
};
kernel void tint_symbol(const constant tint_array_wrapper* tint_symbol_1 [[buffer(0)]]) {
tint_array_wrapper const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,37 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 17
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %_arr_v4float_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4
%u_block = OpTypeStruct %_arr_v4float_uint_4
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform__arr_v4float_uint_4 = OpTypePointer Uniform %_arr_v4float_uint_4
%main = OpFunction %void None %9
%12 = OpLabel
%15 = OpAccessChain %_ptr_Uniform__arr_v4float_uint_4 %u %uint_0
%16 = OpLoad %_arr_v4float_uint_4 %15
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : array<vec4<f32>, 4>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : f32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const float x = asfloat(u[0].x);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float* tint_symbol_1 [[buffer(0)]]) {
float const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%u_block = OpTypeStruct %float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%5 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%main = OpFunction %void None %5
%8 = OpLabel
%12 = OpAccessChain %_ptr_Uniform_float %u %uint_0
%13 = OpLoad %float %12
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : f32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : i32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const int x = asint(u[0].x);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant int* tint_symbol_1 [[buffer(0)]]) {
int const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%int = OpTypeInt 32 1
%u_block = OpTypeStruct %int
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%5 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%main = OpFunction %void None %5
%8 = OpLabel
%12 = OpAccessChain %_ptr_Uniform_int %u %uint_0
%13 = OpLoad %int %12
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : i32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : mat2x2<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,17 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
float2x2 tint_symbol(uint4 buffer[1], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load = buffer[scalar_offset / 4];
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset_1 / 4];
return float2x2(asfloat(((scalar_offset & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_1 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
}
[numthreads(1, 1, 1)]
void main() {
const float2x2 x = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float2x2* tint_symbol_1 [[buffer(0)]]) {
float2x2 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,37 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpMemberDecorate %u_block 0 ColMajor
OpMemberDecorate %u_block 0 MatrixStride 8
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%u_block = OpTypeStruct %mat2v2float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%7 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat2v2float = OpTypePointer Uniform %mat2v2float
%main = OpFunction %void None %7
%10 = OpLabel
%14 = OpAccessChain %_ptr_Uniform_mat2v2float %u %uint_0
%15 = OpLoad %mat2v2float %14
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : mat2x2<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : mat2x3<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,15 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[2];
};
float2x3 tint_symbol(uint4 buffer[2], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
return float2x3(asfloat(buffer[scalar_offset / 4].xyz), asfloat(buffer[scalar_offset_1 / 4].xyz));
}
[numthreads(1, 1, 1)]
void main() {
const float2x3 x = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float2x3* tint_symbol_1 [[buffer(0)]]) {
float2x3 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,37 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpMemberDecorate %u_block 0 ColMajor
OpMemberDecorate %u_block 0 MatrixStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%u_block = OpTypeStruct %mat2v3float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%7 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float
%main = OpFunction %void None %7
%10 = OpLabel
%14 = OpAccessChain %_ptr_Uniform_mat2v3float %u %uint_0
%15 = OpLoad %mat2v3float %14
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : mat2x3<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : mat3x2<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,19 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[2];
};
float3x2 tint_symbol(uint4 buffer[2], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load = buffer[scalar_offset / 4];
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset_1 / 4];
const uint scalar_offset_2 = ((offset + 16u)) / 4;
uint4 ubo_load_2 = buffer[scalar_offset_2 / 4];
return float3x2(asfloat(((scalar_offset & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_1 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_2 & 2) ? ubo_load_2.zw : ubo_load_2.xy)));
}
[numthreads(1, 1, 1)]
void main() {
const float3x2 x = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float3x2* tint_symbol_1 [[buffer(0)]]) {
float3x2 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,37 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpMemberDecorate %u_block 0 ColMajor
OpMemberDecorate %u_block 0 MatrixStride 8
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat3v2float = OpTypeMatrix %v2float 3
%u_block = OpTypeStruct %mat3v2float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%7 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat3v2float = OpTypePointer Uniform %mat3v2float
%main = OpFunction %void None %7
%10 = OpLabel
%14 = OpAccessChain %_ptr_Uniform_mat3v2float %u %uint_0
%15 = OpLoad %mat3v2float %14
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : mat3x2<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : mat4x4<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,17 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
float4x4 tint_symbol(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
const uint scalar_offset_1 = ((offset + 16u)) / 4;
const uint scalar_offset_2 = ((offset + 32u)) / 4;
const uint scalar_offset_3 = ((offset + 48u)) / 4;
return float4x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]), asfloat(buffer[scalar_offset_3 / 4]));
}
[numthreads(1, 1, 1)]
void main() {
const float4x4 x = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float4x4* tint_symbol_1 [[buffer(0)]]) {
float4x4 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,37 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 16
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpMemberDecorate %u_block 0 ColMajor
OpMemberDecorate %u_block 0 MatrixStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%mat4v4float = OpTypeMatrix %v4float 4
%u_block = OpTypeStruct %mat4v4float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%7 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%main = OpFunction %void None %7
%10 = OpLabel
%14 = OpAccessChain %_ptr_Uniform_mat4v4float %u %uint_0
%15 = OpLoad %mat4v4float %14
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : mat4x4<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,14 @@
struct Inner {
f : f32;
};
struct S {
inner : Inner;
};
[[group(0), binding(0)]]
var<uniform> u : S;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,27 @@
struct Inner {
float f;
};
struct S {
Inner inner;
};
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
Inner tint_symbol_1(uint4 buffer[1], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
const Inner tint_symbol_3 = {asfloat(buffer[scalar_offset / 4][scalar_offset % 4])};
return tint_symbol_3;
}
S tint_symbol(uint4 buffer[1], uint offset) {
const S tint_symbol_4 = {tint_symbol_1(buffer, (offset + 0u))};
return tint_symbol_4;
}
[numthreads(1, 1, 1)]
void main() {
const S x = tint_symbol(u, 0u);
return;
}

View File

@@ -0,0 +1,15 @@
#include <metal_stdlib>
using namespace metal;
struct Inner {
/* 0x0000 */ float f;
};
struct S {
/* 0x0000 */ Inner inner;
};
kernel void tint_symbol(const constant S* tint_symbol_1 [[buffer(0)]]) {
S const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 11
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %S "S"
OpMemberName %S 0 "inner"
OpName %Inner "Inner"
OpMemberName %Inner 0 "f"
OpName %u "u"
OpName %main "main"
OpDecorate %S Block
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %Inner 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%Inner = OpTypeStruct %float
%S = OpTypeStruct %Inner
%_ptr_Uniform_S = OpTypePointer Uniform %S
%u = OpVariable %_ptr_Uniform_S Uniform
%void = OpTypeVoid
%6 = OpTypeFunction %void
%main = OpFunction %void None %6
%9 = OpLabel
%10 = OpLoad %S %u
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,14 @@
struct Inner {
f : f32;
};
struct S {
inner : Inner;
};
[[group(0), binding(0)]] var<uniform> u : S;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : u32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const uint x = u[0].x;
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant uint* tint_symbol_1 [[buffer(0)]]) {
uint const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,32 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%uint = OpTypeInt 32 0
%u_block = OpTypeStruct %uint
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%5 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
%main = OpFunction %void None %5
%8 = OpLabel
%11 = OpAccessChain %_ptr_Uniform_uint %u %uint_0
%12 = OpLoad %uint %11
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : u32;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : vec2<i32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const int2 x = asint(u[0].xy);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant int2* tint_symbol_1 [[buffer(0)]]) {
int2 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,34 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%int = OpTypeInt 32 1
%v2int = OpTypeVector %int 2
%u_block = OpTypeStruct %v2int
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%6 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%main = OpFunction %void None %6
%9 = OpLabel
%13 = OpAccessChain %_ptr_Uniform_v2int %u %uint_0
%14 = OpLoad %v2int %13
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : vec2<i32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : vec3<u32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const uint3 x = u[0].xyz;
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant uint3* tint_symbol_1 [[buffer(0)]]) {
uint3 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%u_block = OpTypeStruct %v3uint
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%6 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_v3uint = OpTypePointer Uniform %v3uint
%main = OpFunction %void None %6
%9 = OpLabel
%12 = OpAccessChain %_ptr_Uniform_v3uint %u %uint_0
%13 = OpLoad %v3uint %12
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : vec3<u32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,7 @@
[[group(0), binding(0)]]
var<uniform> u : vec4<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}

View File

@@ -0,0 +1,9 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[1];
};
[numthreads(1, 1, 1)]
void main() {
const float4 x = asfloat(u[0]);
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol(const constant float4* tint_symbol_1 [[buffer(0)]]) {
float4 const x = *(tint_symbol_1);
return;
}

View File

@@ -0,0 +1,34 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 15
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %u "u"
OpName %main "main"
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%u_block = OpTypeStruct %v4float
%_ptr_Uniform_u_block = OpTypePointer Uniform %u_block
%u = OpVariable %_ptr_Uniform_u_block Uniform
%void = OpTypeVoid
%6 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%main = OpFunction %void None %6
%9 = OpLabel
%13 = OpAccessChain %_ptr_Uniform_v4float %u %uint_0
%14 = OpLoad %v4float %13
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[group(0), binding(0)]] var<uniform> u : vec4<f32>;
[[stage(compute), workgroup_size(1)]]
fn main() {
let x = u;
}