• 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 DXIL_CONTAINER_H
25 #define DXIL_CONTAINER_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include "util/blob.h"
32 
33 #include "dxil_signature.h"
34 
35 #define DXIL_MAX_PARTS 8
36 struct dxil_container {
37    struct blob parts;
38    unsigned part_offsets[DXIL_MAX_PARTS];
39    unsigned num_parts;
40 };
41 
42 enum dxil_resource_type {
43   DXIL_RES_INVALID = 0,
44   DXIL_RES_SAMPLER = 1,
45   DXIL_RES_CBV = 2,
46   DXIL_RES_SRV_TYPED = 3,
47   DXIL_RES_SRV_RAW = 4,
48   DXIL_RES_SRV_STRUCTURED = 5,
49   DXIL_RES_UAV_TYPED = 6,
50   DXIL_RES_UAV_RAW = 7,
51   DXIL_RES_UAV_STRUCTURED,
52   DXIL_RES_UAV_STRUCTURED_WITH_COUNTER,
53   DXIL_RES_NUM_ENTRIES /* should always be last */
54 };
55 
56 #define DXIL_FOURCC(ch0, ch1, ch2, ch3) ( \
57   (uint32_t)(ch0)        | (uint32_t)(ch1) << 8 | \
58   (uint32_t)(ch2) << 16  | (uint32_t)(ch3) << 24)
59 
60 enum dxil_part_fourcc {
61    DXIL_RDEF = DXIL_FOURCC('R', 'D', 'E', 'F'),
62    DXIL_ISG1 = DXIL_FOURCC('I', 'S', 'G', '1'),
63    DXIL_OSG1 = DXIL_FOURCC('O', 'S', 'G', '1'),
64    DXIL_PSG1 = DXIL_FOURCC('P', 'S', 'G', '1'),
65    DXIL_STAT = DXIL_FOURCC('S', 'T', 'A', 'T'),
66    DXIL_ILDB = DXIL_FOURCC('I', 'L', 'D', 'B'),
67    DXIL_ILDN = DXIL_FOURCC('I', 'L', 'D', 'N'),
68    DXIL_SFI0 = DXIL_FOURCC('S', 'F', 'I', '0'),
69    DXIL_PRIV = DXIL_FOURCC('P', 'R', 'I', 'V'),
70    DXIL_RTS0 = DXIL_FOURCC('R', 'T', 'S', '0'),
71    DXIL_DXIL = DXIL_FOURCC('D', 'X', 'I', 'L'),
72    DXIL_PSV0 = DXIL_FOURCC('P', 'S', 'V', '0'),
73    DXIL_RDAT = DXIL_FOURCC('R', 'D', 'A', 'T'),
74    DXIL_HASH = DXIL_FOURCC('H', 'A', 'S', 'H'),
75 };
76 
77 struct dxil_resource_v0 {
78    uint32_t resource_type;
79    uint32_t space;
80    uint32_t lower_bound;
81    uint32_t upper_bound;
82 };
83 
84 struct dxil_resource_v1 {
85    struct dxil_resource_v0 v0;
86    uint32_t resource_kind;
87    uint32_t resource_flags;
88 };
89 
90 struct dxil_validation_state {
91    struct dxil_psv_runtime_info_2 state;
92    union {
93       const struct dxil_resource_v0 *v0;
94       const struct dxil_resource_v1 *v1;
95    } resources;
96    uint32_t num_resources;
97 };
98 
99 void
100 dxil_container_init(struct dxil_container *c);
101 
102 void
103 dxil_container_finish(struct dxil_container *c);
104 
105 struct dxil_features;
106 
107 bool
108 dxil_container_add_features(struct dxil_container *c,
109                             const struct dxil_features *features);
110 
111 
112 bool
113 dxil_container_add_io_signature(struct dxil_container *c,
114                                 enum dxil_part_fourcc part,
115                                 unsigned num_records,
116                                 struct dxil_signature_record *io,
117                                 bool validator_7);
118 
119 bool
120 dxil_container_add_state_validation(struct dxil_container *c,
121                                     const struct dxil_module *m,
122                                     struct dxil_validation_state *state);
123 
124 bool
125 dxil_container_add_module(struct dxil_container *c,
126                           const struct dxil_module *m);
127 
128 bool
129 dxil_container_write(struct dxil_container *c, struct blob *blob);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
136