Skip to content

Commit

Permalink
Add a vulkan workaround for large buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Jun 21, 2022
1 parent 1915370 commit 05f0477
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,12 @@ impl super::Instance {
);
};

let is_mesa = cfg!(linux);

if is_mesa {
workarounds |= super::Workarounds::BUFFER_EXTENTS_I32;
}

if phd_capabilities.properties.api_version == vk::API_VERSION_1_0
&& !phd_capabilities.supports_extension(vk::KhrStorageBufferStorageClassFn::name())
{
Expand Down
5 changes: 5 additions & 0 deletions wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ impl crate::Device<super::Api> for super::Device {
&self,
desc: &crate::BufferDescriptor,
) -> Result<super::Buffer, crate::DeviceError> {
if self.shared.workarounds.contains(super::Workarounds::BUFFER_EXTENTS_I32) &&
desc.size > std::i32::MAX as wgt::BufferAddress {
return Err(crate::DeviceError::OutOfMemory);
}

let vk_info = vk::BufferCreateInfo::builder()
.size(desc.size)
.usage(conv::map_buffer_usage(desc.usage))
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ bitflags::bitflags!(
/// Qualcomm OOMs when there are zero color attachments but a non-null pointer
/// to a subpass resolve attachment array. This nulls out that pointer in that case.
const EMPTY_RESOLVE_ATTACHMENT_LISTS = 0x2;
/// Some drivers run into issues if buffer sizes/ranges don't fit an signed 32 bits integer.
const BUFFER_EXTENTS_I32 = 0x4;
}
);

Expand Down

0 comments on commit 05f0477

Please sign in to comment.