123 lines · plain
1// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library -fnative-half-type -verify %s2 3// expected-warning@+1{{cannot mix packoffset elements with nonpackoffset elements in a cbuffer}}4cbuffer Mix5{6 float4 M1 : packoffset(c0);7 float M2;8 float M3 : packoffset(c1.y);9}10 11// expected-warning@+1{{cannot mix packoffset elements with nonpackoffset elements in a cbuffer}}12cbuffer Mix213{14 float4 M4;15 float M5 : packoffset(c1.y);16 float M6 ;17}18 19// expected-error@+1{{attribute 'packoffset' only applies to shader constant in a constant buffer}}20float4 g : packoffset(c0);21 22cbuffer IllegalOffset23{24 // expected-error@+1{{invalid resource class specifier 't2' for packoffset, expected 'c'}}25 float4 i1 : packoffset(t2);26 // expected-error@+1{{invalid component 'm' used; expected 'x', 'y', 'z', or 'w'}}27 float i2 : packoffset(c1.m);28}29 30cbuffer Overlap31{32 float4 o1 : packoffset(c0);33 // expected-error@+1{{packoffset overlap between 'o2', 'o1'}}34 float2 o2 : packoffset(c0.z);35}36 37cbuffer CrossReg38{39 // expected-error@+1{{packoffset cannot cross register boundary}}40 float4 c1 : packoffset(c0.y);41 // expected-error@+1{{packoffset cannot cross register boundary}}42 float2 c2 : packoffset(c1.w);43}44 45struct ST {46 float s;47};48 49cbuffer Aggregate50{51 // expected-error@+1{{packoffset cannot cross register boundary}}52 ST A1 : packoffset(c0.y);53 // expected-error@+1{{packoffset cannot cross register boundary}}54 float A2[2] : packoffset(c1.w);55}56 57cbuffer Double {58 // expected-error@+1{{packoffset at 'y' not match alignment 64 required by 'double'}}59 double d : packoffset(c.y);60 // expected-error@+1{{packoffset cannot cross register boundary}}61 double2 d2 : packoffset(c.z);62 // expected-error@+1{{packoffset cannot cross register boundary}}63 double3 d3 : packoffset(c.z);64}65 66cbuffer ParsingFail {67// expected-error@+1{{expected identifier}}68float pf0 : packoffset();69// expected-error@+1{{expected identifier}}70float pf1 : packoffset((c0));71// expected-error@+1{{expected ')'}}72float pf2 : packoffset(c0, x);73// expected-error@+1{{invalid component 'X' used}}74float pf3 : packoffset(c.X);75// expected-error@+1{{expected '(' after ''}}76float pf4 : packoffset;77// expected-error@+1{{expected identifier}}78float pf5 : packoffset(;79// expected-error@+1{{expected '(' after '}}80float pf6 : packoffset);81// expected-error@+1{{expected '(' after '}}82float pf7 : packoffset c0.x;83 84// expected-error@+1{{invalid component 'xy' used}}85float pf8 : packoffset(c0.xy);86// expected-error@+1{{invalid component 'rg' used}}87float pf9 : packoffset(c0.rg);88// expected-error@+1{{invalid component 'yes' used}}89float pf10 : packoffset(c0.yes);90// expected-error@+1{{invalid component 'woo'}}91float pf11 : packoffset(c0.woo);92// expected-error@+1{{invalid component 'xr' used}}93float pf12 : packoffset(c0.xr);94}95 96struct ST2 {97 float a;98 float2 b;99};100 101cbuffer S {102 float S0 : packoffset(c0.y);103 ST2 S1[2] : packoffset(c1);104 // expected-error@+1{{packoffset overlap between 'S2', 'S1'}}105 half2 S2 : packoffset(c1.w);106 half2 S3 : packoffset(c2.w);107}108 109struct ST23 {110 float s0;111 ST2 s1;112};113 114cbuffer S2 {115 float S20 : packoffset(c0.y);116 ST2 S21 : packoffset(c1);117 half2 S22 : packoffset(c2.w);118 double S23[2] : packoffset(c3);119 // expected-error@+1{{packoffset overlap between 'S24', 'S23'}}120 float S24 : packoffset(c3.z);121 float S25 : packoffset(c4.z);122}123