[][src]Macro vulkayes_core::create_graphics_pipeline

macro_rules! create_graphics_pipeline {
    (
		@Shaders($output_builder: expr)
		stages: [
			$(
				$stage: expr $(, $entry_name: expr $(, $specialization: expr)?)? => $stage_type: expr
			),* $(,)?
		] $(,)?
		input: {
			$($input_tt: tt)*
		} $(,)?
		topology: $topology: expr
		$(, primitive_restart: $primitive_restart: expr)?
		$(,)?
	) => { ... };
    (
		@Tessellation($output_builder: expr)
		patch_control_points: $patch_control_points: expr
		$(, domain_origin: $domain_origin: expr)?
	) => { ... };
    (
		@Viewport($output_builder: expr, $dynamic_info: expr)
		viewports: {
			$($viewports_tt: tt)+
		} $(,)?
	) => { ... };
    (
		@Rasterization($output_builder: expr, $dynamic_info: expr)
		$(depth_clamp: $depth_clamp: expr,)?
		$(depth_clip: $depth_clip: expr,)?
		$(discard: $discard: expr,)?
		polygon_mode: $polygon_mode: expr
		$(, depth_bias: $depth_bias: expr)?
		$(,)?
	) => { ... };
    (
		@Multisampling($output_builder: expr)
		samples: $samples: expr
		$(, sample_shading: $sample_shading: expr)?
		$(, sample_mask: $sample_mask: expr)?
		$(, alpha_to_coverage: $alpha_to_coverage: expr)?
		$(, alpha_to_one: $alpha_to_one: expr)?
		$(,)?
	) => { ... };
    (
		@DepthStencil($output_builder: expr, $dynamic_info: expr)
		depth: $depth_test: expr
		$(, depth_bounds: $depth_bounds_test: expr)?
		$(, stencil: $stencil_test: expr)?
		$(,)?
	) => { ... };
    (
		@ColorBlend($output_builder: expr, $dynamic_info: expr)
		$(logic_op: $logic_op: expr,)?
		attachments: [
			$(
				{ $($attachment_tt: tt)+ }
			),*
			$(,)?
		]
		$(, blend_constants: $blend_constants: expr)?
		$(,)?
	) => { ... };
    (
		@Deps($output_builder: expr)
		layout: $layout: expr,
		render_pass: $render_pass: expr
		$(, subpass: $subpass: expr)?
		$(,)?
	) => { ... };
    (
		let $create_info_variable_name: ident;

		Shaders {
			$($shaders_tt: tt)+
		}

		$(
			Tessellation {
				$($tessellation_tt: tt)+
			}
		)?

		$(
			Viewport {
				$($viewport_tt: tt)+
			}
		)?

		Rasterization {
			$($rasterization_tt: tt)+
		}

		$(
			Multisampling {
				$($multisampling_tt: tt)+
			}
		)?

		$(
			DepthStencil {
				$($depth_stencil_tt: tt)+
			}
		)?

		$(
			ColorBlend {
				$($color_blend_tt: tt)+
			}
		)?

		Deps {
			$($deps_tt: tt)+
		}
	) => { ... };
}

Graphics pipeline creation macro that makes it easier to specify parameters.

This macro expands to an item. To use the generated vk::GraphicsPipelineCreateInfoBuilder, the variable expanded from $create_info_variable_name is introduced into the scope after calling this macro.

The builder is only valid for the lifetime of the calling scope because it borrows from variables declared inside this macro. Calling build on the builder and then returning it is undefined behavior!. TODO

The parameters are split into several sections grouping similar paramters. The following list shows separate sections, their fields and the types of arguments expected. ? marks an optional parameter.

  • Shaders - Parameters affecting shader stages, input descriptions and primitive topology.
    • stages - array of binding expressions: module, entry?, spec? => point:
      • module - value of type ShaderModule
      • entry? - value of type ShaderEntryPoint, default: ShaderEntryPoint::default()
      • spec? - any value defining fn specialization_info(&self) -> vk::SpecializationInfoBuilder, default: unset (null pointer)
      • point -> value of type vk::ShaderStageFlags
    • input - tokens passed directly to vertex_input_description! macro
    • topology - value of type vk::PrimitiveTopology
    • primitive_restart? - value of type bool, default: false
  • Tessellation - Parameters affecting tessellation.
    • patch_control_points? - value of type u32, default: 0
  • Viewport - Parameters affecting viewports and scissors.
  • Rasterization - Parameters affecting rasterization, clipping and clamping.
    • depth_clamp? - value of type bool, default: false
    • depth_clip? - value of type bool, default: unset (extension struct not passed)
    • discard? - value of type bool, default: false
    • polygon_mode - value of type PolygonMode
    • depth_bias? - value of type DepthBias, default: DepthBias::default()
  • Multisampling - Parameters affecting multisampling.
    • samples - value of type vk::SampleCountFlags
    • sample_shading? - value of type SampleShading, default: SampleShading::default()
    • sample_mask? - value that borrows as &[u32], default: unset (null pointer)
    • alpha_to_coverage? - value of type bool, default: false
    • alpha_to_one? - value of type bool, default: false
  • DepthStencil - Parameters affecting depth and stencil tests.
    • depth - value of type DepthTest
    • depth_bounds? - value of type DepthBoundsTest, default: DepthBoundsTest::default()
    • stencil? - value of type StencilTest, default: StencilTest::default()
  • ColorBlend - Parameters affecting color blending and operations.
    • logic_op? - value of type BlendLogicOp, default: BlendLogicOp::default()
    • attachments - array of blending expressions passed directly to color_blend_state_expr! macro
    • blend_constants? - value of type Option<[f32; 4]>, default: Some([0.0; 4]), None means to enable dynamic state
  • Deps - Parameters needed as dependencies.
    • layout - any value defining fn handle(&self) -> vk::PipelineLayout
    • render_pass - any value defining fn handle(&self) -> vk::RenderPass
    • subpass? - value of type u32, default: 0

Note that some sections are optional altogether, however, not specifying a section means it won't be included at all in the create info and no defaults will be provided (the struct pointer will be null). Commonly only the Tessellation section is left out, but with rasterization disabled the Viewport, Multisampling, DepthStencil and ColorBlend sections can be left out as well. DepthStencil and ColorBlend also have additional cases where they can be left out: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkGraphicsPipelineCreateInfo.html.