From 610d7e00a78124ec04c5bebd9f771d0126ff752f Mon Sep 17 00:00:00 2001 From: Alagris Date: Tue, 22 Jun 2021 10:40:57 +0200 Subject: [PATCH] improvement for subbuffer --- ocl/src/standard/buffer.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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,