diff --git a/ocl/src/standard/buffer.rs b/ocl/src/standard/buffer.rs index b50309ac2..912c73518 100644 --- a/ocl/src/standard/buffer.rs +++ b/ocl/src/standard/buffer.rs @@ -2046,8 +2046,17 @@ impl Buffer { offset, len, buffer_len).into()); } - let obj_core = core::create_sub_buffer::(self, flags, - &BufferRegion::new(offset, len))?; + let (offset,obj_core) = if let Some(parent_offset) = self.offset(){ + let offset = parent_offset+offset; + let reg = BufferRegion::new(offset, len); + (offset,match self.mem_info(MemInfo::AssociatedMemobject).unwrap() { + MemInfoResult::AssociatedMemobject(Some(parent)) => core::create_sub_buffer::(&parent, flags,®)?, + _ => unreachable!(), + }) + }else{ + let reg = BufferRegion::new(offset, len); + (offset,core::create_sub_buffer::(self, flags,®)?) + }; Ok(Buffer { obj_core,