[d3d12] Move private_capabilities to DeviceShared

This commit is contained in:
Connor Fitzgerald
2025-04-03 13:20:59 -04:00
committed by Teodor Tanasoaia
parent e8e66afb72
commit 74b37916db
4 changed files with 18 additions and 13 deletions

View File

@@ -149,6 +149,7 @@ impl super::Device {
capacity_views,
)?,
sampler_heap: super::sampler::SamplerHeap::new(&raw, &private_caps)?,
private_caps,
};
let mut rtv_pool =
@@ -180,7 +181,6 @@ impl super::Device {
fence: idle_fence,
event: Event::create(false, false)?,
},
private_caps,
features,
shared: Arc::new(shared),
rtv_pool: Mutex::new(rtv_pool),
@@ -502,7 +502,9 @@ impl crate::Device for super::Device {
desc.format,
desc.usage,
!desc.view_formats.is_empty(),
self.private_caps.casting_fully_typed_format_supported,
self.shared
.private_caps
.casting_fully_typed_format_supported,
),
SampleDesc: Dxgi::Common::DXGI_SAMPLE_DESC {
Count: desc.sample_count,
@@ -1351,7 +1353,7 @@ impl crate::Device for super::Device {
},
bind_group_infos,
naga_options: hlsl::Options {
shader_model: self.private_caps.shader_model,
shader_model: self.shared.private_caps.shader_model,
binding_map,
fake_missing_bindings: false,
special_constants_binding,

View File

@@ -630,6 +630,7 @@ struct DeviceShared {
cmd_signatures: CommandSignatures,
heap_views: descriptor::GeneralHeap,
sampler_heap: sampler::SamplerHeap,
private_caps: PrivateCapabilities,
}
unsafe impl Send for DeviceShared {}
@@ -639,7 +640,6 @@ pub struct Device {
raw: Direct3D12::ID3D12Device,
present_queue: Direct3D12::ID3D12CommandQueue,
idler: Idler,
private_caps: PrivateCapabilities,
features: wgt::Features,
shared: Arc<DeviceShared>,
// CPU only pools
@@ -660,6 +660,7 @@ impl Drop for Device {
fn drop(&mut self) {
self.rtv_pool.lock().free_handle(self.null_rtv_handle);
if self
.shared
.private_caps
.instance_flags
.contains(wgt::InstanceFlags::VALIDATION)

View File

@@ -23,6 +23,7 @@ pub(super) fn compile_fxc(
let mut shader_data = None;
let mut compile_flags = Fxc::D3DCOMPILE_ENABLE_STRICTNESS;
if device
.shared
.private_caps
.instance_flags
.contains(wgt::InstanceFlags::DEBUG)
@@ -290,6 +291,7 @@ pub(super) fn compile_dxc(
}
if device
.shared
.private_caps
.instance_flags
.contains(wgt::InstanceFlags::DEBUG)

View File

@@ -57,7 +57,7 @@ pub(crate) fn create_buffer_resource(
let is_cpu_write = desc.usage.contains(wgt::BufferUses::MAP_WRITE);
// Workaround for Intel Xe drivers
if !device.private_caps.suballocation_supported {
if !device.shared.private_caps.suballocation_supported {
return create_committed_buffer_resource(device, desc, raw_desc)
.map(|resource| (resource, None));
}
@@ -110,7 +110,7 @@ pub(crate) fn create_texture_resource(
raw_desc: Direct3D12::D3D12_RESOURCE_DESC,
) -> Result<(Direct3D12::ID3D12Resource, Option<AllocationWrapper>), crate::DeviceError> {
// Workaround for Intel Xe drivers
if !device.private_caps.suballocation_supported {
if !device.shared.private_caps.suballocation_supported {
return create_committed_texture_resource(device, desc, raw_desc)
.map(|resource| (resource, None));
}
@@ -157,7 +157,7 @@ pub(crate) fn create_acceleration_structure_resource(
raw_desc: Direct3D12::D3D12_RESOURCE_DESC,
) -> Result<(Direct3D12::ID3D12Resource, Option<AllocationWrapper>), crate::DeviceError> {
// Workaround for Intel Xe drivers
if !device.private_caps.suballocation_supported {
if !device.shared.private_caps.suballocation_supported {
return create_committed_acceleration_structure_resource(device, desc, raw_desc)
.map(|resource| (resource, None));
}
@@ -301,7 +301,7 @@ pub(crate) fn create_committed_buffer_resource(
} else {
Direct3D12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE
},
MemoryPoolPreference: match device.private_caps.memory_architecture {
MemoryPoolPreference: match device.shared.private_caps.memory_architecture {
crate::dx12::MemoryArchitecture::NonUnified if !is_cpu_read && !is_cpu_write => {
Direct3D12::D3D12_MEMORY_POOL_L1
}
@@ -316,7 +316,7 @@ pub(crate) fn create_committed_buffer_resource(
unsafe {
device.raw.CreateCommittedResource(
&heap_properties,
if device.private_caps.heap_create_not_zeroed {
if device.shared.private_caps.heap_create_not_zeroed {
Direct3D12::D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
Direct3D12::D3D12_HEAP_FLAG_NONE
@@ -340,7 +340,7 @@ pub(crate) fn create_committed_texture_resource(
let heap_properties = Direct3D12::D3D12_HEAP_PROPERTIES {
Type: Direct3D12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: Direct3D12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE,
MemoryPoolPreference: match device.private_caps.memory_architecture {
MemoryPoolPreference: match device.shared.private_caps.memory_architecture {
crate::dx12::MemoryArchitecture::NonUnified => Direct3D12::D3D12_MEMORY_POOL_L1,
crate::dx12::MemoryArchitecture::Unified { .. } => Direct3D12::D3D12_MEMORY_POOL_L0,
},
@@ -353,7 +353,7 @@ pub(crate) fn create_committed_texture_resource(
unsafe {
device.raw.CreateCommittedResource(
&heap_properties,
if device.private_caps.heap_create_not_zeroed {
if device.shared.private_caps.heap_create_not_zeroed {
Direct3D12::D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
Direct3D12::D3D12_HEAP_FLAG_NONE
@@ -377,7 +377,7 @@ pub(crate) fn create_committed_acceleration_structure_resource(
let heap_properties = Direct3D12::D3D12_HEAP_PROPERTIES {
Type: Direct3D12::D3D12_HEAP_TYPE_CUSTOM,
CPUPageProperty: Direct3D12::D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE,
MemoryPoolPreference: match device.private_caps.memory_architecture {
MemoryPoolPreference: match device.shared.private_caps.memory_architecture {
crate::dx12::MemoryArchitecture::NonUnified => Direct3D12::D3D12_MEMORY_POOL_L1,
_ => Direct3D12::D3D12_MEMORY_POOL_L0,
},
@@ -390,7 +390,7 @@ pub(crate) fn create_committed_acceleration_structure_resource(
unsafe {
device.raw.CreateCommittedResource(
&heap_properties,
if device.private_caps.heap_create_not_zeroed {
if device.shared.private_caps.heap_create_not_zeroed {
Direct3D12::D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
} else {
Direct3D12::D3D12_HEAP_FLAG_NONE