hitting this damn shader module again. Very unergonomic interface with the fact that the entry point doesn't just own the shadermodule
This commit is contained in:
@@ -6,6 +6,7 @@ use vulkano::descriptor::pipeline_layout::PipelineLayout;
|
||||
use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, PersistentDescriptorSetBuf};
|
||||
use image::ImageBuffer;
|
||||
use image::Rgba;
|
||||
use shade_runner::Layout;
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct CompuBufferHandle {
|
||||
@@ -68,8 +69,8 @@ impl CompuBuffers {
|
||||
self.dimensions
|
||||
}
|
||||
|
||||
pub fn get_descriptor_set(&self, compute_pipeline: std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>>)
|
||||
-> Arc<PersistentDescriptorSet<std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>>, ((((),
|
||||
pub fn get_descriptor_set(&self, compute_pipeline: std::sync::Arc<ComputePipeline<PipelineLayout<Layout>>>)
|
||||
-> Arc<PersistentDescriptorSet<std::sync::Arc<ComputePipeline<PipelineLayout<Layout>>>, ((((),
|
||||
PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u8]>>>),
|
||||
PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u8]>>>),
|
||||
PersistentDescriptorSetBuf<std::sync::Arc<vulkano::buffer::cpu_access::CpuAccessibleBuffer<[u32]>>>)>> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::ffi::CStr;
|
||||
use std::path::PathBuf;
|
||||
use shade_runner as sr;
|
||||
use vulkano::descriptor::pipeline_layout::PipelineLayout;
|
||||
use shade_runner::{CompileError, FragLayout, FragInput, FragOutput, VertInput, VertOutput, VertLayout, CompiledShaders, Entry};
|
||||
use shade_runner::{CompileError, Layout, Input, Output, CompiledShaders, Entry, CompiledShader};
|
||||
use shaderc::CompileOptions;
|
||||
use vulkano::pipeline::shader::{ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry};
|
||||
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle};
|
||||
@@ -20,12 +20,12 @@ pub struct CompuKernel {
|
||||
|
||||
handle: Arc<CompuKernelHandle>,
|
||||
|
||||
compute_pipeline: Option<std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>>>,
|
||||
compute_pipeline: Option<std::sync::Arc<ComputePipeline<PipelineLayout<Layout>>>>,
|
||||
compute_kernel_path: PathBuf,
|
||||
|
||||
name: String,
|
||||
|
||||
shader: CompiledShaders,
|
||||
shader: CompiledShader,
|
||||
entry: Entry,
|
||||
shader_module: Arc<ShaderModule>,
|
||||
device: Arc<Device>,
|
||||
@@ -61,7 +61,7 @@ impl CompuKernel {
|
||||
.expect("Failed to parse");
|
||||
|
||||
let shader_module = unsafe {
|
||||
vulkano::pipeline::shader::ShaderModule::from_words(device.clone(), &shader.compute)
|
||||
vulkano::pipeline::shader::ShaderModule::from_words(device.clone(), &shader.spriv)
|
||||
}.unwrap();
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ impl CompuKernel {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_pipeline(&mut self) -> std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>> {
|
||||
pub fn get_pipeline(&mut self) -> std::sync::Arc<ComputePipeline<PipelineLayout<Layout>>> {
|
||||
|
||||
match self.compute_pipeline.clone() {
|
||||
Some(t) => t,
|
||||
@@ -91,7 +91,7 @@ impl CompuKernel {
|
||||
unsafe {
|
||||
ComputePipeline::new(self.device.clone(), &self.shader_module.compute_entry_point(
|
||||
CStr::from_bytes_with_nul_unchecked(b"main\0"),
|
||||
self.entry.compute_layout.clone()), &self.specialization_constants,
|
||||
self.entry.layout.clone()), &self.specialization_constants,
|
||||
).unwrap()
|
||||
}
|
||||
}));
|
||||
@@ -100,11 +100,11 @@ impl CompuKernel {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recompile_kernel(&mut self) -> std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>> {
|
||||
pub fn recompile_kernel(&mut self) -> std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::Layout>>> {
|
||||
self.compile_kernel(String::from(self.compute_kernel_path.clone().to_str().unwrap()))
|
||||
}
|
||||
|
||||
pub fn compile_kernel(&mut self, filename: String) -> std::sync::Arc<ComputePipeline<PipelineLayout<shade_runner::layouts::ComputeLayout>>> {
|
||||
pub fn compile_kernel(&mut self, filename: String) -> std::sync::Arc<ComputePipeline<PipelineLayout<Layout>>> {
|
||||
|
||||
let mut options = CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap();
|
||||
self.compute_kernel_path = CompuKernel::get_path(filename);
|
||||
@@ -118,7 +118,7 @@ impl CompuKernel {
|
||||
.expect("Failed to parse");
|
||||
|
||||
self.shader_module = unsafe {
|
||||
vulkano::pipeline::shader::ShaderModule::from_words(self.device.clone(), &self.shader.compute)
|
||||
vulkano::pipeline::shader::ShaderModule::from_words(self.device.clone(), &self.shader.spriv)
|
||||
}.unwrap();
|
||||
|
||||
self.get_pipeline()
|
||||
|
||||
Reference in New Issue
Block a user