}
+/**
+ * Compute slice/image to use for 1D or 2D array texture.
+ */
+static INLINE GLint
+tex_array_slice(GLfloat coord, GLsizei size)
+{
+ GLint slice = IFLOOR(coord);
+ slice = CLAMP(slice, 0, size - 1);
+ return slice;
+}
+
+
/**
* Compute nearest integer texcoords for given texobj and coordinate.
*/
break;
case GL_TEXTURE_1D_ARRAY_EXT:
*i = nearest_texel_location(texObj->WrapS, img, width, texcoord[0]);
- *j = clamp_rect_coord_nearest(texObj->WrapT, texcoord[1], height);
+ *j = tex_array_slice(texcoord[1], height);
*k = 0;
break;
case GL_TEXTURE_2D_ARRAY_EXT:
*i = nearest_texel_location(texObj->WrapS, img, width, texcoord[0]);
*j = nearest_texel_location(texObj->WrapT, img, height, texcoord[1]);
- *k = clamp_rect_coord_nearest(texObj->WrapR, texcoord[2], depth);
+ *k = tex_array_slice(texcoord[2], depth);
break;
default:
*i = *j = *k = 0;
case GL_TEXTURE_1D_ARRAY_EXT:
linear_texel_locations(texObj->WrapS, img, width,
texcoord[0], i0, i1, wi);
- *j0 = clamp_rect_coord_nearest(texObj->WrapT, texcoord[1], height);
+ *j0 = tex_array_slice(texcoord[1], height);
*j1 = *j0;
*slice = 0;
break;
texcoord[0], i0, i1, wi);
linear_texel_locations(texObj->WrapT, img, height,
texcoord[1], j0, j1, wj);
- *slice = clamp_rect_coord_nearest(texObj->WrapR, texcoord[2], depth);
+ *slice = tex_array_slice(texcoord[2], depth);
break;
default:
}
-
/**********************************************************************/
/* 2D Texture Array Sampling Functions */
/**********************************************************************/
i = nearest_texel_location(tObj->WrapS, img, width, texcoord[0]);
j = nearest_texel_location(tObj->WrapT, img, height, texcoord[1]);
- array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth);
+ array = tex_array_slice(texcoord[2], depth);
if (i < 0 || i >= (GLint) img->Width ||
j < 0 || j >= (GLint) img->Height ||
linear_texel_locations(tObj->WrapS, img, width, texcoord[0], &i0, &i1, &a);
linear_texel_locations(tObj->WrapT, img, height, texcoord[1], &j0, &j1, &b);
- array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth);
+ array = tex_array_slice(texcoord[2], depth);
if (array < 0 || array >= depth) {
COPY_4V(rgba, tObj->BorderColor.f);
(void) ctx;
i = nearest_texel_location(tObj->WrapS, img, width, texcoord[0]);
- array = clamp_rect_coord_nearest(tObj->WrapT, texcoord[1], height);
+ array = tex_array_slice(texcoord[1], height);
if (i < 0 || i >= (GLint) img->Width ||
array < 0 || array >= (GLint) img->Height) {
GLfloat t0[4], t1[4];
linear_texel_locations(tObj->WrapS, img, width, texcoord[0], &i0, &i1, &a);
- array = clamp_rect_coord_nearest(tObj->WrapT, texcoord[1], height);
+ array = tex_array_slice(texcoord[1], height);
if (img->Border) {
i0 += img->Border;