[glsl][ir] Always polyfill `any` and `all`. This CL switches `any` and `all` to always generate a GLSL defined method. This means we avoid the potential issue of a downstream transform adding an `any` or `all` call which is invalid in GLSL. Bug: 42251044 Change-Id: I33b8a94771902ba87885338e0f4fff1595b62afc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/208094 Commit-Queue: dan sinclair <dsinclair@chromium.org> Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/glsl/builtin_fn.cc b/src/tint/lang/glsl/builtin_fn.cc index 0a3bc76..a3369a7 100644 --- a/src/tint/lang/glsl/builtin_fn.cc +++ b/src/tint/lang/glsl/builtin_fn.cc
@@ -72,6 +72,10 @@ return "packFloat2x16"; case BuiltinFn::kUnpackFloat2X16: return "unpackFloat2x16"; + case BuiltinFn::kAny: + return "any"; + case BuiltinFn::kAll: + return "all"; case BuiltinFn::kDot: return "dot"; case BuiltinFn::kModf:
diff --git a/src/tint/lang/glsl/builtin_fn.h b/src/tint/lang/glsl/builtin_fn.h index 8016a65..1ed6ba0 100644 --- a/src/tint/lang/glsl/builtin_fn.h +++ b/src/tint/lang/glsl/builtin_fn.h
@@ -62,6 +62,8 @@ kBitfieldInsert, kPackFloat2X16, kUnpackFloat2X16, + kAny, + kAll, kDot, kModf, kTextureSize,
diff --git a/src/tint/lang/glsl/glsl.def b/src/tint/lang/glsl/glsl.def index 0df49fc..51e5829 100644 --- a/src/tint/lang/glsl/glsl.def +++ b/src/tint/lang/glsl/glsl.def
@@ -167,7 +167,8 @@ fn packFloat2x16(value: vec2<f16>) -> u32 fn unpackFloat2x16(value: u32) -> vec2<f16> - +implicit(N: num) fn any(vec<N, bool>) -> bool +implicit(N: num) fn all(vec<N, bool>) -> bool implicit(T: f32_f16, N: num) fn dot(vec<N, T>, vec<N, T>) -> T @must_use @const implicit(T: f32_f16) fn modf(value: T, result: ptr<function, T, read_write>) -> T
diff --git a/src/tint/lang/glsl/intrinsic/data.cc b/src/tint/lang/glsl/intrinsic/data.cc index 2e1a3ef..1c50097 100644 --- a/src/tint/lang/glsl/intrinsic/data.cc +++ b/src/tint/lang/glsl/intrinsic/data.cc
@@ -963,99 +963,102 @@ /* [37] */ MatcherIndex(12), /* [38] */ MatcherIndex(1), /* [39] */ MatcherIndex(0), - /* [40] */ MatcherIndex(26), + /* [40] */ MatcherIndex(12), /* [41] */ MatcherIndex(0), - /* [42] */ MatcherIndex(1), - /* [43] */ MatcherIndex(27), + /* [42] */ MatcherIndex(2), + /* [43] */ MatcherIndex(26), /* [44] */ MatcherIndex(0), /* [45] */ MatcherIndex(1), - /* [46] */ MatcherIndex(28), + /* [46] */ MatcherIndex(27), /* [47] */ MatcherIndex(0), /* [48] */ MatcherIndex(1), - /* [49] */ MatcherIndex(29), + /* [49] */ MatcherIndex(28), /* [50] */ MatcherIndex(0), /* [51] */ MatcherIndex(1), - /* [52] */ MatcherIndex(26), - /* [53] */ MatcherIndex(8), - /* [54] */ MatcherIndex(4), + /* [52] */ MatcherIndex(29), + /* [53] */ MatcherIndex(0), + /* [54] */ MatcherIndex(1), /* [55] */ MatcherIndex(26), - /* [56] */ MatcherIndex(10), + /* [56] */ MatcherIndex(8), /* [57] */ MatcherIndex(4), /* [58] */ MatcherIndex(26), - /* [59] */ MatcherIndex(9), + /* [59] */ MatcherIndex(10), /* [60] */ MatcherIndex(4), - /* [61] */ MatcherIndex(27), - /* [62] */ MatcherIndex(8), + /* [61] */ MatcherIndex(26), + /* [62] */ MatcherIndex(9), /* [63] */ MatcherIndex(4), /* [64] */ MatcherIndex(27), - /* [65] */ MatcherIndex(10), + /* [65] */ MatcherIndex(8), /* [66] */ MatcherIndex(4), /* [67] */ MatcherIndex(27), - /* [68] */ MatcherIndex(9), + /* [68] */ MatcherIndex(10), /* [69] */ MatcherIndex(4), - /* [70] */ MatcherIndex(29), - /* [71] */ MatcherIndex(8), + /* [70] */ MatcherIndex(27), + /* [71] */ MatcherIndex(9), /* [72] */ MatcherIndex(4), /* [73] */ MatcherIndex(29), - /* [74] */ MatcherIndex(10), + /* [74] */ MatcherIndex(8), /* [75] */ MatcherIndex(4), /* [76] */ MatcherIndex(29), - /* [77] */ MatcherIndex(9), + /* [77] */ MatcherIndex(10), /* [78] */ MatcherIndex(4), - /* [79] */ MatcherIndex(28), - /* [80] */ MatcherIndex(8), + /* [79] */ MatcherIndex(29), + /* [80] */ MatcherIndex(9), /* [81] */ MatcherIndex(4), /* [82] */ MatcherIndex(28), - /* [83] */ MatcherIndex(10), + /* [83] */ MatcherIndex(8), /* [84] */ MatcherIndex(4), /* [85] */ MatcherIndex(28), - /* [86] */ MatcherIndex(9), + /* [86] */ MatcherIndex(10), /* [87] */ MatcherIndex(4), - /* [88] */ MatcherIndex(12), - /* [89] */ MatcherIndex(1), - /* [90] */ MatcherIndex(2), - /* [91] */ MatcherIndex(9), - /* [92] */ MatcherIndex(3), - /* [93] */ MatcherIndex(14), - /* [94] */ MatcherIndex(0), - /* [95] */ MatcherIndex(9), - /* [96] */ MatcherIndex(5), - /* [97] */ MatcherIndex(15), - /* [98] */ MatcherIndex(0), - /* [99] */ MatcherIndex(10), - /* [100] */ MatcherIndex(5), - /* [101] */ MatcherIndex(16), - /* [102] */ MatcherIndex(0), - /* [103] */ MatcherIndex(17), - /* [104] */ MatcherIndex(0), - /* [105] */ MatcherIndex(18), - /* [106] */ MatcherIndex(0), - /* [107] */ MatcherIndex(19), - /* [108] */ MatcherIndex(0), - /* [109] */ MatcherIndex(20), - /* [110] */ MatcherIndex(0), - /* [111] */ MatcherIndex(11), - /* [112] */ MatcherIndex(0), - /* [113] */ MatcherIndex(11), - /* [114] */ MatcherIndex(4), - /* [115] */ MatcherIndex(11), - /* [116] */ MatcherIndex(5), - /* [117] */ MatcherIndex(11), - /* [118] */ MatcherIndex(6), - /* [119] */ MatcherIndex(9), - /* [120] */ MatcherIndex(0), - /* [121] */ MatcherIndex(10), - /* [122] */ MatcherIndex(0), - /* [123] */ MatcherIndex(30), - /* [124] */ MatcherIndex(34), - /* [125] */ MatcherIndex(31), - /* [126] */ MatcherIndex(21), - /* [127] */ MatcherIndex(22), - /* [128] */ MatcherIndex(23), - /* [129] */ MatcherIndex(24), - /* [130] */ MatcherIndex(25), - /* [131] */ MatcherIndex(32), - /* [132] */ MatcherIndex(33), + /* [88] */ MatcherIndex(28), + /* [89] */ MatcherIndex(9), + /* [90] */ MatcherIndex(4), + /* [91] */ MatcherIndex(12), + /* [92] */ MatcherIndex(1), + /* [93] */ MatcherIndex(2), + /* [94] */ MatcherIndex(9), + /* [95] */ MatcherIndex(3), + /* [96] */ MatcherIndex(14), + /* [97] */ MatcherIndex(0), + /* [98] */ MatcherIndex(9), + /* [99] */ MatcherIndex(5), + /* [100] */ MatcherIndex(15), + /* [101] */ MatcherIndex(0), + /* [102] */ MatcherIndex(10), + /* [103] */ MatcherIndex(5), + /* [104] */ MatcherIndex(16), + /* [105] */ MatcherIndex(0), + /* [106] */ MatcherIndex(17), + /* [107] */ MatcherIndex(0), + /* [108] */ MatcherIndex(18), + /* [109] */ MatcherIndex(0), + /* [110] */ MatcherIndex(19), + /* [111] */ MatcherIndex(0), + /* [112] */ MatcherIndex(20), + /* [113] */ MatcherIndex(0), + /* [114] */ MatcherIndex(11), + /* [115] */ MatcherIndex(0), + /* [116] */ MatcherIndex(11), + /* [117] */ MatcherIndex(4), + /* [118] */ MatcherIndex(11), + /* [119] */ MatcherIndex(5), + /* [120] */ MatcherIndex(11), + /* [121] */ MatcherIndex(6), + /* [122] */ MatcherIndex(9), + /* [123] */ MatcherIndex(0), + /* [124] */ MatcherIndex(10), + /* [125] */ MatcherIndex(0), + /* [126] */ MatcherIndex(30), + /* [127] */ MatcherIndex(34), + /* [128] */ MatcherIndex(31), + /* [129] */ MatcherIndex(21), + /* [130] */ MatcherIndex(22), + /* [131] */ MatcherIndex(23), + /* [132] */ MatcherIndex(24), + /* [133] */ MatcherIndex(25), + /* [134] */ MatcherIndex(32), + /* [135] */ MatcherIndex(33), }; static_assert(MatcherIndicesIndex::CanIndex(kMatcherIndices), @@ -1145,7 +1148,7 @@ { /* [16] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(93), + /* matcher_indices */ MatcherIndicesIndex(96), }, { /* [17] */ @@ -1160,12 +1163,12 @@ { /* [19] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(97), + /* matcher_indices */ MatcherIndicesIndex(100), }, { /* [20] */ /* usage */ core::ParameterUsage::kLocation, - /* matcher_indices */ MatcherIndicesIndex(95), + /* matcher_indices */ MatcherIndicesIndex(98), }, { /* [21] */ @@ -1175,12 +1178,12 @@ { /* [22] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(101), + /* matcher_indices */ MatcherIndicesIndex(104), }, { /* [23] */ /* usage */ core::ParameterUsage::kLocation, - /* matcher_indices */ MatcherIndicesIndex(99), + /* matcher_indices */ MatcherIndicesIndex(102), }, { /* [24] */ @@ -1190,12 +1193,12 @@ { /* [25] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(109), + /* matcher_indices */ MatcherIndicesIndex(112), }, { /* [26] */ /* usage */ core::ParameterUsage::kLocation, - /* matcher_indices */ MatcherIndicesIndex(95), + /* matcher_indices */ MatcherIndicesIndex(98), }, { /* [27] */ @@ -1205,12 +1208,12 @@ { /* [28] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(103), + /* matcher_indices */ MatcherIndicesIndex(106), }, { /* [29] */ /* usage */ core::ParameterUsage::kLocation, - /* matcher_indices */ MatcherIndicesIndex(99), + /* matcher_indices */ MatcherIndicesIndex(102), }, { /* [30] */ @@ -1220,7 +1223,7 @@ { /* [31] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(52), + /* matcher_indices */ MatcherIndicesIndex(55), }, { /* [32] */ @@ -1230,12 +1233,12 @@ { /* [33] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(113), + /* matcher_indices */ MatcherIndicesIndex(116), }, { /* [34] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(55), + /* matcher_indices */ MatcherIndicesIndex(58), }, { /* [35] */ @@ -1245,12 +1248,12 @@ { /* [36] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(115), + /* matcher_indices */ MatcherIndicesIndex(118), }, { /* [37] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(58), + /* matcher_indices */ MatcherIndicesIndex(61), }, { /* [38] */ @@ -1260,142 +1263,142 @@ { /* [39] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(117), + /* matcher_indices */ MatcherIndicesIndex(120), }, { /* [40] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(61), + /* matcher_indices */ MatcherIndicesIndex(64), }, { /* [41] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(119), + /* matcher_indices */ MatcherIndicesIndex(122), }, { /* [42] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(113), + /* matcher_indices */ MatcherIndicesIndex(116), }, { /* [43] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(64), + /* matcher_indices */ MatcherIndicesIndex(67), }, { /* [44] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(119), + /* matcher_indices */ MatcherIndicesIndex(122), }, { /* [45] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(115), + /* matcher_indices */ MatcherIndicesIndex(118), }, { /* [46] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(67), + /* matcher_indices */ MatcherIndicesIndex(70), }, { /* [47] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(119), + /* matcher_indices */ MatcherIndicesIndex(122), }, { /* [48] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(117), + /* matcher_indices */ MatcherIndicesIndex(120), }, { /* [49] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(70), + /* matcher_indices */ MatcherIndicesIndex(73), }, { /* [50] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [51] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(113), + /* matcher_indices */ MatcherIndicesIndex(116), }, { /* [52] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(73), + /* matcher_indices */ MatcherIndicesIndex(76), }, { /* [53] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [54] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(115), + /* matcher_indices */ MatcherIndicesIndex(118), }, { /* [55] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(76), + /* matcher_indices */ MatcherIndicesIndex(79), }, { /* [56] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [57] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(117), + /* matcher_indices */ MatcherIndicesIndex(120), }, { /* [58] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(79), + /* matcher_indices */ MatcherIndicesIndex(82), }, { /* [59] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [60] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(113), + /* matcher_indices */ MatcherIndicesIndex(116), }, { /* [61] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(82), + /* matcher_indices */ MatcherIndicesIndex(85), }, { /* [62] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [63] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(115), + /* matcher_indices */ MatcherIndicesIndex(118), }, { /* [64] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(85), + /* matcher_indices */ MatcherIndicesIndex(88), }, { /* [65] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(121), + /* matcher_indices */ MatcherIndicesIndex(124), }, { /* [66] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(117), + /* matcher_indices */ MatcherIndicesIndex(120), }, { /* [67] */ @@ -1440,7 +1443,7 @@ { /* [75] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(93), + /* matcher_indices */ MatcherIndicesIndex(96), }, { /* [76] */ @@ -1450,7 +1453,7 @@ { /* [77] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(97), + /* matcher_indices */ MatcherIndicesIndex(100), }, { /* [78] */ @@ -1460,7 +1463,7 @@ { /* [79] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(101), + /* matcher_indices */ MatcherIndicesIndex(104), }, { /* [80] */ @@ -1470,7 +1473,7 @@ { /* [81] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(103), + /* matcher_indices */ MatcherIndicesIndex(106), }, { /* [82] */ @@ -1480,7 +1483,7 @@ { /* [83] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(105), + /* matcher_indices */ MatcherIndicesIndex(108), }, { /* [84] */ @@ -1490,7 +1493,7 @@ { /* [85] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(107), + /* matcher_indices */ MatcherIndicesIndex(110), }, { /* [86] */ @@ -1500,7 +1503,7 @@ { /* [87] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(126), + /* matcher_indices */ MatcherIndicesIndex(129), }, { /* [88] */ @@ -1510,7 +1513,7 @@ { /* [89] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(127), + /* matcher_indices */ MatcherIndicesIndex(130), }, { /* [90] */ @@ -1520,7 +1523,7 @@ { /* [91] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(128), + /* matcher_indices */ MatcherIndicesIndex(131), }, { /* [92] */ @@ -1530,7 +1533,7 @@ { /* [93] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(129), + /* matcher_indices */ MatcherIndicesIndex(132), }, { /* [94] */ @@ -1540,7 +1543,7 @@ { /* [95] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(40), + /* matcher_indices */ MatcherIndicesIndex(43), }, { /* [96] */ @@ -1550,32 +1553,32 @@ { /* [97] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(43), + /* matcher_indices */ MatcherIndicesIndex(46), }, { /* [98] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(95), + /* matcher_indices */ MatcherIndicesIndex(98), }, { /* [99] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(46), + /* matcher_indices */ MatcherIndicesIndex(49), }, { /* [100] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(99), + /* matcher_indices */ MatcherIndicesIndex(102), }, { /* [101] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(49), + /* matcher_indices */ MatcherIndicesIndex(52), }, { /* [102] */ /* usage */ core::ParameterUsage::kCoords, - /* matcher_indices */ MatcherIndicesIndex(99), + /* matcher_indices */ MatcherIndicesIndex(102), }, { /* [103] */ @@ -1615,12 +1618,17 @@ { /* [110] */ /* usage */ core::ParameterUsage::kValue, - /* matcher_indices */ MatcherIndicesIndex(91), + /* matcher_indices */ MatcherIndicesIndex(94), }, { /* [111] */ + /* usage */ core::ParameterUsage::kNone, + /* matcher_indices */ MatcherIndicesIndex(40), + }, + { + /* [112] */ /* usage */ core::ParameterUsage::kTexture, - /* matcher_indices */ MatcherIndicesIndex(130), + /* matcher_indices */ MatcherIndicesIndex(133), }, }; @@ -1643,7 +1651,7 @@ { /* [2] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(123), + /* matcher_indices */ MatcherIndicesIndex(126), /* kind */ TemplateInfo::Kind::kType, }, { @@ -1655,7 +1663,7 @@ { /* [4] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(123), + /* matcher_indices */ MatcherIndicesIndex(126), /* kind */ TemplateInfo::Kind::kType, }, { @@ -1667,7 +1675,7 @@ { /* [6] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(124), + /* matcher_indices */ MatcherIndicesIndex(127), /* kind */ TemplateInfo::Kind::kType, }, { @@ -1697,37 +1705,37 @@ { /* [11] */ /* name */ "A", - /* matcher_indices */ MatcherIndicesIndex(92), + /* matcher_indices */ MatcherIndicesIndex(95), /* kind */ TemplateInfo::Kind::kNumber, }, { /* [12] */ /* name */ "F", - /* matcher_indices */ MatcherIndicesIndex(56), + /* matcher_indices */ MatcherIndicesIndex(59), /* kind */ TemplateInfo::Kind::kNumber, }, { /* [13] */ /* name */ "A", - /* matcher_indices */ MatcherIndicesIndex(92), + /* matcher_indices */ MatcherIndicesIndex(95), /* kind */ TemplateInfo::Kind::kNumber, }, { /* [14] */ /* name */ "F", - /* matcher_indices */ MatcherIndicesIndex(59), + /* matcher_indices */ MatcherIndicesIndex(62), /* kind */ TemplateInfo::Kind::kNumber, }, { /* [15] */ /* name */ "A", - /* matcher_indices */ MatcherIndicesIndex(92), + /* matcher_indices */ MatcherIndicesIndex(95), /* kind */ TemplateInfo::Kind::kNumber, }, { /* [16] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(131), + /* matcher_indices */ MatcherIndicesIndex(134), /* kind */ TemplateInfo::Kind::kType, }, { @@ -1739,7 +1747,7 @@ { /* [18] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(132), + /* matcher_indices */ MatcherIndicesIndex(135), /* kind */ TemplateInfo::Kind::kType, }, { @@ -1751,13 +1759,13 @@ { /* [20] */ /* name */ "T", - /* matcher_indices */ MatcherIndicesIndex(125), + /* matcher_indices */ MatcherIndicesIndex(128), /* kind */ TemplateInfo::Kind::kType, }, { /* [21] */ /* name */ "C", - /* matcher_indices */ MatcherIndicesIndex(123), + /* matcher_indices */ MatcherIndicesIndex(126), /* kind */ TemplateInfo::Kind::kType, }, }; @@ -1792,7 +1800,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(77), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1803,7 +1811,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(79), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1814,7 +1822,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(81), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1825,7 +1833,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(83), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1836,7 +1844,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(85), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1847,7 +1855,7 @@ /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), /* parameters */ ParameterIndex(87), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1858,7 +1866,7 @@ /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), /* parameters */ ParameterIndex(89), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1869,7 +1877,7 @@ /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), /* parameters */ ParameterIndex(91), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1880,7 +1888,7 @@ /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), /* parameters */ ParameterIndex(93), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1891,7 +1899,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(25), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1901,8 +1909,8 @@ /* num_explicit_templates */ 0, /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), - /* parameters */ ParameterIndex(111), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* parameters */ ParameterIndex(112), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1913,7 +1921,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(10), /* parameters */ ParameterIndex(95), - /* return_matcher_indices */ MatcherIndicesIndex(113), + /* return_matcher_indices */ MatcherIndicesIndex(116), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1924,7 +1932,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(10), /* parameters */ ParameterIndex(97), - /* return_matcher_indices */ MatcherIndicesIndex(113), + /* return_matcher_indices */ MatcherIndicesIndex(116), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1935,7 +1943,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(10), /* parameters */ ParameterIndex(99), - /* return_matcher_indices */ MatcherIndicesIndex(113), + /* return_matcher_indices */ MatcherIndicesIndex(116), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1946,7 +1954,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(10), /* parameters */ ParameterIndex(101), - /* return_matcher_indices */ MatcherIndicesIndex(113), + /* return_matcher_indices */ MatcherIndicesIndex(116), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1957,7 +1965,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(12), /* parameters */ ParameterIndex(95), - /* return_matcher_indices */ MatcherIndicesIndex(115), + /* return_matcher_indices */ MatcherIndicesIndex(118), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1968,7 +1976,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(12), /* parameters */ ParameterIndex(97), - /* return_matcher_indices */ MatcherIndicesIndex(115), + /* return_matcher_indices */ MatcherIndicesIndex(118), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1979,7 +1987,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(12), /* parameters */ ParameterIndex(99), - /* return_matcher_indices */ MatcherIndicesIndex(115), + /* return_matcher_indices */ MatcherIndicesIndex(118), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -1990,7 +1998,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(12), /* parameters */ ParameterIndex(101), - /* return_matcher_indices */ MatcherIndicesIndex(115), + /* return_matcher_indices */ MatcherIndicesIndex(118), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2001,7 +2009,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(14), /* parameters */ ParameterIndex(95), - /* return_matcher_indices */ MatcherIndicesIndex(117), + /* return_matcher_indices */ MatcherIndicesIndex(120), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2012,7 +2020,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(14), /* parameters */ ParameterIndex(97), - /* return_matcher_indices */ MatcherIndicesIndex(117), + /* return_matcher_indices */ MatcherIndicesIndex(120), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2023,7 +2031,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(14), /* parameters */ ParameterIndex(99), - /* return_matcher_indices */ MatcherIndicesIndex(117), + /* return_matcher_indices */ MatcherIndicesIndex(120), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2034,7 +2042,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(14), /* parameters */ ParameterIndex(101), - /* return_matcher_indices */ MatcherIndicesIndex(117), + /* return_matcher_indices */ MatcherIndicesIndex(120), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2177,7 +2185,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(16), - /* return_matcher_indices */ MatcherIndicesIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(114), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2188,7 +2196,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(19), - /* return_matcher_indices */ MatcherIndicesIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(114), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2199,7 +2207,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(22), - /* return_matcher_indices */ MatcherIndicesIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(114), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2210,7 +2218,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(25), - /* return_matcher_indices */ MatcherIndicesIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(114), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2221,7 +2229,7 @@ /* num_templates */ 1, /* templates */ TemplateIndex(20), /* parameters */ ParameterIndex(28), - /* return_matcher_indices */ MatcherIndicesIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(114), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2243,7 +2251,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(8), /* parameters */ ParameterIndex(97), - /* return_matcher_indices */ MatcherIndicesIndex(95), + /* return_matcher_indices */ MatcherIndicesIndex(98), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2254,7 +2262,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(8), /* parameters */ ParameterIndex(99), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2265,7 +2273,7 @@ /* num_templates */ 2, /* templates */ TemplateIndex(8), /* parameters */ ParameterIndex(101), - /* return_matcher_indices */ MatcherIndicesIndex(99), + /* return_matcher_indices */ MatcherIndicesIndex(102), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { @@ -2507,12 +2515,23 @@ /* num_templates */ 0, /* templates */ TemplateIndex(/* invalid */), /* parameters */ ParameterIndex(108), - /* return_matcher_indices */ MatcherIndicesIndex(91), + /* return_matcher_indices */ MatcherIndicesIndex(94), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { /* [67] */ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), + /* num_parameters */ 1, + /* num_explicit_templates */ 0, + /* num_templates */ 1, + /* templates */ TemplateIndex(5), + /* parameters */ ParameterIndex(111), + /* return_matcher_indices */ MatcherIndicesIndex(5), + /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), + }, + { + /* [68] */ + /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), /* num_parameters */ 2, /* num_explicit_templates */ 0, /* num_templates */ 2, @@ -2522,25 +2541,25 @@ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { - /* [68] */ + /* [69] */ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), /* num_parameters */ 2, /* num_explicit_templates */ 0, /* num_templates */ 2, /* templates */ TemplateIndex(16), /* parameters */ ParameterIndex(69), - /* return_matcher_indices */ MatcherIndicesIndex(88), + /* return_matcher_indices */ MatcherIndicesIndex(91), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, { - /* [69] */ + /* [70] */ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), /* num_parameters */ 2, /* num_explicit_templates */ 0, /* num_templates */ 2, /* templates */ TemplateIndex(18), /* parameters */ ParameterIndex(69), - /* return_matcher_indices */ MatcherIndicesIndex(88), + /* return_matcher_indices */ MatcherIndicesIndex(91), /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */), }, }; @@ -2648,19 +2667,31 @@ }, { /* [15] */ - /* fn dot[T : f32_f16, N : num](vec<N, T>, vec<N, T>) -> T */ + /* fn any[N : num](vec<N, bool>) -> bool */ /* num overloads */ 1, /* overloads */ OverloadIndex(67), }, { /* [16] */ + /* fn all[N : num](vec<N, bool>) -> bool */ + /* num overloads */ 1, + /* overloads */ OverloadIndex(67), + }, + { + /* [17] */ + /* fn dot[T : f32_f16, N : num](vec<N, T>, vec<N, T>) -> T */ + /* num overloads */ 1, + /* overloads */ OverloadIndex(68), + }, + { + /* [18] */ /* fn modf[T : f32_f16](value: T, result: ptr<function, T, read_write>) -> T */ /* fn modf[N : num, T : f32_f16](value: vec<N, T>, result: ptr<function, vec<N, T>, read_write>) -> vec<N, T> */ /* num overloads */ 2, /* overloads */ OverloadIndex(59), }, { - /* [17] */ + /* [19] */ /* fn textureSize[T : fiu32](texture: texture_1d<T>, level: i32) -> i32 */ /* fn textureSize[T : fiu32](texture: texture_2d<T>, level: i32) -> vec2<i32> */ /* fn textureSize[T : fiu32](texture: texture_2d_array<T>, level: i32) -> vec3<i32> */ @@ -2677,7 +2708,7 @@ /* overloads */ OverloadIndex(0), }, { - /* [18] */ + /* [20] */ /* fn imageSize[F : texel_format, A : access](texture: texture_storage_1d<F, A>) -> i32 */ /* fn imageSize[F : texel_format, A : access](texture: texture_storage_2d<F, A>) -> vec2<i32> */ /* fn imageSize[F : texel_format, A : access](texture: texture_storage_2d_array<F, A>) -> vec3<i32> */ @@ -2686,7 +2717,7 @@ /* overloads */ OverloadIndex(41), }, { - /* [19] */ + /* [21] */ /* fn texelFetch[T : fiu32](texture: texture_1d<T>, location: i32, level: i32) -> vec4<T> */ /* fn texelFetch[T : fiu32](texture: texture_2d<T>, location: vec2<i32>, level: i32) -> vec4<T> */ /* fn texelFetch[T : fiu32](texture: texture_2d_array<T>, location: vec3<i32>, level: i32) -> vec4<T> */ @@ -2696,7 +2727,7 @@ /* overloads */ OverloadIndex(36), }, { - /* [20] */ + /* [22] */ /* fn imageLoad[F : f32_texel_format, A : readable](texture: texture_storage_1d<F, A>, coords: i32) -> vec4<f32> */ /* fn imageLoad[F : f32_texel_format, A : readable](texture: texture_storage_2d<F, A>, coords: vec2<i32>) -> vec4<f32> */ /* fn imageLoad[F : f32_texel_format, A : readable](texture: texture_storage_2d_array<F, A>, coords: vec3<i32>) -> vec4<f32> */ @@ -2713,7 +2744,7 @@ /* overloads */ OverloadIndex(12), }, { - /* [21] */ + /* [23] */ /* fn imageStore[C : iu32](texture: texture_storage_1d<f32_texel_format, writable>, coords: C, value: vec4<f32>) */ /* fn imageStore[C : iu32](texture: texture_storage_1d<i32_texel_format, writable>, coords: C, value: vec4<i32>) */ /* fn imageStore[C : iu32](texture: texture_storage_1d<u32_texel_format, writable>, coords: C, value: vec4<u32>) */ @@ -2730,41 +2761,41 @@ /* overloads */ OverloadIndex(24), }, { - /* [22] */ + /* [24] */ /* fn lessThan[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ /* num overloads */ 1, - /* overloads */ OverloadIndex(68), - }, - { - /* [23] */ - /* fn lessThanEqual[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ - /* num overloads */ 1, - /* overloads */ OverloadIndex(68), - }, - { - /* [24] */ - /* fn greaterThan[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ - /* num overloads */ 1, - /* overloads */ OverloadIndex(68), + /* overloads */ OverloadIndex(69), }, { /* [25] */ - /* fn greaterThanEqual[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ + /* fn lessThanEqual[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ /* num overloads */ 1, - /* overloads */ OverloadIndex(68), + /* overloads */ OverloadIndex(69), }, { /* [26] */ - /* fn equal[T : fiu32_f16_bool, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ + /* fn greaterThan[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ /* num overloads */ 1, /* overloads */ OverloadIndex(69), }, { /* [27] */ - /* fn notEqual[T : fiu32_f16_bool, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ + /* fn greaterThanEqual[T : fiu32_f16, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ /* num overloads */ 1, /* overloads */ OverloadIndex(69), }, + { + /* [28] */ + /* fn equal[T : fiu32_f16_bool, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ + /* num overloads */ 1, + /* overloads */ OverloadIndex(70), + }, + { + /* [29] */ + /* fn notEqual[T : fiu32_f16_bool, N : num](vec<N, T>, vec<N, T>) -> vec<N, bool> */ + /* num overloads */ 1, + /* overloads */ OverloadIndex(70), + }, }; // clang-format on
diff --git a/src/tint/lang/glsl/writer/printer/printer.cc b/src/tint/lang/glsl/writer/printer/printer.cc index 0cede8e..d02ccce 100644 --- a/src/tint/lang/glsl/writer/printer/printer.cc +++ b/src/tint/lang/glsl/writer/printer/printer.cc
@@ -1324,8 +1324,6 @@ case core::BuiltinFn::kAbs: case core::BuiltinFn::kAcos: case core::BuiltinFn::kAcosh: - case core::BuiltinFn::kAll: - case core::BuiltinFn::kAny: case core::BuiltinFn::kAsin: case core::BuiltinFn::kAsinh: case core::BuiltinFn::kAtan:
diff --git a/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc b/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc index 93f7181..7f9f727 100644 --- a/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc +++ b/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
@@ -70,15 +70,9 @@ Vector<core::ir::CoreBuiltinCall*, 4> call_worklist; for (auto* inst : ir.Instructions()) { if (auto* call = inst->As<core::ir::CoreBuiltinCall>()) { - auto args = call->Args(); - switch (call->Func()) { case core::BuiltinFn::kAll: case core::BuiltinFn::kAny: - if (args[0]->Type()->Is<core::type::Scalar>()) { - call_worklist.Push(call); - } - break; case core::BuiltinFn::kArrayLength: case core::BuiltinFn::kAtomicCompareExchangeWeak: case core::BuiltinFn::kAtomicSub: @@ -110,8 +104,10 @@ for (auto* call : call_worklist) { switch (call->Func()) { case core::BuiltinFn::kAll: + All(call); + break; case core::BuiltinFn::kAny: - ConvertToNop(call); + Any(call); break; case core::BuiltinFn::kArrayLength: ArrayLength(call); @@ -169,8 +165,33 @@ } } - void ConvertToNop(core::ir::Call* call) { - call->Result(0)->ReplaceAllUsesWith(call->Args()[0]); + void Any(core::ir::BuiltinCall* call) { + auto args = call->Args(); + + if (args[0]->Type()->Is<core::type::Scalar>()) { + // GLSL has no scalar `any`, replace it with the arg. + call->Result(0)->ReplaceAllUsesWith(args[0]); + } else { + b.InsertBefore(call, [&] { + b.CallWithResult<glsl::ir::BuiltinCall>(call->DetachResult(), glsl::BuiltinFn::kAny, + args[0]); + }); + } + call->Destroy(); + } + + void All(core::ir::BuiltinCall* call) { + auto args = call->Args(); + + if (args[0]->Type()->Is<core::type::Scalar>()) { + // GLSL has no scalar `all`, replace it with the arg. + call->Result(0)->ReplaceAllUsesWith(args[0]); + } else { + b.InsertBefore(call, [&] { + b.CallWithResult<glsl::ir::BuiltinCall>(call->DetachResult(), glsl::BuiltinFn::kAll, + args[0]); + }); + } call->Destroy(); }