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
@@ -33,9 +33,9 @@ struct tint_symbol_5 {
|
||||
};
|
||||
|
||||
vertex tint_symbol_2 vert_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
const float2 a_particlePos = tint_symbol.a_particlePos;
|
||||
const float2 a_particleVel = tint_symbol.a_particleVel;
|
||||
const float2 a_pos = tint_symbol.a_pos;
|
||||
float2 const a_particlePos = tint_symbol.a_particlePos;
|
||||
float2 const a_particleVel = tint_symbol.a_particleVel;
|
||||
float2 const a_pos = tint_symbol.a_pos;
|
||||
float angle = -( atan2(a_particleVel.x, a_particleVel.y));
|
||||
float2 pos = float2(((a_pos.x * cos(angle)) - (a_pos.y * sin(angle))), ((a_pos.x * sin(angle)) + (a_pos.y * cos(angle))));
|
||||
return {float4((pos + a_particlePos), 0.0f, 1.0f)};
|
||||
@@ -46,7 +46,7 @@ fragment tint_symbol_3 frag_main() {
|
||||
}
|
||||
|
||||
kernel void comp_main(tint_symbol_5 tint_symbol_4 [[stage_in]], constant SimParams& params [[buffer(0)]], device Particles& particlesA [[buffer(1)]], device Particles& particlesB [[buffer(2)]]) {
|
||||
const uint3 gl_GlobalInvocationID = tint_symbol_4.gl_GlobalInvocationID;
|
||||
uint3 const gl_GlobalInvocationID = tint_symbol_4.gl_GlobalInvocationID;
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
if ((index >= 5u)) {
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ struct tint_symbol_5 {
|
||||
};
|
||||
|
||||
vertex tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol [[stage_in]], constant Uniforms& uniforms [[buffer(0)]]) {
|
||||
const VertexInput input = {tint_symbol.cur_position, tint_symbol.color};
|
||||
VertexInput const input = {tint_symbol.cur_position, tint_symbol.color};
|
||||
VertexOutput output = {};
|
||||
output.Position = (uniforms.modelViewProjectionMatrix * input.cur_position);
|
||||
output.vtxFragColor = input.color;
|
||||
@@ -36,7 +36,7 @@ vertex tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol [[stage_in]], constant U
|
||||
}
|
||||
|
||||
fragment tint_symbol_5 frag_main(tint_symbol_4 tint_symbol_3 [[stage_in]]) {
|
||||
const float4 fragColor = tint_symbol_3.fragColor;
|
||||
float4 const fragColor = tint_symbol_3.fragColor;
|
||||
return {fragColor};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ struct tint_symbol_3 {
|
||||
|
||||
constant float2 pos[3] = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
|
||||
vertex tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol [[stage_in]]) {
|
||||
const int VertexIndex = tint_symbol.VertexIndex;
|
||||
int const VertexIndex = tint_symbol.VertexIndex;
|
||||
return {float4(pos[VertexIndex], 0.0f, 1.0f)};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user