gallium: add blob field to pipe_llvm_program_header
authorKarol Herbst <kherbst@redhat.com>
Fri, 10 May 2019 07:22:25 +0000 (09:22 +0200)
committerKarol Herbst <karolherbst@gmail.com>
Sat, 21 Sep 2019 08:28:32 +0000 (08:28 +0000)
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>
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/clover/spirv/invocation.cpp

index 0dad0f04c1aa755c54a9a40afd5f22587b8ecad9..0f6c5c2f2ff2b0c611fe21816faafedfdd109cfb 100644 (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 */
index 3acc1c69a0a809ff5f19416be17784fa90a472a6..037b1927189a8387a9f1f599b4e043a075872e55 100644 (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);
index 41c374028233e416aac939230d73906b2d0be67d..4b23824f3de3b6e4263aaf4f415918ebdb5954ad 100644 (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
index fa5b4dba6063871ad83421457a6b5da08a4d46b0..86916117b4892cd5d11e2aa8563ab673f699dc3d 100644 (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));