mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
Implement Pointers and References
This change implements pointers and references as described by the WGSL specification change in https://github.com/gpuweb/gpuweb/pull/1569. reader/spirv: * Now emits address-of `&expr` and indirection `*expr` operators as needed. * As an identifier may now resolve to a pointer or reference type depending on whether the declaration is a `var`, `let` or parameter, `Function::identifier_values_` has been changed from an ID set to an ID -> Type* map. resolver: * Now correctly resolves all expressions to either a value type, reference type or pointer type. * Validates pointer / reference rules on assignment, `var` and `let` construction, and usage. * Handles the address-of and indirection operators. * No longer does any implicit loads of pointer types. * Storage class validation is still TODO (crbug.com/tint/809) writer/spirv: * Correctly handles variables and expressions of pointer and reference types, emitting OpLoads where necessary. test: * Lots of new test cases Fixed: tint:727 Change-Id: I77d3281590e35e5a3122f5b74cdeb71a6fe51f74 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50740 Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
d1232670ae
commit
9b54a2e53c
@@ -2,7 +2,7 @@
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
const float x_24 = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))[1u].y;
|
||||
float const x_24 = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))[1u].y;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
const float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
const float3 v = m[1];
|
||||
const float f = v[1];
|
||||
float3x3 const m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
|
||||
float3 const v = m[1];
|
||||
float const f = v[1];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,24 +3,24 @@
|
||||
; 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 %main "main"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%10 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%v2float = OpTypeVector %float 2
|
||||
%main = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%11 = OpCompositeExtract %float %10 1
|
||||
%13 = OpVectorShuffle %v2float %10 %10 0 2
|
||||
%14 = OpVectorShuffle %v3float %10 %10 0 2 1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %main "main"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_3 = OpConstant %float 3
|
||||
%10 = OpConstantComposite %v3float %float_1 %float_2 %float_3
|
||||
%v2float = OpTypeVector %float 2
|
||||
%main = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%11 = OpCompositeExtract %float %10 1
|
||||
%13 = OpVectorShuffle %v2float %10 %10 0 2
|
||||
%14 = OpVectorShuffle %v3float %10 %10 0 2 1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
const float x_11 = float3(1.0f, 2.0f, 3.0f).y;
|
||||
const float2 x_13 = float2(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z);
|
||||
const float3 x_14 = float3(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z, float3(1.0f, 2.0f, 3.0f).y);
|
||||
float const x_11 = float3(1.0f, 2.0f, 3.0f).y;
|
||||
float2 const x_13 = float2(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z);
|
||||
float3 const x_14 = float3(float3(1.0f, 2.0f, 3.0f).x, float3(1.0f, 2.0f, 3.0f).z, float3(1.0f, 2.0f, 3.0f).y);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
const float3 v = float3(1.0f, 2.0f, 3.0f);
|
||||
const float scalar = v.y;
|
||||
const float2 swizzle2 = v.xz;
|
||||
const float3 swizzle3 = v.xzy;
|
||||
float3 const v = float3(1.0f, 2.0f, 3.0f);
|
||||
float const scalar = v.y;
|
||||
float2 const swizzle2 = v.xz;
|
||||
float3 const swizzle3 = v.xzy;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
float3x3 m = float3x3(float3(0.0f, 0.0f, 0.0f), float3(0.0f, 0.0f, 0.0f), float3(0.0f, 0.0f, 0.0f));
|
||||
const float3 x_15 = m[1];
|
||||
const float x_16 = x_15.y;
|
||||
float3 const x_15 = m[1];
|
||||
float const x_16 = x_15.y;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
float3x3 m = 0.0f;
|
||||
const float3 v = m[1];
|
||||
const float f = v[1];
|
||||
float3 const v = m[1];
|
||||
float const f = v[1];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,30 +3,30 @@
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 20
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %main "main"
|
||||
OpName %v "v"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %main "main"
|
||||
OpName %v "v"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||
%9 = OpConstantNull %v3float
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%v2float = OpTypeVector %float 2
|
||||
%main = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v3float Function %9
|
||||
%13 = OpAccessChain %_ptr_Function_float %v %uint_1
|
||||
%14 = OpLoad %float %13
|
||||
%16 = OpLoad %v3float %v
|
||||
%17 = OpVectorShuffle %v2float %16 %16 0 2
|
||||
%18 = OpLoad %v3float %v
|
||||
%19 = OpVectorShuffle %v3float %18 %18 0 2 1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%9 = OpConstantNull %v3float
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%v2float = OpTypeVector %float 2
|
||||
%main = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v3float Function %9
|
||||
%13 = OpAccessChain %_ptr_Function_float %v %uint_1
|
||||
%14 = OpLoad %float %13
|
||||
%16 = OpLoad %v3float %v
|
||||
%17 = OpVectorShuffle %v2float %16 %16 0 2
|
||||
%18 = OpLoad %v3float %v
|
||||
%19 = OpVectorShuffle %v3float %18 %18 0 2 1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
float3 v = float3(0.0f, 0.0f, 0.0f);
|
||||
const float x_14 = v.y;
|
||||
const float3 x_16 = v;
|
||||
const float2 x_17 = float2(x_16.x, x_16.z);
|
||||
const float3 x_18 = v;
|
||||
const float3 x_19 = float3(x_18.x, x_18.z, x_18.y);
|
||||
float const x_14 = v.y;
|
||||
float3 const x_16 = v;
|
||||
float2 const x_17 = float2(x_16.x, x_16.z);
|
||||
float3 const x_18 = v;
|
||||
float3 const x_19 = float3(x_18.x, x_18.z, x_18.y);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
float3 v = 0.0f;
|
||||
const float scalar = v.y;
|
||||
const float2 swizzle2 = v.xz;
|
||||
const float3 swizzle3 = v.xzy;
|
||||
float const scalar = v.y;
|
||||
float2 const swizzle2 = v.xz;
|
||||
float3 const swizzle3 = v.xzy;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user