Skip to content

Precompiled Shaders #3103

@dfrg

Description

@dfrg

I am working with @raphlinus on piet-gpu and we're considering replacing our internal HAL with wgpu-hal but we would like to retain the ability to use precompiled shaders to reduce both binary size and startup cost.

After some investigation, it seems the least invasive solution would be to add variants to ShaderInput for MSL source (or potentially a MTLLibrary instance) and DXIL and feed those through to pipeline creation in the same way that SpirV works for Vulkan today. This would require the user to assign bindings that are compatible with those generated by wgpu-hal during pipeline layout creation. For our purposes, this would be an acceptable constraint.

Alternatively, we've also considered a more sophisticated approach that would allow the user to provide a bind mapping during shader module creation. This seems to require deferring native resource binding until the whole pipeline state is known so that discrepancies between the pipeline layout and the expected binding slots for the entry point can be reconciled.

My understanding is that the project is amenable to such a change, and we're willing to do the work, but wanted to provide an opportunity for other potential users who are interested in this feature to weigh in and develop a consensus on the best path forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apiIssues related to API surfacehelp requiredWe need community help to make this happen.type: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions