File: bitcast.wgsl

package info (click to toggle)
webkit2gtk 2.48.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 429,764 kB
  • sloc: cpp: 3,697,587; javascript: 194,444; ansic: 169,997; python: 46,499; asm: 19,295; ruby: 18,528; perl: 16,602; xml: 4,650; yacc: 2,360; sh: 2,098; java: 1,993; lex: 1,327; pascal: 366; makefile: 298
file content (52 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download | duplicates (8)
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
// RUN: %not %wgslc | %check

fn testWrongNumberOfArguments()
{
    // CHECK: bitcast expects a single argument, found 2
    _ = bitcast<i32>(0, 0);

    // CHECK: bitcast expects a single argument, found 0
    _ = bitcast<i32>();
}

fn testWrongNumberOfTemplateArguments()
{
    // CHECK: bitcast expects a single template argument, found 2
    _ = bitcast<i32, i32>(0);

    // CHECK: bitcast expects a single template argument, found 0
    _ = bitcast(0);
}

fn testInvalidConversion()
{
    // CHECK: cannot bitcast from 'i32' to 'vec2<i32>'
    _ = bitcast<vec2<i32>>(0);

    // CHECK: cannot bitcast from 'vec2<i32>' to 'i32'
    _ = bitcast<i32>(vec2(0));
}

fn testI32Overflow()
{
    // CHECK-L: value 4294967295 cannot be represented as 'i32'
    { const x: f32 = bitcast<f32>(4294967295); }
}

fn testFunctionAsValue()
{
    // CHECK-L: cannot use function 'testI32Overflow' as value
    { const x: f32 = bitcast<f32>(testI32Overflow); }
}

@group(0) @binding(1) var s: sampler;
@group(0) @binding(2) var t: texture_depth_2d;

fn testTypeCannotBeConcretized()
{
    // CHECK-L: cannot bitcast from 'sampler' to 'i32'
    let x = bitcast<i32>(s);

    // CHECK-L: cannot bitcast from 'texture_depth_2d' to 'i32'
    let x = bitcast<i32>(t);
}