intel/compiler: Generalize shader relocations a bit

This commit adds a delta to be added to the relocated value as well as
the possibility of multiple types of relocations.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8637>
This commit is contained in:
Jason Ekstrand
2020-09-04 12:09:11 -05:00
committed by Marge Bot
parent f7668d6fe5
commit 55508bbe66
4 changed files with 47 additions and 15 deletions

View File

@@ -284,10 +284,17 @@ brw_write_shader_relocs(const struct intel_device_info *devinfo,
{
for (unsigned i = 0; i < prog_data->num_relocs; i++) {
assert(prog_data->relocs[i].offset % 8 == 0);
brw_inst *inst = (brw_inst *)(program + prog_data->relocs[i].offset);
void *dst = program + prog_data->relocs[i].offset;
for (unsigned j = 0; j < num_values; j++) {
if (prog_data->relocs[i].id == values[j].id) {
brw_update_reloc_imm(devinfo, inst, values[j].value);
uint32_t value = values[j].value + prog_data->relocs[i].delta;
switch (prog_data->relocs[i].type) {
case BRW_SHADER_RELOC_TYPE_MOV_IMM:
brw_update_reloc_imm(devinfo, dst, value);
break;
default:
unreachable("Invalid relocation type");
}
break;
}
}