Bug 262346 - [WGSL] Overrides with default values have initializers which doesn't compile
Summary: [WGSL] Overrides with default values have initializers which doesn't compile
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-09-28 16:46 PDT by Mike Wyrzykowski
Modified: 2023-09-28 16:46 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wyrzykowski 2023-09-28 16:46:03 PDT
[WGSL] Overrides with default values have initializers which doesn't compile

Opening https://webgpu.github.io/webgpu-samples/samples/shadowMapping

results in the following error:

program_source:58:47: error: an attribute list cannot appear here
  constant float shadowDepthTextureSize = 1024. [[function_constant(0)]];

as the generated metal looks like:
  constant float shadowDepthTextureSize = 1024. [[function_constant(0)]];

instead it should be:
  constant float shadowDepthTextureSize [[function_constant(0)]];

and the default value of 1024 should be returned in likely SpecializationConstant:

  struct SpecializationConstant {
      String mangledName;
      SpecializationConstantType type;
      String value; // <-- new member, or alternatively, std::variant<bool, float, int, unsigned, __fp16>
  };

Also it would be nice to add "Half" to SpecializationConstantType, that could be done separately.


Then the default can be used in:

  MTLFunctionConstantValues *createConstantValues(uint32_t constantCount, const WGPUConstantEntry* constants, const WGSL::Reflection::EntryPointInformation& entryPointInformation)
Comment 1 Radar WebKit Bug Importer 2023-09-28 16:46:26 PDT
<rdar://problem/116209279>