mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 22:20:14 +01:00
intel-clc: avoid using spirv-linker.
There is not real need to use the spirv-linker here at all, we can just read all the CL C files into one buffer, then compile that buffer in a single pass. This worksaround an issue seen with llvm17 and opaque pointers and the spirv linker. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25759>
This commit is contained in:
parent
843f2eb3c8
commit
d6613deed9
1 changed files with 41 additions and 35 deletions
|
|
@ -402,6 +402,8 @@ int main(int argc, char **argv)
|
||||||
.warning = msg_callback,
|
.warning = msg_callback,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t total_size = 0;
|
||||||
|
char *all_inputs = NULL;
|
||||||
util_dynarray_foreach(&input_files, char *, infile) {
|
util_dynarray_foreach(&input_files, char *, infile) {
|
||||||
int fd = open(*infile, O_RDONLY);
|
int fd = open(*infile, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|
@ -411,14 +413,19 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t len = lseek(fd, 0, SEEK_END);
|
off_t len = lseek(fd, 0, SEEK_END);
|
||||||
const void *map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
|
size_t new_size = total_size + len;
|
||||||
close(fd);
|
all_inputs = reralloc_size(mem_ctx, all_inputs, new_size + 1);
|
||||||
if (map == MAP_FAILED) {
|
if (!all_inputs) {
|
||||||
fprintf(stderr, "Failed to mmap the file: errno=%d, %s\n",
|
fprintf(stderr, "Failed to allocate memory\n");
|
||||||
errno, strerror(errno));
|
|
||||||
ralloc_free(mem_ctx);
|
ralloc_free(mem_ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
read(fd, all_inputs + total_size, len);
|
||||||
|
close(fd);
|
||||||
|
total_size = new_size;
|
||||||
|
all_inputs[total_size] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
const char *allowed_spirv_extensions[] = {
|
const char *allowed_spirv_extensions[] = {
|
||||||
"SPV_EXT_shader_atomic_float_add",
|
"SPV_EXT_shader_atomic_float_add",
|
||||||
|
|
@ -430,8 +437,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
struct clc_compile_args clc_args = {
|
struct clc_compile_args clc_args = {
|
||||||
.source = {
|
.source = {
|
||||||
.name = *infile,
|
.name = "intel_clc_files",
|
||||||
.value = map,
|
.value = all_inputs,
|
||||||
},
|
},
|
||||||
.features = {
|
.features = {
|
||||||
.fp16 = true,
|
.fp16 = true,
|
||||||
|
|
@ -451,7 +458,6 @@ int main(int argc, char **argv)
|
||||||
ralloc_free(mem_ctx);
|
ralloc_free(mem_ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
util_dynarray_foreach(&spirv_objs, struct clc_binary, p) {
|
util_dynarray_foreach(&spirv_objs, struct clc_binary, p) {
|
||||||
util_dynarray_append(&spirv_ptr_objs, struct clc_binary *, p);
|
util_dynarray_append(&spirv_ptr_objs, struct clc_binary *, p);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue