Skip to content

Commit 40c48b5

Browse files
bors[bot]kvark
andauthored
Merge #3068
3068: [dx12] update d3d12 to 0.3 and use explicit linking r=msiglreith a=kvark Fixes #3067 (not exactly matching the wording but addresses the real blocker) Depends on gfx-rs/d3d12-rs#20 merged and published, doesn't need to be updated when that happens PR checklist: - [ ] `make` succeeds (on *nix) - [ ] `make reftests` succeeds - [x] tested examples with the following backends: d3d12 - [ ] `rustfmt` run on changed code Verified on a Windows 7 machine that we are gracefully failing to init DX12 now. Co-authored-by: Dzmitry Malyshau <[email protected]>
2 parents 3cd88e2 + 1ddd20d commit 40c48b5

File tree

9 files changed

+172
-171
lines changed

9 files changed

+172
-171
lines changed

src/backend/dx12/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ auxil = { path = "../../auxil/auxil", version = "0.2", package = "gfx-auxil", fe
2323
hal = { path = "../../hal", version = "0.4", package = "gfx-hal" }
2424
range-alloc = { path = "../../auxil/range-alloc", version = "0.1" }
2525
bitflags = "1"
26-
native = { version = "0.2.2", package = "d3d12" }
26+
native = { package = "d3d12", version = "0.3", features = ["libloading"] }
2727
log = { version = "0.4" }
2828
smallvec = "0.6"
2929
spirv_cross = { version = "0.16", features = ["hlsl"] }

src/backend/dx12/src/command.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ use winapi::{
3232
Interface,
3333
};
3434

35-
use device::{ViewInfo, IDENTITY_MAPPING};
36-
use native::descriptor;
3735
use smallvec::SmallVec;
3836

3937
use crate::{
@@ -676,12 +674,12 @@ impl CommandBuffer {
676674
stencil: Option<u32>,
677675
rects: &[d3d12::D3D12_RECT],
678676
) {
679-
let mut flags = native::command_list::ClearFlags::empty();
677+
let mut flags = native::ClearFlags::empty();
680678
if depth.is_some() {
681-
flags |= native::command_list::ClearFlags::DEPTH;
679+
flags |= native::ClearFlags::DEPTH;
682680
}
683681
if stencil.is_some() {
684-
flags |= native::command_list::ClearFlags::STENCIL;
682+
flags |= native::ClearFlags::STENCIL;
685683
}
686684

687685
self.raw.clear_depth_stencil_view(
@@ -1482,7 +1480,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
14821480

14831481
let mut rtv_pool = descriptors_cpu::HeapLinear::new(
14841482
device,
1485-
descriptor::HeapType::Rtv,
1483+
native::DescriptorHeapType::Rtv,
14861484
clear_rects.len(),
14871485
);
14881486

@@ -1496,7 +1494,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
14961494
caps: image::ViewCapabilities::empty(),
14971495
view_kind: image::ViewKind::D2Array,
14981496
format: attachment.dxgi_format,
1499-
component_mapping: IDENTITY_MAPPING,
1497+
component_mapping: device::IDENTITY_MAPPING,
15001498
range: image::SubresourceRange {
15011499
aspects: Aspects::COLOR,
15021500
levels: attachment.mip_levels.0 .. attachment.mip_levels.1,
@@ -1519,7 +1517,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
15191517

15201518
let mut dsv_pool = descriptors_cpu::HeapLinear::new(
15211519
device,
1522-
descriptor::HeapType::Dsv,
1520+
native::DescriptorHeapType::Dsv,
15231521
clear_rects.len(),
15241522
);
15251523

@@ -1533,7 +1531,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
15331531
caps: image::ViewCapabilities::empty(),
15341532
view_kind: image::ViewKind::D2Array,
15351533
format: attachment.dxgi_format,
1536-
component_mapping: IDENTITY_MAPPING,
1534+
component_mapping: device::IDENTITY_MAPPING,
15371535
range: image::SubresourceRange {
15381536
aspects: if depth.is_some() {
15391537
Aspects::DEPTH
@@ -1650,17 +1648,17 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
16501648
// Descriptor heap for the current blit, only storing the src image
16511649
let (srv_heap, _) = device.create_descriptor_heap(
16521650
1,
1653-
descriptor::HeapType::CbvSrvUav,
1654-
descriptor::HeapFlags::SHADER_VISIBLE,
1651+
native::DescriptorHeapType::CbvSrvUav,
1652+
native::DescriptorHeapFlags::SHADER_VISIBLE,
16551653
0,
16561654
);
1657-
let srv_desc = Device::build_image_as_shader_resource_desc(&ViewInfo {
1655+
let srv_desc = Device::build_image_as_shader_resource_desc(&device::ViewInfo {
16581656
resource: src.resource,
16591657
kind: src.kind,
16601658
caps: src.view_caps,
16611659
view_kind: image::ViewKind::D2Array, // TODO
16621660
format: src.default_view_format.unwrap(),
1663-
component_mapping: IDENTITY_MAPPING,
1661+
component_mapping: device::IDENTITY_MAPPING,
16641662
range: image::SubresourceRange {
16651663
aspects: format::Aspects::COLOR, // TODO
16661664
levels: 0 .. src.descriptor.MipLevels as _,
@@ -1698,7 +1696,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
16981696
// WORKAROUND: renderdoc crashes if we destroy the pool too early
16991697
let rtv_pool = Device::create_descriptor_heap_impl(
17001698
device,
1701-
descriptor::HeapType::Rtv,
1699+
native::DescriptorHeapType::Rtv,
17021700
false,
17031701
num_layers as _,
17041702
);
@@ -2526,7 +2524,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25262524

25272525
unsafe fn begin_query(&mut self, query: query::Query<Backend>, flags: query::ControlFlags) {
25282526
let query_ty = match query.pool.ty {
2529-
native::query::HeapType::Occlusion => {
2527+
native::QueryHeapType::Occlusion => {
25302528
if flags.contains(query::ControlFlags::PRECISE) {
25312529
self.occlusion_query = Some(OcclusionQuery::Precise(query.id));
25322530
d3d12::D3D12_QUERY_TYPE_OCCLUSION
@@ -2537,8 +2535,8 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25372535
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
25382536
}
25392537
}
2540-
native::query::HeapType::Timestamp => panic!("Timestap queries are issued via "),
2541-
native::query::HeapType::PipelineStatistics => {
2538+
native::QueryHeapType::Timestamp => panic!("Timestap queries are issued via "),
2539+
native::QueryHeapType::PipelineStatistics => {
25422540
self.pipeline_stats_query = Some(query.id);
25432541
d3d12::D3D12_QUERY_TYPE_PIPELINE_STATISTICS
25442542
}
@@ -2552,19 +2550,19 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25522550
unsafe fn end_query(&mut self, query: query::Query<Backend>) {
25532551
let id = query.id;
25542552
let query_ty = match query.pool.ty {
2555-
native::query::HeapType::Occlusion
2553+
native::QueryHeapType::Occlusion
25562554
if self.occlusion_query == Some(OcclusionQuery::Precise(id)) =>
25572555
{
25582556
self.occlusion_query = None;
25592557
d3d12::D3D12_QUERY_TYPE_OCCLUSION
25602558
}
2561-
native::query::HeapType::Occlusion
2559+
native::QueryHeapType::Occlusion
25622560
if self.occlusion_query == Some(OcclusionQuery::Binary(id)) =>
25632561
{
25642562
self.occlusion_query = None;
25652563
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
25662564
}
2567-
native::query::HeapType::PipelineStatistics
2565+
native::QueryHeapType::PipelineStatistics
25682566
if self.pipeline_stats_query == Some(id) =>
25692567
{
25702568
self.pipeline_stats_query = None;

src/backend/dx12/src/conv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use hal::{
1919
pso,
2020
};
2121

22-
use native::descriptor::ShaderVisibility;
22+
use native::ShaderVisibility;
2323

2424
pub fn map_format(format: Format) -> Option<DXGI_FORMAT> {
2525
use hal::format::Format::*;

src/backend/dx12/src/descriptors_cpu.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use native::descriptor::{CpuDescriptor, HeapFlags, HeapType};
1+
use native::{CpuDescriptor, DescriptorHeapFlags, DescriptorHeapType};
22
use std::{collections::HashSet, fmt};
33

44
// Linear stack allocator for CPU descriptor heaps.
@@ -17,8 +17,8 @@ impl fmt::Debug for HeapLinear {
1717
}
1818

1919
impl HeapLinear {
20-
pub fn new(device: native::Device, ty: HeapType, size: usize) -> Self {
21-
let (heap, _hr) = device.create_descriptor_heap(size as _, ty, HeapFlags::empty(), 0);
20+
pub fn new(device: native::Device, ty: DescriptorHeapType, size: usize) -> Self {
21+
let (heap, _hr) = device.create_descriptor_heap(size as _, ty, DescriptorHeapFlags::empty(), 0);
2222

2323
HeapLinear {
2424
handle_size: device.get_descriptor_increment_size(ty) as _,
@@ -74,9 +74,9 @@ impl fmt::Debug for Heap {
7474
}
7575

7676
impl Heap {
77-
pub fn new(device: native::Device, ty: HeapType) -> Self {
77+
pub fn new(device: native::Device, ty: DescriptorHeapType) -> Self {
7878
let (heap, _hr) =
79-
device.create_descriptor_heap(HEAP_SIZE_FIXED as _, ty, HeapFlags::empty(), 0);
79+
device.create_descriptor_heap(HEAP_SIZE_FIXED as _, ty, DescriptorHeapFlags::empty(), 0);
8080

8181
Heap {
8282
handle_size: device.get_descriptor_increment_size(ty) as _,
@@ -109,7 +109,7 @@ impl Heap {
109109

110110
pub struct DescriptorCpuPool {
111111
device: native::Device,
112-
ty: HeapType,
112+
ty: DescriptorHeapType,
113113
heaps: Vec<Heap>,
114114
free_list: HashSet<usize>,
115115
}
@@ -121,7 +121,7 @@ impl fmt::Debug for DescriptorCpuPool {
121121
}
122122

123123
impl DescriptorCpuPool {
124-
pub fn new(device: native::Device, ty: HeapType) -> Self {
124+
pub fn new(device: native::Device, ty: DescriptorHeapType) -> Self {
125125
DescriptorCpuPool {
126126
device,
127127
ty,

0 commit comments

Comments
 (0)