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

This commit is contained in:
2019-07-07 01:00:26 -07:00
parent 942ff4035d
commit 820b99ae4e
5 changed files with 50 additions and 5 deletions

0
src/button.rs Normal file
View File

View File

@@ -18,7 +18,6 @@ use sfml::window::{Event, Key, Style};
use sfml::window::mouse::*;
use sfml::window::mouse;
use vulkano::sync;
use std::sync::Arc;
use std::{fs, mem, iter, ptr};
@@ -30,7 +29,6 @@ use crate::slider::Slider;
use crate::timer::Timer;
use na::DimAdd;
use std::time::{SystemTime, Duration};
use shade_runner as sr;
use std::ffi::CStr;
use std::ptr::write;
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::pipeline::ComputePipeline;
use vulkano::sync::GpuFuture;
use shaderc::CompileOptions;
use shade_runner::CompileError;
mod slider;
mod timer;
mod input;
mod vkprocessor;
mod util;
// What next?

View File

@@ -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())
//}

View File

@@ -15,8 +15,9 @@ use image::{DynamicImage, ImageBuffer};
use image::GenericImageView;
use vulkano::descriptor::pipeline_layout::PipelineLayout;
use image::GenericImage;
use shade_runner::ComputeLayout;
use shade_runner::{ComputeLayout, CompileError};
use vulkano::descriptor::descriptor_set::PersistentDescriptorSetBuf;
use shaderc::CompileOptions;
pub struct VkProcessor<'a> {
pub instance: Arc<Instance>,
@@ -68,8 +69,15 @@ impl<'a> VkProcessor<'a> {
compute_path.push(PathBuf::from("resources/shaders/"));
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 =
sr::load_compute(compute_path)
sr::load_compute_with_options(compute_path, options)
.expect("Failed to compile");
let vulkano_entry =