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
35 struct ac_shader_reloc
{
40 struct ac_shader_binary
{
43 /** The number of bytes of config information for each global symbol.
45 unsigned config_size_per_symbol
;
47 unsigned global_symbol_count
;
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
;
59 /** Constant data accessed by the shader. This will be uploaded
60 * into a constant buffer. */
61 unsigned char *rodata
;
63 /** List of symbol offsets for the shader */
64 uint64_t *global_symbol_offsets
;
66 struct ac_shader_reloc
*relocs
;
68 /** Disassembled shader in a string. */
73 struct ac_shader_config
{
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
;
82 unsigned scratch_bytes_per_wave
;
88 * Parse the elf binary stored in \p elf_data and create a
89 * ac_shader_binary object.
91 bool ac_elf_read(const char *elf_data
, unsigned elf_size
,
92 struct ac_shader_binary
*binary
);
95 * @returns A pointer to the start of the configuration information for
96 * the function starting at \p symbol_offset of the binary.
98 const unsigned char *ac_shader_binary_config_start(
99 const struct ac_shader_binary
*binary
,
100 uint64_t symbol_offset
);
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
);
115 #endif /* AC_BINARY_H */