Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions source/adapters/opencl/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,38 @@ urSamplerGetInfo(ur_sampler_handle_t hSampler, ur_sampler_info_t propName,
static_assert(sizeof(cl_addressing_mode) ==
sizeof(ur_sampler_addressing_mode_t));

size_t CheckPropSize = 0;
ur_result_t Err = mapCLErrorToUR(
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
propSize, pPropValue, &CheckPropSize));
if (pPropValue && CheckPropSize != propSize) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
UR_RETURN_ON_FAILURE(Err);
if (pPropSizeRet) {
*pPropSizeRet = CheckPropSize;
ur_result_t Err = UR_RESULT_SUCCESS;
// ur_bool_t have a size of uint8_t, but cl_bool size have the size of
// uint32_t so this adjust UR_SAMPLER_INFO_NORMALIZED_COORDS info to map
// between them.
if (propName == UR_SAMPLER_INFO_NORMALIZED_COORDS) {
cl_bool normalized_coords = false;
Err = mapCLErrorToUR(
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
sizeof(cl_bool), &normalized_coords, nullptr));
if (pPropValue && propSize != sizeof(ur_bool_t)) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
UR_RETURN_ON_FAILURE(Err);
if (pPropValue) {
*static_cast<ur_bool_t *>(pPropValue) =
static_cast<ur_bool_t>(normalized_coords);
}
if (pPropSizeRet) {
*pPropSizeRet = sizeof(ur_bool_t);
}
} else {
size_t CheckPropSize = 0;
Err = mapCLErrorToUR(
clGetSamplerInfo(cl_adapter::cast<cl_sampler>(hSampler), SamplerInfo,
propSize, pPropValue, &CheckPropSize));
if (pPropValue && CheckPropSize != propSize) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
UR_RETURN_ON_FAILURE(Err);
if (pPropSizeRet) {
*pPropSizeRet = CheckPropSize;
}
}

// Convert OpenCL returns to UR
Expand Down