mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[d3d12] Internalize raw buffer desc mapping
This commit is contained in:
committed by
Erich Gubler
parent
4fce269b1d
commit
014b5b52f2
@@ -414,10 +414,8 @@ impl crate::Device for super::Device {
|
||||
.next_multiple_of(Direct3D12::D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT.into())
|
||||
}
|
||||
|
||||
let raw_desc = conv::map_buffer_descriptor(&desc);
|
||||
|
||||
let (resource, allocation) =
|
||||
suballocation::DeviceAllocationContext::from(self).create_buffer(&desc, raw_desc)?;
|
||||
suballocation::DeviceAllocationContext::from(self).create_buffer(&desc)?;
|
||||
|
||||
if let Some(label) = desc.label {
|
||||
unsafe { resource.SetName(&windows::core::HSTRING::from(label)) }
|
||||
@@ -1542,10 +1540,8 @@ impl crate::Device for super::Device {
|
||||
memory_flags: crate::MemoryFlags::empty(),
|
||||
};
|
||||
|
||||
let raw_buffer_desc = conv::map_buffer_descriptor(&buffer_desc);
|
||||
|
||||
let (buffer, allocation) = suballocation::DeviceAllocationContext::from(self)
|
||||
.create_buffer(&buffer_desc, raw_buffer_desc)?;
|
||||
let (buffer, allocation) =
|
||||
suballocation::DeviceAllocationContext::from(self).create_buffer(&buffer_desc)?;
|
||||
|
||||
unsafe { buffer.SetName(&windows::core::HSTRING::from(&*label)) }
|
||||
.into_device_result("SetName")?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use gpu_allocator::{
|
||||
use parking_lot::Mutex;
|
||||
use windows::Win32::Graphics::Direct3D12;
|
||||
|
||||
use crate::auxil::dxgi::result::HResult as _;
|
||||
use crate::{auxil::dxgi::result::HResult as _, dx12::conv};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum AllocationType {
|
||||
@@ -96,11 +96,12 @@ impl<'a> DeviceAllocationContext<'a> {
|
||||
pub(crate) fn create_buffer(
|
||||
&self,
|
||||
desc: &crate::BufferDescriptor,
|
||||
raw_desc: Direct3D12::D3D12_RESOURCE_DESC,
|
||||
) -> Result<(Direct3D12::ID3D12Resource, Allocation), crate::DeviceError> {
|
||||
let is_cpu_read = desc.usage.contains(wgt::BufferUses::MAP_READ);
|
||||
let is_cpu_write = desc.usage.contains(wgt::BufferUses::MAP_WRITE);
|
||||
|
||||
let raw_desc = conv::map_buffer_descriptor(desc);
|
||||
|
||||
// Workaround for Intel Xe drivers
|
||||
if !self.shared.private_caps.suballocation_supported {
|
||||
let resource = self.create_committed_buffer(desc, raw_desc)?;
|
||||
|
||||
Reference in New Issue
Block a user