Restore specialization constants

This commit is contained in:
Pierre Krieger 2016-04-05 11:18:15 +02:00
parent 304f05256a
commit 2cb409fbcd
4 changed files with 27 additions and 25 deletions

View File

@ -226,7 +226,7 @@ fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) -> St
format!("({}, ::std::borrow::Cow::Borrowed(\"{}\"))", loc, name)
}).collect::<Vec<_>>().join(", ");
let t = format!("::vulkano::pipeline::shader::VertexShaderEntryPoint<({input}), Layout>",
let t = format!("::vulkano::pipeline::shader::VertexShaderEntryPoint<(), ({input}), Layout>",
input = input);
let f = format!("vertex_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), Layout, vec![{}])", attributes);
(t, f)
@ -266,13 +266,13 @@ fn write_entry_point(doc: &parse::Spirv, instruction: &parse::Instruction) -> St
if output.is_empty() { output } else { output + "," }
};
let t = format!("::vulkano::pipeline::shader::FragmentShaderEntryPoint<({output}), Layout>",
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)"))
},
enums::ExecutionModel::ExecutionModelGLCompute => {
(format!("::vulkano::pipeline::shader::ComputeShaderEntryPoint<Layout>"),
(format!("::vulkano::pipeline::shader::ComputeShaderEntryPoint<(), Layout>"),
format!("compute_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), Layout)"))
},

View File

@ -38,9 +38,9 @@ impl<Pl> ComputePipeline<Pl> {
/// # Panic
///
/// Panicks if the pipeline layout and/or shader don't belong to the device.
pub fn new<Csl>(device: &Arc<Device>, pipeline_layout: &Arc<Pl>,
shader: &ComputeShaderEntryPoint<Csl>)
-> Result<Arc<ComputePipeline<Pl>>, OomError>
pub fn new<Css, Csl>(device: &Arc<Device>, pipeline_layout: &Arc<Pl>,
shader: &ComputeShaderEntryPoint<Css, Csl>)
-> Result<Arc<ComputePipeline<Pl>>, OomError>
where Pl: PipelineLayout// + PipelineLayoutSuperset<Csl>, Csl: PipelineLayoutDesc
{
let vk = device.pointers();

View File

@ -70,11 +70,11 @@ impl<Mv, L, Rp> GraphicsPipeline<Mv, L, Rp>
/// - Panicks if the line width is different from 1.0 and the `wide_lines` feature is not enabled.
///
// TODO: check all the device's limits
pub fn new<Vi, Fo, Vl, Fl>
(device: &Arc<Device>, vertex: Mv, vertex_shader: &VertexShaderEntryPoint<Vi, Vl>,
pub fn new<Vs, Vi, Fo, Vl, Fs, Fl>
(device: &Arc<Device>, vertex: Mv, vertex_shader: &VertexShaderEntryPoint<Vs, Vi, Vl>,
input_assembly: &InputAssembly, viewport: &ViewportsState,
raster: &Rasterization, multisample: &Multisample, blend: &Blend,
fragment_shader: &FragmentShaderEntryPoint<Fo, Fl>,
fragment_shader: &FragmentShaderEntryPoint<Fs, Fo, Fl>,
layout: &Arc<L>, render_pass: Subpass<Rp>)
-> Result<Arc<GraphicsPipeline<Mv, L, Rp>>, OomError>
where L: PipelineLayout + PipelineLayoutSuperset<Vl> + PipelineLayoutSuperset<Fl>,

View File

@ -67,16 +67,16 @@ impl ShaderModule {
}))
}
pub unsafe fn vertex_shader_entry_point<'a, V, L>(&'a self, name: &'a CStr, layout: L,
attributes: Vec<(u32, Cow<'static, str>)>)
-> VertexShaderEntryPoint<'a, V, L>
pub unsafe fn vertex_shader_entry_point<'a, S, V, L>(&'a self, name: &'a CStr, layout: L,
attributes: Vec<(u32, Cow<'static, str>)>)
-> VertexShaderEntryPoint<'a, S, V, L>
{
VertexShaderEntryPoint {
module: self,
name: name,
layout: layout,
marker: PhantomData,
attributes: attributes,
marker: PhantomData,
}
}
@ -92,8 +92,8 @@ 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, F, L>(&'a self, name: &'a CStr, layout: L)
-> FragmentShaderEntryPoint<'a, F, L>
pub unsafe fn fragment_shader_entry_point<'a, S, F, L>(&'a self, name: &'a CStr, layout: L)
-> FragmentShaderEntryPoint<'a, S, F, L>
{
FragmentShaderEntryPoint {
module: self,
@ -104,13 +104,14 @@ impl ShaderModule {
}
#[inline]
pub unsafe fn compute_shader_entry_point<'a, L>(&'a self, name: &'a CStr, layout: L)
-> ComputeShaderEntryPoint<'a, L>
pub unsafe fn compute_shader_entry_point<'a, S, L>(&'a self, name: &'a CStr, layout: L)
-> ComputeShaderEntryPoint<'a, S, L>
{
ComputeShaderEntryPoint {
module: self,
name: name,
layout: layout,
marker: PhantomData,
}
}
}
@ -134,15 +135,15 @@ impl Drop for ShaderModule {
}
}
pub struct VertexShaderEntryPoint<'a, V, L> {
pub struct VertexShaderEntryPoint<'a, S, V, L> {
module: &'a ShaderModule,
name: &'a CStr,
marker: PhantomData<V>,
attributes: Vec<(u32, Cow<'static, str>)>,
layout: L,
marker: PhantomData<(S, V)>,
}
impl<'a, V, L> VertexShaderEntryPoint<'a, V, L> {
impl<'a, S, V, L> VertexShaderEntryPoint<'a, S, V, L> {
#[inline]
pub fn module(&self) -> &'a ShaderModule {
self.module
@ -165,13 +166,14 @@ impl<'a, V, L> VertexShaderEntryPoint<'a, V, L> {
}
}
pub struct ComputeShaderEntryPoint<'a, L> {
pub struct ComputeShaderEntryPoint<'a, S, L> {
module: &'a ShaderModule,
name: &'a CStr,
layout: L,
marker: PhantomData<S>,
}
impl<'a, L> ComputeShaderEntryPoint<'a, L> {
impl<'a, S, L> ComputeShaderEntryPoint<'a, S, L> {
#[inline]
pub fn module(&self) -> &'a ShaderModule {
self.module
@ -188,14 +190,14 @@ impl<'a, L> ComputeShaderEntryPoint<'a, L> {
}
}
pub struct FragmentShaderEntryPoint<'a, F, L> {
pub struct FragmentShaderEntryPoint<'a, S, F, L> {
module: &'a ShaderModule,
name: &'a CStr,
marker: PhantomData<F>,
layout: L,
marker: PhantomData<(S, F)>,
}
impl<'a, F, L> FragmentShaderEntryPoint<'a, F, L> {
impl<'a, S, F, L> FragmentShaderEntryPoint<'a, S, F, L> {
#[inline]
pub fn module(&self) -> &'a ShaderModule {
self.module