move projection matrix to push constants
parent
792409145d
commit
9c217bd83c
|
@ -1,7 +1,7 @@
|
|||
// vim: set ft=glsl:
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject {
|
||||
layout(push_constant) uniform UniformBufferObject {
|
||||
mat4 model;
|
||||
} ubo;
|
||||
|
||||
|
|
|
@ -198,14 +198,14 @@ impl<WT: 'static + Send + Sync> Instance<WT> {
|
|||
let ubo = data::UniformBufferObject {
|
||||
model: proj.clone() * view.clone() * d.get_transform(),
|
||||
};
|
||||
let ub = self.uniform_pool.as_ref().unwrap().next(ubo.clone()).unwrap();
|
||||
let ds = self.pipeline.as_mut().unwrap().make_descriptor_set(Box::new(ub));
|
||||
//let ub = self.uniform_pool.as_ref().unwrap().next(ubo.clone()).unwrap();
|
||||
//let ds = self.pipeline.as_mut().unwrap().make_descriptor_set(Box::new(ub));
|
||||
let pipeline = self.pipeline.as_ref().unwrap().get_pipeline();
|
||||
c = c.draw_indexed(pipeline, &vc::DynamicState::none(),
|
||||
vec![vbuffer.clone()],
|
||||
ibuffer.clone(),
|
||||
ds,
|
||||
()).unwrap();
|
||||
(),
|
||||
ubo).unwrap();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::sync::Arc;
|
|||
use vulkano::buffer as vb;
|
||||
use vulkano::descriptor::descriptor as vdD;
|
||||
use vulkano::descriptor::descriptor_set as vdd;
|
||||
use vulkano::descriptor::pipeline_layout as vdp;
|
||||
use vulkano::device as vd;
|
||||
use vulkano::format::Format;
|
||||
use vulkano::framebuffer as vf;
|
||||
|
@ -53,14 +54,11 @@ impl Forward {
|
|||
name: Some(Cow::Borrowed("fragColor")),
|
||||
}
|
||||
],
|
||||
uniforms: vec![
|
||||
vdD::DescriptorDesc {
|
||||
ty: vdD::DescriptorDescTy::Buffer(vdD::DescriptorBufferDesc {
|
||||
dynamic: Some(false),
|
||||
storage: false,
|
||||
}),
|
||||
array_count: 1,
|
||||
readonly: true,
|
||||
uniforms: vec![],
|
||||
push_constants: vec![
|
||||
vdp::PipelineLayoutDescPcRange {
|
||||
offset: 0,
|
||||
size: 64usize,
|
||||
stages: vdD::ShaderStages {
|
||||
vertex: true,
|
||||
..vdD::ShaderStages::none()
|
||||
|
@ -85,6 +83,7 @@ impl Forward {
|
|||
}
|
||||
],
|
||||
uniforms: vec![],
|
||||
push_constants: vec![],
|
||||
}.load_into(device.clone()).expect("could not load fragment shader");
|
||||
|
||||
let dimensions = [viewport_dimensions[0] as f32, viewport_dimensions[1] as f32];
|
||||
|
|
|
@ -16,6 +16,7 @@ pub struct ShaderDefinition {
|
|||
pub inputs: Vec<vps::ShaderInterfaceDefEntry>,
|
||||
pub outputs: Vec<vps::ShaderInterfaceDefEntry>,
|
||||
pub uniforms: Vec<vdd::DescriptorDesc>,
|
||||
pub push_constants: Vec<vdp::PipelineLayoutDescPcRange>,
|
||||
}
|
||||
|
||||
impl ShaderDefinition {
|
||||
|
@ -56,7 +57,7 @@ impl LoadedShader {
|
|||
}
|
||||
|
||||
fn layout(&self) -> RuntimeShaderLayout {
|
||||
RuntimeShaderLayout{ descs: vec![self.def.uniforms.clone()], push_constants: vec![], }
|
||||
RuntimeShaderLayout{ descs: vec![self.def.uniforms.clone()], push_constants: self.def.push_constants.clone(), }
|
||||
}
|
||||
|
||||
pub fn entry_point<'a, S>(&'a self) -> vps::GraphicsEntryPoint<'a, S, ShaderInterface, ShaderInterface, RuntimeShaderLayout> {
|
||||
|
@ -104,20 +105,6 @@ unsafe impl vdp::PipelineLayoutDesc for RuntimeShaderLayout {
|
|||
}
|
||||
Some(self.push_constants[0].clone())
|
||||
}
|
||||
//fn num_push_constants_ranges(&self) -> usize { 1 }
|
||||
//fn push_constants_range(&self, num: usize) -> Option<vdp::PipelineLayoutDescPcRange> {
|
||||
// match num {
|
||||
// 0 => Some(vdp::PipelineLayoutDescPcRange {
|
||||
// offset: 0,
|
||||
// size: 64usize,
|
||||
// stages: vdd::ShaderStages {
|
||||
// vertex: true,
|
||||
// ..vdd::ShaderStages::none()
|
||||
// },
|
||||
// }),
|
||||
// _ => None,
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
pub struct ShaderInterface {
|
||||
|
|
Loading…
Reference in New Issue