Skip to content

Commit dc8b2e2

Browse files
gowtham-sarcAngle LUCI CQ
authored andcommitted
CL: Pass in memory properties from cl entry point
The spec requires the valid properties to be reported as by `clGetMemObjectInfo()`. So pass in the properties as is post their validation. Bug: angleproject:378017028 Change-Id: I8b7ddc9d0e71ea56b2f8d81764fc3a21cee6bef4 Signed-off-by: Gowtham Tammana <[email protected]> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6004684 Reviewed-by: Geoff Lang <[email protected]> Reviewed-by: Shahbaz Youssefi <[email protected]>
1 parent 743dd7b commit dc8b2e2

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

src/libANGLE/CLContext.cpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

126142
cl_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

Comments
 (0)