diff --git a/vulkano-shaders/src/entry_point.rs b/vulkano-shaders/src/entry_point.rs index 1f8d0694..8b4640bc 100644 --- a/vulkano-shaders/src/entry_point.rs +++ b/vulkano-shaders/src/entry_point.rs @@ -16,14 +16,15 @@ use location_decoration; use name_from_id; pub fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) -> (String, String) { - let (execution, ep_name, interface) = match instruction { + let (execution, id, ep_name, interface) = match instruction { &parse::Instruction::EntryPoint { ref execution, + id, ref name, ref interface, .. } => { - (execution, name, interface) + (execution, id, name, interface) }, _ => unreachable!(), }; @@ -88,13 +89,35 @@ pub fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) - }, enums::ExecutionModel::ExecutionModelGeometry => { + let mut execution_mode = "Points"; // fallback value + + for instruction in doc.instructions.iter() { + if let &parse::Instruction::ExecutionMode { target_id, ref mode, .. } = instruction { + if target_id != id { + continue; + } + execution_mode = match mode { + &enums::ExecutionMode::ExecutionModeInputPoints => "Points", + &enums::ExecutionMode::ExecutionModeInputLines => "Lines", + &enums::ExecutionMode::ExecutionModeInputLinesAdjacency => "LinesWithAdjacency", + &enums::ExecutionMode::ExecutionModeTriangles => "Triangles", + &enums::ExecutionMode::ExecutionModeInputTrianglesAdjacency => "TrianglesWithAdjacency", + _ => continue, + }; + break; + } + } + + let execution_mode = format!("::vulkano::pipeline::shader::GeometryShaderExecutionMode::{0}", execution_mode); + let t = format!("::vulkano::pipeline::shader::GeometryShaderEntryPoint<(), {0}Input, \ {0}Output, Layout>", capitalized_ep_name); let f = format!("geometry_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.\ - as_ptr() as *const _), {0}Input, {0}Output, Layout(ShaderStages {{ \ + as_ptr() as *const _), {1}, {0}Input, {0}Output, Layout(ShaderStages {{ \ geometry: true, .. ShaderStages::none() }}))", - capitalized_ep_name); + capitalized_ep_name, + execution_mode); (t, f) }, diff --git a/vulkano-shaders/src/parse.rs b/vulkano-shaders/src/parse.rs index 7f209dff..8179fb05 100644 --- a/vulkano-shaders/src/parse.rs +++ b/vulkano-shaders/src/parse.rs @@ -108,6 +108,11 @@ pub enum Instruction { name: String, interface: Vec, }, + ExecutionMode { + target_id: u32, + mode: ExecutionMode, + optional_literals: Vec, + }, Capability(Capability), TypeVoid { result_id: u32 }, TypeBool { result_id: u32 }, @@ -227,6 +232,13 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result { + Instruction::ExecutionMode { + target_id: operands[0], + mode: ExecutionMode::from_num(operands[1])?, + optional_literals: operands[2..].to_vec(), + } + } 17 => Instruction::Capability(Capability::from_num(operands[0])?), 19 => Instruction::TypeVoid { result_id: operands[0] }, 20 => Instruction::TypeBool { result_id: operands[0] },