Skip to content

Commit d4b46d6

Browse files
committed
[vk] remove usage of imageless framebuffers
Imageless framebuffers are not needed, we know which views will be attached to the render pass already. Even if we wanted to more aggressively cache imageless framebuffers that wouldn't be possible since they still require specifiying view usage, texture usage and view formats. Removing usage of imageless framebuffers simplifies the code substantially.
1 parent 2bb8325 commit d4b46d6

File tree

6 files changed

+23
-200
lines changed

6 files changed

+23
-200
lines changed

wgpu-hal/src/vulkan/adapter.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ pub struct PhysicalDeviceFeatures {
4444
pub(super) descriptor_indexing:
4545
Option<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT<'static>>,
4646

47-
/// Features provided by `VK_KHR_imageless_framebuffer`, promoted to Vulkan 1.2.
48-
imageless_framebuffer: Option<vk::PhysicalDeviceImagelessFramebufferFeaturesKHR<'static>>,
49-
5047
/// Features provided by `VK_KHR_timeline_semaphore`, promoted to Vulkan 1.2
5148
timeline_semaphore: Option<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR<'static>>,
5249

@@ -138,9 +135,6 @@ impl PhysicalDeviceFeatures {
138135
if let Some(ref mut feature) = self.descriptor_indexing {
139136
info = info.push_next(feature);
140137
}
141-
if let Some(ref mut feature) = self.imageless_framebuffer {
142-
info = info.push_next(feature);
143-
}
144138
if let Some(ref mut feature) = self.timeline_semaphore {
145139
info = info.push_next(feature);
146140
}
@@ -329,16 +323,6 @@ impl PhysicalDeviceFeatures {
329323
} else {
330324
None
331325
},
332-
imageless_framebuffer: if device_api_version >= vk::API_VERSION_1_2
333-
|| enabled_extensions.contains(&khr::imageless_framebuffer::NAME)
334-
{
335-
Some(
336-
vk::PhysicalDeviceImagelessFramebufferFeaturesKHR::default()
337-
.imageless_framebuffer(private_caps.imageless_framebuffers),
338-
)
339-
} else {
340-
None
341-
},
342326
timeline_semaphore: if device_api_version >= vk::API_VERSION_1_2
343327
|| enabled_extensions.contains(&khr::timeline_semaphore::NAME)
344328
{
@@ -976,15 +960,6 @@ impl PhysicalDeviceProperties {
976960
extensions.push(khr::image_format_list::NAME);
977961
}
978962

979-
// Optional `VK_KHR_imageless_framebuffer`
980-
if self.supports_extension(khr::imageless_framebuffer::NAME) {
981-
extensions.push(khr::imageless_framebuffer::NAME);
982-
// Require `VK_KHR_maintenance2` due to it being a dependency
983-
if self.device_api_version < vk::API_VERSION_1_1 {
984-
extensions.push(khr::maintenance2::NAME);
985-
}
986-
}
987-
988963
// Optional `VK_KHR_driver_properties`
989964
if self.supports_extension(khr::driver_properties::NAME) {
990965
extensions.push(khr::driver_properties::NAME);
@@ -1420,15 +1395,6 @@ impl super::InstanceShared {
14201395
features2 = features2.push_next(next);
14211396
}
14221397

1423-
// `VK_KHR_imageless_framebuffer` is promoted to 1.2, but has no
1424-
// changes, so we can keep using the extension unconditionally.
1425-
if capabilities.supports_extension(khr::imageless_framebuffer::NAME) {
1426-
let next = features
1427-
.imageless_framebuffer
1428-
.insert(vk::PhysicalDeviceImagelessFramebufferFeaturesKHR::default());
1429-
features2 = features2.push_next(next);
1430-
}
1431-
14321398
// `VK_KHR_timeline_semaphore` is promoted to 1.2, but has no
14331399
// changes, so we can keep using the extension unconditionally.
14341400
if capabilities.supports_extension(khr::timeline_semaphore::NAME) {
@@ -1655,12 +1621,6 @@ impl super::Instance {
16551621
}
16561622

16571623
let private_caps = super::PrivateCapabilities {
1658-
imageless_framebuffers: match phd_features.imageless_framebuffer {
1659-
Some(features) => features.imageless_framebuffer == vk::TRUE,
1660-
None => phd_features
1661-
.imageless_framebuffer
1662-
.is_some_and(|ext| ext.imageless_framebuffer != 0),
1663-
},
16641624
image_view_usage: phd_capabilities.device_api_version >= vk::API_VERSION_1_1
16651625
|| phd_capabilities.supports_extension(khr::maintenance2::NAME),
16661626
timeline_semaphores: match phd_features.timeline_semaphore {

wgpu-hal/src/vulkan/command.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ impl crate::CommandEncoder for super::CommandEncoder {
714714
) -> Result<(), crate::DeviceError> {
715715
let mut vk_clear_values =
716716
ArrayVec::<vk::ClearValue, { super::MAX_TOTAL_ATTACHMENTS }>::new();
717-
let mut vk_image_views = ArrayVec::<vk::ImageView, { super::MAX_TOTAL_ATTACHMENTS }>::new();
718717
let mut rp_key = super::RenderPassKey::default();
719718
let mut fb_key = super::FramebufferKey {
720719
attachments: ArrayVec::default(),
@@ -728,7 +727,6 @@ impl crate::CommandEncoder for super::CommandEncoder {
728727
vk_clear_values.push(vk::ClearValue {
729728
color: unsafe { cat.make_vk_clear_color() },
730729
});
731-
vk_image_views.push(cat.target.view.raw);
732730
let color = super::ColorAttachmentKey {
733731
base: cat.target.make_attachment_key(cat.ops, caps),
734732
resolve: cat.resolve_target.as_ref().map(|target| {
@@ -737,11 +735,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
737735
};
738736

739737
rp_key.colors.push(Some(color));
740-
fb_key.attachments.push(cat.target.view.attachment.clone());
738+
fb_key.attachments.push(cat.target.view.raw);
741739
if let Some(ref at) = cat.resolve_target {
742740
vk_clear_values.push(unsafe { mem::zeroed() });
743-
vk_image_views.push(at.view.raw);
744-
fb_key.attachments.push(at.view.attachment.clone());
741+
fb_key.attachments.push(at.view.raw);
745742
}
746743

747744
// Assert this attachment is valid for the detected multiview, as a sanity check
@@ -763,12 +760,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
763760
stencil: ds.clear_value.1,
764761
},
765762
});
766-
vk_image_views.push(ds.target.view.raw);
767763
rp_key.depth_stencil = Some(super::DepthStencilAttachmentKey {
768764
base: ds.target.make_attachment_key(ds.depth_ops, caps),
769765
stencil_ops: ds.stencil_ops,
770766
});
771-
fb_key.attachments.push(ds.target.view.attachment.clone());
767+
fb_key.attachments.push(ds.target.view.raw);
772768

773769
// Assert this attachment is valid for the detected multiview, as a sanity check
774770
// The driver crash for this is really bad on AMD, so the check is worth it
@@ -801,19 +797,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
801797
.make_framebuffer(fb_key, raw_pass, desc.label)
802798
.unwrap();
803799

804-
let mut vk_info = vk::RenderPassBeginInfo::default()
800+
let vk_info = vk::RenderPassBeginInfo::default()
805801
.render_pass(raw_pass)
806802
.render_area(render_area)
807803
.clear_values(&vk_clear_values)
808804
.framebuffer(raw_framebuffer);
809-
let mut vk_attachment_info = if caps.imageless_framebuffers {
810-
Some(vk::RenderPassAttachmentBeginInfo::default().attachments(&vk_image_views))
811-
} else {
812-
None
813-
};
814-
if let Some(attachment_info) = vk_attachment_info.as_mut() {
815-
vk_info = vk_info.push_next(attachment_info);
816-
}
817805

818806
if let Some(label) = desc.label {
819807
unsafe { self.begin_debug_marker(label) };

wgpu-hal/src/vulkan/conv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ impl crate::Attachment<'_, super::TextureView> {
188188
caps: &super::PrivateCapabilities,
189189
) -> super::AttachmentKey {
190190
super::AttachmentKey {
191-
format: caps.map_texture_format(self.view.attachment.view_format),
192-
layout: derive_image_layout(self.usage, self.view.attachment.view_format),
191+
format: caps.map_texture_format(self.view.view_format),
192+
layout: derive_image_layout(self.usage, self.view.view_format),
193193
ops,
194194
}
195195
}
@@ -201,7 +201,6 @@ impl crate::ColorAttachment<'_, super::TextureView> {
201201
match self
202202
.target
203203
.view
204-
.attachment
205204
.view_format
206205
.sample_type(None, None)
207206
.unwrap()

0 commit comments

Comments
 (0)