Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Investigate inferring storage class #300

@khyperia

Description

@khyperia

Instead of having explicit pointer-wrapping types in spirv-std like Input<T>, instead, have the compiler not emit storage classes at all (using Generic as a placeholder or something, even though that's not what Generic storage class means). Then, in the linker, do a whole-program-analysis and propagate storage classes throughout the program. Essentially, treat any place where a pointer type appears as a "generic type parameter" except it's a "generic storage class parameter", then do monomorphization (so duplicating functions that are called with multiple storage classes, etc.).

This would solve many problems:

  • Constants could be emitted to OpVariables of Private storage class, and pointers to them could be passed to functions.
  • OpTypeRuntimeArray would be able to be supported really easily, as the current Input<T> system requires loading a value of T, but with OpTypeRuntimeArray, T is unsized. Rust's normal rules around this work great, if it were &T, you could write obj.the_unsized_array[5] and it'd generate the right code with the right storage classes.
  • This looks really really nice:
    fn main (#[spirv(input)] input: &f32, #[spirv(output)] output: &mut f32) {}

Metadata

Metadata

Assignees

Labels

t: enhancementA new feature or improvement to an existing one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions