mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
Put all inputs and outputs in entry point structs
This commit is contained in:
parent
e2fc113711
commit
fe8706aae8
@ -31,47 +31,33 @@ pub fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) -
|
||||
|
||||
let (ty, f_call) = match *execution {
|
||||
enums::ExecutionModel::ExecutionModelVertex => {
|
||||
let t = format!("::vulkano::pipeline::shader::VertexShaderEntryPoint<(), {}Input, Layout>", capitalized_ep_name);
|
||||
let f = format!("vertex_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), Layout, {}Input)", capitalized_ep_name);
|
||||
let t = format!("::vulkano::pipeline::shader::VertexShaderEntryPoint<(), {0}Input, {0}Output, Layout>", capitalized_ep_name);
|
||||
let f = format!("vertex_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), {0}Input, {0}Output, Layout)", capitalized_ep_name);
|
||||
(t, f)
|
||||
},
|
||||
|
||||
enums::ExecutionModel::ExecutionModelTessellationControl => {
|
||||
(format!("::vulkano::pipeline::shader::TessControlShaderEntryPoint"), String::new())
|
||||
let t = format!("::vulkano::pipeline::shader::TessControlShaderEntryPoint<(), {0}Input, {0}Output, Layout>", capitalized_ep_name);
|
||||
let f = format!("tess_control_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), {0}Input, {0}Output, Layout)", capitalized_ep_name);
|
||||
(t, f)
|
||||
},
|
||||
|
||||
enums::ExecutionModel::ExecutionModelTessellationEvaluation => {
|
||||
(format!("::vulkano::pipeline::shader::TessEvaluationShaderEntryPoint"), String::new())
|
||||
let t = format!("::vulkano::pipeline::shader::TessEvaluationShaderEntryPoint<(), {0}Input, {0}Output, Layout>", capitalized_ep_name);
|
||||
let f = format!("tess_evaluation_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), {0}Input, {0}Output, Layout)", capitalized_ep_name);
|
||||
(t, f)
|
||||
},
|
||||
|
||||
enums::ExecutionModel::ExecutionModelGeometry => {
|
||||
(format!("::vulkano::pipeline::shader::GeometryShaderEntryPoint"), String::new())
|
||||
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)", capitalized_ep_name);
|
||||
(t, f)
|
||||
},
|
||||
|
||||
enums::ExecutionModel::ExecutionModelFragment => {
|
||||
let mut output_types = Vec::new();
|
||||
|
||||
for interface in interface.iter() {
|
||||
for i in doc.instructions.iter() {
|
||||
match i {
|
||||
&parse::Instruction::Variable { result_type_id, result_id, ref storage_class,
|
||||
.. } if &result_id == interface =>
|
||||
{
|
||||
output_types.push(type_from_id(doc, result_type_id));
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let output = {
|
||||
let output = output_types.join(", ");
|
||||
if output.is_empty() { output } else { output + "," }
|
||||
};
|
||||
|
||||
let t = format!("::vulkano::pipeline::shader::FragmentShaderEntryPoint<(), ({output}), Layout>",
|
||||
output = output);
|
||||
(t, format!("fragment_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), Layout)"))
|
||||
let t = format!("::vulkano::pipeline::shader::FragmentShaderEntryPoint<(), {0}Input, {0}Output, Layout>", capitalized_ep_name);
|
||||
let f = format!("fragment_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), {0}Input, {0}Output, Layout)", capitalized_ep_name);
|
||||
(t, f)
|
||||
},
|
||||
|
||||
enums::ExecutionModel::ExecutionModelGLCompute => {
|
||||
|
@ -47,15 +47,15 @@ use pipeline::vertex::Definition as VertexDefinition;
|
||||
use pipeline::vertex::Vertex;
|
||||
use pipeline::viewport::ViewportsState;
|
||||
|
||||
pub struct GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vl, Gs, Gi, Go, Gl, Fs, Fo, Fl, L, Rp> where L: 'a, Rp: 'a {
|
||||
pub struct GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vo, Vl, Gs, Gi, Go, Gl, Fs, Fi, Fo, Fl, L, Rp> where L: 'a, Rp: 'a {
|
||||
pub vertex_input: Vdef,
|
||||
pub vertex_shader: VertexShaderEntryPoint<'a, Vsp, Vi, Vl>,
|
||||
pub vertex_shader: VertexShaderEntryPoint<'a, Vsp, Vi, Vo, Vl>,
|
||||
pub input_assembly: InputAssembly,
|
||||
pub geometry_shader: Option<GeometryShaderEntryPoint<'a, Gs, Gi, Go, Gl>>,
|
||||
pub viewport: ViewportsState,
|
||||
pub raster: Rasterization,
|
||||
pub multisample: Multisample,
|
||||
pub fragment_shader: FragmentShaderEntryPoint<'a, Fs, Fo, Fl>,
|
||||
pub fragment_shader: FragmentShaderEntryPoint<'a, Fs, Fi, Fo, Fl>,
|
||||
pub depth_stencil: DepthStencil,
|
||||
pub blend: Blend,
|
||||
pub layout: &'a Arc<L>,
|
||||
@ -94,23 +94,23 @@ impl<Vdef, L, Rp> GraphicsPipeline<Vdef, L, Rp>
|
||||
{
|
||||
/// Builds a new graphics pipeline object.
|
||||
#[inline]
|
||||
pub fn new<'a, Vsp, Vi, Vl, Fs, Fo, Fl>
|
||||
pub fn new<'a, Vsp, Vi, Vo, Vl, Fs, Fi, Fo, Fl>
|
||||
(device: &Arc<Device>,
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vl, (), (), (), (), Fs, Fo, Fl,
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vo, Vl, (), (), (), (), Fs, Fi, Fo, Fl,
|
||||
L, Rp>)
|
||||
-> Result<Arc<GraphicsPipeline<Vdef, L, Rp>>, GraphicsPipelineCreationError>
|
||||
where Vdef: VertexDefinition<Vi>,
|
||||
L: PipelineLayout + PipelineLayoutSuperset<Vl> + PipelineLayoutSuperset<Fl>,
|
||||
Vl: PipelineLayoutDesc, Fl: PipelineLayoutDesc
|
||||
{
|
||||
GraphicsPipeline::new_inner::<_, _, _, (), (), (), (), _, _, _>(device, params)
|
||||
GraphicsPipeline::new_inner::<_, _, _, _, (), (), (), (), _, _, _, _>(device, params)
|
||||
}
|
||||
|
||||
/// Builds a new graphics pipeline object with a geometry shader.
|
||||
#[inline]
|
||||
pub fn with_geometry_shader<'a, Vsp, Vi, Vl, Gsp, Gi, Go, Gl, Fs, Fo, Fl>
|
||||
pub fn with_geometry_shader<'a, Vsp, Vi, Vo, Vl, Gsp, Gi, Go, Gl, Fs, Fi, Fo, Fl>
|
||||
(device: &Arc<Device>,
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vl, Gsp, Gi, Go, Gl, Fs, Fo, Fl, L, Rp>)
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vo, Vl, Gsp, Gi, Go, Gl, Fs, Fi, Fo, Fl, L, Rp>)
|
||||
-> Result<Arc<GraphicsPipeline<Vdef, L, Rp>>, GraphicsPipelineCreationError>
|
||||
where Vdef: VertexDefinition<Vi>,
|
||||
L: PipelineLayout + PipelineLayoutSuperset<Vl> + PipelineLayoutSuperset<Fl>,
|
||||
@ -119,9 +119,9 @@ impl<Vdef, L, Rp> GraphicsPipeline<Vdef, L, Rp>
|
||||
GraphicsPipeline::new_inner(device, params)
|
||||
}
|
||||
|
||||
fn new_inner<'a, Vsp, Vi, Vl, Gsp, Gi, Go, Gl, Fs, Fo, Fl>
|
||||
fn new_inner<'a, Vsp, Vi, Vo, Vl, Gsp, Gi, Go, Gl, Fs, Fi, Fo, Fl>
|
||||
(device: &Arc<Device>,
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vl, Gsp, Gi, Go, Gl, Fs, Fo, Fl, L, Rp>)
|
||||
params: GraphicsPipelineParams<'a, Vdef, Vsp, Vi, Vo, Vl, Gsp, Gi, Go, Gl, Fs, Fi, Fo, Fl, L, Rp>)
|
||||
-> Result<Arc<GraphicsPipeline<Vdef, L, Rp>>, GraphicsPipelineCreationError>
|
||||
where Vdef: VertexDefinition<Vi>,
|
||||
L: PipelineLayout + PipelineLayoutSuperset<Vl> + PipelineLayoutSuperset<Fl>,
|
||||
|
@ -72,43 +72,48 @@ impl ShaderModule {
|
||||
}))
|
||||
}
|
||||
|
||||
pub unsafe fn vertex_shader_entry_point<'a, S, V, L>
|
||||
(&'a self, name: &'a CStr, layout: L,vertex_input: V)
|
||||
-> VertexShaderEntryPoint<'a, S, V, L>
|
||||
pub unsafe fn vertex_shader_entry_point<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, input: I, output: O, layout: L)
|
||||
-> VertexShaderEntryPoint<'a, S, I, O, L>
|
||||
{
|
||||
VertexShaderEntryPoint {
|
||||
module: self,
|
||||
name: name,
|
||||
vertex_input: vertex_input,
|
||||
input: input,
|
||||
output: output,
|
||||
layout: layout,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn tess_control_shader_entry_point<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, layout: L) -> TessControlShaderEntryPoint<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, input: I, output: O, layout: L) -> TessControlShaderEntryPoint<'a, S, I, O, L>
|
||||
{
|
||||
TessControlShaderEntryPoint {
|
||||
module: self,
|
||||
name: name,
|
||||
layout: layout,
|
||||
input: input,
|
||||
output: output,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn tess_evaluation_shader_entry_point<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, layout: L) -> TessEvaluationShaderEntryPoint<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, input: I, output: O, layout: L) -> TessEvaluationShaderEntryPoint<'a, S, I, O, L>
|
||||
{
|
||||
TessEvaluationShaderEntryPoint {
|
||||
module: self,
|
||||
name: name,
|
||||
layout: layout,
|
||||
input: input,
|
||||
output: output,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn geometry_shader_entry_point<'a, S, I, O, L>
|
||||
(&'a self, name: &'a CStr, primitives: GeometryShaderExecutionMode, layout: L)
|
||||
(&'a self, name: &'a CStr, primitives: GeometryShaderExecutionMode, input: I, output: O, layout: L)
|
||||
-> GeometryShaderEntryPoint<'a, S, I, O, L>
|
||||
{
|
||||
GeometryShaderEntryPoint {
|
||||
@ -116,6 +121,8 @@ impl ShaderModule {
|
||||
name: name,
|
||||
layout: layout,
|
||||
primitives: primitives,
|
||||
input: input,
|
||||
output: output,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
@ -132,13 +139,15 @@ impl ShaderModule {
|
||||
/// - Calling this function also determines the template parameters associated to the
|
||||
/// `EntryPoint` struct. Therefore care must be taken that the values there are correct.
|
||||
///
|
||||
pub unsafe fn fragment_shader_entry_point<'a, S, F, L>(&'a self, name: &'a CStr, layout: L)
|
||||
-> FragmentShaderEntryPoint<'a, S, F, L>
|
||||
pub unsafe fn fragment_shader_entry_point<'a, S, I, O, L>(&'a self, name: &'a CStr, input: I, output: O, layout: L)
|
||||
-> FragmentShaderEntryPoint<'a, S, I, O, L>
|
||||
{
|
||||
FragmentShaderEntryPoint {
|
||||
module: self,
|
||||
name: name,
|
||||
layout: layout,
|
||||
input: input,
|
||||
output: output,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
@ -175,15 +184,16 @@ impl Drop for ShaderModule {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VertexShaderEntryPoint<'a, S, V, L> {
|
||||
pub struct VertexShaderEntryPoint<'a, S, I, O, L> {
|
||||
module: &'a ShaderModule,
|
||||
name: &'a CStr,
|
||||
vertex_input: V,
|
||||
input: I,
|
||||
layout: L,
|
||||
output: O,
|
||||
marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<'a, S, V, L> VertexShaderEntryPoint<'a, S, V, L> {
|
||||
impl<'a, S, I, O, L> VertexShaderEntryPoint<'a, S, I, O, L> {
|
||||
#[inline]
|
||||
pub fn module(&self) -> &'a ShaderModule {
|
||||
self.module
|
||||
@ -199,9 +209,15 @@ impl<'a, S, V, L> VertexShaderEntryPoint<'a, S, V, L> {
|
||||
&self.layout
|
||||
}
|
||||
|
||||
// TODO: rename "input" for consistency
|
||||
#[inline]
|
||||
pub fn input_definition(&self) -> &V {
|
||||
&self.vertex_input
|
||||
pub fn input_definition(&self) -> &I {
|
||||
&self.input
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(&self) -> &O {
|
||||
&self.output
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +225,9 @@ pub struct TessControlShaderEntryPoint<'a, S, I, O, L> {
|
||||
module: &'a ShaderModule,
|
||||
name: &'a CStr,
|
||||
layout: L,
|
||||
marker: PhantomData<(S, I, O)>,
|
||||
input: I,
|
||||
output: O,
|
||||
marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<'a, S, I, O, L> TessControlShaderEntryPoint<'a, S, I, O, L> {
|
||||
@ -227,13 +245,25 @@ impl<'a, S, I, O, L> TessControlShaderEntryPoint<'a, S, I, O, L> {
|
||||
pub fn layout(&self) -> &L {
|
||||
&self.layout
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn input(&self) -> &I {
|
||||
&self.input
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(&self) -> &O {
|
||||
&self.output
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TessEvaluationShaderEntryPoint<'a, S, I, O, L> {
|
||||
module: &'a ShaderModule,
|
||||
name: &'a CStr,
|
||||
layout: L,
|
||||
marker: PhantomData<(S, I, O)>,
|
||||
input: I,
|
||||
output: O,
|
||||
marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<'a, S, I, O, L> TessEvaluationShaderEntryPoint<'a, S, I, O, L> {
|
||||
@ -251,6 +281,16 @@ impl<'a, S, I, O, L> TessEvaluationShaderEntryPoint<'a, S, I, O, L> {
|
||||
pub fn layout(&self) -> &L {
|
||||
&self.layout
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn input(&self) -> &I {
|
||||
&self.input
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(&self) -> &O {
|
||||
&self.output
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GeometryShaderEntryPoint<'a, S, I, O, L> {
|
||||
@ -258,7 +298,9 @@ pub struct GeometryShaderEntryPoint<'a, S, I, O, L> {
|
||||
name: &'a CStr,
|
||||
layout: L,
|
||||
primitives: GeometryShaderExecutionMode,
|
||||
marker: PhantomData<(S, I, O)>,
|
||||
input: I,
|
||||
output: O,
|
||||
marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<'a, S, I, O, L> GeometryShaderEntryPoint<'a, S, I, O, L> {
|
||||
@ -282,6 +324,16 @@ impl<'a, S, I, O, L> GeometryShaderEntryPoint<'a, S, I, O, L> {
|
||||
pub fn layout(&self) -> &L {
|
||||
&self.layout
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn input(&self) -> &I {
|
||||
&self.input
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(&self) -> &O {
|
||||
&self.output
|
||||
}
|
||||
}
|
||||
|
||||
/// Declares which type of primitives are expected by the geometry shader.
|
||||
@ -318,14 +370,16 @@ impl GeometryShaderExecutionMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FragmentShaderEntryPoint<'a, S, F, L> {
|
||||
pub struct FragmentShaderEntryPoint<'a, S, I, O, L> {
|
||||
module: &'a ShaderModule,
|
||||
name: &'a CStr,
|
||||
layout: L,
|
||||
marker: PhantomData<(S, F)>,
|
||||
input: I,
|
||||
output: O,
|
||||
marker: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<'a, S, F, L> FragmentShaderEntryPoint<'a, S, F, L> {
|
||||
impl<'a, S, I, O, L> FragmentShaderEntryPoint<'a, S, I, O, L> {
|
||||
#[inline]
|
||||
pub fn module(&self) -> &'a ShaderModule {
|
||||
self.module
|
||||
@ -340,6 +394,16 @@ impl<'a, S, F, L> FragmentShaderEntryPoint<'a, S, F, L> {
|
||||
pub fn layout(&self) -> &L {
|
||||
&self.layout
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn input(&self) -> &I {
|
||||
&self.input
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn output(&self) -> &O {
|
||||
&self.output
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ComputeShaderEntryPoint<'a, S, L> {
|
||||
|
Loading…
Reference in New Issue
Block a user