inline_opaque_test.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. // Copyright (c) 2017 Valve Corporation
  2. // Copyright (c) 2017 LunarG Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #include <string>
  16. #include "test/opt/pass_fixture.h"
  17. #include "test/opt/pass_utils.h"
  18. namespace spvtools {
  19. namespace opt {
  20. namespace {
  21. using InlineOpaqueTest = PassTest<::testing::Test>;
  22. TEST_F(InlineOpaqueTest, InlineCallWithStructArgContainingSampledImage) {
  23. // Function with opaque argument is inlined.
  24. // TODO(greg-lunarg): Add HLSL code
  25. const std::string predefs_1 =
  26. R"(OpCapability Shader
  27. %1 = OpExtInstImport "GLSL.std.450"
  28. OpMemoryModel Logical GLSL450
  29. OpEntryPoint Fragment %main "main" %outColor %texCoords
  30. OpExecutionMode %main OriginUpperLeft
  31. OpSource GLSL 140
  32. OpName %main "main"
  33. OpName %S_t "S_t"
  34. OpMemberName %S_t 0 "v0"
  35. OpMemberName %S_t 1 "v1"
  36. OpMemberName %S_t 2 "smp"
  37. OpName %foo_struct_S_t_vf2_vf21_ "foo(struct-S_t-vf2-vf21;"
  38. OpName %s "s"
  39. OpName %outColor "outColor"
  40. OpName %sampler15 "sampler15"
  41. OpName %s0 "s0"
  42. OpName %texCoords "texCoords"
  43. OpName %param "param"
  44. )";
  45. const std::string name = R"(OpName %return_value "return_value"
  46. )";
  47. const std::string predefs_2 = R"(OpDecorate %sampler15 DescriptorSet 0
  48. %void = OpTypeVoid
  49. %13 = OpTypeFunction %void
  50. %float = OpTypeFloat 32
  51. %v2float = OpTypeVector %float 2
  52. %v4float = OpTypeVector %float 4
  53. %_ptr_Output_v4float = OpTypePointer Output %v4float
  54. %outColor = OpVariable %_ptr_Output_v4float Output
  55. %18 = OpTypeImage %float 2D 0 0 0 1 Unknown
  56. %19 = OpTypeSampledImage %18
  57. %S_t = OpTypeStruct %v2float %v2float %19
  58. %_ptr_Function_S_t = OpTypePointer Function %S_t
  59. %21 = OpTypeFunction %void %_ptr_Function_S_t
  60. %_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19
  61. %_ptr_Function_19 = OpTypePointer Function %19
  62. %sampler15 = OpVariable %_ptr_UniformConstant_19 UniformConstant
  63. %int = OpTypeInt 32 1
  64. %int_0 = OpConstant %int 0
  65. %int_2 = OpConstant %int 2
  66. %_ptr_Function_v2float = OpTypePointer Function %v2float
  67. %_ptr_Input_v2float = OpTypePointer Input %v2float
  68. %texCoords = OpVariable %_ptr_Input_v2float Input
  69. )";
  70. const std::string before =
  71. R"(%main = OpFunction %void None %13
  72. %29 = OpLabel
  73. %s0 = OpVariable %_ptr_Function_S_t Function
  74. %param = OpVariable %_ptr_Function_S_t Function
  75. %30 = OpLoad %v2float %texCoords
  76. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  77. OpStore %31 %30
  78. %32 = OpLoad %19 %sampler15
  79. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  80. OpStore %33 %32
  81. %34 = OpLoad %S_t %s0
  82. OpStore %param %34
  83. %return_value = OpFunctionCall %void %foo_struct_S_t_vf2_vf21_ %param
  84. OpReturn
  85. OpFunctionEnd
  86. )";
  87. const std::string after =
  88. R"(%main = OpFunction %void None %13
  89. %29 = OpLabel
  90. %s0 = OpVariable %_ptr_Function_S_t Function
  91. %param = OpVariable %_ptr_Function_S_t Function
  92. %30 = OpLoad %v2float %texCoords
  93. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  94. OpStore %31 %30
  95. %32 = OpLoad %19 %sampler15
  96. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  97. OpStore %33 %32
  98. %34 = OpLoad %S_t %s0
  99. OpStore %param %34
  100. %42 = OpAccessChain %_ptr_Function_19 %param %int_2
  101. %43 = OpLoad %19 %42
  102. %44 = OpAccessChain %_ptr_Function_v2float %param %int_0
  103. %45 = OpLoad %v2float %44
  104. %46 = OpImageSampleImplicitLod %v4float %43 %45
  105. OpStore %outColor %46
  106. OpReturn
  107. OpFunctionEnd
  108. )";
  109. const std::string post_defs =
  110. R"(%foo_struct_S_t_vf2_vf21_ = OpFunction %void None %21
  111. %s = OpFunctionParameter %_ptr_Function_S_t
  112. %35 = OpLabel
  113. %36 = OpAccessChain %_ptr_Function_19 %s %int_2
  114. %37 = OpLoad %19 %36
  115. %38 = OpAccessChain %_ptr_Function_v2float %s %int_0
  116. %39 = OpLoad %v2float %38
  117. %40 = OpImageSampleImplicitLod %v4float %37 %39
  118. OpStore %outColor %40
  119. OpReturn
  120. OpFunctionEnd
  121. )";
  122. SinglePassRunAndCheck<InlineOpaquePass>(
  123. predefs_1 + name + predefs_2 + before + post_defs,
  124. predefs_1 + predefs_2 + after + post_defs, true, true);
  125. }
  126. TEST_F(InlineOpaqueTest, InlineOpaqueReturn) {
  127. // Function with opaque return value is inlined.
  128. // TODO(greg-lunarg): Add HLSL code
  129. const std::string predefs =
  130. R"(OpCapability Shader
  131. %1 = OpExtInstImport "GLSL.std.450"
  132. OpMemoryModel Logical GLSL450
  133. OpEntryPoint Fragment %main "main" %texCoords %outColor
  134. OpExecutionMode %main OriginUpperLeft
  135. OpSource GLSL 140
  136. OpName %main "main"
  137. OpName %foo_ "foo("
  138. OpName %texCoords "texCoords"
  139. OpName %outColor "outColor"
  140. OpName %sampler15 "sampler15"
  141. OpName %sampler16 "sampler16"
  142. OpDecorate %sampler15 DescriptorSet 0
  143. OpDecorate %sampler16 DescriptorSet 0
  144. %void = OpTypeVoid
  145. %9 = OpTypeFunction %void
  146. %float = OpTypeFloat 32
  147. %v2float = OpTypeVector %float 2
  148. %bool = OpTypeBool
  149. %false = OpConstantFalse %bool
  150. %_ptr_Input_v2float = OpTypePointer Input %v2float
  151. %texCoords = OpVariable %_ptr_Input_v2float Input
  152. %float_0 = OpConstant %float 0
  153. %16 = OpConstantComposite %v2float %float_0 %float_0
  154. %v4float = OpTypeVector %float 4
  155. %_ptr_Output_v4float = OpTypePointer Output %v4float
  156. %outColor = OpVariable %_ptr_Output_v4float Output
  157. %19 = OpTypeImage %float 2D 0 0 0 1 Unknown
  158. %20 = OpTypeSampledImage %19
  159. %21 = OpTypeFunction %20
  160. %_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20
  161. %_ptr_Function_20 = OpTypePointer Function %20
  162. %sampler15 = OpVariable %_ptr_UniformConstant_20 UniformConstant
  163. %sampler16 = OpVariable %_ptr_UniformConstant_20 UniformConstant
  164. )";
  165. const std::string before =
  166. R"(%main = OpFunction %void None %9
  167. %24 = OpLabel
  168. %25 = OpVariable %_ptr_Function_20 Function
  169. %26 = OpFunctionCall %20 %foo_
  170. OpStore %25 %26
  171. %27 = OpLoad %20 %25
  172. %28 = OpLoad %v2float %texCoords
  173. %29 = OpImageSampleImplicitLod %v4float %27 %28
  174. OpStore %outColor %29
  175. OpReturn
  176. OpFunctionEnd
  177. )";
  178. const std::string after =
  179. R"(%main = OpFunction %void None %9
  180. %24 = OpLabel
  181. %34 = OpVariable %_ptr_Function_20 Function
  182. %35 = OpVariable %_ptr_Function_20 Function
  183. %25 = OpVariable %_ptr_Function_20 Function
  184. %37 = OpLoad %20 %sampler16
  185. OpStore %34 %37
  186. %38 = OpLoad %20 %34
  187. OpStore %35 %38
  188. %26 = OpLoad %20 %35
  189. OpStore %25 %26
  190. %27 = OpLoad %20 %25
  191. %28 = OpLoad %v2float %texCoords
  192. %29 = OpImageSampleImplicitLod %v4float %27 %28
  193. OpStore %outColor %29
  194. OpReturn
  195. OpFunctionEnd
  196. )";
  197. const std::string post_defs =
  198. R"(%foo_ = OpFunction %20 None %21
  199. %30 = OpLabel
  200. %31 = OpVariable %_ptr_Function_20 Function
  201. %32 = OpLoad %20 %sampler16
  202. OpStore %31 %32
  203. %33 = OpLoad %20 %31
  204. OpReturnValue %33
  205. OpFunctionEnd
  206. )";
  207. SinglePassRunAndCheck<InlineOpaquePass>(
  208. predefs + before + post_defs, predefs + after + post_defs, true, true);
  209. }
  210. TEST_F(InlineOpaqueTest, InlineOpaqueForLinkage) {
  211. const std::string predefs_1 =
  212. R"(OpCapability Shader
  213. OpCapability Linkage
  214. %1 = OpExtInstImport "GLSL.std.450"
  215. OpMemoryModel Logical GLSL450
  216. OpSource HLSL 630
  217. OpName %main "main"
  218. OpName %S_t "S_t"
  219. OpMemberName %S_t 0 "v0"
  220. OpMemberName %S_t 1 "v1"
  221. OpMemberName %S_t 2 "smp"
  222. OpName %foo_struct_S_t_vf2_vf21_ "foo(struct-S_t-vf2-vf21;"
  223. OpName %s "s"
  224. OpName %outColor "outColor"
  225. OpName %sampler15 "sampler15"
  226. OpName %s0 "s0"
  227. OpName %texCoords "texCoords"
  228. OpName %param "param"
  229. OpDecorate %main LinkageAttributes "main" Export
  230. )";
  231. const std::string name = R"(OpName %return_value "return_value"
  232. )";
  233. const std::string predefs_2 = R"(OpDecorate %sampler15 DescriptorSet 0
  234. %void = OpTypeVoid
  235. %13 = OpTypeFunction %void
  236. %float = OpTypeFloat 32
  237. %v2float = OpTypeVector %float 2
  238. %v4float = OpTypeVector %float 4
  239. %_ptr_Output_v4float = OpTypePointer Output %v4float
  240. %outColor = OpVariable %_ptr_Output_v4float Output
  241. %18 = OpTypeImage %float 2D 0 0 0 1 Unknown
  242. %19 = OpTypeSampledImage %18
  243. %S_t = OpTypeStruct %v2float %v2float %19
  244. %_ptr_Function_S_t = OpTypePointer Function %S_t
  245. %21 = OpTypeFunction %void %_ptr_Function_S_t
  246. %_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19
  247. %_ptr_Function_19 = OpTypePointer Function %19
  248. %sampler15 = OpVariable %_ptr_UniformConstant_19 UniformConstant
  249. %int = OpTypeInt 32 1
  250. %int_0 = OpConstant %int 0
  251. %int_2 = OpConstant %int 2
  252. %_ptr_Function_v2float = OpTypePointer Function %v2float
  253. %_ptr_Input_v2float = OpTypePointer Input %v2float
  254. %texCoords = OpVariable %_ptr_Input_v2float Input
  255. )";
  256. const std::string before =
  257. R"(%main = OpFunction %void None %13
  258. %29 = OpLabel
  259. %s0 = OpVariable %_ptr_Function_S_t Function
  260. %param = OpVariable %_ptr_Function_S_t Function
  261. %30 = OpLoad %v2float %texCoords
  262. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  263. OpStore %31 %30
  264. %32 = OpLoad %19 %sampler15
  265. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  266. OpStore %33 %32
  267. %34 = OpLoad %S_t %s0
  268. OpStore %param %34
  269. %return_value = OpFunctionCall %void %foo_struct_S_t_vf2_vf21_ %param
  270. OpReturn
  271. OpFunctionEnd
  272. )";
  273. const std::string after =
  274. R"(%main = OpFunction %void None %13
  275. %29 = OpLabel
  276. %s0 = OpVariable %_ptr_Function_S_t Function
  277. %param = OpVariable %_ptr_Function_S_t Function
  278. %30 = OpLoad %v2float %texCoords
  279. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  280. OpStore %31 %30
  281. %32 = OpLoad %19 %sampler15
  282. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  283. OpStore %33 %32
  284. %34 = OpLoad %S_t %s0
  285. OpStore %param %34
  286. %42 = OpAccessChain %_ptr_Function_19 %param %int_2
  287. %43 = OpLoad %19 %42
  288. %44 = OpAccessChain %_ptr_Function_v2float %param %int_0
  289. %45 = OpLoad %v2float %44
  290. %46 = OpImageSampleImplicitLod %v4float %43 %45
  291. OpStore %outColor %46
  292. OpReturn
  293. OpFunctionEnd
  294. )";
  295. const std::string post_defs =
  296. R"(%foo_struct_S_t_vf2_vf21_ = OpFunction %void None %21
  297. %s = OpFunctionParameter %_ptr_Function_S_t
  298. %35 = OpLabel
  299. %36 = OpAccessChain %_ptr_Function_19 %s %int_2
  300. %37 = OpLoad %19 %36
  301. %38 = OpAccessChain %_ptr_Function_v2float %s %int_0
  302. %39 = OpLoad %v2float %38
  303. %40 = OpImageSampleImplicitLod %v4float %37 %39
  304. OpStore %outColor %40
  305. OpReturn
  306. OpFunctionEnd
  307. )";
  308. SinglePassRunAndCheck<InlineOpaquePass>(
  309. predefs_1 + name + predefs_2 + before + post_defs,
  310. predefs_1 + predefs_2 + after + post_defs, true, true);
  311. }
  312. TEST_F(InlineOpaqueTest, InlineInNonEntryPointFunction) {
  313. // This demonstrates opaque inlining in a function that is not
  314. // an entry point function (main2) but is in the call tree of an
  315. // entry point function (main).
  316. // TODO(greg-lunarg): Add HLSL code
  317. const std::string predefs =
  318. R"(OpCapability Shader
  319. %1 = OpExtInstImport "GLSL.std.450"
  320. OpMemoryModel Logical GLSL450
  321. OpEntryPoint Fragment %main "main" %outColor %texCoords
  322. OpExecutionMode %main OriginUpperLeft
  323. OpSource GLSL 140
  324. OpName %main "main"
  325. OpName %main2 "main2"
  326. OpName %S_t "S_t"
  327. OpMemberName %S_t 0 "v0"
  328. OpMemberName %S_t 1 "v1"
  329. OpMemberName %S_t 2 "smp"
  330. OpName %foo_struct_S_t_vf2_vf21_ "foo(struct-S_t-vf2-vf21;"
  331. OpName %s "s"
  332. OpName %outColor "outColor"
  333. OpName %sampler15 "sampler15"
  334. OpName %s0 "s0"
  335. OpName %texCoords "texCoords"
  336. OpName %param "param"
  337. OpDecorate %sampler15 DescriptorSet 0
  338. %void = OpTypeVoid
  339. %13 = OpTypeFunction %void
  340. %float = OpTypeFloat 32
  341. %v2float = OpTypeVector %float 2
  342. %v4float = OpTypeVector %float 4
  343. %_ptr_Output_v4float = OpTypePointer Output %v4float
  344. %outColor = OpVariable %_ptr_Output_v4float Output
  345. %18 = OpTypeImage %float 2D 0 0 0 1 Unknown
  346. %19 = OpTypeSampledImage %18
  347. %S_t = OpTypeStruct %v2float %v2float %19
  348. %_ptr_Function_S_t = OpTypePointer Function %S_t
  349. %21 = OpTypeFunction %void %_ptr_Function_S_t
  350. %_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19
  351. %_ptr_Function_19 = OpTypePointer Function %19
  352. %sampler15 = OpVariable %_ptr_UniformConstant_19 UniformConstant
  353. %int = OpTypeInt 32 1
  354. %int_0 = OpConstant %int 0
  355. %int_2 = OpConstant %int 2
  356. %_ptr_Function_v2float = OpTypePointer Function %v2float
  357. %_ptr_Input_v2float = OpTypePointer Input %v2float
  358. %texCoords = OpVariable %_ptr_Input_v2float Input
  359. )";
  360. const std::string before =
  361. R"(%main2 = OpFunction %void None %13
  362. %29 = OpLabel
  363. %s0 = OpVariable %_ptr_Function_S_t Function
  364. %param = OpVariable %_ptr_Function_S_t Function
  365. %30 = OpLoad %v2float %texCoords
  366. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  367. OpStore %31 %30
  368. %32 = OpLoad %19 %sampler15
  369. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  370. OpStore %33 %32
  371. %34 = OpLoad %S_t %s0
  372. OpStore %param %34
  373. %35 = OpFunctionCall %void %foo_struct_S_t_vf2_vf21_ %param
  374. OpReturn
  375. OpFunctionEnd
  376. )";
  377. const std::string after =
  378. R"(%main2 = OpFunction %void None %13
  379. %29 = OpLabel
  380. %s0 = OpVariable %_ptr_Function_S_t Function
  381. %param = OpVariable %_ptr_Function_S_t Function
  382. %30 = OpLoad %v2float %texCoords
  383. %31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
  384. OpStore %31 %30
  385. %32 = OpLoad %19 %sampler15
  386. %33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
  387. OpStore %33 %32
  388. %34 = OpLoad %S_t %s0
  389. OpStore %param %34
  390. %45 = OpAccessChain %_ptr_Function_19 %param %int_2
  391. %46 = OpLoad %19 %45
  392. %47 = OpAccessChain %_ptr_Function_v2float %param %int_0
  393. %48 = OpLoad %v2float %47
  394. %49 = OpImageSampleImplicitLod %v4float %46 %48
  395. OpStore %outColor %49
  396. OpReturn
  397. OpFunctionEnd
  398. )";
  399. const std::string post_defs =
  400. R"(%main = OpFunction %void None %13
  401. %36 = OpLabel
  402. %37 = OpFunctionCall %void %main2
  403. OpReturn
  404. OpFunctionEnd
  405. %foo_struct_S_t_vf2_vf21_ = OpFunction %void None %21
  406. %s = OpFunctionParameter %_ptr_Function_S_t
  407. %38 = OpLabel
  408. %39 = OpAccessChain %_ptr_Function_19 %s %int_2
  409. %40 = OpLoad %19 %39
  410. %41 = OpAccessChain %_ptr_Function_v2float %s %int_0
  411. %42 = OpLoad %v2float %41
  412. %43 = OpImageSampleImplicitLod %v4float %40 %42
  413. OpStore %outColor %43
  414. OpReturn
  415. OpFunctionEnd
  416. )";
  417. SinglePassRunAndCheck<InlineOpaquePass>(
  418. predefs + before + post_defs, predefs + after + post_defs, true, true);
  419. }
  420. TEST_F(InlineOpaqueTest, NoInlineNoOpaque) {
  421. // Function without opaque interface is not inlined.
  422. // #version 140
  423. //
  424. // in vec4 BaseColor;
  425. //
  426. // float foo(vec4 bar)
  427. // {
  428. // return bar.x + bar.y;
  429. // }
  430. //
  431. // void main()
  432. // {
  433. // vec4 color = vec4(foo(BaseColor));
  434. // gl_FragColor = color;
  435. // }
  436. const std::string assembly =
  437. R"(OpCapability Shader
  438. %1 = OpExtInstImport "GLSL.std.450"
  439. OpMemoryModel Logical GLSL450
  440. OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor
  441. OpExecutionMode %main OriginUpperLeft
  442. OpSource GLSL 140
  443. OpName %main "main"
  444. OpName %foo_vf4_ "foo(vf4;"
  445. OpName %bar "bar"
  446. OpName %color "color"
  447. OpName %BaseColor "BaseColor"
  448. OpName %param "param"
  449. OpName %gl_FragColor "gl_FragColor"
  450. %void = OpTypeVoid
  451. %10 = OpTypeFunction %void
  452. %float = OpTypeFloat 32
  453. %v4float = OpTypeVector %float 4
  454. %_ptr_Function_v4float = OpTypePointer Function %v4float
  455. %14 = OpTypeFunction %float %_ptr_Function_v4float
  456. %uint = OpTypeInt 32 0
  457. %uint_0 = OpConstant %uint 0
  458. %_ptr_Function_float = OpTypePointer Function %float
  459. %uint_1 = OpConstant %uint 1
  460. %_ptr_Input_v4float = OpTypePointer Input %v4float
  461. %BaseColor = OpVariable %_ptr_Input_v4float Input
  462. %_ptr_Output_v4float = OpTypePointer Output %v4float
  463. %gl_FragColor = OpVariable %_ptr_Output_v4float Output
  464. %main = OpFunction %void None %10
  465. %21 = OpLabel
  466. %color = OpVariable %_ptr_Function_v4float Function
  467. %param = OpVariable %_ptr_Function_v4float Function
  468. %22 = OpLoad %v4float %BaseColor
  469. OpStore %param %22
  470. %23 = OpFunctionCall %float %foo_vf4_ %param
  471. %24 = OpCompositeConstruct %v4float %23 %23 %23 %23
  472. OpStore %color %24
  473. %25 = OpLoad %v4float %color
  474. OpStore %gl_FragColor %25
  475. OpReturn
  476. OpFunctionEnd
  477. %foo_vf4_ = OpFunction %float None %14
  478. %bar = OpFunctionParameter %_ptr_Function_v4float
  479. %26 = OpLabel
  480. %27 = OpAccessChain %_ptr_Function_float %bar %uint_0
  481. %28 = OpLoad %float %27
  482. %29 = OpAccessChain %_ptr_Function_float %bar %uint_1
  483. %30 = OpLoad %float %29
  484. %31 = OpFAdd %float %28 %30
  485. OpReturnValue %31
  486. OpFunctionEnd
  487. )";
  488. SinglePassRunAndCheck<InlineOpaquePass>(assembly, assembly, true, true);
  489. }
  490. } // namespace
  491. } // namespace opt
  492. } // namespace spvtools