summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wgpu-hal/src/dx11/mod.rs
blob: 91827874b194e31263d9258e7972c875eaa84d0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#![allow(dead_code)]
#![allow(unused_variables)]

use winapi::um::{d3d11, d3d11_1, d3d11_2};

mod adapter;
mod command;
mod device;
mod instance;
mod library;

#[derive(Clone)]
pub struct Api;

impl crate::Api for Api {
    type Instance = Instance;
    type Surface = Surface;
    type Adapter = Adapter;
    type Device = Device;

    type Queue = Queue;
    type CommandEncoder = CommandEncoder;
    type CommandBuffer = CommandBuffer;

    type Buffer = Buffer;
    type Texture = Texture;
    type SurfaceTexture = SurfaceTexture;
    type TextureView = TextureView;
    type Sampler = Sampler;
    type QuerySet = QuerySet;
    type Fence = Fence;

    type BindGroupLayout = BindGroupLayout;
    type BindGroup = BindGroup;
    type PipelineLayout = PipelineLayout;
    type ShaderModule = ShaderModule;
    type RenderPipeline = RenderPipeline;
    type ComputePipeline = ComputePipeline;
}

pub struct Instance {
    lib_d3d11: library::D3D11Lib,
    lib_dxgi: d3d12::DxgiLib,
    factory: d3d12::DxgiFactory,
}

unsafe impl Send for Instance {}
unsafe impl Sync for Instance {}

pub struct Surface {}

pub struct Adapter {
    device: D3D11Device,
}

unsafe impl Send for Adapter {}
unsafe impl Sync for Adapter {}

d3d12::weak_com_inheritance_chain! {
    #[derive(Debug, Copy, Clone, PartialEq)]
    enum D3D11Device {
        Device(d3d11::ID3D11Device), from_device, as_device, device;
        Device1(d3d11_1::ID3D11Device1), from_device1, as_device1, unwrap_device1;
        Device2(d3d11_2::ID3D11Device2), from_device2, as_device2, unwrap_device2;
    }
}

pub struct Device {}

unsafe impl Send for Device {}
unsafe impl Sync for Device {}

pub struct Queue {}

#[derive(Debug)]
pub struct CommandEncoder {}

#[derive(Debug)]
pub struct CommandBuffer {}

#[derive(Debug)]
pub struct Buffer {}
#[derive(Debug)]
pub struct Texture {}
#[derive(Debug)]
pub struct SurfaceTexture {}

impl std::borrow::Borrow<Texture> for SurfaceTexture {
    fn borrow(&self) -> &Texture {
        todo!()
    }
}

#[derive(Debug)]
pub struct TextureView {}
#[derive(Debug)]
pub struct Sampler {}
#[derive(Debug)]
pub struct QuerySet {}
#[derive(Debug)]
pub struct Fence {}
#[derive(Debug)]

pub struct BindGroupLayout {}
#[derive(Debug)]
pub struct BindGroup {}
#[derive(Debug)]
pub struct PipelineLayout {}
#[derive(Debug)]
pub struct ShaderModule {}
pub struct RenderPipeline {}
pub struct ComputePipeline {}

impl crate::Surface<Api> for Surface {
    unsafe fn configure(
        &mut self,
        device: &Device,
        config: &crate::SurfaceConfiguration,
    ) -> Result<(), crate::SurfaceError> {
        todo!()
    }

    unsafe fn unconfigure(&mut self, device: &Device) {
        todo!()
    }

    unsafe fn acquire_texture(
        &mut self,
        _timeout: Option<std::time::Duration>,
    ) -> Result<Option<crate::AcquiredSurfaceTexture<Api>>, crate::SurfaceError> {
        todo!()
    }

    unsafe fn discard_texture(&mut self, texture: SurfaceTexture) {
        todo!()
    }
}