hlsl.init2.frag 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. void Test1()
  2. {
  3. struct mystruct { float2 a; };
  4. mystruct test1 = {
  5. { 1, 2, }, // test trailing commas in list
  6. };
  7. mystruct test2 = {
  8. float2(3, 4),
  9. };
  10. // mystruct test3 = {
  11. // { { 5, 6, } }, // TODO: test unneeded levels
  12. // };
  13. float test4 = { 7, } ; // test scalar initialization
  14. struct mystruct2 { float a; float b; float c; };
  15. mystruct2 test5 = { {8,}, {9,}, {10}, };
  16. const mystruct2 constTest5 = { {8,}, {9,}, {10}, };
  17. constTest5.c;
  18. const float step = 1.f;
  19. float n = 0;
  20. const float3 a[8] = {
  21. normalize(float3(1, 1, 1)) * (n += step),
  22. normalize(float3(-1, -1, -1)) * (n += step),
  23. normalize(float3(-1, -1, 1)) * (n += step),
  24. normalize(float3(-1, 1, -1)) * (n += step),
  25. normalize(float3(-1, 1, 1)) * (n += step),
  26. normalize(float3(1, -1, -1)) * (n += step),
  27. normalize(float3(1, -1, 1)) * (n += step),
  28. normalize(float3(1, 1, -1)) * (n += step) };
  29. const struct one { float3 a; } oneNonConst = { normalize(float3(-1, 1, 1)) * (n += step) };
  30. const struct two { float3 a;
  31. float3 b; } twoNonConst = { normalize(float3(-1, 1, 1)) * (n += step),
  32. normalize(float3(-1, 1, 1)) * (n += step) };
  33. }
  34. struct PS_OUTPUT { float4 color : SV_Target0; };
  35. PS_OUTPUT main()
  36. {
  37. Test1();
  38. PS_OUTPUT ps_output;
  39. ps_output.color = 1.0;
  40. return ps_output;
  41. }