RFC: link-time capabilities
還沒有人認領這個 Issue。
評估
研究方向
先閱讀 Large Integer polyfills issue (#307),然後追蹤 spirv-builder 目前如何宣告 capabilities,以及最終的 shader crate 如何建置。比較依 entry point、依 crate 以及 feature-gated 的方案。完成的標準是確定一種設計,並制定一份實作計畫,以便重複使用已編譯的 crate,同時連結具有不同 capabilities 的變體。
由索引模型根據 Issue 內容生成。
描述
Link-time capabilities are capabilities that are not exposed to codegen, but only set at link time. Importantly, changing link-time capabilities does not require a clean recompile, unlike the current spirv capabilities.
I good first experiment ground would likely be Large Integer polyfills, which I think they are better suited at link time. A really common use-case would likely be to emit one shader module with Int64 Capabilitiy enabled, and another with u32 polyfill for all u64 integers. So implementing this at link time would allow you to compile the shader crate only once and link it twice.
There's a few variants I could imagine to specify these link-time capabilities:
- per entry point in the
#[spirv(capability(polyfill_u64))], mapping well with multimodule - per shader crate using
#![spirv(capability(polyfill_u64))]at root level, mapping well to single module - some new system that allows specifying how entry points are grouped, potentially allowing entry points to be emitted in a variety of modules with different link-time capabilities. Maybe not with the first implementation.
Importantly, this should work well with rust features, so you can #[cfg_attr(feature = "u64_emulation", spirv(capability(polyfill_u64)))] and compile only the final shader crate twice, while reusing the remaining compiled crate tree.
I could also see a similar system being employed for usual spirv capabilities in the future, replacing the current pre-declaration of used features in spirv-builder. Similarly to the zombie system, you could attach an OpCapability to a certain instruction. If that instruction is linked into a shader module, add the OpCapability to it. But if it's unused, DCE will kill the instruction thus the capability.
This reverses how you'd enable code that depends on some capability: Currently, you'd declare the capability in spirv-builder and have a #[cfg(target_feature = "")] in your code. With link-time capabilities, you use a normal rust feature like #[cfg(feature = "")]to gate your code requiring some capability, and if the end user enables that feature, it implicitly enables the required capability. The final shader crate binary can itself have features enabled though spirv-builder, that enable features of any such library gating required capabilities like you'd normally do in Cargo.toml.
- 主要語言
- Rust
- 星號
- 3.4k
- 分支
- 126
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Rust-GPU/rust-gpu 的其他 Issue
-
enhancement
難度 1/5 1 小時以內 新手友好度 68/100
-
bug
-
enhancement
-
bug
難度 4/5 3-5 天 新手友好度 48/100
-
bug
難度 3/5 1-2 天 新手友好度 48/100
查看 Rust-GPU/rust-gpu 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
bug core
難度 2/5 1-3 小時 新手友好度 86/100
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW 未關閉fuzz
難度 2/5 1-3 小時 新手友好度 82/100
ClickHouse/ClickHouse#122114 ·
-
難度 1/5 1 小時以內 新手友好度 92/100
linebender/vello_svg#90 ·
-
難度 2/5 1-3 小時 新手友好度 74/100