refactoring the shader container. To Trait or not to Trait? Probably Trait

This commit is contained in:
2019-09-22 01:37:58 -07:00
parent 34c23eebc0
commit 3db8eaf006
6 changed files with 165 additions and 187 deletions

View File

@@ -2,12 +2,13 @@ use crate::canvas::canvas_state::{CanvasTextureHandle, CanvasImageHandle};
use vulkano::image::{ImmutableImage, AttachmentImage};
use std::sync::Arc;
use vulkano::format::{Format, R8Unorm};
use crate::canvas::canvas_shader::CanvasShader;
use crate::canvas::canvas_shader::GenericShader;
use vulkano::sampler::Sampler;
use vulkano::descriptor::DescriptorSet;
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::buffer::CpuAccessibleBuffer;
use crate::canvas::canvas_text::{CanvasTextCacheHandle, CanvasTextHandle};
use vulkano::pipeline::GraphicsPipelineAbstract;
#[derive(Clone)]
pub struct CanvasTexture {
@@ -19,11 +20,11 @@ pub struct CanvasTexture {
impl CanvasTexture {
pub fn get_descriptor_set(&self,
shader: Arc<CanvasShader>,
pipeline: Arc<dyn GraphicsPipelineAbstract + Sync + Send>,
sampler: Arc<Sampler>) -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start(
shader.clone().get_pipeline().clone(), 0,
pipeline.clone(), 0,
)
.add_sampled_image(self.buffer.clone(), sampler.clone()).unwrap()
.build().unwrap());
@@ -39,11 +40,11 @@ pub struct CanvasImage {
}
impl CanvasImage {
pub fn get_descriptor_set(&self, shader: Arc<CanvasShader>)
pub fn get_descriptor_set(&self, pipeline: Arc<dyn GraphicsPipelineAbstract + Sync + Send>)
-> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start(
shader.clone().get_pipeline().clone(), 0,
pipeline.clone(), 0,
)
.add_image(self.buffer.clone()).unwrap()
.build().unwrap());
@@ -60,11 +61,11 @@ pub struct CanvasTextCache {
impl CanvasTextCache {
pub fn get_descriptor_set(&self,
shader: Arc<CanvasShader>,
pipeline: Arc<dyn GraphicsPipelineAbstract + Sync + Send>,
sampler: Arc<Sampler>) -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start(
shader.clone().get_pipeline().clone(), 0,
pipeline.clone(), 0,
)
.add_buffer(self.buffer.clone()).unwrap()
.build().unwrap());
@@ -82,11 +83,11 @@ pub struct CanvasText {
impl CanvasText {
pub fn get_descriptor_set(&self,
shader: Arc<CanvasShader>,
pipeline: Arc<dyn GraphicsPipelineAbstract + Sync + Send>,
sampler: Arc<Sampler>) -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start(
shader.clone().get_pipeline().clone(), 0,
pipeline.clone(), 0,
)
.add_sampled_image(self.buffer.clone(), sampler.clone()).unwrap()
.build().unwrap());