mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
remove duplicate extensions
This commit is contained in:
parent
b0c9965cfb
commit
16338fb079
@ -4,6 +4,18 @@ use rspirv::dr::{Instruction, Module, Operand};
|
||||
use rspirv::spirv::{Op, Word};
|
||||
use std::collections::{hash_map, HashMap, HashSet};
|
||||
|
||||
pub fn remove_duplicate_extensions(module: &mut Module) {
|
||||
let mut set = HashSet::new();
|
||||
|
||||
module.extensions.retain(|inst| {
|
||||
inst.class.opcode != Op::Extension
|
||||
|| set.insert(match &inst.operands[0] {
|
||||
Operand::LiteralString(s) => s.clone(),
|
||||
_ => panic!(),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn remove_duplicate_capablities(module: &mut Module) {
|
||||
let mut set = HashSet::new();
|
||||
let mut caps = vec![];
|
||||
|
@ -107,6 +107,7 @@ pub fn link<T>(inputs: &mut [&mut Module], timer: impl Fn(&'static str) -> T) ->
|
||||
|
||||
let remove_duplicates_timer = timer("link_remove_duplicates");
|
||||
// remove duplicates (https://github.com/KhronosGroup/SPIRV-Tools/blob/e7866de4b1dc2a7e8672867caeb0bdca49f458d3/source/opt/remove_duplicates_pass.cpp)
|
||||
duplicates::remove_duplicate_extensions(&mut output);
|
||||
duplicates::remove_duplicate_capablities(&mut output);
|
||||
duplicates::remove_duplicate_ext_inst_imports(&mut output);
|
||||
duplicates::remove_duplicate_types(&mut output);
|
||||
|
Loading…
Reference in New Issue
Block a user