Skip to content

Commit c2c8c41

Browse files
committed
[dx12] update d3d12 to 0.3 and use explicit linking
1 parent 4638647 commit c2c8c41

File tree

9 files changed

+176
-179
lines changed

9 files changed

+176
-179
lines changed

src/backend/dx12/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gfx-backend-dx12"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
description = "DirectX-12 API backend for gfx-rs"
55
homepage = "https://github.com/gfx-rs/gfx"
66
repository = "https://github.com/gfx-rs/gfx"
@@ -22,7 +22,7 @@ auxil = { path = "../../auxil/auxil", version = "0.1", package = "gfx-auxil" }
2222
gfx-hal = { path = "../../hal", version = "0.4" }
2323
range-alloc = { path = "../../auxil/range-alloc", version = "0.1" }
2424
bitflags = "1"
25-
d3d12 = "0.2.2"
25+
d3d12 = { version = "0.3", features = ["libloading"] }
2626
log = { version = "0.4" }
2727
smallvec = "0.6"
2828
spirv_cross = { version = "0.16", features = ["hlsl"] }

src/backend/dx12/src/command.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ use winapi::shared::{dxgiformat, winerror};
2222
use winapi::um::{d3d12, d3dcommon};
2323
use winapi::Interface;
2424

25-
use native::{self, descriptor};
25+
use native;
2626

