forked shade_runner and added compiler options. Going to add buttons along with a workflow for picking swatches

master
mitchellhansen 5 years ago
parent 942ff4035d
commit 820b99ae4e

@ -14,5 +14,7 @@ rand = "0.6.5"
vulkano = "0.12.0" vulkano = "0.12.0"
vulkano-shaders = "0.12.0" vulkano-shaders = "0.12.0"
time = "0.1.38" time = "0.1.38"
shade_runner = "0.1.1" shaderc = "0.5.0"
shade_runner = {version = "0.1.1", git = "https://github.com/MitchellHansen/shade_runner"}
#shade_runner = {version = "0.1.1", path = "../shade_runner"}

@ -18,7 +18,6 @@ use sfml::window::{Event, Key, Style};
use sfml::window::mouse::*; use sfml::window::mouse::*;
use sfml::window::mouse; use sfml::window::mouse;
use vulkano::sync; use vulkano::sync;
use std::sync::Arc; use std::sync::Arc;
use std::{fs, mem, iter, ptr}; use std::{fs, mem, iter, ptr};
@ -30,7 +29,6 @@ use crate::slider::Slider;
use crate::timer::Timer; use crate::timer::Timer;
use na::DimAdd; use na::DimAdd;
use std::time::{SystemTime, Duration}; use std::time::{SystemTime, Duration};
use shade_runner as sr;
use std::ffi::CStr; use std::ffi::CStr;
use std::ptr::write; use std::ptr::write;
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess}; use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, DeviceLocalBuffer, ImmutableBuffer, BufferAccess};
@ -40,11 +38,14 @@ use vulkano::device::{Device, DeviceExtensions};
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice}; use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
use vulkano::pipeline::ComputePipeline; use vulkano::pipeline::ComputePipeline;
use vulkano::sync::GpuFuture; use vulkano::sync::GpuFuture;
use shaderc::CompileOptions;
use shade_runner::CompileError;
mod slider; mod slider;
mod timer; mod timer;
mod input; mod input;
mod vkprocessor; mod vkprocessor;
mod util;
// What next? // What next?

@ -0,0 +1,34 @@
//use crate::error::CompileError;
//use shaderc::{IncludeType, ResolvedInclude};
//use shaderc::{ShaderKind, CompileOptions};
//use std::fs::File;
//use std::io::Read;
//use std::path::{Path, PathBuf};
//
//
//
//pub fn compile<T>(path: T, shader_kind: ShaderKind) -> Result<Vec<u32>, CompileError>
// where
// T: AsRef<Path>,
//{
// // TODO Probably shouldn't create this every time.
// let mut compiler = shaderc::Compiler::new().ok_or(CompileError::CreateCompiler)?;
// let mut options = CompileOptions::new().ok_or(CompileError::CreateCompiler)?;
// let mut f = File::open(&path).map_err(CompileError::Open)?;
// let mut src = String::new();
// f.read_to_string(&mut src).map_err(CompileError::Open)?;
// options.set_include_callback(|path, include_type, folder_path, depth| {
// get_include(path, include_type, folder_path, depth)
// });
// let result = compiler
// .compile_into_spirv(
// src.as_str(),
// shader_kind,
// path.as_ref().to_str().ok_or(CompileError::InvalidPath)?,
// "main",
// Some(&options),
// )
// .map_err(CompileError::Compile)?;
// let data = result.as_binary();
// Ok(data.to_owned())
//}

@ -15,8 +15,9 @@ use image::{DynamicImage, ImageBuffer};
use image::GenericImageView; use image::GenericImageView;
use vulkano::descriptor::pipeline_layout::PipelineLayout; use vulkano::descriptor::pipeline_layout::PipelineLayout;
use image::GenericImage; use image::GenericImage;
use shade_runner::ComputeLayout; use shade_runner::{ComputeLayout, CompileError};
use vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf; use vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf;
use shaderc::CompileOptions;
pub struct VkProcessor<'a> { pub struct VkProcessor<'a> {
pub instance: Arc<Instance>, pub instance: Arc<Instance>,
@ -68,8 +69,15 @@ impl<'a> VkProcessor<'a> {
compute_path.push(PathBuf::from("resources/shaders/")); compute_path.push(PathBuf::from("resources/shaders/"));
compute_path.push(PathBuf::from(filename)); compute_path.push(PathBuf::from(filename));
let mut options = CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap();
options.add_macro_definition("SETTING_POS_X", Some("0"));
options.add_macro_definition("SETTING_POS_Y", Some("1"));
options.add_macro_definition("SETTING_BUCKETS_START", Some("2"));
options.add_macro_definition("SETTING_BUCKETS_LEN", Some("2"));
let shader = let shader =
sr::load_compute(compute_path) sr::load_compute_with_options(compute_path, options)
.expect("Failed to compile"); .expect("Failed to compile");
let vulkano_entry = let vulkano_entry =

Loading…
Cancel
Save