1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
__global__ void FUNCTION_NAME_7(cubemapMapKernel, face, fromSphereToInput, isWithin, distortionMetersTransform, distortionPixelsTransform, equiangular)
(global_mem uint32_t* __restrict__ g_odata,
global_mem const unsigned char * __restrict__ mask,
uint32_t imBit,
int inWidth, int inHeight,
int length,
int cropLeft, int cropRight, int cropTop, int cropBottom,
const vsfloat3x4 pose,
const float2 inputScale,
const vsDistortion distortion,
const float2 centerShift
) {
int x = get_global_id_x();
int y = get_global_id_y();
if (x < length && y < length) {
float2 uv = make_float2((float)x, (float)y);
/*To Center coordinates*/
uv.x -= (length - 1) / 2.0f;
uv.y -= (length - 1) / 2.0f;
uv = FUNCTION_NAME_6(mapFunctionCubemap, face, fromSphereToInput, distortionMetersTransform, distortionPixelsTransform, equiangular) (uv, length, pose, inputScale, distortion, centerShift);
/* To Topleft coordinates */
/* compensate fetching offset by adding 0.5f */
uv.x += inWidth / 2.0f;
uv.y += inHeight / 2.0f;
/* Check if pixel is inside the input */
uint32_t v = isWithin(uv, inWidth, inHeight, (float)cropLeft, (float)cropRight, (float)cropTop, (float)cropBottom) * imBit;
if (mask) {
if ((v != 0) && (mask[(int)uv.y * inWidth + (int)uv.x] == 1)) {
v = 0;
}
}
g_odata[y * length + x] |= v;
}
}