#ifdef HAVE_OPENCL
-static void r600_shader_binary_read_config(const struct radeon_shader_binary *binary,
+static void r600_shader_binary_read_config(const struct ac_shader_binary *binary,
struct r600_bytecode *bc,
uint64_t symbol_offset,
boolean *use_kill)
}
static unsigned r600_create_shader(struct r600_bytecode *bc,
- const struct radeon_shader_binary *binary,
+ const struct ac_shader_binary *binary,
boolean *use_kill)
{
struct r600_pipe_compute {
struct r600_context *ctx;
- struct radeon_shader_binary binary;
+ struct ac_shader_binary binary;
struct r600_resource *code_bo;
struct r600_bytecode bc;
/*
* shader binary helpers.
*/
-void radeon_shader_binary_init(struct radeon_shader_binary *b)
+void radeon_shader_binary_init(struct ac_shader_binary *b)
{
memset(b, 0, sizeof(*b));
}
-void radeon_shader_binary_clean(struct radeon_shader_binary *b)
+void radeon_shader_binary_clean(struct ac_shader_binary *b)
{
if (!b)
return;
#include <stdio.h>
+#include "amd/common/ac_binary.h"
+
#include "radeon/radeon_winsys.h"
#include "util/disk_cache.h"
struct tgsi_shader_info;
struct r600_qbo_state;
-struct radeon_shader_reloc {
- char name[32];
- uint64_t offset;
-};
-
-struct radeon_shader_binary {
- /** Shader code */
- unsigned char *code;
- unsigned code_size;
-
- /** Config/Context register state that accompanies this shader.
- * This is a stream of dword pairs. First dword contains the
- * register address, the second dword contains the value.*/
- unsigned char *config;
- unsigned config_size;
-
- /** The number of bytes of config information for each global symbol.
- */
- unsigned config_size_per_symbol;
-
- /** Constant data accessed by the shader. This will be uploaded
- * into a constant buffer. */
- unsigned char *rodata;
- unsigned rodata_size;
-
- /** List of symbol offsets for the shader */
- uint64_t *global_symbol_offsets;
- unsigned global_symbol_count;
-
- struct radeon_shader_reloc *relocs;
- unsigned reloc_count;
-
- /** Disassembled shader in a string. */
- char *disasm_string;
- char *llvm_ir_string;
-};
-
-void radeon_shader_binary_init(struct radeon_shader_binary *b);
-void radeon_shader_binary_clean(struct radeon_shader_binary *b);
+void radeon_shader_binary_init(struct ac_shader_binary *b);
+void radeon_shader_binary_clean(struct ac_shader_binary *b);
/* Only 32-bit buffer allocations are supported, gallium doesn't support more
* at the moment.
static void parse_symbol_table(Elf_Data *symbol_table_data,
const GElf_Shdr *symbol_table_header,
- struct radeon_shader_binary *binary)
+ struct ac_shader_binary *binary)
{
GElf_Sym symbol;
unsigned i = 0;
static void parse_relocs(Elf *elf, Elf_Data *relocs, Elf_Data *symbols,
unsigned symbol_sh_link,
- struct radeon_shader_binary *binary)
+ struct ac_shader_binary *binary)
{
unsigned i;
return;
}
binary->relocs = CALLOC(binary->reloc_count,
- sizeof(struct radeon_shader_reloc));
+ sizeof(struct ac_shader_reloc));
for (i = 0; i < binary->reloc_count; i++) {
GElf_Sym symbol;
GElf_Rel rel;
char *symbol_name;
- struct radeon_shader_reloc *reloc = &binary->relocs[i];
+ struct ac_shader_reloc *reloc = &binary->relocs[i];
gelf_getrel(relocs, i, &rel);
gelf_getsym(symbols, GELF_R_SYM(rel.r_info), &symbol);
}
void radeon_elf_read(const char *elf_data, unsigned elf_size,
- struct radeon_shader_binary *binary)
+ struct ac_shader_binary *binary)
{
char *elf_buffer;
Elf *elf;
}
const unsigned char *radeon_shader_binary_config_start(
- const struct radeon_shader_binary *binary,
+ const struct ac_shader_binary *binary,
uint64_t symbol_offset)
{
unsigned i;
#include <stdint.h>
-struct radeon_shader_binary;
-struct radeon_shader_reloc;
+struct ac_shader_binary;
/*
* Parse the elf binary stored in \p elf_data and create a
* radeon_shader_binary object.
*/
void radeon_elf_read(const char *elf_data, unsigned elf_size,
- struct radeon_shader_binary *binary);
+ struct ac_shader_binary *binary);
/**
* @returns A pointer to the start of the configuration information for
* the function starting at \p symbol_offset of the binary.
*/
const unsigned char *radeon_shader_binary_config_start(
- const struct radeon_shader_binary *binary,
+ const struct ac_shader_binary *binary,
uint64_t symbol_offset);
#endif /* RADEON_ELF_UTIL_H */
* Shader compiles can be overridden with arbitrary ELF objects by setting
* the environment variable RADEON_REPLACE_SHADERS=num1:filename1[;num2:filename2]
*/
-bool si_replace_shader(unsigned num, struct radeon_shader_binary *binary)
+bool si_replace_shader(unsigned num, struct ac_shader_binary *binary)
{
const char *p = debug_get_option_replace_shaders();
const char *semicolon;
void si_init_debug_functions(struct si_context *sctx);
void si_check_vm_faults(struct r600_common_context *ctx,
struct radeon_saved_cs *saved, enum ring_type ring);
-bool si_replace_shader(unsigned num, struct radeon_shader_binary *binary);
+bool si_replace_shader(unsigned num, struct ac_shader_binary *binary);
/* si_dma.c */
void si_init_dma_functions(struct si_context *sctx);
lp_build_intrinsic(builder, "llvm.AMDGPU.kill", ctx->voidt, &bit, 1, 0);
}
-void si_shader_binary_read_config(struct radeon_shader_binary *binary,
+void si_shader_binary_read_config(struct ac_shader_binary *binary,
struct si_shader_config *conf,
unsigned symbol_offset)
{
* Find out if we really need the scratch buffer.
*/
for (i = 0; i < binary->reloc_count; i++) {
- const struct radeon_shader_reloc *reloc = &binary->relocs[i];
+ const struct ac_shader_reloc *reloc = &binary->relocs[i];
if (!strcmp(scratch_rsrc_dword0_symbol, reloc->name) ||
!strcmp(scratch_rsrc_dword1_symbol, reloc->name)) {
S_008F04_STRIDE(config->scratch_bytes_per_wave / 64);
for (i = 0 ; i < shader->binary.reloc_count; i++) {
- const struct radeon_shader_reloc *reloc =
+ const struct ac_shader_reloc *reloc =
&shader->binary.relocs[i];
if (!strcmp(scratch_rsrc_dword0_symbol, reloc->name)) {
util_memcpy_cpu_to_le32(shader->binary.code + reloc->offset,
int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
{
- const struct radeon_shader_binary *prolog =
+ const struct ac_shader_binary *prolog =
shader->prolog ? &shader->prolog->binary : NULL;
- const struct radeon_shader_binary *epilog =
+ const struct ac_shader_binary *epilog =
shader->epilog ? &shader->epilog->binary : NULL;
- const struct radeon_shader_binary *mainb = &shader->binary;
+ const struct ac_shader_binary *mainb = &shader->binary;
unsigned bo_size = si_get_shader_binary_size(shader) +
(!epilog ? mainb->rodata_size : 0);
unsigned char *ptr;
return 0;
}
-static void si_shader_dump_disassembly(const struct radeon_shader_binary *binary,
+static void si_shader_dump_disassembly(const struct ac_shader_binary *binary,
struct pipe_debug_callback *debug,
const char *name, FILE *file)
{
}
int si_compile_llvm(struct si_screen *sscreen,
- struct radeon_shader_binary *binary,
+ struct ac_shader_binary *binary,
struct si_shader_config *conf,
LLVMTargetMachineRef tm,
LLVMModuleRef mod,
#include "util/u_queue.h"
#include "si_state.h"
-struct radeon_shader_binary;
-struct radeon_shader_reloc;
+struct ac_shader_binary;
#define SI_MAX_VS_OUTPUTS 40
bool is_gs_copy_shader;
/* The following data is all that's needed for binary shaders. */
- struct radeon_shader_binary binary;
+ struct ac_shader_binary binary;
struct si_shader_config config;
struct si_shader_info info;
struct si_shader_part {
struct si_shader_part *next;
union si_shader_part_key key;
- struct radeon_shader_binary binary;
+ struct ac_shader_binary binary;
struct si_shader_config config;
};
struct si_shader *shader,
struct pipe_debug_callback *debug);
int si_compile_llvm(struct si_screen *sscreen,
- struct radeon_shader_binary *binary,
+ struct ac_shader_binary *binary,
struct si_shader_config *conf,
LLVMTargetMachineRef tm,
LLVMModuleRef mod,
struct si_shader *shader,
struct si_shader_config *config,
uint64_t scratch_va);
-void si_shader_binary_read_config(struct radeon_shader_binary *binary,
+void si_shader_binary_read_config(struct ac_shader_binary *binary,
struct si_shader_config *conf,
unsigned symbol_offset);
unsigned si_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
#include <llvm-c/TargetMachine.h>
struct pipe_debug_callback;
-struct radeon_shader_binary;
+struct ac_shader_binary;
#define RADEON_LLVM_MAX_INPUT_SLOTS 32
#define RADEON_LLVM_MAX_INPUTS 32 * 4
LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple);
-unsigned si_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binary,
+unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
LLVMTargetMachineRef tm,
struct pipe_debug_callback *debug);
*
* @returns 0 for success, 1 for failure
*/
-unsigned si_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binary,
+unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
LLVMTargetMachineRef tm,
struct pipe_debug_callback *debug)
{