Debian Codegraph @

shared/source/built_ins/kernels/copy_image3d_to_buffer.builtin_kernel

raw
1 /*
2 * Copyright (C) 2019-2025 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 R"===(
9
10 __kernel void CopyImage3dToBufferBytes(__read_only image3d_t input,
11 __global uchar *dst,
12 int4 srcOffset,
13 offset_t dstOffset,
14 coord2_t Pitch) {
15 idx_t x = get_global_id(0);
16 idx_t y = get_global_id(1);
17 idx_t z = get_global_id(2);
18
19 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
20 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
21
22 uint4 c = read_imageui(input, srcCoord);
23 *(dst + DstOffset + x) = convert_uchar_sat(c.x);
24 }
25
26 __kernel void CopyImage3dToBuffer2Bytes(__read_only image3d_t input,
27 __global uchar *dst,
28 int4 srcOffset,
29 offset_t dstOffset,
30 coord2_t Pitch) {
31 idx_t x = get_global_id(0);
32 idx_t y = get_global_id(1);
33 idx_t z = get_global_id(2);
34
35 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
36 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
37
38 uint4 c = read_imageui(input, srcCoord);
39
40 if(((ulong)(dst + dstOffset)) & 0x00000001){
41 *((__global uchar*)(dst + DstOffset + x * 2 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
42 *((__global uchar*)(dst + DstOffset + x * 2)) = convert_uchar_sat(c.x & 0xff);
43 }
44 else{
45 *((__global ushort*)(dst + DstOffset + x * 2)) = convert_ushort_sat(c.x);
46 }
47 }
48
49 __kernel void CopyImage3dToBuffer3Bytes(__read_only image3d_t input,
50 __global uchar *dst,
51 int4 srcOffset,
52 offset_t dstOffset,
53 coord2_t Pitch) {
54 idx_t x = get_global_id(0);
55 idx_t y = get_global_id(1);
56 idx_t z = get_global_id(2);
57
58 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
59 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
60
61 uint4 c = read_imageui(input, srcCoord);
62
63 *((__global uchar*)(dst + DstOffset + x * 3 + 2)) = convert_uchar_sat(c.z & 0xff);
64 *((__global uchar*)(dst + DstOffset + x * 3 + 1)) = convert_uchar_sat(c.y & 0xff);
65 *((__global uchar*)(dst + DstOffset + x * 3)) = convert_uchar_sat(c.x & 0xff);
66 }
67
68 __kernel void CopyImage3dToBuffer4Bytes(__read_only image3d_t input,
69 __global uchar *dst,
70 int4 srcOffset,
71 offset_t dstOffset,
72 coord2_t Pitch) {
73 idx_t x = get_global_id(0);
74 idx_t y = get_global_id(1);
75 idx_t z = get_global_id(2);
76
77 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
78 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
79
80 uint4 c = read_imageui(input, srcCoord);
81
82 if(((ulong)(dst + dstOffset)) & 0x00000003){
83 *((__global uchar*)(dst + DstOffset + x * 4 + 3)) = convert_uchar_sat((c.x >> 24 ) & 0xff);
84 *((__global uchar*)(dst + DstOffset + x * 4 + 2)) = convert_uchar_sat((c.x >> 16 ) & 0xff);
85 *((__global uchar*)(dst + DstOffset + x * 4 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
86 *((__global uchar*)(dst + DstOffset + x * 4)) = convert_uchar_sat(c.x & 0xff);
87 }
88 else{
89 *((__global uint*)(dst + DstOffset + x * 4)) = c.x;
90 }
91 }
92
93 __kernel void CopyImage3dToBuffer4To3Bytes(__read_only image3d_t input,
94 __global uchar *dst,
95 int4 srcOffset,
96 offset_t dstOffset,
97 coord2_t Pitch) {
98 idx_t x = get_global_id(0);
99 idx_t y = get_global_id(1);
100 idx_t z = get_global_id(2);
101
102 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
103 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
104
105 uint4 c = read_imageui(input, srcCoord);
106
107 *((__global uchar*)(dst + DstOffset + x * 3 + 2)) = convert_uchar_sat((c.x >> 16 ) & 0xff);
108 *((__global uchar*)(dst + DstOffset + x * 3 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
109 *((__global uchar*)(dst + DstOffset + x * 3)) = convert_uchar_sat(c.x & 0xff);
110 }
111
112 __kernel void CopyImage3dToBuffer6Bytes(__read_only image3d_t input,
113 __global uchar *dst,
114 int4 srcOffset,
115 offset_t dstOffset,
116 coord2_t Pitch) {
117 idx_t x = get_global_id(0);
118 idx_t y = get_global_id(1);
119 idx_t z = get_global_id(2);
120
121 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
122 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
123
124 uint4 c = read_imageui(input, srcCoord);
125
126 *((__global uchar*)(dst + DstOffset + x * 6 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
127 *((__global uchar*)(dst + DstOffset + x * 6)) = convert_uchar_sat(c.x & 0xff);
128 *((__global uchar*)(dst + DstOffset + x * 6 + 3)) = convert_uchar_sat((c.y >> 8 ) & 0xff);
129 *((__global uchar*)(dst + DstOffset + x * 6 + 2)) = convert_uchar_sat(c.y & 0xff);
130 *((__global uchar*)(dst + DstOffset + x * 6 + 5)) = convert_uchar_sat((c.z >> 8 ) & 0xff);
131 *((__global uchar*)(dst + DstOffset + x * 6 + 4)) = convert_uchar_sat(c.z & 0xff);
132 }
133
134 __kernel void CopyImage3dToBuffer8Bytes(__read_only image3d_t input,
135 __global uchar *dst,
136 int4 srcOffset,
137 offset_t dstOffset,
138 coord2_t Pitch) {
139 idx_t x = get_global_id(0);
140 idx_t y = get_global_id(1);
141 idx_t z = get_global_id(2);
142
143 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
144 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
145
146 uint4 c = read_imageui(input, srcCoord);
147
148 if(((ulong)(dst + dstOffset)) & 0x00000007){
149 *((__global uchar*)(dst + DstOffset + x * 8 + 3)) = convert_uchar_sat((c.x >> 24 ) & 0xff);
150 *((__global uchar*)(dst + DstOffset + x * 8 + 2)) = convert_uchar_sat((c.x >> 16 ) & 0xff);
151 *((__global uchar*)(dst + DstOffset + x * 8 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
152 *((__global uchar*)(dst + DstOffset + x * 8)) = convert_uchar_sat(c.x & 0xff);
153 *((__global uchar*)(dst + DstOffset + x * 8 + 7)) = convert_uchar_sat((c.y >> 24 ) & 0xff);
154 *((__global uchar*)(dst + DstOffset + x * 8 + 6)) = convert_uchar_sat((c.y >> 16 ) & 0xff);
155 *((__global uchar*)(dst + DstOffset + x * 8 + 5)) = convert_uchar_sat((c.y >> 8 ) & 0xff);
156 *((__global uchar*)(dst + DstOffset + x * 8 + 4)) = convert_uchar_sat(c.y & 0xff);
157 }
158 else{
159 uint2 d = (uint2)(c.x,c.y);
160 *((__global uint2*)(dst + DstOffset + x * 8)) = d;
161 }
162 }
163
164 __kernel void CopyImage3dToBuffer8To6Bytes(__read_only image3d_t input,
165 __global uchar *dst,
166 int4 srcOffset,
167 offset_t dstOffset,
168 coord2_t Pitch) {
169 idx_t x = get_global_id(0);
170 idx_t y = get_global_id(1);
171 idx_t z = get_global_id(2);
172
173 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
174 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
175
176 uint4 c = read_imageui(input, srcCoord);
177
178 *((__global uchar*)(dst + DstOffset + x * 6 + 3)) = convert_uchar_sat((c.x >> 24 ) & 0xff);
179 *((__global uchar*)(dst + DstOffset + x * 6 + 2)) = convert_uchar_sat((c.x >> 16 ) & 0xff);
180 *((__global uchar*)(dst + DstOffset + x * 6 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
181 *((__global uchar*)(dst + DstOffset + x * 6)) = convert_uchar_sat(c.x & 0xff);
182
183 *((__global uchar*)(dst + DstOffset + x * 6 + 5)) = convert_uchar_sat((c.y >> 8 ) & 0xff);
184 *((__global uchar*)(dst + DstOffset + x * 6 + 4)) = convert_uchar_sat(c.y & 0xff);
185 }
186
187 __kernel void CopyImage3dToBuffer16Bytes(__read_only image3d_t input,
188 __global uchar *dst,
189 int4 srcOffset,
190 offset_t dstOffset,
191 coord2_t Pitch) {
192 idx_t x = get_global_id(0);
193 idx_t y = get_global_id(1);
194 idx_t z = get_global_id(2);
195
196 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
197 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
198
199 const uint4 c = read_imageui(input, srcCoord);
200
201 *((__global uchar*)(dst + DstOffset + x * 16 + 3)) = convert_uchar_sat((c.x >> 24 ) & 0xff);
202 *((__global uchar*)(dst + DstOffset + x * 16 + 2)) = convert_uchar_sat((c.x >> 16 ) & 0xff);
203 *((__global uchar*)(dst + DstOffset + x * 16 + 1)) = convert_uchar_sat((c.x >> 8 ) & 0xff);
204 *((__global uchar*)(dst + DstOffset + x * 16)) = convert_uchar_sat(c.x & 0xff);
205 *((__global uchar*)(dst + DstOffset + x * 16 + 7)) = convert_uchar_sat((c.y >> 24 ) & 0xff);
206 *((__global uchar*)(dst + DstOffset + x * 16 + 6)) = convert_uchar_sat((c.y >> 16 ) & 0xff);
207 *((__global uchar*)(dst + DstOffset + x * 16 + 5)) = convert_uchar_sat((c.y >> 8 ) & 0xff);
208 *((__global uchar*)(dst + DstOffset + x * 16 + 4)) = convert_uchar_sat(c.y & 0xff);
209 *((__global uchar*)(dst + DstOffset + x * 16 + 11)) = convert_uchar_sat((c.z >> 24 ) & 0xff);
210 *((__global uchar*)(dst + DstOffset + x * 16 + 10)) = convert_uchar_sat((c.z >> 16 ) & 0xff);
211 *((__global uchar*)(dst + DstOffset + x * 16 + 9)) = convert_uchar_sat((c.z >> 8 ) & 0xff);
212 *((__global uchar*)(dst + DstOffset + x * 16 + 8)) = convert_uchar_sat(c.z & 0xff);
213 *((__global uchar*)(dst + DstOffset + x * 16 + 15)) = convert_uchar_sat((c.w >> 24 ) & 0xff);
214 *((__global uchar*)(dst + DstOffset + x * 16 + 14)) = convert_uchar_sat((c.w >> 16 ) & 0xff);
215 *((__global uchar*)(dst + DstOffset + x * 16 + 13)) = convert_uchar_sat((c.w >> 8 ) & 0xff);
216 *((__global uchar*)(dst + DstOffset + x * 16 + 12)) = convert_uchar_sat(c.w & 0xff);
217 }
218
219 __kernel void CopyImage3dToBuffer16BytesAligned(__read_only image3d_t input,
220 __global uint4 *dst,
221 int4 srcOffset,
222 offset_t dstOffset,
223 coord2_t Pitch) {
224 idx_t x = get_global_id(0);
225 idx_t y = get_global_id(1);
226 idx_t z = get_global_id(2);
227
228 const int4 srcCoord = (int4)(x, y, z, 0) + srcOffset;
229 offset_t DstOffset = dstOffset + (y * Pitch.x) + (z * Pitch.y);
230
231 const uint4 c = read_imageui(input, srcCoord);
232
233 dst[(DstOffset >> 4) + x] = c;
234 }
235 )==="