2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
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
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
34 struct ac_shader_reloc
{
39 struct ac_shader_binary
{
42 /** The number of bytes of config information for each global symbol.
44 unsigned config_size_per_symbol
;
46 unsigned global_symbol_count
;
52 /** Config/Context register state that accompanies this shader.
53 * This is a stream of dword pairs. First dword contains the
54 * register address, the second dword contains the value.*/
55 unsigned char *config
;
58 /** Constant data accessed by the shader. This will be uploaded
59 * into a constant buffer. */
60 unsigned char *rodata
;
62 /** List of symbol offsets for the shader */
63 uint64_t *global_symbol_offsets
;
65 struct ac_shader_reloc
*relocs
;
67 /** Disassembled shader in a string. */
72 struct ac_shader_config
{
75 unsigned spilled_sgprs
;
76 unsigned spilled_vgprs
;
78 unsigned spi_ps_input_ena
;
79 unsigned spi_ps_input_addr
;
81 unsigned scratch_bytes_per_wave
;
85 * Parse the elf binary stored in \p elf_data and create a
86 * ac_shader_binary object.
88 bool ac_elf_read(const char *elf_data
, unsigned elf_size
,
89 struct ac_shader_binary
*binary
);
92 * @returns A pointer to the start of the configuration information for
93 * the function starting at \p symbol_offset of the binary.
95 const unsigned char *ac_shader_binary_config_start(
96 const struct ac_shader_binary
*binary
,
97 uint64_t symbol_offset
);
99 void ac_shader_binary_read_config(struct ac_shader_binary
*binary
,
100 struct ac_shader_config
*conf
,
101 unsigned symbol_offset
,
102 bool supports_spill
);
103 void ac_shader_binary_clean(struct ac_shader_binary
*b
);
109 #endif /* AC_BINARY_H */