Skip to content

importing from single function modules is a little verbose.. #128

Description

@mighdoll

The Lygia library of wgsl functions sensibly breaks up its library into small files with one or two functions in each file. For example, the rgb2hue.wesl file contains only fn rgb2hue() {}. Consuming Lygia becomes a little verbose, with rgb2hue duplicated two or three times:

import lygia::color::space;
  ...
  rgb2hue::rgb2hue();

or:

import lygia::color::space::rgb2hue::rgb2hue;
  ...
  rgb2hue();

Note that the the small file style is handy for WESL users of Lygia. The npm wesl packager makes many small WeslBundle files in the Lygia dist directory, with indexing to each via package.json exports. npm WESL users can include a selected few of the WeslBundles for full dynamic linking of shaders, without unnecessarily bulging their application bundles with unused functions.

Current WESL will work just fine like this, it's just a little wordy. But I bet we can find ways to make this pattern more concise in WESL, even w/o requiring larger application bundles.

cc: @patriciogonzalezvivo @sdedovic @josephreisinger

Metadata

Metadata

Assignees

No one assigned

    Labels

    use caseA challenging example in current WGSL/WESL

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions