radeon/ac: switch from radeon_shader_binary to ac_shader_binary

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri 2017-02-27 10:50:29 +11:00
parent affc8314cb
commit 69a687189e
12 changed files with 36 additions and 73 deletions

View File

@ -180,7 +180,7 @@ static void evergreen_cs_set_constant_buffer(struct r600_context *rctx,
#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)
@ -216,7 +216,7 @@ static void r600_shader_binary_read_config(const struct radeon_shader_binary *bi
}
static unsigned r600_create_shader(struct r600_bytecode *bc,
const struct radeon_shader_binary *binary,
const struct ac_shader_binary *binary,
boolean *use_kill)
{

View File

@ -33,7 +33,7 @@
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;

View File

@ -66,12 +66,12 @@ struct r600_multi_fence {
/*
* 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;

View File

@ -34,6 +34,8 @@
#include <stdio.h>
#include "amd/common/ac_binary.h"
#include "radeon/radeon_winsys.h"
#include "util/disk_cache.h"
@ -128,45 +130,8 @@ struct r600_perfcounters;
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.

View File

@ -35,7 +35,7 @@
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;
@ -78,7 +78,7 @@ static void parse_symbol_table(Elf_Data *symbol_table_data,
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;
@ -86,12 +86,12 @@ static void parse_relocs(Elf *elf, Elf_Data *relocs, Elf_Data *symbols,
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);
@ -104,7 +104,7 @@ static void parse_relocs(Elf *elf, Elf_Data *relocs, Elf_Data *symbols,
}
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;
@ -183,7 +183,7 @@ void radeon_elf_read(const char *elf_data, unsigned elf_size,
}
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;

View File

@ -29,22 +29,21 @@
#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 */

View File

@ -53,7 +53,7 @@ static void si_dump_shader(struct si_screen *sscreen,
* 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;

View File

@ -419,7 +419,7 @@ void si_init_cp_dma_functions(struct si_context *sctx);
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);

View File

@ -5750,7 +5750,7 @@ static void si_llvm_emit_polygon_stipple(struct si_shader_context *ctx,
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)
{
@ -5763,7 +5763,7 @@ void si_shader_binary_read_config(struct radeon_shader_binary *binary,
* 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)) {
@ -5853,7 +5853,7 @@ void si_shader_apply_scratch_relocs(struct si_context *sctx,
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,
@ -5878,11 +5878,11 @@ static unsigned si_get_shader_binary_size(struct si_shader *shader)
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;
@ -5920,7 +5920,7 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
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)
{
@ -6128,7 +6128,7 @@ void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
}
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,

View File

@ -74,8 +74,7 @@
#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
@ -529,7 +528,7 @@ struct si_shader {
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;
@ -543,7 +542,7 @@ struct si_shader {
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;
};
@ -562,7 +561,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
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,
@ -582,7 +581,7 @@ void si_shader_apply_scratch_relocs(struct si_context *sctx,
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,

View File

@ -35,7 +35,7 @@
#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
@ -166,7 +166,7 @@ void si_llvm_shader_type(LLVMValueRef F, unsigned type);
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);

View File

@ -200,7 +200,7 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
*
* @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)
{