Skip to content

[0.4/dx12] update d3d12 to 0.3 and use explicit linking #3069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backend/dx12/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gfx-backend-dx12"
version = "0.4.0"
version = "0.4.1"
description = "DirectX-12 API backend for gfx-rs"
homepage = "https://github.com/gfx-rs/gfx"
repository = "https://github.com/gfx-rs/gfx"
Expand All @@ -22,7 +22,7 @@ auxil = { path = "../../auxil/auxil", version = "0.1", package = "gfx-auxil" }
gfx-hal = { path = "../../hal", version = "0.4" }
range-alloc = { path = "../../auxil/range-alloc", version = "0.1" }
bitflags = "1"
d3d12 = "0.2.2"
d3d12 = { version = "0.3", features = ["libloading"] }
log = { version = "0.4" }
smallvec = "0.6"
spirv_cross = { version = "0.16", features = ["hlsl"] }
Expand Down
39 changes: 19 additions & 20 deletions src/backend/dx12/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ use winapi::shared::{dxgiformat, winerror};
use winapi::um::{d3d12, d3dcommon};
use winapi::Interface;

use native::{self, descriptor};
use native;

use device::{ViewInfo, IDENTITY_MAPPING};
use root_constants::RootConstant;
use smallvec::SmallVec;
use {
Expand Down Expand Up @@ -664,12 +663,12 @@ impl CommandBuffer {
stencil: Option<u32>,
rects: &[d3d12::D3D12_RECT],
) {
let mut flags = native::command_list::ClearFlags::empty();
let mut flags = native::ClearFlags::empty();
if depth.is_some() {
flags |= native::command_list::ClearFlags::DEPTH;
flags |= native::ClearFlags::DEPTH;
}
if stencil.is_some() {
flags |= native::command_list::ClearFlags::STENCIL;
flags |= native::ClearFlags::STENCIL;
}

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

let mut rtv_pool = descriptors_cpu::HeapLinear::new(
device,
descriptor::HeapType::Rtv,
native::DescriptorHeapType::Rtv,
clear_rects.len(),
);

Expand All @@ -1473,7 +1472,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
caps: image::ViewCapabilities::empty(),
view_kind: image::ViewKind::D2Array,
format: attachment.dxgi_format,
component_mapping: IDENTITY_MAPPING,
component_mapping: device::IDENTITY_MAPPING,
range: image::SubresourceRange {
aspects: Aspects::COLOR,
levels: attachment.mip_levels.0 .. attachment.mip_levels.1,
Expand All @@ -1496,7 +1495,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {

let mut dsv_pool = descriptors_cpu::HeapLinear::new(
device,
descriptor::HeapType::Dsv,
native::DescriptorHeapType::Dsv,
clear_rects.len(),
);

Expand All @@ -1510,7 +1509,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
caps: image::ViewCapabilities::empty(),
view_kind: image::ViewKind::D2Array,
format: attachment.dxgi_format,
component_mapping: IDENTITY_MAPPING,
component_mapping: device::IDENTITY_MAPPING,
range: image::SubresourceRange {
aspects: if depth.is_some() {
Aspects::DEPTH
Expand Down Expand Up @@ -1627,17 +1626,17 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
// Descriptor heap for the current blit, only storing the src image
let (srv_heap, _) = device.create_descriptor_heap(
1,
descriptor::HeapType::CbvSrvUav,
descriptor::HeapFlags::SHADER_VISIBLE,
native::DescriptorHeapType::CbvSrvUav,
native::DescriptorHeapFlags::SHADER_VISIBLE,
0,
);
let srv_desc = Device::build_image_as_shader_resource_desc(&ViewInfo {
let srv_desc = Device::build_image_as_shader_resource_desc(&device::ViewInfo {
resource: src.resource,
kind: src.kind,
caps: src.view_caps,
view_kind: image::ViewKind::D2Array, // TODO
format: src.default_view_format.unwrap(),
component_mapping: IDENTITY_MAPPING,
component_mapping: device::IDENTITY_MAPPING,
range: image::SubresourceRange {
aspects: format::Aspects::COLOR, // TODO
levels: 0 .. src.descriptor.MipLevels as _,
Expand Down Expand Up @@ -1675,7 +1674,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
// WORKAROUND: renderdoc crashes if we destroy the pool too early
let rtv_pool = Device::create_descriptor_heap_impl(
device,
descriptor::HeapType::Rtv,
native::DescriptorHeapType::Rtv,
false,
num_layers as _,
);
Expand Down Expand Up @@ -2503,7 +2502,7 @@ impl com::CommandBuffer<Backend> for CommandBuffer {

unsafe fn begin_query(&mut self, query: query::Query<Backend>, flags: query::ControlFlags) {
let query_ty = match query.pool.ty {
native::query::HeapType::Occlusion => {
native::QueryHeapType::Occlusion => {
if flags.contains(query::ControlFlags::PRECISE) {
self.occlusion_query = Some(OcclusionQuery::Precise(query.id));
d3d12::D3D12_QUERY_TYPE_OCCLUSION
Expand All @@ -2514,8 +2513,8 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
}
}
native::query::HeapType::Timestamp => panic!("Timestap queries are issued via "),
native::query::HeapType::PipelineStatistics => {
native::QueryHeapType::Timestamp => panic!("Timestap queries are issued via "),
native::QueryHeapType::PipelineStatistics => {
self.pipeline_stats_query = Some(query.id);
d3d12::D3D12_QUERY_TYPE_PIPELINE_STATISTICS
}
Expand All @@ -2529,19 +2528,19 @@ impl com::CommandBuffer<Backend> for CommandBuffer {
unsafe fn end_query(&mut self, query: query::Query<Backend>) {
let id = query.id;
let query_ty = match query.pool.ty {
native::query::HeapType::Occlusion
native::QueryHeapType::Occlusion
if self.occlusion_query == Some(OcclusionQuery::Precise(id)) =>
{
self.occlusion_query = None;
d3d12::D3D12_QUERY_TYPE_OCCLUSION
}
native::query::HeapType::Occlusion
native::QueryHeapType::Occlusion
if self.occlusion_query == Some(OcclusionQuery::Binary(id)) =>
{
self.occlusion_query = None;
d3d12::D3D12_QUERY_TYPE_BINARY_OCCLUSION
}
native::query::HeapType::PipelineStatistics
native::QueryHeapType::PipelineStatistics
if self.pipeline_stats_query == Some(id) =>
{
self.pipeline_stats_query = None;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/dx12/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use winapi::um::d3dcommon::*;
use hal::format::{Format, ImageFeature, SurfaceType, Swizzle};
use hal::{buffer, image, pso};

use native::descriptor::ShaderVisibility;
use native::ShaderVisibility;

pub fn map_format(format: Format) -> Option<DXGI_FORMAT> {
use hal::format::Format::*;
Expand Down
18 changes: 8 additions & 10 deletions src/backend/dx12/src/descriptors_cpu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use native;
use native::descriptor::{CpuDescriptor, HeapFlags, HeapType};
use std::fmt;
use std::collections::HashSet;
use native::{CpuDescriptor, DescriptorHeapFlags, DescriptorHeapType};
use std::{collections::HashSet, fmt};

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

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

HeapLinear {
handle_size: device.get_descriptor_increment_size(ty) as _,
Expand Down Expand Up @@ -76,9 +74,9 @@ impl fmt::Debug for Heap {
}

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

Heap {
handle_size: device.get_descriptor_increment_size(ty) as _,
Expand Down Expand Up @@ -111,7 +109,7 @@ impl Heap {

pub struct DescriptorCpuPool {
device: native::Device,
ty: HeapType,
ty: DescriptorHeapType,
heaps: Vec<Heap>,
free_list: HashSet<usize>,
}
Expand All @@ -123,7 +121,7 @@ impl fmt::Debug for DescriptorCpuPool {
}

impl DescriptorCpuPool {
pub fn new(device: native::Device, ty: HeapType) -> Self {
pub fn new(device: native::Device, ty: DescriptorHeapType) -> Self {
DescriptorCpuPool {
device,
ty,
Expand Down
Loading