27-
use device::{ViewInfo, IDENTITY_MAPPING};
2827
use root_constants::RootConstant;
2928
use smallvec::SmallVec;
3029
use {
@@ -664,12 +663,12 @@ impl CommandBuffer {
664663
stencil: Option<u32>,
665664
rects: &[d3d12::D3D12_RECT],
666665
) {
667-
let mut flags = native::command_list::ClearFlags::empty();
666+
let mut flags = native::ClearFlags::empty();
668667
if depth.is_some() {
669-
flags |= native::command_list::ClearFlags::DEPTH;
668+
flags |= native::ClearFlags::DEPTH;
670669
}
671670
if stencil.is_some() {
672-
flags |= native::command_list::ClearFlags::STENCIL;
671+
flags |= native::ClearFlags::STENCIL;
673672
}
674673

675674
self.raw.clear_depth_stencil_view(
@@ -1459,7 +1458,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
14591458

14601459
let mut rtv_pool = descriptors_cpu::HeapLinear::new(
14611460
device,
1462-
descriptor::HeapType::Rtv,
1461+
native::DescriptorHeapType::Rtv,
14631462
clear_rects.len(),
14641463
);
14651464

@@ -1473,7 +1472,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
14731472
caps: image::ViewCapabilities::empty(),
14741473
view_kind: image::ViewKind::D2Array,
14751474
format: attachment.dxgi_format,
1476-
component_mapping: IDENTITY_MAPPING,
1475+
component_mapping: device::IDENTITY_MAPPING,
14771476
range: image::SubresourceRange {
14781477
aspects: Aspects::COLOR,
14791478
levels: attachment.mip_levels.0 .. attachment.mip_levels.1,
@@ -1496,7 +1495,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
14961495

14971496
let mut dsv_pool = descriptors_cpu::HeapLinear::new(
14981497
device,
1499-
descriptor::HeapType::Dsv,
1498+
native::DescriptorHeapType::Dsv,
15001499
clear_rects.len(),
15011500
);
15021501

@@ -1510,7 +1509,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
15101509
caps: image::ViewCapabilities::empty(),
15111510
view_kind: image::ViewKind::D2Array,
15121511
format: attachment.dxgi_format,
1513-
component_mapping: IDENTITY_MAPPING,
1512+
component_mapping: device::IDENTITY_MAPPING,
15141513
range: image::SubresourceRange {
15151514
aspects: if depth.is_some() {
15161515
Aspects::DEPTH
@@ -1627,17 +1626,17 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
16271626
// Descriptor heap for the current blit, only storing the src image
16281627
let (srv_heap, _) = device.create_descriptor_heap(
16291628
1,
1630-
descriptor::HeapType::CbvSrvUav,
1631-
descriptor::HeapFlags::SHADER_VISIBLE,
1629+
native::DescriptorHeapType::CbvSrvUav,
1630+
native::DescriptorHeapFlags::SHADER_VISIBLE,
16321631
0,
16331632
);
1634-
let srv_desc = Device::build_image_as_shader_resource_desc(&ViewInfo {
1633+
let srv_desc = Device::build_image_as_shader_resource_desc(&device::ViewInfo {
16351634
resource: src.resource,
16361635
kind: src.kind,
16371636
caps: src.view_caps,
16381637
view_kind: image::ViewKind::D2Array, // TODO
16391638
format: src.default_view_format.unwrap(),
1640-
component_mapping: IDENTITY_MAPPING,
1639+
component_mapping: device::IDENTITY_MAPPING,
16411640
range: image::SubresourceRange {
16421641
aspects: format::Aspects::COLOR, // TODO
16431642
levels: 0 .. src.descriptor.MipLevels as _,
@@ -1675,7 +1674,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
16751674
// WORKAROUND: renderdoc crashes if we destroy the pool too early
16761675
let rtv_pool = Device::create_descriptor_heap_impl(
16771676
device,
1678-
descriptor::HeapType::Rtv,
1677+
native::DescriptorHeapType::Rtv,
16791678
false,
16801679
num_layers as _,
16811680
);
@@ -2503,7 +2502,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25032502

25042503
unsafe fn begin_query(&mut self, query: query::Query<Backend>, flags: query::ControlFlags) {
25052504
let query_ty = match query.pool.ty {
2506-
native::query::HeapType::Occlusion => {
2505+
native::QueryHeapType::Occlusion => {
25072506
if flags.contains(query::ControlFlags::PRECISE) {
25082507
self.occlusion_query = Some(OcclusionQuery::Precise(query.id));
25092508
d3d12::D3D12_QUERY_TYPE_OCCLUSION
@@ -2514,8 +2513,8 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25142513
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
25152514
}
25162515
}
2517-
native::query::HeapType::Timestamp => panic!("Timestap queries are issued via "),
2518-
native::query::HeapType::PipelineStatistics => {
2516+
native::QueryHeapType::Timestamp => panic!("Timestap queries are issued via "),
2517+
native::QueryHeapType::PipelineStatistics => {
25192518
self.pipeline_stats_query = Some(query.id);
25202519
d3d12::D3D12_QUERY_TYPE_PIPELINE_STATISTICS
25212520
}
@@ -2529,19 +2528,19 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
25292528
unsafe fn end_query(&mut self, query: query::Query<Backend>) {
25302529
let id = query.id;
25312530
let query_ty = match query.pool.ty {
2532-
native::query::HeapType::Occlusion
2531+
native::QueryHeapType::Occlusion
25332532
if self.occlusion_query == Some(OcclusionQuery::Precise(id)) =>
25342533
{
25352534
self.occlusion_query = None;
25362535
d3d12::D3D12_QUERY_TYPE_OCCLUSION
25372536
}
2538-
native::query::HeapType::Occlusion
2537+
native::QueryHeapType::Occlusion
25392538
if self.occlusion_query == Some(OcclusionQuery::Binary(id)) =>
25402539
{
25412540
self.occlusion_query = None;
25422541
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
25432542
}
2544-
native::query::HeapType::PipelineStatistics
2543+
native::QueryHeapType::PipelineStatistics
25452544
if self.pipeline_stats_query == Some(id) =>
25462545
{
25472546
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
@@ -12,7 +12,7 @@ use winapi::um::d3dcommon::*;
1212
use hal::format::{Format, ImageFeature, SurfaceType, Swizzle};
1313
use hal::{buffer, image, pso};
1414

15-
use native::descriptor::ShaderVisibility;
15+
use native::ShaderVisibility;
1616

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

src/backend/dx12/src/descriptors_cpu.rs

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

64
// Linear stack allocator for CPU descriptor heaps.
75
pub struct HeapLinear {
@@ -19,8 +17,8 @@ impl fmt::Debug for HeapLinear {
1917
}
2018

2119
impl HeapLinear {
22-
pub fn new(device: native::Device, ty: HeapType, size: usize) -> Self {
23-
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);
2422

2523
HeapLinear {
2624
handle_size: device.get_descriptor_increment_size(ty) as _,
@@ -76,9 +74,9 @@ impl fmt::Debug for Heap {
7674
}
7775

7876
impl Heap {
79-
pub fn new(device: native::Device, ty: HeapType) -> Self {
77+
pub fn new(device: native::Device, ty: DescriptorHeapType) -> Self {
8078
let (heap, _hr) =
81-
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);
8280

8381
Heap {
8482
handle_size: device.get_descriptor_increment_size(ty) as _,
@@ -111,7 +109,7 @@ impl Heap {
111109

112110
pub struct DescriptorCpuPool {
113111
device: native::Device,
114-
ty: HeapType,
112+
ty: DescriptorHeapType,
115113
heaps: Vec<Heap>,
116114
free_list: HashSet<usize>,
117115
}
@@ -123,7 +121,7 @@ impl fmt::Debug for DescriptorCpuPool {
123121
}
124122

125123
impl DescriptorCpuPool {
126-
pub fn new(device: native::Device, ty: HeapType) -> Self {
124+
pub fn new(device: native::Device, ty: DescriptorHeapType) -> Self {
127125
DescriptorCpuPool {
128126
device,
129127
ty,

0 commit comments

Comments
 (0)