mirror of
https://github.com/elwrcl/intel-hard-graphics.git
synced 2026-10-31 19:08:03 +03:00
wip: crocus/rusticl/elk/hasvk local changes before h264 cherry-pick
This commit is contained in:
35 files changed
+1177
-191
No files matched your search
@@ -20,6 +20,14 @@ use std::ffi::c_void;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
fn rusticl_dbg(msg: &str) {
|
||||
use std::io::Write;
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open("/tmp/rusticl_debug.log") {
|
||||
let _ = writeln!(f, "{}", msg);
|
||||
let _ = f.flush();
|
||||
}
|
||||
}
|
||||
|
||||
#[cl_info_entrypoint(clGetContextInfo)]
|
||||
unsafe impl CLInfo<cl_context_info> for cl_context {
|
||||
fn query(&self, q: cl_context_info, v: CLInfoValue) -> CLResult<CLInfoRes> {
|
||||
@@ -99,7 +107,9 @@ pub fn get_gl_context_info_khr(
|
||||
}
|
||||
}
|
||||
|
||||
rusticl_dbg(&format!("RUSTICL_DBG: gl_context={:?} glx_display={:?} egl_display={:?}", gl_context, glx_display, egl_display));
|
||||
let gl_ctx_manager = GLCtxManager::new(gl_context, glx_display, egl_display)?;
|
||||
rusticl_dbg(&format!("RUSTICL_DBG: GLCtxManager::new result is_some={}", gl_ctx_manager.is_some()));
|
||||
unsafe {
|
||||
gl_ctx_manager
|
||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?
|
||||
@@ -175,28 +185,24 @@ fn create_context(
|
||||
|
||||
let gl_ctx_manager = GLCtxManager::new(gl_context, glx_display, egl_display)?;
|
||||
if let Some(gl_ctx_manager) = &gl_ctx_manager {
|
||||
// errcode_ret returns CL_INVALID_OPERATION if a context was specified as described above
|
||||
// and any of the following conditions hold:
|
||||
// ...
|
||||
// Any of the devices specified in the devices argument cannot support OpenCL objects which
|
||||
// share the data store of an OpenGL object.
|
||||
|
||||
let [dev] = devs.as_slice() else {
|
||||
rusticl_dbg(&format!("RUSTICL_DBG: create_context fail at (B) - multiple devices with gl sharing"));
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
};
|
||||
|
||||
if !dev.is_gl_sharing_supported() {
|
||||
rusticl_dbg(&format!("RUSTICL_DBG: create_context fail at (C) - gl sharing not supported on this device"));
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// gl sharing is only supported on devices with an UUID, so we can simply unwrap it
|
||||
let dev_uuid: [c_char; UUID_SIZE] = dev
|
||||
.screen()
|
||||
.device_uuid()
|
||||
.unwrap_or_default()
|
||||
.map(|val| val as c_char);
|
||||
if gl_ctx_manager.interop_dev_info.device_uuid != dev_uuid {
|
||||
// we only support gl_sharing on the same device
|
||||
eprintln!("RUSTICL_DBG: create_context fail at (D) - uuid mismatch: gl_ctx={:?} dev={:?}",
|
||||
gl_ctx_manager.interop_dev_info.device_uuid, dev_uuid);
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,8 +165,14 @@ unsafe impl CLInfo<cl_device_info> for cl_device_id {
|
||||
}
|
||||
CL_DEVICE_LINKER_AVAILABLE => v.write::<bool>(true),
|
||||
CL_DEVICE_LOCAL_MEM_SIZE => v.write::<cl_ulong>(dev.local_mem_size()),
|
||||
// TODO add query for CL_LOCAL vs CL_GLOBAL
|
||||
CL_DEVICE_LOCAL_MEM_TYPE => v.write::<cl_device_local_mem_type>(CL_GLOBAL),
|
||||
CL_DEVICE_LOCAL_MEM_TYPE => {
|
||||
let local_type = if dev.screen().compute_caps().has_dedicated_local_mem {
|
||||
CL_LOCAL
|
||||
} else {
|
||||
CL_GLOBAL
|
||||
};
|
||||
v.write::<cl_device_local_mem_type>(local_type)
|
||||
}
|
||||
CL_DEVICE_LUID => v.write::<[cl_uchar; CL_LUID_SIZE as usize]>(
|
||||
dev.screen().device_luid().unwrap_or_default(),
|
||||
),
|
||||
|
||||
@@ -916,6 +916,23 @@ fn create_image_with_properties(
|
||||
)?;
|
||||
|
||||
let filtered_flags = filter_image_access_flags(flags);
|
||||
{
|
||||
use std::io::Write;
|
||||
if let Ok(mut dbgf) = std::fs::OpenOptions::new().create(true).append(true).open("/tmp/rusticl_debug.log") {
|
||||
let img_fmt = unsafe { *image_format };
|
||||
let _ = writeln!(dbgf, "RUSTICL_DBG: create_image format={:?} channel_order={} channel_data_type={} image_type={} filtered_flags={:#x}",
|
||||
format, img_fmt.image_channel_order, img_fmt.image_channel_data_type, desc.image_type, filtered_flags);
|
||||
for d in &c.devs {
|
||||
match d.formats.get(format) {
|
||||
None => { let _ = writeln!(dbgf, "RUSTICL_DBG: device has NO entry for this pipe_format at all"); }
|
||||
Some(f) => {
|
||||
let _ = writeln!(dbgf, "RUSTICL_DBG: device format map: {:?}", f);
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = dbgf.flush();
|
||||
}
|
||||
}
|
||||
// CL_IMAGE_FORMAT_NOT_SUPPORTED if there are no devices in context that support image_format.
|
||||
c.devs
|
||||
.iter()
|
||||
|
||||
@@ -935,12 +935,21 @@ impl DeviceBase {
|
||||
}
|
||||
|
||||
pub fn is_gl_sharing_supported(&self) -> bool {
|
||||
self.screen.caps().cl_gl_sharing
|
||||
&& self.screen.caps().dmabuf != 0
|
||||
&& !self.is_device_software()
|
||||
&& self.screen.is_res_handle_supported()
|
||||
&& self.screen.device_uuid().is_some()
|
||||
&& self.caps.has_create_fence_fd
|
||||
let c1 = self.screen.caps().cl_gl_sharing;
|
||||
let c2 = self.screen.caps().dmabuf != 0;
|
||||
let c3 = !self.is_device_software();
|
||||
let c4 = self.screen.is_res_handle_supported();
|
||||
let c5 = self.screen.device_uuid().is_some();
|
||||
let c6 = self.caps.has_create_fence_fd;
|
||||
{
|
||||
use std::io::Write;
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open("/tmp/rusticl_debug.log") {
|
||||
let _ = writeln!(f, "RUSTICL_DBG: is_gl_sharing_supported: cl_gl_sharing={} dmabuf={} !is_sw={} res_handle={} uuid_some={} fence_fd={}",
|
||||
c1, c2, c3, c4, c5, c6);
|
||||
let _ = f.flush();
|
||||
}
|
||||
}
|
||||
c1 && c2 && c3 && c4 && c5 && c6
|
||||
}
|
||||
|
||||
pub fn is_device_software(&self) -> bool {
|
||||
|
||||
@@ -1801,6 +1801,9 @@ impl Kernel {
|
||||
// subtract the shader local_size as we only request something on top of that.
|
||||
variable_local_size -= static_local_size;
|
||||
|
||||
let input_ptr_before = exec_builder.input().as_ptr();
|
||||
let input_len_before = exec_builder.input().len();
|
||||
|
||||
let (resources, mut globals) = exec_builder.get_resources_and_globals();
|
||||
|
||||
ctx.bind_kernel(&nir_kernel_builds, variant)?;
|
||||
|
||||
@@ -168,6 +168,7 @@ impl<'c> QueueContextWithState<'c> {
|
||||
pub fn update_cb0(&self, data: &[u8]) -> CLResult<()> {
|
||||
// only update if we actually bind data
|
||||
if !data.is_empty() {
|
||||
eprintln!("update_cb0: use_stream={} len={}", self.use_stream, data.len());
|
||||
if self.use_stream {
|
||||
if !self.ctx.set_constant_buffer_stream(0, data) {
|
||||
return Err(CL_OUT_OF_RESOURCES);
|
||||
|
||||
Reference in new issue
Block a user