Skip to content

Commit d36e5a2

Browse files
authored
Major refactor of shader interface and pipeline layout types (#1581)
* Convert trait `ShaderInterfaceDef` into struct `ShaderInterface` * Convert some instances of PipelineLayoutDesc to RuntimePipelineDesc * Use regular Vec for now * Convert PipelineLayoutDescUnion to RuntimePipelineDesc * Convert PipelineLayoutDescTweaks to use RuntimePipelineDesc * Remove PipelineLayoutDesc trait, replace with what used to be RuntimePipelineDesc * Remove PipelineLayoutAbstract trait * Fix bug * Provide value for push constants to entry point instead of type * Remove GraphicsEntryPointAbstract, allow pipelines without fragment shader * Move descriptor::pipeline_layout to pipeline::layout * Small changelog addition * Fix bug
1 parent 01fcd53 commit d36e5a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1607
-2817
lines changed

Diff for: CHANGELOG_VULKANO.md

+9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
- **Breaking** change to `ImageFormatProperties::sample_counts` field.
1010
- `sample_counts` field is originaly represented as u32 type, which is now represented by `SampleCounts` struct-type which is a boolean collection of supported `sample_counts`.
1111
- Added conversion function between SampleCountFlagBits (u32-type) and `SampleCounts` type.
12+
- **Breaking** Changes to shader interfaces and pipeline layouts.
13+
- The module `descriptor::pipeline_layout` has been renamed to `pipeline::layout`.
14+
- The trait `ShaderInterfaceDef` has been replaced by a simple struct `ShaderInterface`, and its `elements` method returns a slice instead of an iterator. This means you no longer need to define a new type for a shader interface. The accompanying type `ShaderInterfaceDefEntry` has been renamed to `ShaderInterfaceEntry` to match. The `ShaderInterfaceDefMatch` trait and `EmptyShaderInterfaceDef` struct have been removed.
15+
- The trait `PipelineLayoutDesc` has also been converted into a struct, with methods `descriptor_sets` and `push_constants` which return slices. It is functionally equivalent to the old `RuntimePipelineDesc` type, which is now merged into it. The traits `PipelineLayoutSuperset`, `PipelineLayoutSetsCompatible` and `PipelineLayoutPushConstantsCompatible` have been integrated into this struct as well. The `EmptyPipelineDesc` trait has been replaced with an `::empty()` constructor.
16+
- Consequently, functions that took a value of these traits now take a plain `ShaderInterface` or `PipelineLayoutDesc`. Types that had a type parameter for it no longer have it, e.g. `VertexDefinition`, `GraphicsEntryPoint`, `GraphicsEntryPointAbstract`, `PipelineLayout`.
17+
- Now that `PipelineLayout` has no more type parameter, the trait `PipelineLayoutAbstract` is removed. The layout type parameter is also removed from `ComputePipeline` and `GraphicsPipeline`.
18+
- `ComputeEntryPoint` and `GraphicsEntryPoint` now take a value specifying the push constants descriptor, instead of having a type parameter. The corresponding associated type on `EntryPointAbstract` has been removed.
19+
- The `GraphicsEntryPointAbstract` trait has been removed. `GraphicsPipelineBuilder` now takes a `GraphicsEntryPoint` object directly, and has lifetime parameters for the 5 shader types instead. `EntryPointDummy` is no longer needed and has been removed.
1220
- Added `DeviceExtensions::khr_spirv_1_4`, which allows SPIR-V 1.4 shaders in Vulkan 1.1.
1321
- Added `FunctionPointers::api_version` to query the highest supported instance version.
1422
- Added `Instance::api_version` and `Device::api_version` to return the actual supported Vulkan version. These may differ between instance and device, and be lower than what `FunctionPointers::api_version` and `PhysicalDevice::api_version` return (currently never higher than 1.1, but this may change in the future).
1523
- Fixed the issue when creating a buffer with exportable fd on Linux(see to #1545).
1624
- The `draw_indirect` and `draw_indexed_indirect` commands on `AutoCommandBufferBuilder` now check the draw count against the `max_draw_indirect_count` limit.
1725
- Fixed a few documentation errors.
26+
- It is now possible to construct a graphics pipeline without a fragment shader.
1827

1928
# Version 0.23.0 (2021-04-10)
2029

Diff for: examples/src/bin/basic-compute-shader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ use std::sync::Arc;
1717
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
1818
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
1919
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
20-
use vulkano::descriptor::PipelineLayoutAbstract;
2120
use vulkano::device::{Device, DeviceExtensions};
2221
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
2322
use vulkano::pipeline::ComputePipeline;
23+
use vulkano::pipeline::ComputePipelineAbstract;
2424
use vulkano::sync;
2525
use vulkano::sync::GpuFuture;
2626

Diff for: examples/src/bin/deferred/frame/ambient_lighting_system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl AmbientLightingSystem {
123123
color: [ambient_color[0], ambient_color[1], ambient_color[2], 1.0],
124124
};
125125

126-
let layout = self.pipeline.descriptor_set_layout(0).unwrap();
126+
let layout = self.pipeline.layout().descriptor_set_layout(0).unwrap();
127127
let descriptor_set = PersistentDescriptorSet::start(layout.clone())
128128
.add_image(color_input)
129129
.unwrap()

Diff for: examples/src/bin/deferred/frame/directional_lighting_system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl DirectionalLightingSystem {
135135
direction: direction.extend(0.0).into(),
136136
};
137137

138-
let layout = self.pipeline.descriptor_set_layout(0).unwrap();
138+
let layout = self.pipeline.layout().descriptor_set_layout(0).unwrap();
139139
let descriptor_set = PersistentDescriptorSet::start(layout.clone())
140140
.add_image(color_input)
141141
.unwrap()

Diff for: examples/src/bin/deferred/frame/point_lighting_system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl PointLightingSystem {
148148
position: position.extend(0.0).into(),
149149
};
150150

151-
let layout = self.pipeline.descriptor_set_layout(0).unwrap();
151+
let layout = self.pipeline.layout().descriptor_set_layout(0).unwrap();
152152
let descriptor_set = PersistentDescriptorSet::start(layout.clone())
153153
.add_image(color_input)
154154
.unwrap()

Diff for: examples/src/bin/dynamic-buffers.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ use std::sync::Arc;
1919
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
2020
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
2121
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
22-
use vulkano::descriptor::pipeline_layout::{PipelineLayoutDesc, PipelineLayoutDescTweaks};
23-
use vulkano::descriptor::PipelineLayoutAbstract;
2422
use vulkano::device::{Device, DeviceExtensions};
2523
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
24+
use vulkano::pipeline::layout::PipelineLayout;
2625
use vulkano::pipeline::shader::EntryPointAbstract;
2726
use vulkano::pipeline::ComputePipeline;
27+
use vulkano::pipeline::ComputePipelineAbstract;
2828
use vulkano::sync;
2929
use vulkano::sync::GpuFuture;
3030

@@ -88,19 +88,11 @@ fn main() {
8888
device.clone(),
8989
&shader.main_entry_point(),
9090
&(),
91-
Box::new(
92-
PipelineLayoutDescTweaks::new(
93-
shader
94-
.main_entry_point()
95-
.layout()
96-
.clone()
97-
.build(device.clone())
98-
.unwrap(),
99-
vec![(0, 0)], // The dynamic uniform buffer is at set 0, descriptor 0
100-
)
101-
.build(device.clone())
102-
.unwrap(),
103-
),
91+
{
92+
let mut layout_desc = shader.main_entry_point().layout_desc().clone();
93+
layout_desc.tweak(vec![(0, 0)]); // The dynamic uniform buffer is at set 0, descriptor 0
94+
Arc::new(PipelineLayout::new(device.clone(), layout_desc).unwrap())
95+
},
10496
None,
10597
)
10698
.unwrap(),

Diff for: examples/src/bin/dynamic-local-size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ use std::sync::Arc;
2121
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
2222
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
2323
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
24-
use vulkano::descriptor::PipelineLayoutAbstract;
2524
use vulkano::device::{Device, DeviceExtensions};
2625
use vulkano::format::Format;
2726
use vulkano::image::{view::ImageView, ImageDimensions, StorageImage};
2827
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
2928
use vulkano::pipeline::ComputePipeline;
29+
use vulkano::pipeline::ComputePipelineAbstract;
3030
use vulkano::sync;
3131
use vulkano::sync::GpuFuture;
3232

Diff for: examples/src/bin/image/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use vulkano::image::{
2020
use vulkano::instance::{Instance, PhysicalDevice};
2121
use vulkano::pipeline::viewport::Viewport;
2222
use vulkano::pipeline::GraphicsPipeline;
23+
use vulkano::pipeline::GraphicsPipelineAbstract;
2324
use vulkano::render_pass::{Framebuffer, FramebufferAbstract, RenderPass, Subpass};
2425
use vulkano::sampler::{Filter, MipmapMode, Sampler, SamplerAddressMode};
2526
use vulkano::swapchain;

Diff for: examples/src/bin/immutable-buffer-initialization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use std::sync::Arc;
1313
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, ImmutableBuffer};
1414
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
1515
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
16-
use vulkano::descriptor::PipelineLayoutAbstract;
1716
use vulkano::device::{Device, DeviceExtensions};
1817
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
1918
use vulkano::pipeline::ComputePipeline;
19+
use vulkano::pipeline::ComputePipelineAbstract;
2020
use vulkano::sync;
2121
use vulkano::sync::GpuFuture;
2222

Diff for: examples/src/bin/indirect.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ use vulkano::command_buffer::{
3838
SubpassContents,
3939
};
4040
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
41-
use vulkano::descriptor::PipelineLayoutAbstract;
4241
use vulkano::device::{Device, DeviceExtensions};
4342
use vulkano::image::view::ImageView;
4443
use vulkano::image::{ImageUsage, SwapchainImage};
4544
use vulkano::instance::{Instance, PhysicalDevice};
4645
use vulkano::pipeline::viewport::Viewport;
47-
use vulkano::pipeline::{ComputePipeline, GraphicsPipeline};
46+
use vulkano::pipeline::{ComputePipeline, ComputePipelineAbstract, GraphicsPipeline};
4847
use vulkano::render_pass::{Framebuffer, FramebufferAbstract, RenderPass, Subpass};
4948
use vulkano::swapchain;
5049
use vulkano::swapchain::{AcquireError, Swapchain, SwapchainCreationError};

Diff for: examples/src/bin/push-constants.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use std::sync::Arc;
1313
use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
1414
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage};
1515
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
16-
use vulkano::descriptor::PipelineLayoutAbstract;
1716
use vulkano::device::{Device, DeviceExtensions};
1817
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
19-
use vulkano::pipeline::ComputePipeline;
18+
use vulkano::pipeline::{ComputePipeline, ComputePipelineAbstract};
2019
use vulkano::sync;
2120
use vulkano::sync::GpuFuture;
2221

0 commit comments

Comments
 (0)