• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © Microsoft Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef D3D12_DESCRIPTOR_POOL_H
25 #define D3D12_DESCRIPTOR_POOL_H
26 
27 #include "d3d12_common.h"
28 
29 struct d3d12_descriptor_pool;
30 struct d3d12_descriptor_heap;
31 
32 struct d3d12_descriptor_handle {
33     D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle;
34     D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;
35     struct d3d12_descriptor_heap *heap;
36 };
37 
38 inline bool
d3d12_descriptor_handle_is_allocated(struct d3d12_descriptor_handle * handle)39 d3d12_descriptor_handle_is_allocated(struct d3d12_descriptor_handle *handle)
40 {
41     return (handle->heap != NULL);
42 }
43 
44 void
45 d3d12_descriptor_handle_free(struct d3d12_descriptor_handle *handle);
46 
47 /* Offline Descriptor Pool */
48 
49 struct d3d12_descriptor_pool*
50 d3d12_descriptor_pool_new(struct d3d12_screen *screen,
51                           D3D12_DESCRIPTOR_HEAP_TYPE type,
52                           uint32_t num_descriptors);
53 
54 void
55 d3d12_descriptor_pool_free(struct d3d12_descriptor_pool *pool);
56 
57 uint32_t
58 d3d12_descriptor_pool_alloc_handle(struct d3d12_descriptor_pool *pool,
59                                    struct d3d12_descriptor_handle *handle);
60 
61 
62 /* Online/Offline Descriptor Heaps */
63 
64 struct d3d12_descriptor_heap*
65 d3d12_descriptor_heap_new(ID3D12Device *device,
66                           D3D12_DESCRIPTOR_HEAP_TYPE type,
67                           D3D12_DESCRIPTOR_HEAP_FLAGS flags,
68                           uint32_t num_descriptors);
69 
70 void
71 d3d12_descriptor_heap_free(struct d3d12_descriptor_heap *heap);
72 
73 ID3D12DescriptorHeap*
74 d3d12_descriptor_heap_get(struct d3d12_descriptor_heap *heap);
75 
76 void
77 d2d12_descriptor_heap_get_next_handle(struct d3d12_descriptor_heap *heap,
78                                       struct d3d12_descriptor_handle *handle);
79 
80 uint32_t
81 d3d12_descriptor_heap_get_remaining_handles(struct d3d12_descriptor_heap *heap);
82 
83 uint32_t
84 d3d12_descriptor_heap_alloc_handle(struct d3d12_descriptor_heap *heap,
85                                    struct d3d12_descriptor_handle *handle);
86 
87 void
88 d3d12_descriptor_heap_append_handles(struct d3d12_descriptor_heap *heap,
89                                      D3D12_CPU_DESCRIPTOR_HANDLE *handles,
90                                      unsigned num_handles);
91 
92 void
93 d3d12_descriptor_heap_clear(struct d3d12_descriptor_heap *heap);
94 
95 #endif
96