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

Document recommendations and limitations of automatic layout creation #2282

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
27 changes: 27 additions & 0 deletions vulkano/src/pipeline/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,33 @@ pub struct PipelineDescriptorSetLayoutCreateInfo {
impl PipelineDescriptorSetLayoutCreateInfo {
/// Creates a new `PipelineDescriptorSetLayoutCreateInfo` from the union of the requirements of
/// each shader stage in `stages`.
///
/// This is intended for quick prototyping or for single use layouts that do not have any
/// bindings in common with other shaders. For the general case, it is strongly recommended
/// to create pipeline layouts manually:
/// - When multiple pipelines share the same layout object, it is faster than if they have
/// different objects, even if the objects both contain identical bindings. It is also faster
/// (though a little bit less), if multiple pipeline layout objects share common descriptor
/// set objects.
/// - Pipeline layouts only need to be a superset of what the shaders use, they don't have to
/// match exactly. Creating a manual pipeline layout therefore allows you to specify layouts
/// that are applicable for many shaders, as long as each one uses a subset. This allows
/// further sharing.
/// - Creating a manual pipeline layout makes your code more robust against changes in the
/// shader, in particular regarding whether a particular binding in the shader is used or not
/// (see also the limitations below).
///
/// # Limitations:
///
/// Only bindings that are [statically used] are included in the descriptor binding
/// requirements, and therefore are included in the descriptor set layout.
/// If the use of a binding depends on input variables to the shader (buffers, images,
/// push constants etc.) then the shader reflection is unable to know that the binding is in
/// use, and it will not be included in the pipeline layout.
///
/// Note that this corresponds to the `shader_*_array_dynamic_indexing` device features.
///
/// [statically used]: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#shaders-staticuse
pub fn from_stages<'a>(
stages: impl IntoIterator<Item = &'a PipelineShaderStageCreateInfo>,
) -> Self {
Expand Down