gallium: add blob field to pipe_llvm_program_header

makes it easier to consume a IR_NATIVE binary

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
This commit is contained in:
Karol Herbst 2019-05-10 09:22:25 +02:00 committed by Karol Herbst
parent 2043c5f37c
commit b6c47abe3e
4 changed files with 4 additions and 8 deletions

View File

@ -430,7 +430,6 @@ static void *evergreen_create_compute_state(struct pipe_context *ctx,
struct r600_pipe_compute *shader = CALLOC_STRUCT(r600_pipe_compute);
#ifdef HAVE_OPENCL
const struct pipe_llvm_program_header *header;
const char *code;
void *p;
boolean use_kill;
#endif
@ -449,9 +448,8 @@ static void *evergreen_create_compute_state(struct pipe_context *ctx,
#ifdef HAVE_OPENCL
COMPUTE_DBG(rctx->screen, "*** evergreen_create_compute_state\n");
header = cso->prog;
code = cso->prog + sizeof(struct pipe_llvm_program_header);
radeon_shader_binary_init(&shader->binary);
r600_elf_read(code, header->num_bytes, &shader->binary);
r600_elf_read(header->blob, header->num_bytes, &shader->binary);
r600_create_shader(&shader->bc, &shader->binary, &use_kill);
/* Upload code + ROdata */

View File

@ -257,9 +257,7 @@ static void *si_create_compute_state(
program, si_create_compute_state_async);
} else {
const struct pipe_llvm_program_header *header;
const char *code;
header = cso->prog;
code = cso->prog + sizeof(struct pipe_llvm_program_header);
program->shader.binary.elf_size = header->num_bytes;
program->shader.binary.elf_buffer = malloc(header->num_bytes);
@ -267,7 +265,7 @@ static void *si_create_compute_state(
FREE(program);
return NULL;
}
memcpy((void *)program->shader.binary.elf_buffer, code, header->num_bytes);
memcpy((void *)program->shader.binary.elf_buffer, header->blob, header->num_bytes);
const amd_kernel_code_t *code_object =
si_compute_get_code_object(program, 0);

View File

@ -884,6 +884,7 @@ struct pipe_grid_info
struct pipe_llvm_program_header
{
uint32_t num_bytes; /**< Number of bytes in the LLVM bytecode program. */
char blob[];
};
struct pipe_compute_state

View File

@ -625,8 +625,7 @@ clover::spirv::link_program(const std::vector<module> &modules,
sec.type == module::section::text_library;
}, mod.secs);
const auto c_il = msec.data.data() +
sizeof(struct pipe_llvm_program_header);
const auto c_il = ((struct pipe_llvm_program_header*)msec.data.data())->blob;
const auto length = msec.size;
sections.push_back(reinterpret_cast<const uint32_t *>(c_il));