File: packoffset-invalid.hlsl

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (122 lines) | stat: -rw-r--r-- 3,443 bytes parent folder | download | duplicates (7)
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
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library -fnative-half-type -verify %s

// expected-warning@+1{{cannot mix packoffset elements with nonpackoffset elements in a cbuffer}}
cbuffer Mix
{
    float4 M1 : packoffset(c0);
    float M2;
    float M3 : packoffset(c1.y);
}

// expected-warning@+1{{cannot mix packoffset elements with nonpackoffset elements in a cbuffer}}
cbuffer Mix2
{
    float4 M4;
    float M5 : packoffset(c1.y);
    float M6 ;
}

// expected-error@+1{{attribute 'packoffset' only applies to shader constant in a constant buffer}}
float4 g : packoffset(c0);

cbuffer IllegalOffset
{
    // expected-error@+1{{invalid resource class specifier 't2' for packoffset, expected 'c'}}
    float4 i1 : packoffset(t2);
    // expected-error@+1{{invalid component 'm' used; expected 'x', 'y', 'z', or 'w'}}
    float i2 : packoffset(c1.m);
}

cbuffer Overlap
{
    float4 o1 : packoffset(c0);
    // expected-error@+1{{packoffset overlap between 'o2', 'o1'}}
    float2 o2 : packoffset(c0.z);
}

cbuffer CrossReg
{
    // expected-error@+1{{packoffset cannot cross register boundary}}
    float4 c1 : packoffset(c0.y);
    // expected-error@+1{{packoffset cannot cross register boundary}}
    float2 c2 : packoffset(c1.w);
}

struct ST {
  float s;
};

cbuffer Aggregate
{
    // expected-error@+1{{packoffset cannot cross register boundary}}
    ST A1 : packoffset(c0.y);
    // expected-error@+1{{packoffset cannot cross register boundary}}
    float A2[2] : packoffset(c1.w);
}

cbuffer Double {
    // expected-error@+1{{packoffset at 'y' not match alignment 64 required by 'double'}}
    double d : packoffset(c.y);
    // expected-error@+1{{packoffset cannot cross register boundary}}
	double2 d2 : packoffset(c.z);
    // expected-error@+1{{packoffset cannot cross register boundary}}
	double3 d3 : packoffset(c.z);
}

cbuffer ParsingFail {
// expected-error@+1{{expected identifier}}
float pf0 : packoffset();
// expected-error@+1{{expected identifier}}
float pf1 : packoffset((c0));
// expected-error@+1{{expected ')'}}
float pf2 : packoffset(c0, x);
// expected-error@+1{{invalid component 'X' used}}
float pf3 : packoffset(c.X);
// expected-error@+1{{expected '(' after ''}}
float pf4 : packoffset;
// expected-error@+1{{expected identifier}}
float pf5 : packoffset(;
// expected-error@+1{{expected '(' after '}}
float pf6 : packoffset);
// expected-error@+1{{expected '(' after '}}
float pf7 : packoffset c0.x;

// expected-error@+1{{invalid component 'xy' used}}
float pf8 : packoffset(c0.xy);
// expected-error@+1{{invalid component 'rg' used}}
float pf9 : packoffset(c0.rg);
// expected-error@+1{{invalid component 'yes' used}}
float pf10 : packoffset(c0.yes);
// expected-error@+1{{invalid component 'woo'}}
float pf11 : packoffset(c0.woo);
// expected-error@+1{{invalid component 'xr' used}}
float pf12 : packoffset(c0.xr);
}

struct ST2 {
  float a;
  float2 b;
};

cbuffer S {
  float S0 : packoffset(c0.y);
  ST2 S1[2] : packoffset(c1);
  // expected-error@+1{{packoffset overlap between 'S2', 'S1'}}
  half2 S2 : packoffset(c1.w);
  half2 S3 : packoffset(c2.w);
}

struct ST23 {
  float s0;
  ST2 s1;
};

cbuffer S2 {
  float S20 : packoffset(c0.y);
  ST2 S21 : packoffset(c1);
  half2 S22 : packoffset(c2.w);
  double S23[2] : packoffset(c3);
  // expected-error@+1{{packoffset overlap between 'S24', 'S23'}}
  float S24 : packoffset(c3.z);
  float S25 : packoffset(c4.z);
}