Skip to content

Commit

Permalink
Don't create allocator if suballocation isn't supported
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed Apr 15, 2023
1 parent a9dce2b commit 75eec5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ impl super::Device {
library: &Arc<d3d12::D3D12Lib>,
dx12_shader_compiler: wgt::Dx12Compiler,
) -> Result<Self, crate::DeviceError> {
let mem_allocator = super::suballocation::create_allocator_wrapper(&raw)?;
let mut mem_allocator = None;
if private_caps.suballocation_supported {
mem_allocator = super::suballocation::create_allocator_wrapper(&raw)?;
}

let dxc_container = match dx12_shader_compiler {
wgt::Dx12Compiler::Dxc {
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/dx12/suballocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ mod allocation {
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
let is_cpu_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);

// It's a workaround for Intel Xe drivers.
if !device.private_caps.suballocation_supported {
let heap_properties = d3d12_ty::D3D12_HEAP_PROPERTIES {
Type: d3d12_ty::D3D12_HEAP_TYPE_CUSTOM,
Expand Down Expand Up @@ -156,6 +157,7 @@ mod allocation {
raw_desc: d3d12_ty::D3D12_RESOURCE_DESC,
resource: &mut WeakPtr<ID3D12Resource>,
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
// It's a workaround for Intel Xe drivers.
if !device.private_caps.suballocation_supported {
let heap_properties = d3d12_ty::D3D12_HEAP_PROPERTIES {
Type: d3d12_ty::D3D12_HEAP_TYPE_CUSTOM,
Expand Down

0 comments on commit 75eec5a

Please sign in to comment.