From af7be04615b324c249e1d0a0330a3b4d9ac4f9a0 Mon Sep 17 00:00:00 2001 From: Till Date: Sun, 18 Aug 2019 23:28:17 +0200 Subject: [PATCH] ubo working --- shaders/triangle.frag | 4 ++-- src/main.rs | 8 ++++---- src/vulkan.rs | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/shaders/triangle.frag b/shaders/triangle.frag index d49105c..3f17d01 100644 --- a/shaders/triangle.frag +++ b/shaders/triangle.frag @@ -5,8 +5,8 @@ layout(location = 0) in vec2 tex_coords; layout(location = 0) out vec4 out_color; -layout(binding = 1) uniform sampler2D tex; +//layout(binding = 1) uniform sampler2D tex; void main() { - out_color = texture(tex, tex_coords); + out_color = vec4(1.0, 0.0, 0.0, 1.0);// texture(tex, tex_coords); } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 77e6ac1..f022117 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,9 +44,9 @@ impl TestGame { fn update(self: &mut Self, renderer: &mut VulkanRenderer) { self.input.frame_start(); -// let new_time = (renderer.game_data.start_time.elapsed().unwrap().as_micros() as f64 / 1000000.0) as f32; + let new_time = (renderer.game_data.start_time.elapsed().unwrap().as_micros() as f64 / 1000000.0) as f32; // let frame_time = new_time - renderer.game_data.uniform_buffers.iter().map(|ubo| ubo.time).max_by(|a,b| if a > b {Ordering::Greater} else {Ordering::Less} ).unwrap(); -// renderer.game_data.uniform_buffers.iter_mut().for_each(|ubo| ubo.time = new_time); +// renderer.uniform_buffers.iter_mut().for_each(|ubo| ubo.time = new_time); // User interaction if self.input.button_just_released("quit") { @@ -87,8 +87,8 @@ impl TestGame { renderer.game_data.push_constants.view = view.into(); renderer.game_data.push_constants.projection = proj.into(); -// renderer.game_data.uniform_buffers.iter_mut().for_each(|ubo| ubo.view = view.into()); -// renderer.game_data.uniform_buffers.iter_mut().for_each(|ubo| ubo.projection = proj.into()); +// renderer.uniform_buffers.iter_mut().for_each(|ubo| ubo.view = view.into()); +// renderer.uniform_buffers.iter_mut().for_each(|ubo| ubo.projection = proj.into()); renderer.game_data.line_push_constants.view = view.into(); renderer.game_data.line_push_constants.projection = proj.into(); diff --git a/src/vulkan.rs b/src/vulkan.rs index 77b241c..a44bb9a 100644 --- a/src/vulkan.rs +++ b/src/vulkan.rs @@ -76,7 +76,8 @@ pub struct GameObject { pub(crate) type GameObjectHandle = usize; pub(crate) type MeshHandle = usize; -type FixedGraphicsDescriptorSet = Arc, ((((), PersistentDescriptorSetBuf>>), PersistentDescriptorSetImg>>), PersistentDescriptorSetSampler)>>; +type FixedGraphicsDescriptorSet = Arc, ((), PersistentDescriptorSetBuf>>)>>; +//type FixedGraphicsDescriptorSet = Arc, ((((), PersistentDescriptorSetBuf>>), PersistentDescriptorSetImg>>), PersistentDescriptorSetSampler)>>; pub struct GameData { pub start_time: SystemTime, @@ -312,7 +313,7 @@ impl VulkanRenderer { descriptor_set_pool .lock().unwrap().next() .add_buffer(uniform_buffer.clone()).unwrap() - .add_sampled_image(default_tex.clone(), sampler.clone()).unwrap() +// .add_sampled_image(default_tex.clone(), sampler.clone()).unwrap() .build().unwrap()) }) .collect();