mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Disable suballocation on Iris(R) Xe gpu (#3668)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
parent
db39b5423e
commit
f9fcb54ce4
@ -83,6 +83,10 @@ Bottom level categories:
|
|||||||
#### Vulkan
|
#### Vulkan
|
||||||
- Fix incorrect aspect in barriers when using emulated Stencil8 textures. By @cwfitzgerald in [#3833](https://github.com/gfx-rs/wgpu/pull/3833).
|
- Fix incorrect aspect in barriers when using emulated Stencil8 textures. By @cwfitzgerald in [#3833](https://github.com/gfx-rs/wgpu/pull/3833).
|
||||||
|
|
||||||
|
#### DX12
|
||||||
|
|
||||||
|
- Disable suballocation on Intel Iris(R) Xe. By @xiaopengli89 in [#3668](https://github.com/gfx-rs/wgpu/pull/3668)
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
@ -200,6 +200,8 @@ impl super::Adapter {
|
|||||||
},
|
},
|
||||||
heap_create_not_zeroed: false, //TODO: winapi support for Options7
|
heap_create_not_zeroed: false, //TODO: winapi support for Options7
|
||||||
casting_fully_typed_format_supported,
|
casting_fully_typed_format_supported,
|
||||||
|
// See https://github.com/gfx-rs/wgpu/issues/3552
|
||||||
|
suballocation_supported: !info.name.contains("Iris(R) Xe"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Theoretically vram limited, but in practice 2^20 is the limit
|
// Theoretically vram limited, but in practice 2^20 is the limit
|
||||||
|
@ -20,7 +20,11 @@ impl super::Device {
|
|||||||
library: &Arc<d3d12::D3D12Lib>,
|
library: &Arc<d3d12::D3D12Lib>,
|
||||||
dx12_shader_compiler: wgt::Dx12Compiler,
|
dx12_shader_compiler: wgt::Dx12Compiler,
|
||||||
) -> Result<Self, crate::DeviceError> {
|
) -> Result<Self, crate::DeviceError> {
|
||||||
let mem_allocator = super::suballocation::create_allocator_wrapper(&raw)?;
|
let mem_allocator = if private_caps.suballocation_supported {
|
||||||
|
super::suballocation::create_allocator_wrapper(&raw)?
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let dxc_container = match dx12_shader_compiler {
|
let dxc_container = match dx12_shader_compiler {
|
||||||
wgt::Dx12Compiler::Dxc {
|
wgt::Dx12Compiler::Dxc {
|
||||||
|
@ -176,6 +176,7 @@ struct PrivateCapabilities {
|
|||||||
#[allow(unused)] // TODO: Exists until windows-rs is standard, then it can probably be removed?
|
#[allow(unused)] // TODO: Exists until windows-rs is standard, then it can probably be removed?
|
||||||
heap_create_not_zeroed: bool,
|
heap_create_not_zeroed: bool,
|
||||||
casting_fully_typed_format_supported: bool,
|
casting_fully_typed_format_supported: bool,
|
||||||
|
suballocation_supported: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -3,6 +3,11 @@ pub(crate) use allocation::{
|
|||||||
free_buffer_allocation, free_texture_allocation, AllocationWrapper, GpuAllocatorWrapper,
|
free_buffer_allocation, free_texture_allocation, AllocationWrapper, GpuAllocatorWrapper,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "windows_rs"))]
|
||||||
|
use committed as allocation;
|
||||||
|
#[cfg(feature = "windows_rs")]
|
||||||
|
use placed as allocation;
|
||||||
|
|
||||||
// This exists to work around https://github.com/gfx-rs/wgpu/issues/3207
|
// This exists to work around https://github.com/gfx-rs/wgpu/issues/3207
|
||||||
// Currently this will work the older, slower way if the windows_rs feature is disabled,
|
// Currently this will work the older, slower way if the windows_rs feature is disabled,
|
||||||
// and will use the fast path of suballocating buffers and textures using gpu_allocator if
|
// and will use the fast path of suballocating buffers and textures using gpu_allocator if
|
||||||
@ -10,7 +15,7 @@ pub(crate) use allocation::{
|
|||||||
|
|
||||||
// This is the fast path using gpu_allocator to suballocate buffers and textures.
|
// This is the fast path using gpu_allocator to suballocate buffers and textures.
|
||||||
#[cfg(feature = "windows_rs")]
|
#[cfg(feature = "windows_rs")]
|
||||||
mod allocation {
|
mod placed {
|
||||||
use d3d12::WeakPtr;
|
use d3d12::WeakPtr;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
@ -63,6 +68,13 @@ mod allocation {
|
|||||||
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
|
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
|
||||||
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
|
let is_cpu_read = desc.usage.contains(crate::BufferUses::MAP_READ);
|
||||||
let is_cpu_write = desc.usage.contains(crate::BufferUses::MAP_WRITE);
|
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 {
|
||||||
|
return super::committed::create_buffer_resource(device, desc, raw_desc, resource)
|
||||||
|
.map(|(hr, _)| (hr, None));
|
||||||
|
}
|
||||||
|
|
||||||
let location = match (is_cpu_read, is_cpu_write) {
|
let location = match (is_cpu_read, is_cpu_write) {
|
||||||
(true, true) => MemoryLocation::CpuToGpu,
|
(true, true) => MemoryLocation::CpuToGpu,
|
||||||
(true, false) => MemoryLocation::GpuToCpu,
|
(true, false) => MemoryLocation::GpuToCpu,
|
||||||
@ -111,6 +123,12 @@ mod allocation {
|
|||||||
raw_desc: d3d12_ty::D3D12_RESOURCE_DESC,
|
raw_desc: d3d12_ty::D3D12_RESOURCE_DESC,
|
||||||
resource: &mut WeakPtr<ID3D12Resource>,
|
resource: &mut WeakPtr<ID3D12Resource>,
|
||||||
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
|
) -> Result<(HRESULT, Option<AllocationWrapper>), crate::DeviceError> {
|
||||||
|
// It's a workaround for Intel Xe drivers.
|
||||||
|
if !device.private_caps.suballocation_supported {
|
||||||
|
return super::committed::create_texture_resource(device, desc, raw_desc, resource)
|
||||||
|
.map(|(hr, _)| (hr, None));
|
||||||
|
}
|
||||||
|
|
||||||
let location = MemoryLocation::GpuOnly;
|
let location = MemoryLocation::GpuOnly;
|
||||||
|
|
||||||
let name = desc.label.unwrap_or("Unlabeled texture");
|
let name = desc.label.unwrap_or("Unlabeled texture");
|
||||||
@ -168,7 +186,6 @@ mod allocation {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "windows_rs")]
|
|
||||||
impl From<gpu_allocator::AllocationError> for crate::DeviceError {
|
impl From<gpu_allocator::AllocationError> for crate::DeviceError {
|
||||||
fn from(result: gpu_allocator::AllocationError) -> Self {
|
fn from(result: gpu_allocator::AllocationError) -> Self {
|
||||||
match result {
|
match result {
|
||||||
@ -203,8 +220,7 @@ mod allocation {
|
|||||||
|
|
||||||
// This is the older, slower path where it doesn't suballocate buffers.
|
// This is the older, slower path where it doesn't suballocate buffers.
|
||||||
// Tracking issue for when it can be removed: https://github.com/gfx-rs/wgpu/issues/3207
|
// Tracking issue for when it can be removed: https://github.com/gfx-rs/wgpu/issues/3207
|
||||||
#[cfg(not(feature = "windows_rs"))]
|
mod committed {
|
||||||
mod allocation {
|
|
||||||
use d3d12::WeakPtr;
|
use d3d12::WeakPtr;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
@ -216,7 +232,8 @@ mod allocation {
|
|||||||
Interface,
|
Interface,
|
||||||
};
|
};
|
||||||
|
|
||||||
const D3D12_HEAP_FLAG_CREATE_NOT_ZEROED: u32 = d3d12_ty::D3D12_HEAP_FLAG_NONE; // TODO: find the exact value
|
// https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_flags
|
||||||
|
const D3D12_HEAP_FLAG_CREATE_NOT_ZEROED: d3d12_ty::D3D12_HEAP_FLAGS = 0x1000;
|
||||||
|
|
||||||
// Allocator isn't needed when not suballocating with gpu_allocator
|
// Allocator isn't needed when not suballocating with gpu_allocator
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -226,6 +243,7 @@ mod allocation {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct AllocationWrapper {}
|
pub(crate) struct AllocationWrapper {}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub(crate) fn create_allocator_wrapper(
|
pub(crate) fn create_allocator_wrapper(
|
||||||
_raw: &d3d12::Device,
|
_raw: &d3d12::Device,
|
||||||
) -> Result<Option<Mutex<GpuAllocatorWrapper>>, crate::DeviceError> {
|
) -> Result<Option<Mutex<GpuAllocatorWrapper>>, crate::DeviceError> {
|
||||||
@ -315,6 +333,7 @@ mod allocation {
|
|||||||
Ok((hr, None))
|
Ok((hr, None))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub(crate) fn free_buffer_allocation(
|
pub(crate) fn free_buffer_allocation(
|
||||||
_allocation: AllocationWrapper,
|
_allocation: AllocationWrapper,
|
||||||
_allocator: &Mutex<GpuAllocatorWrapper>,
|
_allocator: &Mutex<GpuAllocatorWrapper>,
|
||||||
@ -322,6 +341,7 @@ mod allocation {
|
|||||||
// No-op when not using gpu-allocator
|
// No-op when not using gpu-allocator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub(crate) fn free_texture_allocation(
|
pub(crate) fn free_texture_allocation(
|
||||||
_allocation: AllocationWrapper,
|
_allocation: AllocationWrapper,
|
||||||
_allocator: &Mutex<GpuAllocatorWrapper>,
|
_allocator: &Mutex<GpuAllocatorWrapper>,
|
||||||
|
Loading…
Reference in New Issue
Block a user