var.static.hlsl 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Run: %dxc -T vs_6_0 -E main
  2. // CHECK: [[v3b0:%\d+]] = OpConstantNull %v3bool
  3. // CHECK: [[v4f0:%\d+]] = OpConstantNull %v4float
  4. // CHECK: %ga = OpVariable %_ptr_Private_int Private
  5. static int ga = 6;
  6. // CHECK: %gb = OpVariable %_ptr_Private_v3bool Private
  7. static bool3 gb;
  8. // The front end has no const evaluation support for HLSL specific types.
  9. // So the following will ends up trying to create an OpStore into gc. We emit
  10. // those initialization code at the beginning of the entry function.
  11. // TODO: optimize this to emit initializer directly: need to fix either the
  12. // general const evaluation in the front end or add const evaluation in our
  13. // InitListHandler.
  14. static float2x2 gc = {1, 2, 3, 4};
  15. // CHECK: %a = OpVariable %_ptr_Private_uint Private
  16. // CHECK: %init_done_a = OpVariable %_ptr_Private_bool Private %false
  17. // CHECK: %b = OpVariable %_ptr_Private_v4float Private
  18. // CHECK: %init_done_b = OpVariable %_ptr_Private_bool Private %false
  19. // CHECK: %c = OpVariable %_ptr_Private_int Private
  20. // CHECK: %init_done_c = OpVariable %_ptr_Private_bool Private %false
  21. // initialization of ga, gb, and gc appears at the beginning of the entry function wrapper
  22. // CHECK-LABEL: OpLabel
  23. // CHECK: OpStore %ga %int_6
  24. // CHECK-NEXT: OpStore %gb [[v3b0]]
  25. // CHECK-NEXT: [[v2f12:%\d+]] = OpCompositeConstruct %v2float %float_1 %float_2
  26. // CHECK-NEXT: [[v2f34:%\d+]] = OpCompositeConstruct %v2float %float_3 %float_4
  27. // CHECK-NEXT: [[mat1234:%\d+]] = OpCompositeConstruct %mat2v2float [[v2f12]] [[v2f34]]
  28. // CHECK-NEXT: OpStore %gc [[mat1234]]
  29. // CHECK: OpFunctionCall %int %src_main
  30. // CHECK-LABEL: OpFunctionEnd
  31. int main(int input: A) : B {
  32. // CHECK-LABEL: %bb_entry = OpLabel
  33. // CHECK-NEXT: [[initdonea:%\d+]] = OpLoad %bool %init_done_a
  34. // CHECK-NEXT: OpSelectionMerge %if_init_done None
  35. // CHECK-NEXT: OpBranchConditional [[initdonea]] %if_init_done %if_init_todo
  36. // CHECK-NEXT: %if_init_todo = OpLabel
  37. // CHECK-NEXT: OpStore %a %uint_5
  38. // CHECK-NEXT: OpStore %init_done_a %true
  39. // CHECK-NEXT: OpBranch %if_init_done
  40. static uint a = 5; // const init
  41. // CHECK-NEXT: %if_init_done = OpLabel
  42. // CHECK-NEXT: [[initdoneb:%\d+]] = OpLoad %bool %init_done_b
  43. // CHECK-NEXT: OpSelectionMerge %if_init_done_0 None
  44. // CHECK-NEXT: OpBranchConditional [[initdoneb]] %if_init_done_0 %if_init_todo_0
  45. // CHECK-NEXT: %if_init_todo_0 = OpLabel
  46. // CHECK-NEXT: OpStore %b [[v4f0]]
  47. // CHECK-NEXT: OpStore %init_done_b %true
  48. // CHECK-NEXT: OpBranch %if_init_done_0
  49. static float4 b; // no init
  50. // CHECK-NEXT: %if_init_done_0 = OpLabel
  51. // CHECK-NEXT: [[initdonec:%\d+]] = OpLoad %bool %init_done_c
  52. // CHECK-NEXT: OpSelectionMerge %if_init_done_1 None
  53. // CHECK-NEXT: OpBranchConditional [[initdonec]] %if_init_done_1 %if_init_todo_1
  54. // CHECK-NEXT: %if_init_todo_1 = OpLabel
  55. // CHECK-NEXT: [[initc:%\d+]] = OpLoad %int %input
  56. // CHECK-NEXT: OpStore %c [[initc]]
  57. // CHECK-NEXT: OpStore %init_done_c %true
  58. // CHECK-NEXT: OpBranch %if_init_done_1
  59. static int c = input; // var init
  60. // CHECK-NEXT: %if_init_done_1 = OpLabel
  61. return input;
  62. }