Fix using gl_VertexIndex and gl_InstanceIndex producing errors

This commit is contained in:
Pierre Krieger 2016-03-09 13:06:13 +01:00
parent d0738e20e8
commit 4ae0c4541a
2 changed files with 21 additions and 2 deletions

View File

@ -176,6 +176,10 @@ fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) -> St
storage_class: enums::StorageClass::StorageClassInput, .. } storage_class: enums::StorageClass::StorageClassInput, .. }
if &result_id == interface => if &result_id == interface =>
{ {
if is_builtin(doc, result_id) {
continue;
}
input_types.push(type_from_id(doc, result_type_id)); input_types.push(type_from_id(doc, result_type_id));
let name = name_from_id(doc, result_id); let name = name_from_id(doc, result_id);
let loc = match location_decoration(doc, result_id) { let loc = match location_decoration(doc, result_id) {
@ -375,6 +379,23 @@ fn location_decoration(doc: &parse::Spirv, searched: u32) -> Option<u32> {
}).next() }).next()
} }
/// Returns true if a `BuiltIn` decorator is applied on an id.
fn is_builtin(doc: &parse::Spirv, id: u32) -> bool {
for instruction in &doc.instructions {
match *instruction {
parse::Instruction::Decorate { target_id,
decoration: enums::Decoration::DecorationBuiltIn,
.. } if target_id == id =>
{
return true;
},
_ => ()
}
}
false
}
/// Returns the name of the Vulkan something that corresponds to an `OpCapability`. /// Returns the name of the Vulkan something that corresponds to an `OpCapability`.
/// ///
/// Returns `None` if irrelevant. /// Returns `None` if irrelevant.

View File

@ -91,8 +91,6 @@ fn write_struct(doc: &parse::Spirv, struct_id: u32, members: &[u32]) -> String {
/// Returns true if a `BuiltIn` decorator is applied on a struct member. /// Returns true if a `BuiltIn` decorator is applied on a struct member.
fn is_builtin_member(doc: &parse::Spirv, id: u32, member_id: u32) -> bool { fn is_builtin_member(doc: &parse::Spirv, id: u32, member_id: u32) -> bool {
let mut result = String::new();
for instruction in &doc.instructions { for instruction in &doc.instructions {
match *instruction { match *instruction {
parse::Instruction::MemberDecorate { target_id, member, parse::Instruction::MemberDecorate { target_id, member,