diff --git a/source/adapters/opencl/sampler.cpp b/source/adapters/opencl/sampler.cpp index f05177a987..a47ba7f894 100644 --- a/source/adapters/opencl/sampler.cpp +++ b/source/adapters/opencl/sampler.cpp @@ -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(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(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(pPropValue) = + static_cast(normalized_coords); + } + if (pPropSizeRet) { + *pPropSizeRet = sizeof(ur_bool_t); + } + } else { + size_t CheckPropSize = 0; + Err = mapCLErrorToUR( + clGetSamplerInfo(cl_adapter::cast(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