[Beignet] [PATCH 3/5] GBE: Fix the out-of-box checking for normalized coord clamping.
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Sep 25 04:13:17 PDT 2013
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
backend/src/ocl_stdlib.tmpl.h | 30 ++++++++++++++++++------------
src/intel/intel_gpgpu.c | 2 +-
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
index 4dc3bd8..735fc60 100644
--- a/backend/src/ocl_stdlib.tmpl.h
+++ b/backend/src/ocl_stdlib.tmpl.h
@@ -2295,7 +2295,8 @@ ushort __gen_ocl_get_sampler_info(uint sampler_id);
FIXUP_FLOAT_COORD(tmpCoord); \
} \
if (int_clamping_fix) { \
- if (OUT_OF_BOX(tmpCoord, surface_id)) { \
+ if (OUT_OF_BOX(tmpCoord, surface_id, \
+ (samplerValue & CLK_NORMALIZED_COORDS_TRUE))) { \
unsigned int border_alpha; \
int order = __gen_ocl_get_image_channel_order(surface_id); \
if (!CLK_HAS_ALPHA(order)) { \
@@ -2309,8 +2310,8 @@ ushort __gen_ocl_get_sampler_info(uint sampler_id);
} \
} \
} \
- return __gen_ocl_read_image ##suffix(EXPEND_READ_COORD(surface_id, \
- sampler, tmpCoord), 0); \
+ return __gen_ocl_read_image ##suffix( \
+ EXPEND_READ_COORD(surface_id, sampler, tmpCoord), 0);\
}
#define DECL_READ_IMAGE_NOSAMPLER(image_type, type, suffix, coord_type) \
@@ -2335,10 +2336,12 @@ ushort __gen_ocl_get_sampler_info(uint sampler_id);
#define EXPEND_READ_COORD(id, sampler, coord) id, sampler, coord.s0, coord.s1
#define EXPEND_WRITE_COORD(id, coord, color) id, coord.s0, coord.s1, color
-#define OUT_OF_BOX(coord, surface) \
- (coord.s0 < 0 || coord.s1 < 0 \
- || coord.s0 >= __gen_ocl_get_image_width(surface) \
- || coord.s1 >= __gen_ocl_get_image_height(surface))
+#define OUT_OF_BOX(coord, surface, normalized) \
+ (coord.s0 < 0 || coord.s1 < 0 || \
+ ((normalized == 0) \
+ && (coord.s0 >= __gen_ocl_get_image_width(surface) \
+ || coord.s1 >= __gen_ocl_get_image_height(surface))) \
+ || ((normalized != 0) && (coord.s0 > 0x1p0 || coord.s1 > 0x1p0)))
#define FIXUP_FLOAT_COORD(tmpCoord) \
{ \
@@ -2366,11 +2369,14 @@ DECL_IMAGE(0, image2d_t, float4, f, 2)
#define EXPEND_READ_COORD(id, sampler, coord) id, sampler, coord.s0, coord.s1, coord.s2
#define EXPEND_WRITE_COORD(id, coord, color) id, coord.s0, coord.s1, coord.s2, color
-#define OUT_OF_BOX(coord, surface) \
- (coord.s0 < 0 || coord.s1 < 0 || coord.s2 < 0 \
- || coord.s0 >= __gen_ocl_get_image_width(surface) \
- || coord.s1 >= __gen_ocl_get_image_height(surface) \
- || coord.s2 >= __gen_ocl_get_image_depth(surface))
+#define OUT_OF_BOX(coord, surface, normalized) \
+ (coord.s0 < 0 || coord.s1 < 0 || coord.s2 < 0 || \
+ ((normalized == 0) \
+ && (coord.s0 >= __gen_ocl_get_image_width(surface) \
+ || coord.s1 >= __gen_ocl_get_image_height(surface) \
+ || coord.s2 >= __gen_ocl_get_image_depth(surface))) \
+ || ((normalized != 0) \
+ &&(coord.s0 > 1 || coord.s1 > 1 || coord.s2 > 1)))
#define FIXUP_FLOAT_COORD(tmpCoord) \
{ \
diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c
index ae0a3fa..bc7b44c 100644
--- a/src/intel/intel_gpgpu.c
+++ b/src/intel/intel_gpgpu.c
@@ -844,7 +844,7 @@ intel_gpgpu_bind_sampler(intel_gpgpu_t *gpgpu, uint32_t *samplers, size_t sample
* to repeat.*/
if ((samplers[index] & __CLK_ADDRESS_MASK) == CLK_ADDRESS_CLAMP) {
intel_gpgpu_insert_sampler(gpgpu, index + 8,
- (samplers[index] & ~__CLK_ADDRESS_MASK) | CLK_ADDRESS_REPEAT);
+ (samplers[index] & ~__CLK_ADDRESS_MASK) | CLK_ADDRESS_CLAMP_TO_EDGE);
}
#endif
}
--
1.7.9.5
More information about the Beignet
mailing list