GBE/Runtime: implement workaround for IVB sampler bug
authorZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 25 Sep 2013 10:26:49 +0000 (18:26 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Thu, 26 Sep 2013 08:53:01 +0000 (16:53 +0800)
commitb835433189a3dca202e7fc7d9ff0bfbc49676281
treed8b7e6ce5a04d392d477deeda2f396da9f431277
parent7291cf314b55496f56eaddb6a4b0506bd1d6bfcb
GBE/Runtime: implement workaround for IVB sampler bug

Per IVB spec,

If the surface format of the associated surface is UINT or SINT,
the Surface Type cannot be SURFTYPE_3D or SURFTYPE_CUBE and Address
Control Mode cannot be CLAMP_BORDER or HALF_BORDER.

Besides this bug, there is another undocumented issue. If a surface
data type is IEEE float. Then when we use sampler to sample the pixel,
if the value is betweeo -1p-20 to 0, the sampler will rounding it to
zero. And this will also bring problem when we are using the clamp mode.

This patch is to workaround the above two hardware issues.
It introduces a new intrinsic get_sampler_info to get a sampler type
at runtime. When calling to read_image, it will check whether it
hits the above two cases. If it hit case 1, then we will force it to
use clamp to edge for those pixels within the box, And for those
pixel out of the box, we manually set the border color. To achieve this
solution, we have to prepare two sampler slot for each CL_ADDRESS_CLAMP
sampler. And the first has slot_1 which is using CL_ADDRESS_CLAMP,
the second use slot_1 + 8. Thus we can only use half of 16 samplers.
Fortunately, 8 samplers comply with the OpenCL's minimal requirement.

If it hits case 2, then we minor a epsilon to the coordinate, and
let it not rounds to zero.

If possible, programer should avoid to use float coordinates and/or int/uint
format image. Otherwise, it will hit the very slow path.

With this workaround, the compiler_copy_image1 can pass now.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
22 files changed:
CMakeLists.txt
backend/CMakeLists.txt
backend/src/CMakeLists.txt
backend/src/backend/context.cpp
backend/src/backend/gen_insn_selection.cpp
backend/src/backend/gen_reg_allocation.cpp
backend/src/backend/gen_register.hpp
backend/src/backend/program.cpp
backend/src/backend/program.h
backend/src/ir/instruction.cpp
backend/src/ir/instruction.hpp
backend/src/ir/instruction.hxx
backend/src/ir/profile.cpp
backend/src/ir/profile.hpp
backend/src/llvm/llvm_gen_backend.cpp
backend/src/llvm/llvm_gen_ocl_function.hxx
backend/src/ocl_common_defines.h
backend/src/ocl_stdlib.tmpl.h
src/cl_command_queue_gen7.c
src/cl_gt_device.h
src/intel/intel_gpgpu.c
utests/compiler_copy_image1.cpp