1- // RUN: %dxc -spirv -HV 202x -Od -T cs_6_9 %s | FileCheck %s
1+ // RUN: %dxc -spirv -HV 202x -Od -T cs_6_9 %s | FileCheck %s --check-prefix=CHECK --check-prefix=NOFUN
2+ // RUN: %dxc -spirv -HV 202x -Od -T cs_6_9 -DFUN %s | FileCheck %s --check-prefix=CHECK --check-prefix=FUN
23
34// Issue #7302: implicit object argument of Get() evaluates to rvalue
45
@@ -20,16 +21,45 @@ struct Content
2021// CHECK: [[V2UINT:%[_0-9A-Za-z]*]] = OpTypeVector [[UINT]] 2
2122// CHECK: [[VECTOR:%[_0-9A-Za-z]*]] = OpConstantComposite [[V2UINT]] [[UDEADBEEF]] [[U0]]
2223// CHECK: [[CONTENT:%[_0-9A-Za-z]*]] = OpTypeStruct [[INT]]
23- // CHECK: [[PPCONTENT:%[_0-9A-Za-z]*]] = OpTypePointer PhysicalStorageBuffer [[CONTENT]]
24- // CHECK: [[PPINT:%[_0-9A-Za-z]*]] = OpTypePointer PhysicalStorageBuffer [[INT]]
24+ // FUN: [[PFCONTENT:%[_0-9A-Za-z]*]] = OpTypePointer Function [[CONTENT]]
25+ // FUN: [[PFINT:%[_0-9A-Za-z]*]] = OpTypePointer Function [[INT]]
26+ // FUN: [[CONTENT0:%[_0-9A-Za-z]*]] = OpTypeStruct [[INT]]
27+ // FUN: [[PPCONTENT:%[_0-9A-Za-z]*]] = OpTypePointer PhysicalStorageBuffer [[CONTENT0]]
28+ // NOFUN: [[PPCONTENT:%[_0-9A-Za-z]*]] = OpTypePointer PhysicalStorageBuffer [[CONTENT]]
29+ // NOFUN: [[PPINT:%[_0-9A-Za-z]*]] = OpTypePointer PhysicalStorageBuffer [[INT]]
30+
31+ Content f () {
32+ return bitcast<vk::BufferPointer<Content> >(uint32_t2 (0xdeadbeefu,0x0u)).Get ();
33+ }
2534
2635[numthreads (1 , 1 , 1 )]
2736void main ()
2837{
38+ #ifdef FUN
39+ Content c = f ();
40+ c.a = 1 ;
41+ #else
2942 bitcast<vk::BufferPointer<Content> >(uint32_t2 (0xdeadbeefu,0x0u)).Get ().a = 1 ;
43+ #endif
3044}
3145
32- // CHECK: [[BITCAST:%[0-9]*]] = OpBitcast [[PPCONTENT]] [[VECTOR]]
33- // CHECK: [[PTR:%[0-9]*]] = OpAccessChain [[PPINT]] [[BITCAST]] [[IO]]
34- // CHECK: OpStore [[PTR]] [[I1]] Aligned 4
46+ // NOFUN: [[BITCAST:%[0-9]*]] = OpBitcast [[PPCONTENT]] [[VECTOR]]
47+ // NOFUN: [[PTR:%[0-9]*]] = OpAccessChain [[PPINT]] [[BITCAST]] [[IO]]
48+ // NOFUN: OpStore [[PTR]] [[I1]] Aligned 4
49+
50+ // FUN: [[VAR:%[_0-9A-Za-z]*]] = OpVariable [[PFCONTENT]] Function
51+ // FUN: [[CALL:%[0-9]*]] = OpFunctionCall [[CONTENT]] [[F:%[_0-9A-Za-z]*]]
52+ // FUN: OpStore [[VAR]] [[CALL]]
53+ // FUN: [[PTR:%[0-9]*]] = OpAccessChain [[PFINT]] [[VAR]] [[IO]]
54+ // FUN: OpStore [[PTR]] [[I1]]
55+
56+ // FUN: [[F]] = OpFunction [[CONTENT]]
57+ // FUN: [[VAR:%[_0-9A-Za-z]*]] = OpVariable [[PFCONTENT]] Function
58+ // FUN: [[BITCAST:%[0-9]*]] = OpBitcast [[PPCONTENT]] [[VECTOR]]
59+ // FUN: [[CVAL0:%[0-9]*]] = OpLoad [[CONTENT0]] [[BITCAST]] Aligned 4
60+ // FUN: [[IVAL:%[0-9]*]] = OpCompositeExtract [[INT]] [[CVAL0]] 0
61+ // FUN: [[CVAL1:%[0-9]*]] = OpCompositeConstruct [[CONTENT]] [[IVAL]]
62+ // FUN: OpStore [[VAR]] [[CVAL1]]
63+ // FUN: [[RET:%[0-9]*]] = OpLoad [[CONTENT]] [[VAR]]
64+ // FUN: OpReturnValue [[RET]]
3565
0 commit comments