1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 use ctypes::c_void;
7 use shared::basetsd::{UINT16, UINT64, UINT8};
8 use shared::dxgiformat::DXGI_FORMAT;
9 use shared::minwindef::{BOOL, INT, UINT};
10 use um::d3d11::{ID3D11Buffer, ID3D11DeviceChild, ID3D11Resource};
11 use um::d3d11_1::{
12     ID3D11Device1, ID3D11Device1Vtbl, ID3D11DeviceContext1, ID3D11DeviceContext1Vtbl,
13 };
14 use um::winnt::{HRESULT, LPCWSTR};
15 DEFINE_GUID!{IID_ID3D11DeviceContext2,
16     0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a}
17 DEFINE_GUID!{IID_ID3D11Device2,
18     0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41}
19 STRUCT!{struct D3D11_TILED_RESOURCE_COORDINATE {
20     X: UINT,
21     Y: UINT,
22     Z: UINT,
23     Subresource: UINT,
24 }}
25 STRUCT!{struct D3D11_TILE_REGION_SIZE {
26     NumTiles: UINT,
27     bUseBox: BOOL,
28     Width: UINT,
29     Height: UINT16,
30     Depth: UINT16,
31 }}
32 ENUM!{enum D3D11_TILE_MAPPING_FLAG {
33     D3D11_TILE_MAPPING_NO_OVERWRITE = 0x00000001,
34 }}
35 ENUM!{enum D3D11_TILE_RANGE_FLAG {
36     D3D11_TILE_RANGE_NULL = 0x00000001,
37     D3D11_TILE_RANGE_SKIP = 0x00000002,
38     D3D11_TILE_RANGE_REUSE_SINGLE_TILE = 0x00000004,
39 }}
40 STRUCT!{struct D3D11_SUBRESOURCE_TILING {
41     WidthInTiles: UINT,
42     HeightInTiles: UINT16,
43     DepthInTiles: UINT16,
44     StartTileIndexInOverallResource: UINT,
45 }}
46 STRUCT!{struct D3D11_TILE_SHAPE {
47     WidthInTexels: UINT,
48     HeightInTexels: UINT,
49     DepthInTexels: UINT,
50 }}
51 STRUCT!{struct D3D11_PACKED_MIP_DESC {
52     NumStandardMips: UINT8,
53     NumPackedMips: UINT8,
54     NumTilesForPackedMips: UINT,
55     StartTileIndexInOverallResource: UINT,
56 }}
57 ENUM!{enum D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_FLAG {
58     D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_TILED_RESOURCE = 0x00000001,
59 }}
60 ENUM!{enum D3D11_TILE_COPY_FLAG {
61     D3D11_TILE_COPY_NO_OVERWRITE = 0x00000001,
62     D3D11_TILE_COPY_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x00000002,
63     D3D11_TILE_COPY_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x00000004,
64 }}
65 RIDL!{#[uuid(0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a)]
66 interface ID3D11DeviceContext2(ID3D11DeviceContext2Vtbl):
67     ID3D11DeviceContext1(ID3D11DeviceContext1Vtbl) {
68     fn UpdateTileMappings(
69         pTiledResource: *mut ID3D11Resource,
70         NumTiledResourceRegions: UINT,
71         pTiledResourceRegionStartCoordinates: *const D3D11_TILED_RESOURCE_COORDINATE,
72         pTiledResourceRegionSizes: *const D3D11_TILE_REGION_SIZE,
73         pTilePool: *mut ID3D11Buffer,
74         NumRanges: UINT,
75         pRangeFlags: *const UINT,
76         pTilePoolStartOffsets: *const UINT,
77         pRangeTileCounts: *const UINT,
78         Flags: UINT,
79     ) -> HRESULT,
80     fn CopyTileMappings(
81         pDestTiledResource: *mut ID3D11Resource,
82         pDestRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE,
83         pSourceTiledResource: *mut ID3D11Resource,
84         pSourceRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE,
85         pTileRegionSize: *const D3D11_TILE_REGION_SIZE,
86         Flags: UINT,
87     ) -> HRESULT,
88     fn CopyTiles(
89         pTiledResource: *mut ID3D11Resource,
90         pTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE,
91         pTileRegionSize: *const D3D11_TILE_REGION_SIZE,
92         pBuffer: *mut ID3D11Buffer,
93         BufferStartOffsetInBytes: UINT64,
94         Flags: UINT,
95     ) -> (),
96     fn UpdateTiles(
97         pDestTiledResource: *mut ID3D11Resource,
98         pDestTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE,
99         pDestTileRegionSize: *const D3D11_TILE_REGION_SIZE,
100         pSourceTileData: *const c_void,
101         Flags: UINT,
102     ) -> (),
103     fn ResizeTilePool(
104         pTilePool: *mut ID3D11Buffer,
105         NewSizeInBytes: UINT64,
106     ) -> HRESULT,
107     fn TiledResourceBarrier(
108         pTiledResourceOrViewAccessBeforeBarrier: *mut ID3D11DeviceChild,
109         pTiledResourceOrViewAccessAfterBarrier: *mut ID3D11DeviceChild,
110     ) -> (),
111     fn IsAnnotationEnabled() -> BOOL,
112     fn SetMarkerInt(
113         pLabel: LPCWSTR,
114         Data: INT,
115     ) -> (),
116     fn BeginEventInt(
117         pLabel: LPCWSTR,
118         Data: INT,
119     ) -> (),
120     fn EndEvent() -> (),
121 }}
122 RIDL!{#[uuid(0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41)]
123 interface ID3D11Device2(ID3D11Device2Vtbl): ID3D11Device1(ID3D11Device1Vtbl) {
124     fn GetImmediateContext2(
125         ppImmediateContext: *mut *mut ID3D11DeviceContext2,
126     ) -> (),
127     fn CreateDeferredContext2(
128         ContextFlags: UINT,
129         ppDeferredContext: *mut *mut ID3D11DeviceContext2,
130     ) -> HRESULT,
131     fn GetResourceTiling(
132         pTiledResource: *mut ID3D11Resource,
133         pNumTilesForEntireResource: *mut UINT,
134         pPackedMipDesc: *mut D3D11_PACKED_MIP_DESC,
135         pStandardTileShapeForNonPackedMips: *mut D3D11_TILE_SHAPE,
136         pNumSubresourceTilings: *mut UINT,
137         FirstSubresourceTilingToGet: UINT,
138         pSubresourceTilingsForNonPackedMips: *mut D3D11_SUBRESOURCE_TILING,
139     ) -> (),
140     fn CheckMultisampleQualityLevels1(
141         Format: DXGI_FORMAT,
142         SampleCount: UINT,
143         Flags: UINT,
144         pNumQualityLevels: *mut UINT,
145     ) -> HRESULT,
146 }}
147