ac/surface/gfx10: allow "rotated" micro mode
[mesa.git] / src / amd / common / ac_binary.h
1 /*
2 * Copyright 2014 Advanced Micro Devices, Inc.
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #ifndef AC_BINARY_H
25 #define AC_BINARY_H
26
27 #include <stddef.h>
28 #include <stdint.h>
29 #include <stdbool.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 struct ac_shader_reloc {
36 char name[32];
37 uint64_t offset;
38 };
39
40 struct ac_shader_binary {
41 unsigned code_size;
42 unsigned config_size;
43 /** The number of bytes of config information for each global symbol.
44 */
45 unsigned config_size_per_symbol;
46 unsigned rodata_size;
47 unsigned global_symbol_count;
48 unsigned reloc_count;
49
50 /** Shader code */
51 unsigned char *code;
52
53 /** Config/Context register state that accompanies this shader.
54 * This is a stream of dword pairs. First dword contains the
55 * register address, the second dword contains the value.*/
56 unsigned char *config;
57
58
59 /** Constant data accessed by the shader. This will be uploaded
60 * into a constant buffer. */
61 unsigned char *rodata;
62
63 /** List of symbol offsets for the shader */
64 uint64_t *global_symbol_offsets;
65
66 struct ac_shader_reloc *relocs;
67
68 /** Disassembled shader in a string. */
69 char *disasm_string;
70 char *llvm_ir_string;
71 };
72
73 struct ac_shader_config {
74 unsigned num_sgprs;
75 unsigned num_vgprs;
76 unsigned spilled_sgprs;
77 unsigned spilled_vgprs;
78 unsigned lds_size; /* in HW allocation units; i.e 256 bytes on SI, 512 bytes on CI+ */
79 unsigned spi_ps_input_ena;
80 unsigned spi_ps_input_addr;
81 unsigned float_mode;
82 unsigned scratch_bytes_per_wave;
83 unsigned rsrc1;
84 unsigned rsrc2;
85 };
86
87 /*
88 * Parse the elf binary stored in \p elf_data and create a
89 * ac_shader_binary object.
90 */
91 bool ac_elf_read(const char *elf_data, unsigned elf_size,
92 struct ac_shader_binary *binary);
93
94 /**
95 * @returns A pointer to the start of the configuration information for
96 * the function starting at \p symbol_offset of the binary.
97 */
98 const unsigned char *ac_shader_binary_config_start(
99 const struct ac_shader_binary *binary,
100 uint64_t symbol_offset);
101
102 void ac_parse_shader_binary_config(const char *data, size_t nbytes,
103 bool really_needs_scratch,
104 struct ac_shader_config *conf);
105 void ac_shader_binary_read_config(struct ac_shader_binary *binary,
106 struct ac_shader_config *conf,
107 unsigned symbol_offset,
108 bool supports_spill);
109 void ac_shader_binary_clean(struct ac_shader_binary *b);
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif /* AC_BINARY_H */