fprintf(stderr, "\nShader Disassembly:\n\n");
fprintf(stderr, "%.*s\n", (int)section_data->d_size,
(char *)section_data->d_buf);
+ } else if (!strncmp(name, ".rodata", 7)) {
+ section_data = elf_getdata(section, section_data);
+ binary->rodata_size = section_data->d_size;
+ binary->rodata = MALLOC(binary->rodata_size * sizeof(unsigned char));
+ memcpy(binary->rodata, section_data->d_buf, binary->rodata_size);
}
}
bool dump = r600_can_dump_shader(&sctx->screen->b,
shader->selector ? shader->selector->tokens : NULL);
const char * gpu_family = r600_get_llvm_processor_name(sctx->screen->b.family);
+ unsigned code_size;
/* Use LLVM to compile shader */
memset(&binary, 0, sizeof(binary));
}
/* copy new shader */
+ code_size = binary.code_size + binary.rodata_size;
r600_resource_reference(&shader->bo, NULL);
shader->bo = si_resource_create_custom(sctx->b.b.screen, PIPE_USAGE_IMMUTABLE,
- binary.code_size);
+ code_size);
if (shader->bo == NULL) {
return -ENOMEM;
}
for (i = 0; i < binary.code_size / 4; ++i) {
ptr[i] = util_cpu_to_le32((*(uint32_t*)(binary.code + i*4)));
}
+ ptr += (binary.code_size / 4);
+ for (i = 0; i < binary.rodata_size / 4; ++i) {
+ ptr[i] = util_cpu_to_le32((*(uint32_t*)(binary.rodata + i * 4)));
+ }
} else {
memcpy(ptr, binary.code, binary.code_size);
+ if (binary.rodata_size > 0) {
+ ptr += (binary.code_size / 4);
+ memcpy(ptr, binary.rodata, binary.rodata_size);
+ }
}
sctx->b.ws->buffer_unmap(shader->bo->cs_buf);
free(binary.code);
free(binary.config);
+ free(binary.rodata);
return r;
}