mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 14:56:27 +00:00
Test case for OpGroupDecorate
This commit is contained in:
parent
92feaf36f0
commit
470c2ff2e2
@ -152,6 +152,17 @@ where
|
||||
|
||||
fn kill_annotations_and_debug(module: &mut rspirv::dr::Module, id: u32) {
|
||||
kill_with_id(&mut module.annotations, id);
|
||||
|
||||
// need to remove OpGroupDecorate members that mention this id
|
||||
module.annotations.iter_mut().for_each(|inst| {
|
||||
if inst.class.opcode == spirv::Op::GroupDecorate {
|
||||
inst.operands.retain(|op| match op {
|
||||
rspirv::dr::Operand::IdRef(w) if *w != id => return true,
|
||||
_ => return false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
kill_with_id(&mut module.debugs, id);
|
||||
}
|
||||
|
||||
@ -576,6 +587,7 @@ fn link(inputs: &mut [&mut rspirv::dr::Module], opts: &Options) -> Result<rspirv
|
||||
}
|
||||
|
||||
let mut output = loader.module();
|
||||
println!("{}\n\n", output.disassemble());
|
||||
|
||||
// find import / export pairs
|
||||
let defs = DefAnalyzer::new(&output);
|
||||
@ -587,6 +599,8 @@ fn link(inputs: &mut [&mut rspirv::dr::Module], opts: &Options) -> Result<rspirv
|
||||
// remove duplicates (https://github.com/KhronosGroup/SPIRV-Tools/blob/e7866de4b1dc2a7e8672867caeb0bdca49f458d3/source/opt/remove_duplicates_pass.cpp)
|
||||
remove_duplicates(&mut output);
|
||||
|
||||
println!("{}\n\n", output.disassemble());
|
||||
|
||||
// remove names and decorations of import variables / functions https://github.com/KhronosGroup/SPIRV-Tools/blob/8a0ebd40f86d1f18ad42ea96c6ac53915076c3c7/source/opt/ir_context.cpp#L404
|
||||
import_kill_annotations_and_debug(&mut output, &info);
|
||||
|
||||
|
@ -312,8 +312,8 @@ mod test {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
/*
|
||||
|
||||
/*
|
||||
|
||||
//jb-todo: this isn't validated yet in the linker (see ensure_matching_import_export_pairs)
|
||||
#[test]
|
||||
fn decoration_mismatch() -> Result<()> {
|
||||
@ -378,9 +378,9 @@ mod test {
|
||||
without_header_eq(result, expect);
|
||||
Ok(())
|
||||
}
|
||||
/*
|
||||
|
||||
#[test]
|
||||
fn func_ctrl() -> Result<()> {
|
||||
fn use_exported_func_param_attr() -> Result<()> {
|
||||
let a = assemble_spirv(
|
||||
r#"OpCapability Kernel
|
||||
OpCapability Linkage
|
||||
@ -417,48 +417,30 @@ mod test {
|
||||
);
|
||||
|
||||
let result = assemble_and_link(&[&a, &b], &Options::default())?;
|
||||
/*
|
||||
OpCapability Kernel
|
||||
OpModuleProcessed "Linked by rspirv-linker"
|
||||
OpDecorate %1 FuncParamAttr Sext
|
||||
OpDecorate %2 FuncParamAttr Zext
|
||||
%2 = OpDecorationGroup
|
||||
OpGroupDecorate %2 %3 %4
|
||||
%5 = OpTypeVoid
|
||||
%6 = OpTypeInt 32 0
|
||||
%7 = OpTypeFunction %5 %6
|
||||
%8 = OpFunction %5 None %7
|
||||
%4 = OpFunctionParameter %6
|
||||
OpFunctionEnd
|
||||
%9 = OpFunction %5 None %7
|
||||
%1 = OpFunctionParameter %6
|
||||
%10 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
*/
|
||||
|
||||
let expect = r#"OpCapability Kernel
|
||||
OpModuleProcessed "Linked by rspirv-linker"
|
||||
OpDecorate %1 FuncParamAttr Zext
|
||||
OpDecorate %3 FuncParamAttr Sext
|
||||
%1 = OpDecorationGroup
|
||||
OpGroupDecorate %1 %2
|
||||
%4 = OpTypeVoid
|
||||
%5 = OpTypeInt 32 0
|
||||
%6 = OpTypeFunction %4 %5
|
||||
%7 = OpFunction %4 None %6
|
||||
%2 = OpFunctionParameter %5
|
||||
OpFunctionEnd
|
||||
%8 = OpFunction %4 None %6
|
||||
%3 = OpFunctionParameter %5
|
||||
%9 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
OpModuleProcessed "Linked by rspirv-linker"
|
||||
OpDecorate %1 FuncParamAttr Zext
|
||||
OpDecorate %3 FuncParamAttr Sext
|
||||
%1 = OpDecorationGroup
|
||||
OpGroupDecorate %1 %2
|
||||
%4 = OpTypeVoid
|
||||
%5 = OpTypeInt 32 0
|
||||
%6 = OpTypeFunction %4 %5
|
||||
%7 = OpFunction %4 None %6
|
||||
%2 = OpFunctionParameter %5
|
||||
OpFunctionEnd
|
||||
%8 = OpFunction %4 None %6
|
||||
%3 = OpFunctionParameter %5
|
||||
%9 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
"#;
|
||||
|
||||
without_header_eq(result, expect);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/*
|
||||
#[test]
|
||||
fn names_and_decorations() -> Result<()> {
|
||||
let a = assemble_spirv(
|
||||
|
Loading…
Reference in New Issue
Block a user