Commit b6c47abe authored by Karol Herbst's avatar Karol Herbst 🐧 Committed by Karol Herbst

gallium: add blob field to pipe_llvm_program_header

makes it easier to consume a IR_NATIVE binary
Signed-off-by: Karol Herbst's avatarKarol Herbst <kherbst@redhat.com>
Reviewed-by: Francisco Jerez's avatarFrancisco Jerez <currojerez@riseup.net>
Reviewed-by: Pierre Moreau's avatarPierre Moreau <pierre.morrow@free.fr>
parent 2043c5f3
......@@ -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 */
......
......@@ -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);
......
......@@ -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
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment