From 2bb1cba1c60cf69977da0a7cd9fa05f992d12fcc Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Sun, 24 Oct 2021 10:41:54 -0400 Subject: [PATCH 1/2] Raytracing: Add requirements to Raytracing Storage Classes --- vulkano-shaders/src/codegen.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/vulkano-shaders/src/codegen.rs b/vulkano-shaders/src/codegen.rs index f77d64e727..f02cd787e0 100644 --- a/vulkano-shaders/src/codegen.rs +++ b/vulkano-shaders/src/codegen.rs @@ -736,12 +736,24 @@ fn storage_class_requirement(storage_class: &StorageClass) -> &'static [DeviceRe StorageClass::StorageBuffer => &[DeviceRequirement::Extension( "khr_storage_buffer_storage_class", )], - StorageClass::CallableDataKHR => todo!(), - StorageClass::IncomingCallableDataKHR => todo!(), - StorageClass::RayPayloadKHR => todo!(), - StorageClass::HitAttributeKHR => todo!(), - StorageClass::IncomingRayPayloadKHR => todo!(), - StorageClass::ShaderRecordBufferKHR => todo!(), + StorageClass::CallableDataKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] + StorageClass::IncomingCallableDataKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] + StorageClass::RayPayloadKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] + StorageClass::HitAttributeKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] + StorageClass::IncomingRayPayloadKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] + StorageClass::ShaderRecordBufferKHR => &[DeviceRequirement::Extension( + "khr_ray_tracing", + )] StorageClass::PhysicalStorageBuffer => todo!(), StorageClass::CodeSectionINTEL => todo!(), } From 432edc26d6255981f42bf0c72414e3bc17655ba0 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Tue, 14 Apr 2020 17:08:11 +0200 Subject: [PATCH 2/2] vulkano-shaders: Prepare support for rt shaders Refactor write entry point to later support raytracing class of execution models. https://github.com/KhronosGroup/SPIRV-Headers/commit/0350b1d426709a8ea6a9d4988e256fbc58cebf57 https://github.com/KhronosGroup/SPIRV-Headers/commit/95b48cedd07d4134ef0005898f8354615ca64282 --- vulkano-shaders/src/entry_point.rs | 56 +++++++++++++++++------------- vulkano-shaders/src/lib.rs | 15 +++++++- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/vulkano-shaders/src/entry_point.rs b/vulkano-shaders/src/entry_point.rs index faf9ecf3fc..a69b8a0c8a 100644 --- a/vulkano-shaders/src/entry_point.rs +++ b/vulkano-shaders/src/entry_point.rs @@ -107,17 +107,16 @@ pub(super) fn write_entry_point( }; let (ty, f_call) = { - if let ExecutionModel::GLCompute = *execution { - ( - quote! { ::vulkano::pipeline::shader::ComputeEntryPoint }, - quote! { compute_entry_point( - ::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), - #descriptor_set_layout_descs, - #push_constant_ranges, - <#spec_consts_struct>::descriptors(), - )}, - ) - } else { + if let ExecutionModel::Kernel = *execution { + panic!("Kernels are not supported"); + } else if match *execution { + ExecutionModel::Vertex => true, + ExecutionModel::TessellationControl => true, + ExecutionModel::TessellationEvaluation => true, + ExecutionModel::Geometry => true, + ExecutionModel::Fragment => true, + _ => false, + } { let entry_ty = match *execution { ExecutionModel::Vertex => { quote! { ::vulkano::pipeline::shader::GraphicsShaderType::Vertex } @@ -166,19 +165,7 @@ pub(super) fn write_entry_point( quote! { ::vulkano::pipeline::shader::GraphicsShaderType::Fragment } } - ExecutionModel::GLCompute => unreachable!(), - - ExecutionModel::Kernel - | ExecutionModel::TaskNV - | ExecutionModel::MeshNV - | ExecutionModel::RayGenerationKHR - | ExecutionModel::IntersectionKHR - | ExecutionModel::AnyHitKHR - | ExecutionModel::ClosestHitKHR - | ExecutionModel::MissKHR - | ExecutionModel::CallableKHR => { - panic!("Shaders with {:?} are not supported", execution) - } + _ => unreachable!(), }; let ty = quote! { ::vulkano::pipeline::shader::GraphicsEntryPoint }; @@ -195,6 +182,27 @@ pub(super) fn write_entry_point( }; (ty, f_call) + } else if let ExecutionModel::GLCompute = *execution { + ( + quote! { ::vulkano::pipeline::shader::ComputeEntryPoint }, + quote! { compute_entry_point( + ::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), + #descriptor_set_layout_descs, + #push_constant_ranges, + <#spec_consts_struct>::descriptors(), + )}, + ) + } else if match *execution { + ExecutionModel::RayGenerationKHR => true, + ExecutionModel::IntersectionKHR => true, + ExecutionModel::AnyHitKHR => true, + ExecutionModel::ClosestHitKHR => true, + ExecutionModel::MissKHR => true, + ExecutionModel::CallableKHR => true, + } { + panic!("Raytracing Shaders are not supported") + } else { + panic!("Shaders with {:?} are not supported", execution) } }; diff --git a/vulkano-shaders/src/lib.rs b/vulkano-shaders/src/lib.rs index 5d0b7817b3..b49341d893 100644 --- a/vulkano-shaders/src/lib.rs +++ b/vulkano-shaders/src/lib.rs @@ -112,6 +112,12 @@ //! * `tess_ctrl` //! * `tess_eval` //! * `compute` +//! * `ray_generation` +//! * `intersection` +//! * `any_hit` +//! * `closest_hit` +//! * `miss` +//! * `callable` //! //! For details on what these shader types mean, [see Vulkano's documentation][pipeline]. //! @@ -410,7 +416,14 @@ impl Parse for MacroInput { "tess_ctrl" => ShaderKind::TessControl, "tess_eval" => ShaderKind::TessEvaluation, "compute" => ShaderKind::Compute, - _ => panic!("Unexpected shader type, valid values: vertex, fragment, geometry, tess_ctrl, tess_eval, compute") + "ray_generation" => ShaderKind::RayGeneration, + "intersection" => ShaderKind::Intersection, + "any_hit" => ShaderKind::AnyHit, + "closest_hit" => ShaderKind::ClosestHit, + "miss" => ShaderKind::Miss, + "callable" => ShaderKind::Callable, + _ => panic!("Unexpected shader type, valid values: vertex, fragment, geometry, tess_ctrl, tess_eval, compute, \ + ray_generation, intersection, any_hit, closest_hit, miss, callable") }; output.0 = Some(ty);