fn.ctbuffer.hlsl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Run: %dxc -T ps_6_0 -E main
  2. // %S : generated from struct S, with layout decorations
  3. // %S_0: generated from struct S, without layout decorations
  4. // CHECK: %type_MyCBuffer = OpTypeStruct %v4float
  5. cbuffer MyCBuffer {
  6. float4 cb_val;
  7. float4 get_cb_val() { return cb_val; }
  8. }
  9. struct S {
  10. float3 s_val;
  11. float3 get_s_val() { return s_val; }
  12. };
  13. // CHECK: %type_MyTBuffer = OpTypeStruct %float %S
  14. tbuffer MyTBuffer {
  15. float tb_val;
  16. S tb_s;
  17. float get_tb_val() { return tb_val; }
  18. }
  19. float4 main() : SV_Target {
  20. // %S vs %S_0: need destruction and construction
  21. // CHECK: %temp_var_S = OpVariable %_ptr_Function_S_0 Function
  22. // CHECK: [[tb_s:%\d+]] = OpAccessChain %_ptr_Uniform_S %MyTBuffer %int_1
  23. // CHECK-NEXT: [[s:%\d+]] = OpLoad %S [[tb_s]]
  24. // CHECK-NEXT: [[s_val:%\d+]] = OpCompositeExtract %v3float [[s]] 0
  25. // CHECK-NEXT: [[tmp:%\d+]] = OpCompositeConstruct %S_0 [[s_val]]
  26. // CHECK-NEXT: OpStore %temp_var_S [[tmp]]
  27. // CHECK-NEXT: {{%\d+}} = OpFunctionCall %v3float %S_get_s_val %temp_var_S
  28. return get_cb_val() + float4(tb_s.get_s_val(), 0.) * get_tb_val();
  29. }
  30. // CHECK: %get_cb_val = OpFunction %v4float None {{%\d+}}
  31. // CHECK: {{%\d+}} = OpAccessChain %_ptr_Uniform_v4float %MyCBuffer %int_0
  32. // CHECK: %S_get_s_val = OpFunction %v3float None {{%\d+}}
  33. // CHECK-NEXT: %param_this = OpFunctionParameter %_ptr_Function_S_0
  34. // CHECK: {{%\d+}} = OpAccessChain %_ptr_Function_v3float %param_this %int_0
  35. // CHECK: %get_tb_val = OpFunction %float None {{%\d+}}
  36. // CHECK: {{%\d+}} = OpAccessChain %_ptr_Uniform_float %MyTBuffer %int_0