• 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_BUFFER_H
25 #define DXIL_BUFFER_H
26 
27 #include "util/blob.h"
28 
29 struct dxil_buffer {
30    struct blob blob;
31    uint64_t buf;
32    unsigned buf_bits;
33 
34    unsigned abbrev_width;
35 };
36 
37 void
38 dxil_buffer_init(struct dxil_buffer *b, unsigned abbrev_width);
39 
40 void
41 dxil_buffer_finish(struct dxil_buffer *b);
42 
43 bool
44 dxil_buffer_emit_bits(struct dxil_buffer *b, uint32_t data, unsigned width);
45 
46 bool
47 dxil_buffer_emit_vbr_bits(struct dxil_buffer *b, uint64_t data,
48                           unsigned width);
49 
50 bool
51 dxil_buffer_align(struct dxil_buffer *b);
52 
53 static inline bool
dxil_buffer_emit_abbrev_id(struct dxil_buffer * b,uint32_t id)54 dxil_buffer_emit_abbrev_id(struct dxil_buffer *b, uint32_t id)
55 {
56    return dxil_buffer_emit_bits(b, id, b->abbrev_width);
57 }
58 
59 
60 #endif
61