mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 16:53:48 +00:00
[spv] debug labels for types, local variables, and struct members
This commit is contained in:
parent
089a5597c6
commit
4a13ce022b
@ -27,6 +27,14 @@ pub(super) fn instruction_name(target_id: Word, name: &str) -> Instruction {
|
||||
instruction
|
||||
}
|
||||
|
||||
pub(super) fn instruction_member_name(target_id: Word, member: Word, name: &str) -> Instruction {
|
||||
let mut instruction = Instruction::new(Op::MemberName);
|
||||
instruction.add_operand(target_id);
|
||||
instruction.add_operand(member);
|
||||
instruction.add_operands(helpers::string_to_words(name));
|
||||
instruction
|
||||
}
|
||||
|
||||
//
|
||||
// Annotation Instructions
|
||||
//
|
||||
|
@ -374,6 +374,13 @@ impl Writer {
|
||||
for (handle, variable) in ir_function.local_variables.iter() {
|
||||
let id = self.generate_id();
|
||||
|
||||
if self.flags.contains(WriterFlags::DEBUG) {
|
||||
if let Some(ref name) = variable.name {
|
||||
self.debugs
|
||||
.push(super::instructions::instruction_name(id, name));
|
||||
}
|
||||
}
|
||||
|
||||
let init_word = variable
|
||||
.init
|
||||
.map(|constant| self.get_constant_id(constant, ir_module))
|
||||
@ -589,6 +596,13 @@ impl Writer {
|
||||
let ty = &arena[handle];
|
||||
let id = self.generate_id();
|
||||
|
||||
if self.flags.contains(WriterFlags::DEBUG) {
|
||||
if let Some(ref name) = ty.name {
|
||||
self.debugs
|
||||
.push(super::instructions::instruction_name(id, name));
|
||||
}
|
||||
}
|
||||
|
||||
let instruction = match ty.inner {
|
||||
crate::TypeInner::Scalar { kind, width } => {
|
||||
self.lookup_type
|
||||
@ -714,6 +728,17 @@ impl Writer {
|
||||
None => layout.size,
|
||||
};
|
||||
|
||||
if self.flags.contains(WriterFlags::DEBUG) {
|
||||
if let Some(ref name) = member.name {
|
||||
self.debugs
|
||||
.push(super::instructions::instruction_member_name(
|
||||
id,
|
||||
index as u32,
|
||||
name,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if let crate::TypeInner::Matrix {
|
||||
columns,
|
||||
rows: _,
|
||||
@ -886,7 +911,7 @@ impl Writer {
|
||||
if self.flags.contains(WriterFlags::DEBUG) {
|
||||
if let Some(ref name) = global_variable.name {
|
||||
self.debugs
|
||||
.push(super::instructions::instruction_name(id, name.as_str()));
|
||||
.push(super::instructions::instruction_name(id, name));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user