Improve builtin variable detection

This commit is contained in:
Pierre Krieger 2016-06-06 15:20:02 +02:00
parent f220519e05
commit 3a4c1022f5
2 changed files with 31 additions and 4 deletions

View File

@ -114,10 +114,6 @@ fn write_interface_structs(doc: &parse::Spirv, capitalized_ep_name: &str, interf
continue; continue;
} }
if is_builtin(doc, result_type_id) {
continue;
}
let (to_write, ignore_first_array) = match storage_class { let (to_write, ignore_first_array) = match storage_class {
&enums::StorageClass::StorageClassInput => (&mut input_elements, ignore_first_array_in), &enums::StorageClass::StorageClassInput => (&mut input_elements, ignore_first_array_in),
&enums::StorageClass::StorageClassOutput => (&mut output_elements, ignore_first_array_out), &enums::StorageClass::StorageClassOutput => (&mut output_elements, ignore_first_array_out),

View File

@ -369,6 +369,37 @@ fn is_builtin(doc: &parse::Spirv, id: u32) -> bool {
{ {
return true; return true;
}, },
parse::Instruction::MemberDecorate { target_id,
decoration: enums::Decoration::DecorationBuiltIn,
.. } if target_id == id =>
{
return true;
},
_ => ()
}
}
for instruction in &doc.instructions {
match *instruction {
parse::Instruction::Variable { result_type_id, result_id, ref storage_class, .. }
if result_id == id =>
{
return is_builtin(doc, result_type_id);
},
parse::Instruction::TypeArray { result_id, type_id, .. } if result_id == id => {
return is_builtin(doc, type_id);
},
parse::Instruction::TypeRuntimeArray { result_id, type_id } if result_id == id => {
return is_builtin(doc, type_id);
},
parse::Instruction::TypeStruct { result_id, ref member_types } if result_id == id => {
for &mem in member_types {
if is_builtin(doc, mem) { return true; }
}
},
parse::Instruction::TypePointer { result_id, type_id, .. } if result_id == id => {
return is_builtin(doc, type_id);
},
_ => () _ => ()
} }
} }