2
2
// RUN: %HOST_RUN_PLACEHOLDER %t.out %HOST_CHECK_PLACEHOLDER
3
3
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
4
4
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
5
- // XFAIL: gpu && (level_zero || opencl || cuda)
6
- // XFAIL: cpu
7
5
8
- // GPU does not correctly interpolate when using clamp. Waiting on fix.
9
- // Both OCL and LevelZero have this issue.
10
- // CPU failing all linear interpolation at moment. Waiting on fix.
11
- // CUDA fails all linear interpolation. Waiting on fix.
6
+ // UNSUPPORTED: level_zero && windows
7
+ // XFAIL: cuda
8
+
9
+ // LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
10
+
11
+ // CUDA works with image_channel_type::fp32, but not with any 8-bit per channel
12
+ // type (such as unorm_int8)
12
13
13
14
/*
14
15
This file sets up an image, initializes it with data,
23
24
using namespace cl ::sycl;
24
25
25
26
// pixel data-type for RGBA operations (which is the minimum image type)
26
- using pixelT = sycl::uint4 ;
27
+ using pixelT = sycl::float4 ;
27
28
28
29
// will output a pixel as {r,g,b,a}. provide override if a different pixelT is
29
30
// defined.
30
- void outputPixel (sycl::uint4 somePixel) {
31
+ void outputPixel (sycl::float4 somePixel) {
31
32
std::cout << " {" << somePixel[0 ] << " ," << somePixel[1 ] << " ," << somePixel[2 ]
32
33
<< " ," << somePixel[3 ] << " } " ;
33
34
}
@@ -47,10 +48,12 @@ void test_normalized_clamp_linear_sampler(image_channel_order ChanOrder,
47
48
48
49
// we'll use these four pixels for our image. Makes it easy to measure
49
50
// interpolation and spot "off-by-one" probs.
50
- pixelT leftEdge{1 , 2 , 3 , 4 };
51
- pixelT body{49 , 48 , 47 , 46 };
52
- pixelT bony{59 , 58 , 57 , 56 };
53
- pixelT rightEdge{11 , 12 , 13 , 14 };
51
+ // These values will work consistently with different levels of float
52
+ // precision (like unorm_int8 vs. fp32)
53
+ pixelT leftEdge{0 .2f , 0 .4f , 0 .6f , 0 .8f };
54
+ pixelT body{0 .6f , 0 .4f , 0 .2f , 0 .0f };
55
+ pixelT bony{0 .2f , 0 .4f , 0 .6f , 0 .8f };
56
+ pixelT rightEdge{0 .6f , 0 .4f , 0 .2f , 0 .0f };
54
57
55
58
queue Q;
56
59
const sycl::range<1 > ImgRange_1D (width);
@@ -96,31 +99,32 @@ void test_normalized_clamp_linear_sampler(image_channel_order ChanOrder,
96
99
image_acc.read (-0 .25f , Norm_Clamp_Linear_sampler); // {0,0,0,0}
97
100
test_acc[i++] = image_acc.read (
98
101
0 .00f ,
99
- Norm_Clamp_Linear_sampler); // {0,1,2,2} // interpolating with bg
100
- // color. consistent with unnormalized.
101
- // Doesn't seem 100% correct to me, but
102
- // don't ahve anything to compare
103
- // against presnetly
104
- test_acc[i++] =
105
- image_acc.read (0 .25f , Norm_Clamp_Linear_sampler); // {25,25,25,25}
106
- test_acc[i++] =
107
- image_acc.read (0 .50f , Norm_Clamp_Linear_sampler); // {54,53,52,51}
108
- test_acc[i++] =
109
- image_acc.read (0 .75f , Norm_Clamp_Linear_sampler); // {35,35,35,35}
102
+ Norm_Clamp_Linear_sampler); // {0.1,0.2,0.3,0.4} // interpolating
103
+ // with bg color. consistent with
104
+ // unnormalized. Doesn't seem 100%
105
+ // correct to me, but don't ahve
106
+ // anything to compare against presnetly
110
107
test_acc[i++] = image_acc.read (
111
- 1 .00f ,
112
- Norm_Clamp_Linear_sampler); // {6,6,6,7} // interpolating with bg
108
+ 0 .25f , Norm_Clamp_Linear_sampler); // {0.4,0.4,0.4,0.4}
109
+ test_acc[i++] = image_acc.read (
110
+ 0 .50f , Norm_Clamp_Linear_sampler); // {0.4,0.4,0.4,0.4}
111
+ test_acc[i++] = image_acc.read (
112
+ 0 .75f , Norm_Clamp_Linear_sampler); // {0.4,0.4,0.4,0.4}
113
+ test_acc[i++] =
114
+ image_acc.read (1 .00f ,
115
+ Norm_Clamp_Linear_sampler); // {0.3,0.2,0.1,0} //
116
+ // interpolating with bg
113
117
test_acc[i++] =
114
118
image_acc.read (1 .25f , Norm_Clamp_Linear_sampler); // {0,0,0,0}
115
119
116
120
// 7-8 read two pixels on either side of first pixel. float coordinates.
117
121
// CLAMP
118
122
// on GPU CLAMP is apparently stopping the interpolation. ( values on
119
123
// right are expected value)
120
- test_acc[i++] =
121
- image_acc. read ( 0 . 2499f , Norm_Clamp_Linear_sampler); // {25,25,25,25 }
122
- test_acc[i++] =
123
- image_acc. read ( 0 . 2501f , Norm_Clamp_Linear_sampler); // {25,25,25,25 }
124
+ test_acc[i++] = image_acc. read (
125
+ 0 . 2499999f , Norm_Clamp_Linear_sampler); // {0.4,0.4,0.4,0.4 }
126
+ test_acc[i++] = image_acc. read (
127
+ 0 . 2500001f , Norm_Clamp_Linear_sampler); // {0.4,0.4,0.4,0.4 }
124
128
});
125
129
});
126
130
E_Test.wait ();
@@ -130,9 +134,10 @@ void test_normalized_clamp_linear_sampler(image_channel_order ChanOrder,
130
134
for (int i = 0 , idx = 0 ; i < numTests; i++, idx++) {
131
135
if (i == 0 ) {
132
136
idx = -1 ;
133
- std::cout << " read six pixels at 'boundary' locations, starting out of "
134
- " bounds, sample: Normalized + Clamp + Linear"
135
- << std::endl;
137
+ std::cout
138
+ << " read seven pixels at 'boundary' locations, starting out of "
139
+ " bounds, sample: Normalized + Clamp + Linear"
140
+ << std::endl;
136
141
}
137
142
if (i == 7 ) {
138
143
idx = 1 ;
@@ -161,10 +166,14 @@ int main() {
161
166
// RGBA) the _int16/fp16 channels are two bytes per channel, or eight bytes
162
167
// per pixel (for RGBA) the _int32/fp32 channels are four bytes per
163
168
// channel, or sixteen bytes per pixel (for RGBA).
164
- // CUDA has limited support for image_channel_type, so the tests use
165
- // unsigned_int32
169
+
170
+ std::cout << " fp32 ------------- " << std::endl;
166
171
test_normalized_clamp_linear_sampler (image_channel_order::rgba,
167
- image_channel_type::unsigned_int32);
172
+ image_channel_type::fp32);
173
+
174
+ std::cout << " unorm_int8 -------" << std::endl;
175
+ test_normalized_clamp_linear_sampler (image_channel_order::rgba,
176
+ image_channel_type::unorm_int8);
168
177
} else {
169
178
std::cout << " device does not support image operations" << std::endl;
170
179
}
@@ -173,15 +182,28 @@ int main() {
173
182
}
174
183
175
184
// clang-format off
176
- // CHECK: read six pixels at 'boundary' locations, starting out of bounds, sample: Normalized + Clamp + Linear
185
+ // CHECK: fp32 -------------
186
+ // CHECK-NEXT: read seven pixels at 'boundary' locations, starting out of bounds, sample: Normalized + Clamp + Linear
187
+ // CHECK-NEXT: 0 -- -1: {0,0,0,0}
188
+ // CHECK-NEXT: 1 -- 0: {0.1,0.2,0.3,0.4}
189
+ // CHECK-NEXT: 2 -- 1: {0.4,0.4,0.4,0.4}
190
+ // CHECK-NEXT: 3 -- 2: {0.4,0.4,0.4,0.4}
191
+ // CHECK-NEXT: 4 -- 3: {0.4,0.4,0.4,0.4}
192
+ // CHECK-NEXT: 5 -- 4: {0.3,0.2,0.1,0}
193
+ // CHECK-NEXT: 6 -- 5: {0,0,0,0}
194
+ // CHECK-NEXT: read two pixels on either side of first pixel. float coordinates. Normalized + Clamp + Linear
195
+ // CHECK-NEXT: 7 -- 1: {0.4,0.4,0.4,0.4}
196
+ // CHECK-NEXT: 8 -- 1: {0.4,0.4,0.4,0.4}
197
+ // CHECK-NEXT: unorm_int8 -------
198
+ // CHECK-NEXT: read seven pixels at 'boundary' locations, starting out of bounds, sample: Normalized + Clamp + Linear
177
199
// CHECK-NEXT: 0 -- -1: {0,0,0,0}
178
- // CHECK-NEXT: 1 -- 0: {0,1,2,2 }
179
- // CHECK-NEXT: 2 -- 1: {25,25,25,25 }
180
- // CHECK-NEXT: 3 -- 2: {54,53,52,51 }
181
- // CHECK-NEXT: 4 -- 3: {35,35,35,35 }
182
- // CHECK-NEXT: 5 -- 4: {6,6,6,7 }
200
+ // CHECK-NEXT: 1 -- 0: {0.1,0.2,0.3,0.4 }
201
+ // CHECK-NEXT: 2 -- 1: {0.4,0.4,0.4,0.4 }
202
+ // CHECK-NEXT: 3 -- 2: {0.4,0.4,0.4,0.4 }
203
+ // CHECK-NEXT: 4 -- 3: {0.4,0.4,0.4,0.4 }
204
+ // CHECK-NEXT: 5 -- 4: {0.3,0.2,0.1,0 }
183
205
// CHECK-NEXT: 6 -- 5: {0,0,0,0}
184
206
// CHECK-NEXT: read two pixels on either side of first pixel. float coordinates. Normalized + Clamp + Linear
185
- // CHECK-NEXT: 7 -- 1: {25,25,25,25 }
186
- // CHECK-NEXT: 8 -- 1: {25,25,25,25 }
207
+ // CHECK-NEXT: 7 -- 1: {0.4,0.4,0.4,0.4 }
208
+ // CHECK-NEXT: 8 -- 1: {0.4,0.4,0.4,0.4 }
187
209
// clang-format on
0 commit comments