engine/render: make pipeline aware of multiple textures

ecs
q3k 2020-07-13 23:48:39 +02:00
parent cf9ebfbae7
commit 37dd8e39b7
3 changed files with 7 additions and 8 deletions

View File

@ -199,8 +199,8 @@ impl<WT: 'static + Send + Sync> Instance<WT> {
).unwrap();
future.flush().unwrap();
let image = material.vulkan_textures(queue.clone()).diffuse;
let ds = self.pipeline.as_mut().unwrap().make_descriptor_set(image);
let textures = material.vulkan_textures(queue.clone());
let ds = self.pipeline.as_mut().unwrap().make_descriptor_set(textures);
let (vbuffer, ibuffer) = mesh.vulkan_buffers(queue.clone());
builder = builder.draw_indexed(pipeline.clone(), &vc::DynamicState::none(),

View File

@ -1,15 +1,15 @@
use std::sync::Arc;
use vulkano::format::Format;
use vulkano::pipeline as vp;
use vulkano::descriptor::descriptor_set as vdd;
use vulkano::image as vm;
use crate::render::vulkan::data;
pub type VulkanoPipeline = dyn vp::GraphicsPipelineAbstract + Send + Sync;
pub type VulkanoDescriptorSet = dyn vdd::DescriptorSet + Send + Sync;
pub trait Pipeline {
fn get_pipeline(&self) -> Arc<VulkanoPipeline>;
fn make_descriptor_set(&mut self, texture_image: Arc<vm::ImmutableImage<Format>>) -> Arc<VulkanoDescriptorSet>;
fn make_descriptor_set(&mut self, textures: data::Textures) -> Arc<VulkanoDescriptorSet>;
}

View File

@ -7,7 +7,6 @@ use vulkano::descriptor::pipeline_layout as vdp;
use vulkano::device as vd;
use vulkano::format::Format;
use vulkano::framebuffer as vf;
use vulkano::image as vm;
use vulkano::pipeline as vp;
use vulkano::pipeline::shader as vps;
use vulkano::pipeline::vertex as vpv;
@ -149,10 +148,10 @@ impl pipeline::Pipeline for Forward {
self.pipeline.clone()
}
fn make_descriptor_set(&mut self, texture_image: Arc<vm::ImmutableImage<Format>>) -> Arc<pipeline::VulkanoDescriptorSet> {
fn make_descriptor_set(&mut self, textures: data::Textures) -> Arc<pipeline::VulkanoDescriptorSet> {
let image_sampler = vs::Sampler::simple_repeat_linear(self.device.clone());
Arc::new(self.descriptor_set_pool.next()
.add_sampled_image(texture_image.clone(), image_sampler).unwrap()
.add_sampled_image(textures.diffuse.clone(), image_sampler).unwrap()
.build().unwrap())
}
}