-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathreport.html
628 lines (574 loc) · 17.7 KB
/
report.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=500">
<meta charset="utf-8">
<title>blink.js report</title>
<link href="https://fonts.googleapis.com/css?family=Overpass:300,400,700,800" rel="stylesheet">
<style>
body {padding:0; margin:0; font-family:-apple-system, 'Overpass', sans-serif; background:rgb(61,58,47);}
wrapper {display:block; position:relative; width:476px; margin:auto;}
#blinkno, #blinkyes {display:none;}
block {display:block; position:relative; background:white; margin:10px; box-shadow:0 3px 7px rgba(0,0,0,.3);}
block h2 {display:block; background:rgb(255,199,59); padding:14px 22px; font-weight:700; color:rgb(61,58,47); font-size:16px; margin:0;}
block content, block legend {display:block; position:relative; padding:18px 22px;}
block content group {display:block; position:relative; font-weight:800; text-transform:uppercase; font-size:12px; padding:16px 0; color:rgb(51,51,52); margin:3px 20px 3px 0;}
block content group:last-of-type{margin-right:0;}
block content group::before {display:block; content:''; position:absolute; left:0; top:0; width:50px; height:2px; background:rgb(80,201,189);}
block content group span {display:block; font-weight:normal; font-size:15px; text-transform:none; color:rgb(102,102,102); padding-top:4px;}
block content group.big span {font-size:28px; font-weight:300;}
block content flex {display:flex; align-items:space-around;}
block content flex.two group {width:50%;}
block content flex.three group {width:33%;}
#score {display:none; font-size:24px;}
table {position:relative; border-spacing:0; width:100%;}
table * {color:rgb(55,55,55); font-size:15px;}
table th:first-of-type,
table td:first-of-type {width:25%; padding-left:22px; font-weight:700;}
table th:not(:first-of-type),
table td:not(:first-of-type) {width:25%;}
table td:not(:first-of-type) {cursor:pointer; text-align:center;}
table th:nth-of-type(even),
table td:nth-of-type(even),
table tbody tr:hover {background-color:rgba(0,0,0,.02);}
table tr td, table tbody tr {transition:background-color 200ms;}
table th {height:58px;}
table td {height:50px;}
legend {color:rgb(136,135,134); font-size:13px;}
legend p {margin:0; padding:12px 0 12px 40px;}
legend p, table tr td {background-repeat:no-repeat;}
legend p {background-position:0 9px; background-size:20px 20px;}
table tr td {background-position:50% 50%; background-size:24px 24px;}
legend p.success, td.success {background-image:url('icons.svg#check-color');}
td.success.selected {background-image:url('icons.svg#check-white'); background-color:rgb(0,204,78);}
legend p.warning, td.warning {background-image:url('icons.svg#warning-color');}
td.warning.selected {background-image:url('icons.svg#warning-white'); background-color:rgb(252,151,0);}
legend p.failed, td.failed {background-image:url('icons.svg#bad-color');}
td.failed.selected {background-image:url('icons.svg#bad-white'); background-color:rgb(219,58,44);}
table tr td.success:hover:not(.selected) {background-color:rgba(0,204,78,0.1);}
table tr td.warning:hover:not(.selected) {background-color:rgba(252,151,0,0.1);}
table tr td.failed:hover:not(.selected) {background-color:rgba(219,58,44,0.1);}
detailsbox {display:none; position:absolute; background:white; box-shadow:0 2px 10px rgba(0,0,0,.3); border-radius:4px; width:calc(100% - 10px); left:5px; box-sizing:border-box; padding:16px 26px; border:2px solid;}
detailsbox.show {display:block;}
detailsbox.success {border-color:rgb(0,204,78);}
detailsbox.warning {border-color:rgb(252,151,0);}
detailsbox.failed {border-color:rgb(219,58,44);}
detailsbox.warning span.diff {color:rgb(252,151,0);}
detailsbox.failed span.diff {color:rgb(219,58,44);}
detailsbox group {display:block; padding:5px 0;}
detailsbox group h3 {position:relative; margin:0; font-size:15px; padding:5px 0; color:rgb(51,51,51);}
detailsbox code {display:block; background-color:rgba(0,0,0,.05); padding:14px 18px; border-radius:1px; overflow:auto; white-space:nowrap;}
detailsbox code, #expectedarray,
#readarray {font-family:monospace; font-size:14px; color:rgb(102,102,102); line-height:22px;}
.times {float:right; font-weight:normal; font-size:12px; color:rgb(153,153,153);}
.times span {font-weight:700;}
</style>
<script src="../dist/blink.js"></script>
</head>
<body>
<wrapper>
<div id="blinkno">
<block>
<content>
This browser does not support <span>blink.js</span>.
</content>
</block>
</div>
<div id="blinkyes">
<block>
<content>blink.js <span id="version"></span></content>
</block>
<block id="device">
<h2>Device</h2>
<content>
<group id="glslversion">
GLSL Version
<span></span>
</group>
<flex class="three">
<group id="maxcolorattachments" class="big">
Max color<br>attachments
<span></span>
</group>
<group id="maxtextureunits" class="big">
Max texture<br>units
<span></span>
</group>
<group id="maxtexturesize" class="big">
Max texture<br>size
<span></span>
</group>
</flex>
<flex class="two">
<group id="renderer">
Renderer
<span></span>
</group>
<group id="vendor">
Vendor
<span></span>
</group>
</flex>
<flex class="two">
<group id="unmaskedrenderer">
Unmasked renderer
<span></span>
</group>
<group id="unmaskedvendor">
Unmasked vendor
<span></span>
</group>
</flex>
</content>
</block>
<block id="types">
<h2>Type support <div id="score">0 / 42</div></h2>
<table>
<thead>
<tr>
<th></th>
<th>Vector 1</th>
<th>Vector 2</th>
<th>Vector 4</th>
</tr>
</thead>
<tbody>
<tr>
<td>float</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>int32</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>int16</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>int8</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>uint32</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>uint16</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>uint8</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<content>
<div id="totaltime" class="times">Total time: <span></span>ms</div>
</content>
<legend>
<p class="success">Everything checks out.</p>
<p class="warning">Though the browser can read from this type + vector size combination, the returned values differ from the expected values.</p>
<p class="failed">Not supported at all.</p>
</legend>
<detailsbox>
<group>
<h3>
Kernel
<div class="times">Compiled: <span id="compiletime">0.00</span>ms   Exec: <span id="exectime">0.00</span>ms</div>
</h3>
<code id="kernelcode"></code>
</group>
<group>
<h3>Expected</h3>
<span id="expectedarray"></span>
</group>
<group>
<h3>Read</h3>
<span id="readarray"></span>
</group>
</detailsbox>
</block>
</div>
</wrapper>
</body>
<script>
(() => {
if (!window.blink || !blink.context) {
document.getElementById('blinkno').style.display = 'block'
return
}
document.getElementById('blinkyes').style.display = 'block'
const time = (val) => Math.round(val * 100000) / 100000
const code2html = (src) => src.trim().split('\n').join('<br>')
const classNames = ['failed', 'warning', 'success']
// DOM elements
const table = document.body.querySelector('#blinkyes table')
const details = document.body.querySelector('detailsbox')
/**
* Display the `device` constants.
*/
readDevice()
/**
* All the tests being performed. Grouped per primitive.
* A group's first test is done with a vector size of 1.
* Second with a size of 2. Third with a size of 4.
*/
let tests = [
// Float
{
type: blink.FLOAT,
tests: [
{
kernel: `
void main() {
out_buffer = float(bl_Id()) + 0.12345;
}
`,
expected: new Float32Array([0.12345, 1.12345, 2.12345, 3.12345])
},
{
kernel: `
void main() {
float id = float(bl_Id());
out_buffer = vec2(id + 0.12345, id + 0.56789);
}
`,
expected: new Float32Array([0.12345, 0.56789, 1 + 0.12345, 1 + 0.56789])
},
{
kernel: `
void main() {
float id = float(bl_Id());
out_buffer = vec4(id + -0.12345, id + 0.12345, id + -0.56789, id + 0.56789);
}
`,
expected: new Float32Array([-0.12345, 0.12345, -0.56789, 0.56789])
}
]
},
// Int 32
{
type: blink.INT32,
tests: [
{
kernel: `
void main() {
out_buffer = 255 << 16;
}
`,
expected: new Int32Array([255 << 16, 255 << 16, 255 << 16, 255 << 16])
},
{
kernel: `
void main() {
out_buffer = ivec2(16800, 255 << 16);
}
`,
expected: new Int32Array([16800, 255 << 16, 16800, 255 << 16])
},
{
kernel: `
void main() {
out_buffer = ivec4(1, 8900, 48631, 255 << 16);
}
`,
expected: new Int32Array([1, 8900, 48631, 255 << 16])
}
]
},
// Int 16
{
type: blink.INT16,
tests: [
{
kernel: `
void main() {
out_buffer = 1500 << 5;
}
`,
expected: new Int16Array([32767, 32767, 32767, 32767])
},
{
kernel: `
void main() {
out_buffer = ivec2(-16800, 255 << 2);
}
`,
expected: new Int16Array([-16800, 255 << 2, -16800, 255 << 2])
},
{
kernel: `
void main() {
out_buffer = ivec4(1, 8900, 48631, 255 << 8);
}
`,
expected: new Int16Array([1, 8900, 32767, 32767])
}
]
},
// Int 8
{
type: blink.INT8,
tests: [
{
kernel: `
void main() {
out_buffer = 4 << 1;
}
`,
expected: new Int8Array([4 << 1, 4 << 1, 4 << 1, 4 << 1])
},
{
kernel: `
void main() {
out_buffer = ivec2(200, 4 << 1);
}
`,
expected: new Int8Array([127, 4 << 1, 127, 4 << 1])
},
{
kernel: `
void main() {
out_buffer = ivec4(0, -100, 200, 4 << 1);
}
`,
expected: new Int8Array([0, -100, 127, 4 << 1])
}
]
},
// Uint 32
{
type: blink.UINT32,
tests: [
{
kernel: `
void main() {
out_buffer = 255u << 16u;
}
`,
expected: new Uint32Array([255 << 16, 255 << 16, 255 << 16, 255 << 16])
},
{
kernel: `
void main() {
out_buffer = uvec2(16800u, 255u << 16u);
}
`,
expected: new Uint32Array([16800, 255 << 16, 16800, 255 << 16])
},
{
kernel: `
void main() {
out_buffer = uvec4(1u, 8900u, 48631u, 255u << 16u);
}
`,
expected: new Uint32Array([1, 8900, 48631, 255 << 16])
}
]
},
// Uint 16
{
type: blink.UINT16,
tests: [
{
kernel: `
void main() {
out_buffer = 1500u << 5u;
}
`,
expected: new Uint16Array([1500 << 5, 1500 << 5, 1500 << 5, 1500 << 5])
},
{
kernel: `
void main() {
out_buffer = uvec2(16800u, 255u << 2u);
}
`,
expected: new Uint16Array([16800, 255 << 2, 16800, 255 << 2])
},
{
kernel: `
void main() {
out_buffer = uvec4(1u, 8900u, 48631u, 255u << 8u);
}
`,
expected: new Uint16Array([1, 8900, 48631, 255 << 8])
}
]
},
// Uint 8
{
type: blink.UINT8,
tests: [
{
kernel: `
void main() {
out_buffer = 4u << 1u;
}
`,
expected: new Uint8Array([4 << 1, 4 << 1, 4 << 1, 4 << 1])
},
{
kernel: `
void main() {
out_buffer = uvec2(200, 4 << 1);
}
`,
expected: new Uint8Array([200, 4 << 1, 200, 4 << 1])
},
{
kernel: `
void main() {
out_buffer = uvec4(0, 100, 200, 4 << 1);
}
`,
expected: new Uint8Array([0, 100, 200, 4 << 1])
}
]
}
]
// Perform the tests.
performTests()
const cells = document.body.querySelectorAll('#blinkyes table tr td:not(:first-of-type)')
for (const [index, cell] of cells.entries()) {
cell.addEventListener('click', function () {
const className = 'selected'
let selectedCells = table.querySelectorAll('.' + className)
for (let a = 0; a < selectedCells.length; a++) {
if (selectedCells[a] !== this) {
selectedCells[a].classList.remove(className)
}
}
this.classList.toggle(className)
if (this.classList.contains(className)) {
showDetailsbox(this)
}
else {
hideDetailsbox()
}
})
}
//
function readDevice() {
const { device, VERSION } = blink
document.getElementById('version').textContent = 'v' + VERSION
const map = {
glslversion: device.glslVersion,
maxcolorattachments: device.maxColorAttachments,
maxtextureunits: device.maxTextureUnits,
maxtexturesize: device.maxTextureSize,
renderer: device.renderer,
vendor: device.vendor,
unmaskedrenderer: device.unmaskedRenderer,
unmaskedvendor: device.unmaskedVendor,
}
for (const [key, value] of Object.entries(map)) {
document.body.querySelector(`#${key} span`).textContent = value || 'N/A'
}
}
function performTests() {
let score = 0
let totalTime = 0
for (const [gId, group] of tests.entries()) {
const row = table.querySelector(`tbody tr:nth-of-type(${gId + 1})`)
const { type, tests } = group
for (const [tId, test] of tests.entries()) {
const cell = row.querySelector(`td:nth-of-type(${tId + 2})`)
const vector = [1, 2, 4][tId]
let buffer = new blink.Buffer({
alloc: 64 * 64 * 4, // At most 64kb.
vector, type
})
//
let then = performance.now()
let kernel = new blink.Kernel({
output: {
out_buffer: buffer
}
}, test.kernel)
test.compileTime = performance.now() - then
//
then = performance.now()
kernel.exec()
test.execTime = performance.now() - then
//
test.read = buffer.data.subarray(0, 4)
let { expected } = test
// Compare.
// If `passed` remains 2, everything is A-OK.
// If `passed` is 1, there appears to be some inaccuracy in the values.
// If `passed` is 0, the type + vector combo isn't supported at all.
let passed = 2
for (let a = 0; a < 4; a++) {
if (test.read[a] != expected[a]) {
passed = 0
break
}
}
// Check if the sum of the array isn't 0. If it is, it means the
// type isn't supported.
if (passed === 0) {
const sum = test.read.reduce((prev, val) => prev + val, 0)
if (sum !== 0) {
passed = 1
}
}
test.passed = passed
cell.classList.add(classNames[passed])
cell.test = test
// Clean up.
kernel.delete()
buffer.delete()
score += passed
totalTime += test.compileTime + test.execTime
}
}
document.body.querySelector('#totaltime span').textContent = time(totalTime)
}
function showDetailsbox(cell) {
const { test } = cell
classNames.forEach((name, i) => {
i == test.passed ? details.classList.add(name) : details.classList.remove(name)
})
details.classList.add('show')
// Kernel.
details.querySelector('code').innerHTML = code2html(test.kernel)
details.querySelector('#compiletime').textContent = time(test.compileTime)
details.querySelector('#exectime').textContent = time(test.execTime)
// Expected array.
const expected = '[' + test.expected.join(', ') + ']'
details.querySelector('#expectedarray').textContent = expected
// Read array. Highlight the differences.
details.querySelector('#readarray').innerHTML = (() => {
let spans = [...test.read]
for (let a = 0; a < spans.length; a++) {
const difference = Math.abs(test.read[a] - test.expected[a])
if (difference > 0) {
spans[a] = `<span class="diff" title="Difference: ${difference}">${spans[a]}</span>`
}
}
return '[' + spans.join(', ') + ']'
})()
details.style.top = (cell.offsetTop + cell.offsetHeight + 46) + 'px'
}
function hideDetailsbox() {
details.classList.remove('show')
}
})()
</script>
</html>