Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move shader analysis to Vulkano crate, make available for runtime shaders #1747

Merged
merged 5 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/src/bin/basic-compute-shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ fn main() {
"
}
}
let shader = cs::Shader::load(device.clone()).unwrap();
let shader = cs::load(device.clone()).unwrap();
ComputePipeline::new(
device.clone(),
&shader.main_entry_point(),
shader.entry_point("main").unwrap(),
&(),
None,
|_| {},
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/buffer-pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass = vulkano::single_pass_renderpass!(
device.clone(),
Expand All @@ -165,10 +165,10 @@ fn main() {

let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
10 changes: 4 additions & 6 deletions examples/src/bin/deferred/frame/ambient_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ impl AmbientLightingSystem {
};

let pipeline = {
let vs = vs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let fs = fs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module");
let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module");

GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.color_blend_state(ColorBlendState::new(subpass.num_color_attachments()).blend(
AttachmentBlend {
color_op: BlendOp::Add,
Expand Down
10 changes: 4 additions & 6 deletions examples/src/bin/deferred/frame/directional_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ impl DirectionalLightingSystem {
};

let pipeline = {
let vs = vs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let fs = fs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module");
let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module");

GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.color_blend_state(ColorBlendState::new(subpass.num_color_attachments()).blend(
AttachmentBlend {
color_op: BlendOp::Add,
Expand Down
10 changes: 4 additions & 6 deletions examples/src/bin/deferred/frame/point_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ impl PointLightingSystem {
};

let pipeline = {
let vs = vs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let fs = fs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module");
let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module");

GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.color_blend_state(ColorBlendState::new(subpass.num_color_attachments()).blend(
AttachmentBlend {
color_op: BlendOp::Add,
Expand Down
10 changes: 4 additions & 6 deletions examples/src/bin/deferred/triangle_draw_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,15 @@ impl TriangleDrawSystem {
};

let pipeline = {
let vs = vs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let fs = fs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module");
let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module");

GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.depth_stencil_state(DepthStencilState::simple_depth_test())
.render_pass(subpass)
.build(gfx_queue.device().clone())
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/dynamic-buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ fn main() {
}
}

let shader = shader::Shader::load(device.clone()).unwrap();
let shader = shader::load(device.clone()).unwrap();
let pipeline = ComputePipeline::new(
device.clone(),
&shader.main_entry_point(),
shader.entry_point("main").unwrap(),
&(),
None,
|set_descs| {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/dynamic-local-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn main() {
}
}

let shader = cs::Shader::load(device.clone()).unwrap();
let shader = cs::load(device.clone()).unwrap();

// Fetching subgroup size from the Physical Device metadata to compute appropriate
// Compute Shader local size properties.
Expand Down Expand Up @@ -175,7 +175,7 @@ fn main() {
};
let pipeline = ComputePipeline::new(
device.clone(),
&shader.main_entry_point(),
shader.entry_point("main").unwrap(),
&spec_consts,
None,
|_| {},
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ fn main() {
)
.unwrap();

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass = vulkano::single_pass_renderpass!(device.clone(),
attachments: {
Expand Down Expand Up @@ -193,10 +193,10 @@ fn main() {
let subpass = Subpass::from(render_pass.clone(), 0).unwrap();
let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip))
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.color_blend_state(ColorBlendState::new(subpass.num_color_attachments()).blend_alpha())
.render_pass(subpass)
.build(device.clone())
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/immutable-buffer-initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ void main() {
}"
}
}
let shader = cs::Shader::load(device.clone()).unwrap();
let shader = cs::load(device.clone()).unwrap();
ComputePipeline::new(
device.clone(),
&shader.main_entry_point(),
shader.entry_point("main").unwrap(),
&(),
None,
|_| {},
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ fn main() {
)
.unwrap();

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass = vulkano::single_pass_renderpass!(device.clone(),
attachments: {
Expand Down Expand Up @@ -199,10 +199,10 @@ fn main() {
let subpass = Subpass::from(render_pass.clone(), 0).unwrap();
let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new().topology(PrimitiveTopology::TriangleStrip))
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.color_blend_state(ColorBlendState::new(subpass.num_color_attachments()).blend_alpha())
.render_pass(subpass)
.with_auto_layout(device.clone(), |set_descs| {
Expand Down
20 changes: 13 additions & 7 deletions examples/src/bin/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,24 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let cs = cs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();
let cs = cs::load(device.clone()).unwrap();

// Each frame we generate a new set of vertices and each frame we need a new DrawIndirectCommand struct to
// set the number of vertices to draw
let indirect_args_pool: CpuBufferPool<DrawIndirectCommand> =
CpuBufferPool::new(device.clone(), BufferUsage::all());
let vertex_pool: CpuBufferPool<Vertex> = CpuBufferPool::new(device.clone(), BufferUsage::all());

let compute_pipeline =
ComputePipeline::new(device.clone(), &cs.main_entry_point(), &(), None, |_| {}).unwrap();
let compute_pipeline = ComputePipeline::new(
device.clone(),
cs.entry_point("main").unwrap(),
&(),
None,
|_| {},
)
.unwrap();

let render_pass = single_pass_renderpass!(
device.clone(),
Expand All @@ -231,10 +237,10 @@ fn main() {

let render_pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass = single_pass_renderpass!(
device.clone(),
Expand All @@ -241,10 +241,10 @@ fn main() {
.vertex::<Vertex>()
.instance::<InstanceData>(),
)
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ impl FractalComputePipeline {
let end_color = [0.0; 4];

let pipeline = {
let shader = cs::Shader::load(gfx_queue.device().clone()).unwrap();
let shader = cs::load(gfx_queue.device().clone()).unwrap();
ComputePipeline::new(
gfx_queue.device().clone(),
&shader.main_entry_point(),
shader.entry_point("main").unwrap(),
&(),
None,
|_| {},
Expand Down
10 changes: 4 additions & 6 deletions examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ impl PixelsDrawPipeline {
.unwrap();

let pipeline = {
let vs = vs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let fs = fs::Shader::load(gfx_queue.device().clone())
.expect("failed to create shader module");
let vs = vs::load(gfx_queue.device().clone()).expect("failed to create shader module");
let fs = fs::load(gfx_queue.device().clone()).expect("failed to create shader module");
GraphicsPipeline::start()
.vertex_input_single_buffer::<TexturedVertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.render_pass(subpass)
.build(gfx_queue.device().clone())
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/msaa-renderpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

#[derive(Default, Copy, Clone)]
struct Vertex {
Expand All @@ -266,9 +266,9 @@ fn main() {

let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/multi-window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass = vulkano::single_pass_renderpass!(
device.clone(),
Expand All @@ -208,10 +208,10 @@ fn main() {

let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_dynamic_scissor_irrelevant())
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/multiview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ fn main() {
}
}

let vs = vs::Shader::load(device.clone()).unwrap();
let fs = fs::Shader::load(device.clone()).unwrap();
let vs = vs::load(device.clone()).unwrap();
let fs = fs::load(device.clone()).unwrap();

let render_pass_description = RenderPassDesc::with_multiview(
vec![AttachmentDesc {
Expand Down Expand Up @@ -237,7 +237,7 @@ fn main() {

let pipeline = GraphicsPipeline::start()
.vertex_input_single_buffer::<Vertex>()
.vertex_shader(vs.main_entry_point(), ())
.vertex_shader(vs.entry_point("main").unwrap(), ())
.input_assembly_state(InputAssemblyState::new())
.viewport_state(ViewportState::viewport_fixed_scissor_irrelevant([
Viewport {
Expand All @@ -249,7 +249,7 @@ fn main() {
depth_range: 0.0..1.0,
},
]))
.fragment_shader(fs.main_entry_point(), ())
.fragment_shader(fs.entry_point("main").unwrap(), ())
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.build(device.clone())
.unwrap();
Expand Down
Loading