This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Add custom_insts for our own OpExtInsts, and use it for some debuginfo.#1064
Merged
eddyb merged 11 commits intoEmbarkStudios:mainfrom Jun 1, 2023
LykenSol:extinst
Merged
Add custom_insts for our own OpExtInsts, and use it for some debuginfo.#1064eddyb merged 11 commits intoEmbarkStudios:mainfrom LykenSol:extinst
custom_insts for our own OpExtInsts, and use it for some debuginfo.#1064eddyb merged 11 commits intoEmbarkStudios:mainfrom
LykenSol:extinst
Conversation
…starting location.
VZout
approved these changes
Jun 1, 2023
Member
VZout
left a comment
There was a problem hiding this comment.
fancy!
also learned some new rust :p if let [Operand::IdRef(target), ..] = inst.operands[..] {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a Rust-GPU-specific custom "extended instruction set" (
OpExtInstImport/OpExtInst- note that unlike the requirements imposed by the SPIR-V specification, we're only concerned aboutrspirv/spirtcompatibility, as long as we always rewrite such instructions before the final SPIR-V output).Longer-term, we'll likely want such custom instructions for more advanced usecases (e.g. one idea being floated around was adding our own
OpAbortthat gets transformed to standard SPIR-V), and the debuginfo needs will likely get superseded by adoptingNonSemantic.Shader.DebugInfo.100, but for now this is easier for some debuginfo.The main feature this PR adds is the ability to have location ranges, not just the starting point:
error: cannot memcpy dynamically sized data --> $CORE_SRC/intrinsics.rs:2460:9 | 2460 | copy(src, dst, count) | ^ | note: used from within `core::intrinsics::copy::` --> $CORE_SRC/intrinsics.rs:2447:21 | 2447 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 | 28 | unsafe { core::ptr::copy(src, dst, 1) } | ^ note: called by `ptr_copy::main` --> $DIR/ptr_copy.rs:33:5 | 33 | copy_via_raw_ptr(&i, o); | ^ note: called by `main` --> $DIR/ptr_copy.rs:31:1 | 31 | #[spirv(fragment)] | ^error: cannot memcpy dynamically sized data --> $CORE_SRC/intrinsics.rs:2460:9 | 2460 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` --> $CORE_SRC/intrinsics.rs:2447:21 | 2447 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 | 28 | unsafe { core::ptr::copy(src, dst, 1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by `ptr_copy::main` --> $DIR/ptr_copy.rs:33:5 | 33 | copy_via_raw_ptr(&i, o); | ^^^^^^^^^^^^^^^^^^^^^^^ note: called by `main` --> $DIR/ptr_copy.rs:32:8 | 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^The other feature is inline stack frames, e.g. most of this
--no-early-report-zombiesoutput is new:(actually, it used to not even report the zombies, because the decorations were being lost)
error: cannot memcpy dynamically sized data --> $CORE_SRC/intrinsics.rs:2460:9 | 2460 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` --> $CORE_SRC/intrinsics.rs:2460:9 | 2460 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 | 28 | unsafe { core::ptr::copy(src, dst, 1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by `ptr_copy::main` --> $DIR/ptr_copy.rs:33:5 | 33 | copy_via_raw_ptr(&i, o); | ^^^^^^^^^^^^^^^^^^^^^^^ note: called by Fragment entry-point `main` --> $DIR/ptr_copy.rs:32:8 | 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^error: cannot memcpy dynamically sized data --> $CORE_SRC/intrinsics.rs:2460:9 | 2460 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:11:4 | 11 | fn copy_via_raw_ptr(src: &f32, dst: &mut f32) { | ^^^^^^^^^^^^^^^^ note: called by `ptr_copy::main` --> $DIR/ptr_copy.rs:38:5 | 38 | copy_via_raw_ptr(&src, &mut dst); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by Fragment entry-point `main` --> $DIR/ptr_copy.rs:32:8 | 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^
The more flexible debuginfo is only used internally, and replaced with standard SPIR-V
OpLine/OpNoLineinstructions (or rather, the SPIR-T attribute thatspirt::spv::liftmaps toOpLine/OpNoLine) after all possible (zombie or SPIR-T) diagnostics have been emitted, to maximize our diagnostics quality.