Skip to content

Commit

Permalink
windows-rs 0.58
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jul 21, 2024
1 parent 7940593 commit b6c5854
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 70 deletions.
108 changes: 64 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ impl Global {
) -> Result<SurfaceId, CreateSurfaceError> {
profiling::scope!("Instance::instance_create_surface_from_surface_handle");
self.instance_create_surface_dx12(id_in, |inst| unsafe {
inst.create_surface_from_surface_handle(surface_handle as _)
inst.create_surface_from_surface_handle(surface_handle)
})
}

Expand All @@ -665,7 +665,7 @@ impl Global {
) -> Result<SurfaceId, CreateSurfaceError> {
profiling::scope!("Instance::instance_create_surface_from_swap_chain_panel");
self.instance_create_surface_dx12(id_in, |inst| unsafe {
inst.create_surface_from_swap_chain_panel(swap_chain_panel as _)
inst.create_surface_from_swap_chain_panel(swap_chain_panel)
})
}

Expand Down
6 changes: 3 additions & 3 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ libloading = { version = "0.8", optional = true }
# backend: Dx12
bit-set = { version = "0.6", optional = true }
range-alloc = { version = "0.1", optional = true }
gpu-allocator = {version = "0.27", default-features = false, optional = true }
gpu-allocator = { version = "0.27", default-features = false, optional = true }
hassle-rs = { version = "0.11", optional = true }
# backend: Gles
glutin_wgl_sys = { version = "0.6", optional = true }
Expand All @@ -155,8 +155,8 @@ winapi = { version = "0.3", features = [
"dcomp",
] }
# For core macros. This crate is also reexported as windows::core.
windows-core = { version = "0.57.0", optional = true }
windows = { version = "0.57.0", optional = true, features = [
windows-core = { version = "0.58.0", optional = true }
windows = { version = "0.58.0", optional = true, features = [
"Win32_Graphics_Direct3D_Fxc",
"Win32_Graphics_Direct3D",
"Win32_Graphics_Direct3D12",
Expand Down
5 changes: 2 additions & 3 deletions wgpu-hal/src/auxil/dxgi/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ pub enum DxgiFactoryType {
}

fn should_keep_adapter(adapter: &Dxgi::IDXGIAdapter1) -> bool {
let mut desc = unsafe { std::mem::zeroed() };
unsafe { adapter.GetDesc1(&mut desc) }.unwrap();
let desc = unsafe { adapter.GetDesc1() }.unwrap();

// The Intel Haswell family of iGPUs had support for the D3D12 API but it was later
// removed due to a security vulnerability.
Expand Down Expand Up @@ -227,7 +226,7 @@ pub fn create_factory(
crate::InstanceError::with_source(String::from("failed to load dxgi.dll"), e)
})?;

let mut factory_flags = 0;
let mut factory_flags = Dxgi::DXGI_CREATE_FACTORY_FLAGS::default();

if instance_flags.contains(wgt::InstanceFlags::VALIDATION) {
// The `DXGI_CREATE_FACTORY_DEBUG` flag is only allowed to be passed to
Expand Down
20 changes: 17 additions & 3 deletions wgpu-hal/src/dx12/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ impl super::Adapter {

// We have found a possible adapter.
// Acquire the device information.
let mut desc: Dxgi::DXGI_ADAPTER_DESC2 = unsafe { mem::zeroed() };
unsafe { adapter.unwrap_adapter2().GetDesc2(&mut desc) }.unwrap();
let desc = unsafe { adapter.unwrap_adapter2().GetDesc2() }.unwrap();

let device_name = auxil::dxgi::conv::map_adapter_name(desc.Description);

Expand Down Expand Up @@ -186,6 +185,21 @@ impl super::Adapter {
&& features3.CastingFullyTypedFormatSupported.as_bool()
};

let heap_create_not_zeroed = {
// For D3D12_HEAP_FLAG_CREATE_NOT_ZEROED we just need to
// make sure that options7 can be queried. See also:
// https://devblogs.microsoft.com/directx/coming-to-directx-12-more-control-over-memory-allocation/
let mut features7 = Direct3D12::D3D12_FEATURE_DATA_D3D12_OPTIONS7::default();
unsafe {
device.CheckFeatureSupport(
Direct3D12::D3D12_FEATURE_D3D12_OPTIONS7,
<*mut _>::cast(&mut features7),
mem::size_of_val(&features7) as u32,
)
}
.is_ok()
};

let shader_model = if dxc_container.is_none() {
naga::back::hlsl::ShaderModel::V5_1
} else {
Expand Down Expand Up @@ -245,7 +259,7 @@ impl super::Adapter {
} else {
super::MemoryArchitecture::NonUnified
},
heap_create_not_zeroed: false, //TODO: winapi support for Options7
heap_create_not_zeroed,
casting_fully_typed_format_supported,
// See https://github.com/gfx-rs/wgpu/issues/3552
suballocation_supported: !info.name.contains("Iris(R) Xe"),
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/dx12/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
desc.color_attachments.len() as u32,
Some(color_views.as_ptr()),
false,
ds_view.as_ref().map(|v| v as _),
ds_view.as_ref().map(|v| v as *const _),
)
};

Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/dx12/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl FixedSizeHeap {
) -> Result<Self, crate::DeviceError> {
let desc = Direct3D12::D3D12_DESCRIPTOR_HEAP_DESC {
Type: ty,
NumDescriptors: HEAP_SIZE_FIXED as _,
NumDescriptors: HEAP_SIZE_FIXED as u32,
Flags: Direct3D12::D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
NodeMask: 0,
};
Expand All @@ -135,7 +135,7 @@ impl FixedSizeHeap {
.into_device_result("Descriptor heap creation")?;

Ok(Self {
handle_size: unsafe { device.GetDescriptorHandleIncrementSize(ty) } as _,
handle_size: unsafe { device.GetDescriptorHandleIncrementSize(ty) } as usize,
availability: !0, // all free!
start: unsafe { heap.GetCPUDescriptorHandleForHeapStart() },
_raw: heap,
Expand Down
3 changes: 2 additions & 1 deletion wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ impl crate::Device for super::Device {

unsafe fn destroy_buffer(&self, mut buffer: super::Buffer) {
// Only happens when it's using the windows_rs feature and there's an allocation
// TODO: Always happens now?
if let Some(alloc) = buffer.allocation.take() {
// Resource should be dropped before free suballocation
drop(buffer);
Expand Down Expand Up @@ -1040,7 +1041,7 @@ impl crate::Device for super::Device {
ParameterType: Direct3D12::D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE,
Anonymous: Direct3D12::D3D12_ROOT_PARAMETER_0 {
DescriptorTable: Direct3D12::D3D12_ROOT_DESCRIPTOR_TABLE {
NumDescriptorRanges: range.len() as _,
NumDescriptorRanges: range.len() as u32,
pDescriptorRanges: range.as_ptr(),
},
},
Expand Down
Loading

0 comments on commit b6c5854

Please sign in to comment.