hlsl.array.implicit-size.frag 783 B

123456789101112131415161718192021222324252627282930313233
  1. // array size from initializer
  2. static float g_array [ ] = { 1, 2, 3, 4, 5 };
  3. // Unused: array size from initializer
  4. static float g_array_unused [ ] = { 1, 2, 3, 4, 5, 6, 7 };
  5. // Test initializer sizing for arrayed structs
  6. static struct mystruct {
  7. int i;
  8. float f;
  9. } g_mystruct[] = {
  10. { 1, 2.0 },
  11. { 3, 4.0 },
  12. };
  13. struct PS_OUTPUT { float4 color : SV_Target0; };
  14. // INVALID: implicit size requires an initializer expression.
  15. // uniform float bad[];
  16. // INVALID: function parameters cannot be implicitly sized
  17. // void BadFunction(int a[]) { }
  18. void main(out PS_OUTPUT ps_output)
  19. {
  20. // local array sized from initializers
  21. float l_array[] = { 1, 2, 3 };
  22. int idx;
  23. ps_output.color = g_array[0] + g_array[4] + l_array[1] + g_mystruct[0].f + g_array[idx];
  24. }