spv.specConstantComposite.vert 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #version 450
  2. // constant_id specified scalar spec constants
  3. layout(constant_id = 200) const int spec_int = 3;
  4. layout(constant_id = 201) const float spec_float = 3.14;
  5. layout(constant_id = 202) const
  6. double spec_double = 3.1415926535897932384626433832795;
  7. layout(constant_id = 203) const bool spec_bool = true;
  8. // const float cast_spec_float = float(spec_float);
  9. // Flat struct
  10. struct flat_struct {
  11. int i;
  12. float f;
  13. double d;
  14. bool b;
  15. };
  16. // Nesting struct
  17. struct nesting_struct {
  18. flat_struct nested;
  19. vec4 v;
  20. int i;
  21. };
  22. // Expect OpSpecConstantComposite
  23. // Flat struct initializer
  24. //const flat_struct spec_flat_struct_all_spec = {spec_int, spec_float,
  25. // spec_double, spec_bool};
  26. //const flat_struct spec_flat_struct_partial_spec = {30, 30.14, spec_double,
  27. // spec_bool};
  28. // Nesting struct initializer
  29. //const nesting_struct nesting_struct_ctor = {
  30. // {spec_int, spec_float, spec_double, false},
  31. // vec4(0.1, 0.1, 0.1, 0.1),
  32. // spec_int};
  33. // Vector constructor
  34. //const vec4 spec_vec4_all_spec =
  35. // vec4(spec_float, spec_float, spec_float, spec_float);
  36. //const vec4 spec_vec4_partial_spec =
  37. // vec4(spec_float, spec_float, 300.14, 300.14);
  38. //const vec4 spec_vec4_from_one_scalar = vec4(spec_float);
  39. // Matrix constructor
  40. //const mat2x3 spec_mat2x3 = mat2x3(spec_float, spec_float, spec_float, 1.1, 2.2, 3.3);
  41. //const mat2x3 spec_mat2x3_from_one_scalar = mat2x3(spec_float);
  42. // Struct nesting constructor
  43. //const nesting_struct spec_nesting_struct_all_spec = {
  44. // spec_flat_struct_all_spec, spec_vec4_all_spec, spec_int};
  45. //const nesting_struct spec_nesting_struct_partial_spec = {
  46. // spec_flat_struct_partial_spec, spec_vec4_partial_spec, 3000};
  47. //const float spec_float_array[5] = {spec_float, spec_float, 1.0, 2.0, 3.0};
  48. //const int spec_int_array[5] = {spec_int, spec_int, 1, 2, 30};
  49. // global_vec4_array_with_spec_length is not a spec constant, but its array
  50. // size is. When calling global_vec4_array_with_spec_length.length(), A
  51. // TIntermSymbol Node should be returned, instead of a TIntermConstantUnion
  52. // node which represents a known constant value.
  53. in vec4 global_vec4_array_with_spec_length[spec_int];
  54. out vec4 color;
  55. void refer_primary_spec_const() {
  56. if (spec_bool) color *= spec_int;
  57. }
  58. void refer_composite_spec_const() {
  59. //color += spec_vec4_all_spec;
  60. //color -= spec_vec4_partial_spec;
  61. }
  62. void refer_copmosite_dot_dereference() {
  63. //color *= spec_nesting_struct_all_spec.i;
  64. //color += spec_vec4_all_spec.x;
  65. }
  66. void refer_composite_bracket_dereference() {
  67. //color -= spec_float_array[1];
  68. //color /= spec_int_array[spec_int_array[spec_int]];
  69. }
  70. int refer_spec_const_array_length() {
  71. int len = global_vec4_array_with_spec_length.length();
  72. return len;
  73. }
  74. void declare_spec_const_in_func() {
  75. //const nesting_struct spec_const_declared_in_func = {
  76. // spec_flat_struct_partial_spec, spec_vec4_partial_spec, 10};
  77. //color /= spec_const_declared_in_func.i;
  78. }
  79. void main() {}