@@ -120,7 +120,23 @@ cl_mem Context::createBuffer(const cl_mem_properties *properties,
120120 size_t size,
121121 void *hostPtr)
122122{
123- return Object::Create<Buffer>(*this , Memory::PropArray{}, flags, size, hostPtr);
123+ // If the properties argument specified in clCreateBufferWithProperties or
124+ // clCreateImageWithProperties used to create memobj was not NULL, the implementation must
125+ // return the values specified in the properties argument in the same order and without
126+ // including additional properties. So pass them as is.
127+ Memory::PropArray propArray;
128+ if (properties != nullptr )
129+ {
130+ const cl_mem_properties *propIt = properties;
131+ while (*propIt != 0 )
132+ {
133+ propArray.push_back (*propIt);
134+ ++propIt;
135+ }
136+ // there is at least one property - special property 0
137+ propArray.push_back (0 );
138+ }
139+ return Object::Create<Buffer>(*this , std::move (propArray), flags, size, hostPtr);
124140}
125141
126142cl_mem Context::createImage (const cl_mem_properties *properties,
@@ -129,11 +145,33 @@ cl_mem Context::createImage(const cl_mem_properties *properties,
129145 const cl_image_desc *desc,
130146 void *hostPtr)
131147{
132- const ImageDescriptor imageDesc (FromCLenum<MemObjectType>(desc->image_type ), desc->image_width ,
133- desc->image_height , desc->image_depth , desc->image_array_size ,
134- desc->image_row_pitch , desc->image_slice_pitch ,
135- desc->num_mip_levels , desc->num_samples );
136- return Object::Create<Image>(*this , Memory::PropArray{}, flags, *format, imageDesc,
148+ const ImageDescriptor imageDesc = {FromCLenum<MemObjectType>(desc->image_type ),
149+ desc->image_width ,
150+ desc->image_height ,
151+ desc->image_depth ,
152+ desc->image_array_size ,
153+ desc->image_row_pitch ,
154+ desc->image_slice_pitch ,
155+ desc->num_mip_levels ,
156+ desc->num_samples };
157+ Memory::PropArray propArray;
158+
159+ // If the properties argument specified in clCreateBufferWithProperties or
160+ // clCreateImageWithProperties used to create memobj was not NULL, the implementation must
161+ // return the values specified in the properties argument in the same order and without
162+ // including additional properties. So Pass them as is.
163+ if (properties != nullptr )
164+ {
165+ const cl_mem_properties *propIt = properties;
166+ while (*propIt != 0 )
167+ {
168+ propArray.push_back (*propIt);
169+ ++propIt;
170+ }
171+ // there is at least one property - special property 0
172+ propArray.push_back (0 );
173+ }
174+ return Object::Create<Image>(*this , std::move (propArray), flags, *format, imageDesc,
137175 Memory::Cast (desc->buffer ), hostPtr);
138176}
139177
0 commit comments