mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
rusticl: finish implementing clBuildProgram
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
parent
20c90fed5a
commit
1a999e6379
2 changed files with 36 additions and 3 deletions
|
|
@ -149,13 +149,11 @@ pub fn build_program(
|
|||
// CL_BUILD_PROGRAM_FAILURE if there is a failure to build the program executable. This error
|
||||
// will be returned if clBuildProgram does not return until the build has completed.
|
||||
for dev in devs {
|
||||
res &= p.compile(&dev, c_string_to_string(options), &Vec::new());
|
||||
res &= p.build(&dev, c_string_to_string(options));
|
||||
}
|
||||
|
||||
call_cb(pfn_notify, program, user_data);
|
||||
|
||||
// TODO link
|
||||
|
||||
//• CL_INVALID_BINARY if program is created with clCreateProgramWithBinary and devices listed in device_list do not have a valid program binary loaded.
|
||||
//• CL_INVALID_BUILD_OPTIONS if the build options specified by options are invalid.
|
||||
//• CL_INVALID_OPERATION if the build of a program executable for any of the devices listed in device_list by a previous call to clBuildProgram for program has not completed.
|
||||
|
|
|
|||
|
|
@ -111,6 +111,41 @@ impl Program {
|
|||
self.build_info().kernels.clone()
|
||||
}
|
||||
|
||||
pub fn build(&self, dev: &Arc<Device>, options: String) -> bool {
|
||||
let mut info = self.build_info();
|
||||
let d = Self::dev_build_info(&mut info, dev);
|
||||
|
||||
let args = prepare_options(&options);
|
||||
let (spirv, log) =
|
||||
spirv::SPIRVBin::from_clc(&self.src, &args, &Vec::new(), dev.cl_features());
|
||||
|
||||
d.log = log;
|
||||
d.options = options;
|
||||
if spirv.is_none() {
|
||||
d.status = CL_BUILD_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
let spirvs = vec![spirv.as_ref().unwrap()];
|
||||
let (spirv, log) = spirv::SPIRVBin::link(&spirvs, false);
|
||||
|
||||
d.log.push_str(&log);
|
||||
d.spirv = spirv;
|
||||
|
||||
d.status = match &d.spirv {
|
||||
None => CL_BUILD_ERROR,
|
||||
Some(_) => CL_BUILD_SUCCESS as cl_build_status,
|
||||
};
|
||||
|
||||
if d.spirv.is_some() {
|
||||
let mut kernels = d.spirv.as_ref().unwrap().kernels();
|
||||
info.kernels.append(&mut kernels);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compile(
|
||||
&self,
|
||||
dev: &Arc<Device>,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue