Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ray tracing shaders prep #1737

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions vulkano-shaders/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
Expand Down
56 changes: 32 additions & 24 deletions vulkano-shaders/src/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match execution instead of many ifs would be clearer IMO.

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 }
Expand Down Expand Up @@ -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 };
Expand All @@ -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)
}
};

Expand Down
15 changes: 14 additions & 1 deletion vulkano-shaders/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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].
//!
Expand Down Expand Up @@ -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);
Expand Down