Skip to content

Wish list: compile-time SPIRV-Cross #3030

Open
@parasyte

Description

@parasyte

I came across the discussion in gfx-rs/wgpu-rs#44 and it lead me down a bit of a rabbit hole. TL;DR: Make the runtime shader compiler spirv_cross optional in the backends that need it.

Longer version is as follows.

I like vk-shader-macros because it moves the SPIR-V compiler to compile-time. But nearly all of the gfx backends depend on spirv_cross (the exceptions being vulkan and empty 😉). You end up with a shader compiler statically built into your application in most cases, anyway.

There are some valid uses for using a shader compiler at runtime. And then there are some valid uses for compiling shaders entirely at compile time. My pedantic nature lead me down the path of trying to optimize a toy like "hello-triangle", only to find that at least 7% (about 220 KB) of the binary size is spirv_cross; a large chunk of code which arguably should not exist in this kind of trivial executable.

The proposal here is to add a macro that will compile SPIR-V to the native shader language at compile-time, to complement Device::create_shader_module(). The macro should still accept a &[u32] of SPIR-V, and developers can choose their preferred method of creating a shader module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions