From 520bccf8d8bac1d51ecb2391d06ec2c1f31a9613 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Tue, 25 Jan 2022 22:47:05 +0000 Subject: [PATCH] GLSL: implement builtin kNumWorkgroups. Bug: tint:1400 Change-Id: I5f2523d41f73abe55e57b8931833124c2ebaf00d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78260 Reviewed-by: Ben Clayton Kokoro: Kokoro Commit-Queue: Stephen White --- src/writer/glsl/generator_impl.cc | 3 +++ .../compute_input_builtins.wgsl.expected.glsl | 12 +----------- .../compute_input_builtins_struct.wgsl.expected.glsl | 12 +----------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index fa5e06bd4a..7a128d29bc 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -1787,6 +1787,7 @@ sem::Type* GeneratorImpl::builtin_type(ast::Builtin builtin) { } case ast::Builtin::kLocalInvocationId: case ast::Builtin::kGlobalInvocationId: + case ast::Builtin::kNumWorkgroups: case ast::Builtin::kWorkgroupId: { auto* u32 = builder_.create(); return builder_.create(u32, 3); @@ -1828,6 +1829,8 @@ const char* GeneratorImpl::builtin_to_string(ast::Builtin builtin, return "gl_LocalInvocationIndex"; case ast::Builtin::kGlobalInvocationId: return "gl_GlobalInvocationID"; + case ast::Builtin::kNumWorkgroups: + return "gl_NumWorkGroups"; case ast::Builtin::kWorkgroupId: return "gl_WorkGroupID"; case ast::Builtin::kSampleIndex: diff --git a/test/shader_io/compute_input_builtins.wgsl.expected.glsl b/test/shader_io/compute_input_builtins.wgsl.expected.glsl index 992a1bac5a..d69da6d44d 100644 --- a/test/shader_io/compute_input_builtins.wgsl.expected.glsl +++ b/test/shader_io/compute_input_builtins.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -26,16 +24,8 @@ void main() { inputs.local_invocation_index = uint(gl_LocalInvocationIndex); inputs.global_invocation_id = gl_GlobalInvocationID; inputs.workgroup_id = gl_WorkGroupID; - inputs.num_workgroups = uvec3(); + inputs.num_workgroups = gl_NumWorkGroups; tint_symbol(inputs); } -Error parsing GLSL shader: -ERROR: 0:27: 'constructor' : not enough data provided for construction -ERROR: 0:27: 'assign' : cannot convert from ' const float' to ' global highp 3-component vector of uint' -ERROR: 0:27: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - diff --git a/test/shader_io/compute_input_builtins_struct.wgsl.expected.glsl b/test/shader_io/compute_input_builtins_struct.wgsl.expected.glsl index 4952e91387..51de3dad0f 100644 --- a/test/shader_io/compute_input_builtins_struct.wgsl.expected.glsl +++ b/test/shader_io/compute_input_builtins_struct.wgsl.expected.glsl @@ -1,5 +1,3 @@ -SKIP: FAILED - #version 310 es precision mediump float; @@ -34,16 +32,8 @@ void main() { inputs.local_invocation_index = uint(gl_LocalInvocationIndex); inputs.global_invocation_id = gl_GlobalInvocationID; inputs.workgroup_id = gl_WorkGroupID; - inputs.num_workgroups = uvec3(); + inputs.num_workgroups = gl_NumWorkGroups; tint_symbol(inputs); } -Error parsing GLSL shader: -ERROR: 0:35: 'constructor' : not enough data provided for construction -ERROR: 0:35: 'assign' : cannot convert from ' const float' to ' global highp 3-component vector of uint' -ERROR: 0:35: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - -