mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-29 18:24:26 +00:00
Some more graphics pipeline tests
This commit is contained in:
parent
1ac0752882
commit
4486d8199b
@ -1046,9 +1046,11 @@ mod tests {
|
||||
use descriptor::pipeline_layout::EmptyPipelineDesc;
|
||||
use pipeline::GraphicsPipeline;
|
||||
use pipeline::GraphicsPipelineParams;
|
||||
use pipeline::GraphicsPipelineCreationError;
|
||||
use pipeline::blend::Blend;
|
||||
use pipeline::depth_stencil::DepthStencil;
|
||||
use pipeline::input_assembly::InputAssembly;
|
||||
use pipeline::input_assembly::PrimitiveTopology;
|
||||
use pipeline::multisample::Multisample;
|
||||
use pipeline::shader::ShaderModule;
|
||||
use pipeline::shader::EmptyShaderInterfaceDef;
|
||||
@ -1092,6 +1094,168 @@ mod tests {
|
||||
}).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_primitive_restart() {
|
||||
let (device, _) = gfx_dev_and_queue!();
|
||||
|
||||
let vs = unsafe { ShaderModule::new(&device, &BASIC_VS).unwrap() };
|
||||
let fs = unsafe { ShaderModule::new(&device, &BASIC_FS).unwrap() };
|
||||
|
||||
let result = GraphicsPipeline::new(&device, GraphicsPipelineParams {
|
||||
vertex_input: SingleBufferDefinition::<()>::new(),
|
||||
vertex_shader: unsafe {
|
||||
vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
input_assembly: InputAssembly {
|
||||
topology: PrimitiveTopology::TriangleList,
|
||||
primitive_restart_enable: true,
|
||||
},
|
||||
geometry_shader: None,
|
||||
viewport: ViewportsState::Dynamic { num: 1 },
|
||||
raster: Default::default(),
|
||||
multisample: Multisample::disabled(),
|
||||
fragment_shader: unsafe {
|
||||
fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
depth_stencil: DepthStencil::disabled(),
|
||||
blend: Blend::pass_through(),
|
||||
layout: &EmptyPipeline::new(&device).unwrap(),
|
||||
render_pass: Subpass::from(&simple_rp::CustomRenderPass::new(&device, &{
|
||||
simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) }
|
||||
}).unwrap(), 0).unwrap(),
|
||||
});
|
||||
|
||||
match result {
|
||||
Err(GraphicsPipelineCreationError::PrimitiveDoesntSupportPrimitiveRestart { .. }) => (),
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_viewport_feature() {
|
||||
let (device, _) = gfx_dev_and_queue!();
|
||||
|
||||
let vs = unsafe { ShaderModule::new(&device, &BASIC_VS).unwrap() };
|
||||
let fs = unsafe { ShaderModule::new(&device, &BASIC_FS).unwrap() };
|
||||
|
||||
let result = GraphicsPipeline::new(&device, GraphicsPipelineParams {
|
||||
vertex_input: SingleBufferDefinition::<()>::new(),
|
||||
vertex_shader: unsafe {
|
||||
vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
input_assembly: InputAssembly::triangle_list(),
|
||||
geometry_shader: None,
|
||||
viewport: ViewportsState::Dynamic { num: 2 },
|
||||
raster: Default::default(),
|
||||
multisample: Multisample::disabled(),
|
||||
fragment_shader: unsafe {
|
||||
fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
depth_stencil: DepthStencil::disabled(),
|
||||
blend: Blend::pass_through(),
|
||||
layout: &EmptyPipeline::new(&device).unwrap(),
|
||||
render_pass: Subpass::from(&simple_rp::CustomRenderPass::new(&device, &{
|
||||
simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) }
|
||||
}).unwrap(), 0).unwrap(),
|
||||
});
|
||||
|
||||
match result {
|
||||
Err(GraphicsPipelineCreationError::MultiViewportFeatureNotEnabled) => (),
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_viewports() {
|
||||
let (device, _) = gfx_dev_and_queue!(multi_viewport);
|
||||
|
||||
let vs = unsafe { ShaderModule::new(&device, &BASIC_VS).unwrap() };
|
||||
let fs = unsafe { ShaderModule::new(&device, &BASIC_FS).unwrap() };
|
||||
|
||||
let result = GraphicsPipeline::new(&device, GraphicsPipelineParams {
|
||||
vertex_input: SingleBufferDefinition::<()>::new(),
|
||||
vertex_shader: unsafe {
|
||||
vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
input_assembly: InputAssembly::triangle_list(),
|
||||
geometry_shader: None,
|
||||
viewport: ViewportsState::Dynamic { num: !0 },
|
||||
raster: Default::default(),
|
||||
multisample: Multisample::disabled(),
|
||||
fragment_shader: unsafe {
|
||||
fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
depth_stencil: DepthStencil::disabled(),
|
||||
blend: Blend::pass_through(),
|
||||
layout: &EmptyPipeline::new(&device).unwrap(),
|
||||
render_pass: Subpass::from(&simple_rp::CustomRenderPass::new(&device, &{
|
||||
simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) }
|
||||
}).unwrap(), 0).unwrap(),
|
||||
});
|
||||
|
||||
match result {
|
||||
Err(GraphicsPipelineCreationError::MaxViewportsExceeded { .. }) => (),
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_depth_attachment() {
|
||||
let (device, _) = gfx_dev_and_queue!();
|
||||
|
||||
let vs = unsafe { ShaderModule::new(&device, &BASIC_VS).unwrap() };
|
||||
let fs = unsafe { ShaderModule::new(&device, &BASIC_FS).unwrap() };
|
||||
|
||||
let result = GraphicsPipeline::new(&device, GraphicsPipelineParams {
|
||||
vertex_input: SingleBufferDefinition::<()>::new(),
|
||||
vertex_shader: unsafe {
|
||||
vs.vertex_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
input_assembly: InputAssembly::triangle_list(),
|
||||
geometry_shader: None,
|
||||
viewport: ViewportsState::Dynamic { num: 1 },
|
||||
raster: Default::default(),
|
||||
multisample: Multisample::disabled(),
|
||||
fragment_shader: unsafe {
|
||||
fs.fragment_shader_entry_point::<(), _, _, _>(&CString::new("main").unwrap(),
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyShaderInterfaceDef,
|
||||
EmptyPipelineDesc)
|
||||
},
|
||||
depth_stencil: DepthStencil::simple_depth_test(),
|
||||
blend: Blend::pass_through(),
|
||||
layout: &EmptyPipeline::new(&device).unwrap(),
|
||||
render_pass: Subpass::from(&simple_rp::CustomRenderPass::new(&device, &{
|
||||
simple_rp::Formats { color: (Format::R8G8B8A8Unorm, 1) }
|
||||
}).unwrap(), 0).unwrap(),
|
||||
});
|
||||
|
||||
match result {
|
||||
Err(GraphicsPipelineCreationError::NoDepthAttachment) => (),
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mod simple_rp {
|
||||
|
@ -24,6 +24,7 @@
|
||||
pub use self::compute_pipeline::ComputePipeline;
|
||||
pub use self::graphics_pipeline::GraphicsPipeline;
|
||||
pub use self::graphics_pipeline::GraphicsPipelineParams;
|
||||
pub use self::graphics_pipeline::GraphicsPipelineCreationError;
|
||||
|
||||
mod compute_pipeline;
|
||||
mod graphics_pipeline;
|
||||
|
Loading…
Reference in New Issue
Block a user