[glsl][ir] Polyfill the `extractBits` call
This Cl implements the `extractBits` WGSL call in terms of the
`bitfieldExtract` GLSL call.
Bug: 42251044
Change-Id: I5de7316a3bb6a33d01cfd2e38ab6d4148ab107eb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/206795
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/cmd/fuzz/wgsl/dictionary.txt b/src/tint/cmd/fuzz/wgsl/dictionary.txt
index a266992..20f39a9 100644
--- a/src/tint/cmd/fuzz/wgsl/dictionary.txt
+++ b/src/tint/cmd/fuzz/wgsl/dictionary.txt
@@ -147,6 +147,7 @@
"bgra8unorm"
"binding"
"bitcast"
+"bits"
"blend_src"
"bool"
"break"
diff --git a/src/tint/lang/core/core.def b/src/tint/lang/core/core.def
index be6b580..b7fcdea 100644
--- a/src/tint/lang/core/core.def
+++ b/src/tint/lang/core/core.def
@@ -230,6 +230,7 @@
// These are parameter usages which show up in other def files but not in core.def.
enum usages {
+ bits
depth
compare_value
elements
diff --git a/src/tint/lang/core/parameter_usage.cc b/src/tint/lang/core/parameter_usage.cc
index 73fe884..e33497b 100644
--- a/src/tint/lang/core/parameter_usage.cc
+++ b/src/tint/lang/core/parameter_usage.cc
@@ -46,6 +46,8 @@
return "array_index";
case ParameterUsage::kBias:
return "bias";
+ case ParameterUsage::kBits:
+ return "bits";
case ParameterUsage::kCompareValue:
return "compare_value";
case ParameterUsage::kComponent:
diff --git a/src/tint/lang/core/parameter_usage.h b/src/tint/lang/core/parameter_usage.h
index 3e110b1..8a8ca8d 100644
--- a/src/tint/lang/core/parameter_usage.h
+++ b/src/tint/lang/core/parameter_usage.h
@@ -49,6 +49,7 @@
enum class ParameterUsage : uint8_t {
kArrayIndex,
kBias,
+ kBits,
kCompareValue,
kComponent,
kCoords,
diff --git a/src/tint/lang/glsl/builtin_fn.cc b/src/tint/lang/glsl/builtin_fn.cc
index cf13898..32299c4 100644
--- a/src/tint/lang/glsl/builtin_fn.cc
+++ b/src/tint/lang/glsl/builtin_fn.cc
@@ -62,6 +62,8 @@
return "uintBitsToFloat";
case BuiltinFn::kBitCount:
return "bitCount";
+ case BuiltinFn::kBitfieldExtract:
+ return "bitfieldExtract";
case BuiltinFn::kPackFloat2X16:
return "packFloat2x16";
case BuiltinFn::kUnpackFloat2X16:
diff --git a/src/tint/lang/glsl/builtin_fn.h b/src/tint/lang/glsl/builtin_fn.h
index c7fd30c..9f7de1d 100644
--- a/src/tint/lang/glsl/builtin_fn.h
+++ b/src/tint/lang/glsl/builtin_fn.h
@@ -57,6 +57,7 @@
kIntBitsToFloat,
kUintBitsToFloat,
kBitCount,
+ kBitfieldExtract,
kPackFloat2X16,
kUnpackFloat2X16,
kTextureSize,
diff --git a/src/tint/lang/glsl/glsl.def b/src/tint/lang/glsl/glsl.def
index f85352c..62aa028 100644
--- a/src/tint/lang/glsl/glsl.def
+++ b/src/tint/lang/glsl/glsl.def
@@ -114,6 +114,9 @@
implicit(T: iu32) fn bitCount(value: T) -> i32
implicit(T: iu32, N: num) fn bitCount(value: vec<N, T>) -> vec<N, i32>
+implicit(T: iu32) fn bitfieldExtract(value: T, offset: i32, bits: i32) -> T
+implicit(T: iu32, N: num) fn bitfieldExtract(value: vec<N, T>, offset: i32, bits: i32) -> vec<N, T>
+
fn packFloat2x16(value: vec2<f16>) -> u32
fn unpackFloat2x16(value: u32) -> vec2<f16>
diff --git a/src/tint/lang/glsl/intrinsic/data.cc b/src/tint/lang/glsl/intrinsic/data.cc
index 1b175ec..4506581 100644
--- a/src/tint/lang/glsl/intrinsic/data.cc
+++ b/src/tint/lang/glsl/intrinsic/data.cc
@@ -780,181 +780,201 @@
},
{
/* [3] */
- /* usage */ core::ParameterUsage::kNone,
- /* matcher_indices */ MatcherIndicesIndex(5),
+ /* usage */ core::ParameterUsage::kOffset,
+ /* matcher_indices */ MatcherIndicesIndex(12),
},
{
/* [4] */
- /* usage */ core::ParameterUsage::kNone,
- /* matcher_indices */ MatcherIndicesIndex(3),
+ /* usage */ core::ParameterUsage::kBits,
+ /* matcher_indices */ MatcherIndicesIndex(12),
},
{
/* [5] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(39),
- },
- {
- /* [6] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [7] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(43),
- },
- {
- /* [8] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [9] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(47),
- },
- {
- /* [10] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [11] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(49),
- },
- {
- /* [12] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [13] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(51),
- },
- {
- /* [14] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [15] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(53),
- },
- {
- /* [16] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [17] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(59),
- },
- {
- /* [18] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [19] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(60),
- },
- {
- /* [20] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [21] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(61),
- },
- {
- /* [22] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [23] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(62),
- },
- {
- /* [24] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [25] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(1),
- },
- {
- /* [26] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(13),
- },
- {
- /* [27] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(12),
- },
- {
- /* [28] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(10),
- },
- {
- /* [29] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(18),
- },
- {
- /* [30] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(16),
- },
- {
- /* [31] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(22),
},
{
+ /* [6] */
+ /* usage */ core::ParameterUsage::kOffset,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [7] */
+ /* usage */ core::ParameterUsage::kBits,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [8] */
+ /* usage */ core::ParameterUsage::kNone,
+ /* matcher_indices */ MatcherIndicesIndex(5),
+ },
+ {
+ /* [9] */
+ /* usage */ core::ParameterUsage::kNone,
+ /* matcher_indices */ MatcherIndicesIndex(3),
+ },
+ {
+ /* [10] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(39),
+ },
+ {
+ /* [11] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [12] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(43),
+ },
+ {
+ /* [13] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [14] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(47),
+ },
+ {
+ /* [15] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [16] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(49),
+ },
+ {
+ /* [17] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [18] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(51),
+ },
+ {
+ /* [19] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [20] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(53),
+ },
+ {
+ /* [21] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [22] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(59),
+ },
+ {
+ /* [23] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [24] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(60),
+ },
+ {
+ /* [25] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [26] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(61),
+ },
+ {
+ /* [27] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [28] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(62),
+ },
+ {
+ /* [29] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [30] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(1),
+ },
+ {
+ /* [31] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(13),
+ },
+ {
/* [32] */
/* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [33] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(10),
+ },
+ {
+ /* [34] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(18),
+ },
+ {
+ /* [35] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(16),
+ },
+ {
+ /* [36] */
+ /* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(37),
},
{
- /* [33] */
+ /* [37] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(55),
},
{
- /* [34] */
+ /* [38] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(63),
},
{
- /* [35] */
+ /* [39] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(25),
},
{
- /* [36] */
+ /* [40] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(28),
},
{
- /* [37] */
+ /* [41] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(31),
},
{
- /* [38] */
+ /* [42] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(34),
},
@@ -1019,7 +1039,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(5),
+ /* parameters */ ParameterIndex(10),
/* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1030,7 +1050,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(7),
+ /* parameters */ ParameterIndex(12),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1041,7 +1061,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(9),
+ /* parameters */ ParameterIndex(14),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1052,7 +1072,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(11),
+ /* parameters */ ParameterIndex(16),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1063,7 +1083,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(13),
+ /* parameters */ ParameterIndex(18),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1074,7 +1094,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(15),
+ /* parameters */ ParameterIndex(20),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1085,7 +1105,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(17),
+ /* parameters */ ParameterIndex(22),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1096,7 +1116,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(19),
+ /* parameters */ ParameterIndex(24),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1107,7 +1127,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(21),
+ /* parameters */ ParameterIndex(26),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1118,7 +1138,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(23),
+ /* parameters */ ParameterIndex(28),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1129,7 +1149,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(33),
+ /* parameters */ ParameterIndex(37),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1140,7 +1160,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(34),
+ /* parameters */ ParameterIndex(38),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1151,7 +1171,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(35),
+ /* parameters */ ParameterIndex(39),
/* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1162,7 +1182,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(36),
+ /* parameters */ ParameterIndex(40),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1173,7 +1193,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(37),
+ /* parameters */ ParameterIndex(41),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1184,7 +1204,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(38),
+ /* parameters */ ParameterIndex(42),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1195,7 +1215,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(25),
+ /* parameters */ ParameterIndex(30),
/* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1206,7 +1226,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(26),
+ /* parameters */ ParameterIndex(31),
/* return_matcher_indices */ MatcherIndicesIndex(10),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1217,7 +1237,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(25),
+ /* parameters */ ParameterIndex(30),
/* return_matcher_indices */ MatcherIndicesIndex(18),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1228,7 +1248,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(26),
+ /* parameters */ ParameterIndex(31),
/* return_matcher_indices */ MatcherIndicesIndex(16),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1239,7 +1259,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(27),
+ /* parameters */ ParameterIndex(32),
/* return_matcher_indices */ MatcherIndicesIndex(1),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1250,7 +1270,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(28),
+ /* parameters */ ParameterIndex(33),
/* return_matcher_indices */ MatcherIndicesIndex(13),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1261,7 +1281,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(29),
+ /* parameters */ ParameterIndex(34),
/* return_matcher_indices */ MatcherIndicesIndex(1),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1272,7 +1292,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(30),
+ /* parameters */ ParameterIndex(35),
/* return_matcher_indices */ MatcherIndicesIndex(13),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1294,12 +1314,34 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(2),
- /* parameters */ ParameterIndex(31),
+ /* parameters */ ParameterIndex(5),
/* return_matcher_indices */ MatcherIndicesIndex(19),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [26] */
+ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
+ /* num_parameters */ 3,
+ /* num_explicit_templates */ 0,
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(0),
+ /* parameters */ ParameterIndex(2),
+ /* return_matcher_indices */ MatcherIndicesIndex(3),
+ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
+ },
+ {
+ /* [27] */
+ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
+ /* num_parameters */ 3,
+ /* num_explicit_templates */ 0,
+ /* num_templates */ 2,
+ /* templates */ TemplateIndex(2),
+ /* parameters */ ParameterIndex(5),
+ /* return_matcher_indices */ MatcherIndicesIndex(22),
+ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
+ },
+ {
+ /* [28] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 0,
/* num_explicit_templates */ 0,
@@ -1310,7 +1352,7 @@
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
- /* [27] */
+ /* [29] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 3,
/* num_explicit_templates */ 0,
@@ -1321,35 +1363,35 @@
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
- /* [28] */
+ /* [30] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 2,
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(0),
- /* parameters */ ParameterIndex(3),
+ /* parameters */ ParameterIndex(8),
/* return_matcher_indices */ MatcherIndicesIndex(3),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
- /* [29] */
+ /* [31] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(32),
+ /* parameters */ ParameterIndex(36),
/* return_matcher_indices */ MatcherIndicesIndex(18),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
- /* [30] */
+ /* [32] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(29),
+ /* parameters */ ParameterIndex(34),
/* return_matcher_indices */ MatcherIndicesIndex(37),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1363,31 +1405,31 @@
/* [0] */
/* fn barrier() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(26),
+ /* overloads */ OverloadIndex(28),
},
{
/* [1] */
/* fn memoryBarrierBuffer() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(26),
+ /* overloads */ OverloadIndex(28),
},
{
/* [2] */
/* fn memoryBarrierImage() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(26),
+ /* overloads */ OverloadIndex(28),
},
{
/* [3] */
/* fn atomicCompSwap[T : iu32](ptr<workgroup_or_storage, atomic<T>, read_write>, compare_value: T, value: T) -> T */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(27),
+ /* overloads */ OverloadIndex(29),
},
{
/* [4] */
/* fn atomicSub[T : iu32, S : workgroup_or_storage](ptr<S, atomic<T>, read_write>, T) -> T */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(28),
+ /* overloads */ OverloadIndex(30),
},
{
/* [5] */
@@ -1426,18 +1468,25 @@
},
{
/* [10] */
- /* fn packFloat2x16(value: vec2<f16>) -> u32 */
- /* num overloads */ 1,
- /* overloads */ OverloadIndex(29),
+ /* fn bitfieldExtract[T : iu32](value: T, offset: i32, bits: i32) -> T */
+ /* fn bitfieldExtract[T : iu32, N : num](value: vec<N, T>, offset: i32, bits: i32) -> vec<N, T> */
+ /* num overloads */ 2,
+ /* overloads */ OverloadIndex(26),
},
{
/* [11] */
- /* fn unpackFloat2x16(value: u32) -> vec2<f16> */
+ /* fn packFloat2x16(value: vec2<f16>) -> u32 */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(30),
+ /* overloads */ OverloadIndex(31),
},
{
/* [12] */
+ /* fn unpackFloat2x16(value: u32) -> vec2<f16> */
+ /* num overloads */ 1,
+ /* overloads */ OverloadIndex(32),
+ },
+ {
+ /* [13] */
/* 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> */
@@ -1454,7 +1503,7 @@
/* overloads */ OverloadIndex(0),
},
{
- /* [13] */
+ /* [14] */
/* 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> */
diff --git a/src/tint/lang/glsl/writer/builtin_test.cc b/src/tint/lang/glsl/writer/builtin_test.cc
index 349b45d..a30c0b7 100644
--- a/src/tint/lang/glsl/writer/builtin_test.cc
+++ b/src/tint/lang/glsl/writer/builtin_test.cc
@@ -974,5 +974,25 @@
)");
}
+TEST_F(GlslWriterTest, ExtractBits) {
+ auto* func = b.Function("foo", ty.void_(), core::ir::Function::PipelineStage::kFragment);
+ b.Append(func->Block(), [&] {
+ b.Let("x", b.Call(ty.u32(), core::BuiltinFn::kExtractBits, 1_u, 2_u, 3_u));
+ b.Return(func);
+ });
+
+ ASSERT_TRUE(Generate()) << err_ << output_.glsl;
+ EXPECT_EQ(output_.glsl, GlslHeader() + R"(precision highp float;
+precision highp int;
+
+void main() {
+ uint v = min(2u, 32u);
+ uint v_1 = min(3u, (32u - v));
+ int v_2 = int(v);
+ uint x = bitfieldExtract(1u, v_2, int(v_1));
+}
+)");
+}
+
} // namespace
} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc b/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
index b135a2d..658f861 100644
--- a/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
+++ b/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
@@ -83,6 +83,7 @@
case core::BuiltinFn::kAtomicSub:
case core::BuiltinFn::kAtomicLoad:
case core::BuiltinFn::kCountOneBits:
+ case core::BuiltinFn::kExtractBits:
case core::BuiltinFn::kSelect:
case core::BuiltinFn::kStorageBarrier:
case core::BuiltinFn::kTextureBarrier:
@@ -112,6 +113,9 @@
case core::BuiltinFn::kCountOneBits:
CountOneBits(call);
break;
+ case core::BuiltinFn::kExtractBits:
+ ExtractBits(call);
+ break;
case core::BuiltinFn::kSelect:
Select(call);
break;
@@ -151,6 +155,18 @@
}
}
+ void ExtractBits(core::ir::Call* call) {
+ b.InsertBefore(call, [&] {
+ auto args = call->Args();
+ auto* offset = b.Convert(ty.i32(), args[1]);
+ auto* bits = b.Convert(ty.i32(), args[2]);
+
+ b.CallWithResult<glsl::ir::BuiltinCall>(
+ call->DetachResult(), glsl::BuiltinFn::kBitfieldExtract, args[0], offset, bits);
+ });
+ call->Destroy();
+ }
+
// GLSL `bitCount` always returns an `i32` so we need to convert it. Convert to a `bitCount`
// call to make it clear this isn't `countOneBits`.
void CountOneBits(core::ir::Call* call) {
diff --git a/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc b/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc
index 7778114..bd27adf 100644
--- a/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc
+++ b/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc
@@ -1476,5 +1476,39 @@
EXPECT_EQ(expect, str());
}
+TEST_F(GlslWriter_BuiltinPolyfillTest, ExtractBits) {
+ auto* func = b.Function("foo", ty.void_(), core::ir::Function::PipelineStage::kFragment);
+ b.Append(func->Block(), [&] {
+ b.Let("x", b.Call(ty.u32(), core::BuiltinFn::kExtractBits, 1_u, 2_u, 3_u));
+ b.Return(func);
+ });
+
+ auto* src = R"(
+%foo = @fragment func():void {
+ $B1: {
+ %2:u32 = extractBits 1u, 2u, 3u
+ %x:u32 = let %2
+ ret
+ }
+}
+)";
+ EXPECT_EQ(src, str());
+
+ auto* expect = R"(
+%foo = @fragment func():void {
+ $B1: {
+ %2:i32 = convert 2u
+ %3:i32 = convert 3u
+ %4:u32 = glsl.bitfieldExtract 1u, %2, %3
+ %x:u32 = let %4
+ ret
+ }
+}
+)";
+
+ Run(BuiltinPolyfill);
+ EXPECT_EQ(expect, str());
+}
+
} // namespace
} // namespace tint::glsl::writer::raise
diff --git a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.glsl b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.glsl
index 0d096f0..80d615a 100644
--- a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.glsl
@@ -1,11 +1,17 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
-
-tint executable returned error: signal: trace/BPT trap
+void f_1() {
+ int v = 0;
+ uint offset_1 = 0u;
+ uint count = 0u;
+ int v_1 = v;
+ uint v_2 = count;
+ uint v_3 = min(offset_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ int x_14 = bitfieldExtract(v_1, v_5, int(v_4));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}
diff --git a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.glsl b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.glsl
index 0d096f0..15d41ad 100644
--- a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.glsl
@@ -1,11 +1,17 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
-
-tint executable returned error: signal: trace/BPT trap
+void f_1() {
+ uint v = 0u;
+ uint offset_1 = 0u;
+ uint count = 0u;
+ uint v_1 = v;
+ uint v_2 = count;
+ uint v_3 = min(offset_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uint x_11 = bitfieldExtract(v_1, v_5, int(v_4));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}
diff --git a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.glsl b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.glsl
index 0d096f0..8f7de87 100644
--- a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.glsl
@@ -1,11 +1,17 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
-
-tint executable returned error: signal: trace/BPT trap
+void f_1() {
+ ivec3 v = ivec3(0);
+ uint offset_1 = 0u;
+ uint count = 0u;
+ ivec3 v_1 = v;
+ uint v_2 = count;
+ uint v_3 = min(offset_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec3 x_15 = bitfieldExtract(v_1, v_5, int(v_4));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}
diff --git a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.glsl b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.glsl
index 0d096f0..d8d5c5d 100644
--- a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.glsl
@@ -1,11 +1,17 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
-
-tint executable returned error: signal: trace/BPT trap
+void f_1() {
+ uvec3 v = uvec3(0u);
+ uint offset_1 = 0u;
+ uint count = 0u;
+ uvec3 v_1 = v;
+ uint v_2 = count;
+ uint v_3 = min(offset_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec3 x_14 = bitfieldExtract(v_1, v_5, int(v_4));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}
diff --git a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.glsl
index 0d096f0..cf95e05 100644
--- a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec3 tint_symbol;
+} v;
+uvec3 extractBits_12b197() {
+ uvec3 arg_0 = uvec3(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec3 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec3 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_12b197();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec3 tint_symbol;
+} v;
+uvec3 extractBits_12b197() {
+ uvec3 arg_0 = uvec3(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec3 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec3 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_12b197();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ uvec3 prevent_dce;
+};
+
+layout(location = 0) flat out uvec3 vertex_main_loc0_Output;
+uvec3 extractBits_12b197() {
+ uvec3 arg_0 = uvec3(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec3 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ uvec3 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), uvec3(0u));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_12b197();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.glsl
index 0d096f0..6205dd2 100644
--- a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ int tint_symbol;
+} v;
+int extractBits_249874() {
+ int arg_0 = 1;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ int v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ int res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_249874();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ int tint_symbol;
+} v;
+int extractBits_249874() {
+ int arg_0 = 1;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ int v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ int res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_249874();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ int prevent_dce;
+};
+
+layout(location = 0) flat out int vertex_main_loc0_Output;
+int extractBits_249874() {
+ int arg_0 = 1;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ int v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ int res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), 0);
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_249874();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.glsl
index 0d096f0..7482898 100644
--- a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec4 tint_symbol;
+} v;
+uvec4 extractBits_631377() {
+ uvec4 arg_0 = uvec4(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec4 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec4 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_631377();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec4 tint_symbol;
+} v;
+uvec4 extractBits_631377() {
+ uvec4 arg_0 = uvec4(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec4 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec4 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_631377();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ uvec4 prevent_dce;
+};
+
+layout(location = 0) flat out uvec4 vertex_main_loc0_Output;
+uvec4 extractBits_631377() {
+ uvec4 arg_0 = uvec4(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec4 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ uvec4 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), uvec4(0u));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_631377();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.glsl
index 0d096f0..a1f9652 100644
--- a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec2 tint_symbol;
+} v;
+ivec2 extractBits_a99a8d() {
+ ivec2 arg_0 = ivec2(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec2 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec2 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_a99a8d();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec2 tint_symbol;
+} v;
+ivec2 extractBits_a99a8d() {
+ ivec2 arg_0 = ivec2(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec2 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec2 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_a99a8d();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ ivec2 prevent_dce;
+};
+
+layout(location = 0) flat out ivec2 vertex_main_loc0_Output;
+ivec2 extractBits_a99a8d() {
+ ivec2 arg_0 = ivec2(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec2 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ ivec2 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), ivec2(0));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_a99a8d();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.glsl
index 0d096f0..db55c6b 100644
--- a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uint tint_symbol;
+} v;
+uint extractBits_ce81f8() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uint res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_ce81f8();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uint tint_symbol;
+} v;
+uint extractBits_ce81f8() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uint res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_ce81f8();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ uint prevent_dce;
+};
+
+layout(location = 0) flat out uint vertex_main_loc0_Output;
+uint extractBits_ce81f8() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ uint res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), 0u);
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_ce81f8();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.glsl
index 0d096f0..a118919 100644
--- a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec3 tint_symbol;
+} v;
+ivec3 extractBits_e04f5d() {
+ ivec3 arg_0 = ivec3(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec3 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec3 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_e04f5d();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec3 tint_symbol;
+} v;
+ivec3 extractBits_e04f5d() {
+ ivec3 arg_0 = ivec3(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec3 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec3 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_e04f5d();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ ivec3 prevent_dce;
+};
+
+layout(location = 0) flat out ivec3 vertex_main_loc0_Output;
+ivec3 extractBits_e04f5d() {
+ ivec3 arg_0 = ivec3(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec3 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ ivec3 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), ivec3(0));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_e04f5d();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.glsl
index 0d096f0..6da5715 100644
--- a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec2 tint_symbol;
+} v;
+uvec2 extractBits_f28f69() {
+ uvec2 arg_0 = uvec2(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec2 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec2 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_f28f69();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ uvec2 tint_symbol;
+} v;
+uvec2 extractBits_f28f69() {
+ uvec2 arg_0 = uvec2(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec2 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uvec2 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_f28f69();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ uvec2 prevent_dce;
+};
+
+layout(location = 0) flat out uvec2 vertex_main_loc0_Output;
+uvec2 extractBits_f28f69() {
+ uvec2 arg_0 = uvec2(1u);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uvec2 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ uvec2 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), uvec2(0u));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_f28f69();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.glsl
index 0d096f0..277e719 100644
--- a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.glsl
@@ -1,11 +1,80 @@
-SKIP: FAILED
+#version 310 es
+precision highp float;
+precision highp int;
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: extractBits
-********************************************************************
-* The tint shader compiler has encountered an unexpected error. *
-* *
-* Please help us fix this issue by submitting a bug report at *
-* crbug.com/tint with the source program that triggered the bug. *
-********************************************************************
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec4 tint_symbol;
+} v;
+ivec4 extractBits_fb850f() {
+ ivec4 arg_0 = ivec4(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec4 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec4 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+void main() {
+ v.tint_symbol = extractBits_fb850f();
+}
+#version 310 es
-tint executable returned error: signal: trace/BPT trap
+layout(binding = 0, std430)
+buffer tint_symbol_1_1_ssbo {
+ ivec4 tint_symbol;
+} v;
+ivec4 extractBits_fb850f() {
+ ivec4 arg_0 = ivec4(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec4 v_1 = arg_0;
+ uint v_2 = arg_2;
+ uint v_3 = min(arg_1, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ ivec4 res = bitfieldExtract(v_1, v_5, int(v_4));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = extractBits_fb850f();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ ivec4 prevent_dce;
+};
+
+layout(location = 0) flat out ivec4 vertex_main_loc0_Output;
+ivec4 extractBits_fb850f() {
+ ivec4 arg_0 = ivec4(1);
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ ivec4 v = arg_0;
+ uint v_1 = arg_2;
+ uint v_2 = min(arg_1, 32u);
+ uint v_3 = min(v_1, (32u - v_2));
+ int v_4 = int(v_2);
+ ivec4 res = bitfieldExtract(v, v_4, int(v_3));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), ivec4(0));
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = extractBits_fb850f();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_5 = vertex_main_inner();
+ gl_Position = v_5.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_5.prevent_dce;
+ gl_PointSize = 1.0f;
+}