这是indexloc提供的服务,不要输入任何密码
Skip to content

[wgsl] Variable loads and stores #622

@kvark

Description

@kvark

In SPIR-V, local variables inside functions are loaded (with OpLoad) and stored (with OpStore). In WGSL, however, the semantics of "load" is lost. For example:

var x = 1.0;
const y = x * x + x + 1;

This would translate to 3 OpLoad instructions for x instead of one. It would be unfortunate to recommend people to have temporary const variables, since nothing visually indicates whether an access to something is an actual operation, or just a use of an SSA value.
One way to address this would be to have a syntax for "load" of a variable, e.g. *x.
Another way is to rely on drivers doing this optimization, if they always do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issueswgsl resolvedResolved - waiting for a change to the WGSL specification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions