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

Consider allowing overridden pipeline constants to refer to a non-existent identifier string #5112

@mellinoe

Description

@mellinoe

Currently, all overridden constants during pipeline creation must exist in the shader module. It is permitted for a constant to exist and be unused, but it must exist to begin with.

First, I hit this issue because my engine passes a common set of specializations when a pipeline is created, to bake in certain types of engine-level configuration into shaders where necessary. This is permitted in Metal and Vulkan. Not all shaders reference the full set of these specializations, but extras are automatically ignored in both APIs. In WebGPU, referencing an unused constant will trigger a pipeline creation failure. This means its not possible to pass a common set of specialization values around; each shader must be given only the specializations that it knows about.

Second, I don't directly author WGSL, but use Slang to target it. Currently, Slang "optimizes out" unused constant variables. This behavior could possibly be changed, but at face value it's not an unreasonable approach. For shaders in other languages that use WGSL as a compilation target, I think that it's much more likely that these constants will disappear from the final text when unused, even if they originally existed in the source.

I've only recently started using WebGPU, but I think a possible solution would be to turn this error into a "diagnostic" which is enabled by default with the current severity (e.g. fails compilation). It could then be ignored by the user if they opt into it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU API

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions