[glsl][ir] Polyfill the `insertBits` call
This Cl implements the `insertBits` WGSL call in terms of the
`bitfieldInsert` GLSL call.
Bug: 42251044
Change-Id: I58f6a4457b24bc300df93ff5c4bf8ad6477e2eed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/206814
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/cmd/fuzz/wgsl/dictionary.txt b/src/tint/cmd/fuzz/wgsl/dictionary.txt
index 20f39a9..9277be7 100644
--- a/src/tint/cmd/fuzz/wgsl/dictionary.txt
+++ b/src/tint/cmd/fuzz/wgsl/dictionary.txt
@@ -144,6 +144,7 @@
"atomicSub"
"atomicXor"
"b"
+"base"
"bgra8unorm"
"binding"
"bitcast"
@@ -249,6 +250,7 @@
"inputAttachmentLoad"
"input_attachment"
"input_attachment_index"
+"insert"
"insertBits"
"instance_index"
"interpolate"
diff --git a/src/tint/lang/core/core.def b/src/tint/lang/core/core.def
index b7fcdea..3f4b944 100644
--- a/src/tint/lang/core/core.def
+++ b/src/tint/lang/core/core.def
@@ -230,11 +230,13 @@
// These are parameter usages which show up in other def files but not in core.def.
enum usages {
+ base
bits
depth
compare_value
elements
height
+ insert
level
location
num_levels
diff --git a/src/tint/lang/core/parameter_usage.cc b/src/tint/lang/core/parameter_usage.cc
index e33497b..fe04938 100644
--- a/src/tint/lang/core/parameter_usage.cc
+++ b/src/tint/lang/core/parameter_usage.cc
@@ -44,6 +44,8 @@
return "none";
case ParameterUsage::kArrayIndex:
return "array_index";
+ case ParameterUsage::kBase:
+ return "base";
case ParameterUsage::kBias:
return "bias";
case ParameterUsage::kBits:
@@ -74,6 +76,8 @@
return "id";
case ParameterUsage::kInputAttachment:
return "input_attachment";
+ case ParameterUsage::kInsert:
+ return "insert";
case ParameterUsage::kLevel:
return "level";
case ParameterUsage::kLocation:
diff --git a/src/tint/lang/core/parameter_usage.h b/src/tint/lang/core/parameter_usage.h
index 8a8ca8d..76283be 100644
--- a/src/tint/lang/core/parameter_usage.h
+++ b/src/tint/lang/core/parameter_usage.h
@@ -48,6 +48,7 @@
/// overload position
enum class ParameterUsage : uint8_t {
kArrayIndex,
+ kBase,
kBias,
kBits,
kCompareValue,
@@ -63,6 +64,7 @@
kHeight,
kId,
kInputAttachment,
+ kInsert,
kLevel,
kLocation,
kMask,
diff --git a/src/tint/lang/glsl/builtin_fn.cc b/src/tint/lang/glsl/builtin_fn.cc
index 32299c4..24ce141 100644
--- a/src/tint/lang/glsl/builtin_fn.cc
+++ b/src/tint/lang/glsl/builtin_fn.cc
@@ -64,6 +64,8 @@
return "bitCount";
case BuiltinFn::kBitfieldExtract:
return "bitfieldExtract";
+ case BuiltinFn::kBitfieldInsert:
+ return "bitfieldInsert";
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 9f7de1d..5012d9f 100644
--- a/src/tint/lang/glsl/builtin_fn.h
+++ b/src/tint/lang/glsl/builtin_fn.h
@@ -58,6 +58,7 @@
kUintBitsToFloat,
kBitCount,
kBitfieldExtract,
+ kBitfieldInsert,
kPackFloat2X16,
kUnpackFloat2X16,
kTextureSize,
diff --git a/src/tint/lang/glsl/glsl.def b/src/tint/lang/glsl/glsl.def
index 62aa028..53d4d61 100644
--- a/src/tint/lang/glsl/glsl.def
+++ b/src/tint/lang/glsl/glsl.def
@@ -117,6 +117,12 @@
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>
+implicit(T: iu32) fn bitfieldInsert(base: T, insert: T, offset: i32, bits: i32) -> T
+implicit(T: iu32, N: num) fn bitfieldExtract(base: vec<N, T>,
+ insert: 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 4506581..44bfd68 100644
--- a/src/tint/lang/glsl/intrinsic/data.cc
+++ b/src/tint/lang/glsl/intrinsic/data.cc
@@ -765,33 +765,33 @@
constexpr ParameterInfo kParameters[] = {
{
/* [0] */
- /* usage */ core::ParameterUsage::kNone,
- /* matcher_indices */ MatcherIndicesIndex(0),
+ /* usage */ core::ParameterUsage::kBase,
+ /* matcher_indices */ MatcherIndicesIndex(22),
},
{
/* [1] */
- /* usage */ core::ParameterUsage::kCompareValue,
- /* matcher_indices */ MatcherIndicesIndex(3),
+ /* usage */ core::ParameterUsage::kInsert,
+ /* matcher_indices */ MatcherIndicesIndex(22),
},
{
/* [2] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(3),
- },
- {
- /* [3] */
/* usage */ core::ParameterUsage::kOffset,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
- /* [4] */
+ /* [3] */
/* usage */ core::ParameterUsage::kBits,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
+ /* [4] */
+ /* usage */ core::ParameterUsage::kBase,
+ /* matcher_indices */ MatcherIndicesIndex(3),
+ },
+ {
/* [5] */
- /* usage */ core::ParameterUsage::kValue,
- /* matcher_indices */ MatcherIndicesIndex(22),
+ /* usage */ core::ParameterUsage::kInsert,
+ /* matcher_indices */ MatcherIndicesIndex(3),
},
{
/* [6] */
@@ -806,57 +806,57 @@
{
/* [8] */
/* usage */ core::ParameterUsage::kNone,
- /* matcher_indices */ MatcherIndicesIndex(5),
+ /* matcher_indices */ MatcherIndicesIndex(0),
},
{
/* [9] */
- /* usage */ core::ParameterUsage::kNone,
+ /* usage */ core::ParameterUsage::kCompareValue,
/* matcher_indices */ MatcherIndicesIndex(3),
},
{
/* [10] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(39),
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(3),
},
{
/* [11] */
- /* usage */ core::ParameterUsage::kLevel,
+ /* usage */ core::ParameterUsage::kOffset,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
/* [12] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(43),
- },
- {
- /* [13] */
- /* usage */ core::ParameterUsage::kLevel,
+ /* usage */ core::ParameterUsage::kBits,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
+ /* [13] */
+ /* usage */ core::ParameterUsage::kValue,
+ /* matcher_indices */ MatcherIndicesIndex(22),
+ },
+ {
/* [14] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(47),
+ /* usage */ core::ParameterUsage::kOffset,
+ /* matcher_indices */ MatcherIndicesIndex(12),
},
{
/* [15] */
- /* usage */ core::ParameterUsage::kLevel,
+ /* usage */ core::ParameterUsage::kBits,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
/* [16] */
- /* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(49),
+ /* usage */ core::ParameterUsage::kNone,
+ /* matcher_indices */ MatcherIndicesIndex(5),
},
{
/* [17] */
- /* usage */ core::ParameterUsage::kLevel,
- /* matcher_indices */ MatcherIndicesIndex(12),
+ /* usage */ core::ParameterUsage::kNone,
+ /* matcher_indices */ MatcherIndicesIndex(3),
},
{
/* [18] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(51),
+ /* matcher_indices */ MatcherIndicesIndex(39),
},
{
/* [19] */
@@ -866,7 +866,7 @@
{
/* [20] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(53),
+ /* matcher_indices */ MatcherIndicesIndex(43),
},
{
/* [21] */
@@ -876,7 +876,7 @@
{
/* [22] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(59),
+ /* matcher_indices */ MatcherIndicesIndex(47),
},
{
/* [23] */
@@ -886,7 +886,7 @@
{
/* [24] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(60),
+ /* matcher_indices */ MatcherIndicesIndex(49),
},
{
/* [25] */
@@ -896,7 +896,7 @@
{
/* [26] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(61),
+ /* matcher_indices */ MatcherIndicesIndex(51),
},
{
/* [27] */
@@ -906,7 +906,7 @@
{
/* [28] */
/* usage */ core::ParameterUsage::kTexture,
- /* matcher_indices */ MatcherIndicesIndex(62),
+ /* matcher_indices */ MatcherIndicesIndex(53),
},
{
/* [29] */
@@ -915,66 +915,106 @@
},
{
/* [30] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(59),
+ },
+ {
+ /* [31] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [32] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(60),
+ },
+ {
+ /* [33] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [34] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(61),
+ },
+ {
+ /* [35] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [36] */
+ /* usage */ core::ParameterUsage::kTexture,
+ /* matcher_indices */ MatcherIndicesIndex(62),
+ },
+ {
+ /* [37] */
+ /* usage */ core::ParameterUsage::kLevel,
+ /* matcher_indices */ MatcherIndicesIndex(12),
+ },
+ {
+ /* [38] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(1),
},
{
- /* [31] */
+ /* [39] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(13),
},
{
- /* [32] */
+ /* [40] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(12),
},
{
- /* [33] */
+ /* [41] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(10),
},
{
- /* [34] */
+ /* [42] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(18),
},
{
- /* [35] */
+ /* [43] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(16),
},
{
- /* [36] */
+ /* [44] */
/* usage */ core::ParameterUsage::kValue,
/* matcher_indices */ MatcherIndicesIndex(37),
},
{
- /* [37] */
+ /* [45] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(55),
},
{
- /* [38] */
+ /* [46] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(63),
},
{
- /* [39] */
+ /* [47] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(25),
},
{
- /* [40] */
+ /* [48] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(28),
},
{
- /* [41] */
+ /* [49] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(31),
},
{
- /* [42] */
+ /* [50] */
/* usage */ core::ParameterUsage::kTexture,
/* matcher_indices */ MatcherIndicesIndex(34),
},
@@ -1039,7 +1079,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(10),
+ /* parameters */ ParameterIndex(18),
/* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1050,7 +1090,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(12),
+ /* parameters */ ParameterIndex(20),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1061,7 +1101,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(14),
+ /* parameters */ ParameterIndex(22),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1072,7 +1112,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(16),
+ /* parameters */ ParameterIndex(24),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1083,7 +1123,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(18),
+ /* parameters */ ParameterIndex(26),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1094,7 +1134,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(20),
+ /* parameters */ ParameterIndex(28),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1105,7 +1145,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(22),
+ /* parameters */ ParameterIndex(30),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1116,7 +1156,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(24),
+ /* parameters */ ParameterIndex(32),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1127,7 +1167,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(26),
+ /* parameters */ ParameterIndex(34),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1138,7 +1178,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(28),
+ /* parameters */ ParameterIndex(36),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1149,7 +1189,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(6),
- /* parameters */ ParameterIndex(37),
+ /* parameters */ ParameterIndex(45),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1160,7 +1200,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 0,
/* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(38),
+ /* parameters */ ParameterIndex(46),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1171,7 +1211,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(39),
+ /* parameters */ ParameterIndex(47),
/* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1182,7 +1222,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(40),
+ /* parameters */ ParameterIndex(48),
/* return_matcher_indices */ MatcherIndicesIndex(41),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1193,7 +1233,7 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(41),
+ /* parameters */ ParameterIndex(49),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1204,41 +1244,41 @@
/* num_explicit_templates */ 0,
/* num_templates */ 2,
/* templates */ TemplateIndex(4),
- /* parameters */ ParameterIndex(42),
+ /* parameters */ ParameterIndex(50),
/* return_matcher_indices */ MatcherIndicesIndex(45),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [16] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 1,
+ /* num_parameters */ 3,
/* num_explicit_templates */ 0,
- /* num_templates */ 0,
- /* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(30),
- /* return_matcher_indices */ MatcherIndicesIndex(12),
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(0),
+ /* parameters */ ParameterIndex(10),
+ /* return_matcher_indices */ MatcherIndicesIndex(3),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [17] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 1,
+ /* num_parameters */ 3,
/* num_explicit_templates */ 0,
- /* num_templates */ 1,
- /* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(31),
- /* return_matcher_indices */ MatcherIndicesIndex(10),
+ /* num_templates */ 2,
+ /* templates */ TemplateIndex(2),
+ /* parameters */ ParameterIndex(13),
+ /* return_matcher_indices */ MatcherIndicesIndex(22),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [18] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 1,
+ /* num_parameters */ 4,
/* num_explicit_templates */ 0,
- /* num_templates */ 0,
- /* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(30),
- /* return_matcher_indices */ MatcherIndicesIndex(18),
+ /* num_templates */ 2,
+ /* templates */ TemplateIndex(2),
+ /* parameters */ ParameterIndex(0),
+ /* return_matcher_indices */ MatcherIndicesIndex(22),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1246,10 +1286,10 @@
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
- /* num_templates */ 1,
- /* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(31),
- /* return_matcher_indices */ MatcherIndicesIndex(16),
+ /* num_templates */ 0,
+ /* templates */ TemplateIndex(/* invalid */),
+ /* parameters */ ParameterIndex(38),
+ /* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1257,10 +1297,10 @@
/* 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),
- /* return_matcher_indices */ MatcherIndicesIndex(1),
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(3),
+ /* parameters */ ParameterIndex(39),
+ /* return_matcher_indices */ MatcherIndicesIndex(10),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1268,10 +1308,10 @@
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
- /* num_templates */ 1,
- /* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(33),
- /* return_matcher_indices */ MatcherIndicesIndex(13),
+ /* num_templates */ 0,
+ /* templates */ TemplateIndex(/* invalid */),
+ /* parameters */ ParameterIndex(38),
+ /* return_matcher_indices */ MatcherIndicesIndex(18),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1279,10 +1319,10 @@
/* 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(34),
- /* return_matcher_indices */ MatcherIndicesIndex(1),
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(3),
+ /* parameters */ ParameterIndex(39),
+ /* return_matcher_indices */ MatcherIndicesIndex(16),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1290,10 +1330,10 @@
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
- /* num_templates */ 1,
- /* templates */ TemplateIndex(3),
- /* parameters */ ParameterIndex(35),
- /* return_matcher_indices */ MatcherIndicesIndex(13),
+ /* num_templates */ 0,
+ /* templates */ TemplateIndex(/* invalid */),
+ /* parameters */ ParameterIndex(40),
+ /* return_matcher_indices */ MatcherIndicesIndex(1),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1302,9 +1342,9 @@
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
/* num_templates */ 1,
- /* templates */ TemplateIndex(0),
- /* parameters */ ParameterIndex(2),
- /* return_matcher_indices */ MatcherIndicesIndex(12),
+ /* templates */ TemplateIndex(3),
+ /* parameters */ ParameterIndex(41),
+ /* return_matcher_indices */ MatcherIndicesIndex(13),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
@@ -1312,36 +1352,47 @@
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 1,
/* num_explicit_templates */ 0,
- /* num_templates */ 2,
- /* templates */ TemplateIndex(2),
- /* parameters */ ParameterIndex(5),
- /* return_matcher_indices */ MatcherIndicesIndex(19),
+ /* num_templates */ 0,
+ /* templates */ TemplateIndex(/* invalid */),
+ /* parameters */ ParameterIndex(42),
+ /* return_matcher_indices */ MatcherIndicesIndex(1),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [26] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 3,
+ /* num_parameters */ 1,
/* num_explicit_templates */ 0,
/* num_templates */ 1,
- /* templates */ TemplateIndex(0),
- /* parameters */ ParameterIndex(2),
- /* return_matcher_indices */ MatcherIndicesIndex(3),
+ /* templates */ TemplateIndex(3),
+ /* parameters */ ParameterIndex(43),
+ /* return_matcher_indices */ MatcherIndicesIndex(13),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [27] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 3,
+ /* num_parameters */ 1,
/* num_explicit_templates */ 0,
- /* num_templates */ 2,
- /* templates */ TemplateIndex(2),
- /* parameters */ ParameterIndex(5),
- /* return_matcher_indices */ MatcherIndicesIndex(22),
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(0),
+ /* parameters */ ParameterIndex(10),
+ /* return_matcher_indices */ MatcherIndicesIndex(12),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [28] */
+ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
+ /* num_parameters */ 1,
+ /* num_explicit_templates */ 0,
+ /* num_templates */ 2,
+ /* templates */ TemplateIndex(2),
+ /* parameters */ ParameterIndex(13),
+ /* return_matcher_indices */ MatcherIndicesIndex(19),
+ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
+ },
+ {
+ /* [29] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 0,
/* num_explicit_templates */ 0,
@@ -1352,46 +1403,57 @@
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
- /* [29] */
+ /* [30] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* num_parameters */ 3,
/* num_explicit_templates */ 0,
/* num_templates */ 1,
/* templates */ TemplateIndex(0),
- /* parameters */ ParameterIndex(0),
- /* return_matcher_indices */ MatcherIndicesIndex(3),
- /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
- },
- {
- /* [30] */
- /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 2,
- /* num_explicit_templates */ 0,
- /* num_templates */ 2,
- /* templates */ TemplateIndex(0),
/* parameters */ ParameterIndex(8),
/* return_matcher_indices */ MatcherIndicesIndex(3),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [31] */
- /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* num_parameters */ 1,
+ /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
+ /* num_parameters */ 2,
/* num_explicit_templates */ 0,
- /* num_templates */ 0,
- /* templates */ TemplateIndex(/* invalid */),
- /* parameters */ ParameterIndex(36),
- /* return_matcher_indices */ MatcherIndicesIndex(18),
+ /* num_templates */ 2,
+ /* templates */ TemplateIndex(0),
+ /* parameters */ ParameterIndex(16),
+ /* return_matcher_indices */ MatcherIndicesIndex(3),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
{
/* [32] */
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
+ /* num_parameters */ 4,
+ /* num_explicit_templates */ 0,
+ /* num_templates */ 1,
+ /* templates */ TemplateIndex(0),
+ /* parameters */ ParameterIndex(4),
+ /* return_matcher_indices */ MatcherIndicesIndex(3),
+ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
+ },
+ {
+ /* [33] */
+ /* 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(34),
+ /* parameters */ ParameterIndex(44),
+ /* return_matcher_indices */ MatcherIndicesIndex(18),
+ /* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
+ },
+ {
+ /* [34] */
+ /* 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(42),
/* return_matcher_indices */ MatcherIndicesIndex(37),
/* const_eval_fn */ ConstEvalFunctionIndex(/* invalid */),
},
@@ -1405,88 +1467,95 @@
/* [0] */
/* fn barrier() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(28),
+ /* overloads */ OverloadIndex(29),
},
{
/* [1] */
/* fn memoryBarrierBuffer() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(28),
+ /* overloads */ OverloadIndex(29),
},
{
/* [2] */
/* fn memoryBarrierImage() */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(28),
+ /* overloads */ OverloadIndex(29),
},
{
/* [3] */
/* fn atomicCompSwap[T : iu32](ptr<workgroup_or_storage, atomic<T>, read_write>, compare_value: T, value: T) -> T */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(29),
+ /* overloads */ OverloadIndex(30),
},
{
/* [4] */
/* fn atomicSub[T : iu32, S : workgroup_or_storage](ptr<S, atomic<T>, read_write>, T) -> T */
/* num overloads */ 1,
- /* overloads */ OverloadIndex(30),
+ /* overloads */ OverloadIndex(31),
},
{
/* [5] */
/* fn floatBitsToInt(value: f32) -> i32 */
/* fn floatBitsToInt[N : num](value: vec<N, f32>) -> vec<N, i32> */
/* num overloads */ 2,
- /* overloads */ OverloadIndex(16),
+ /* overloads */ OverloadIndex(19),
},
{
/* [6] */
/* fn floatBitsToUint(value: f32) -> u32 */
/* fn floatBitsToUint[N : num](value: vec<N, f32>) -> vec<N, u32> */
/* num overloads */ 2,
- /* overloads */ OverloadIndex(18),
+ /* overloads */ OverloadIndex(21),
},
{
/* [7] */
/* fn intBitsToFloat(value: i32) -> f32 */
/* fn intBitsToFloat[N : num](value: vec<N, i32>) -> vec<N, f32> */
/* num overloads */ 2,
- /* overloads */ OverloadIndex(20),
+ /* overloads */ OverloadIndex(23),
},
{
/* [8] */
/* fn uintBitsToFloat(value: u32) -> f32 */
/* fn uintBitsToFloat[N : num](value: vec<N, u32>) -> vec<N, f32> */
/* num overloads */ 2,
- /* overloads */ OverloadIndex(22),
+ /* overloads */ OverloadIndex(25),
},
{
/* [9] */
/* fn bitCount[T : iu32](value: T) -> i32 */
/* fn bitCount[T : iu32, N : num](value: vec<N, T>) -> vec<N, i32> */
/* num overloads */ 2,
- /* overloads */ OverloadIndex(24),
+ /* overloads */ OverloadIndex(27),
},
{
/* [10] */
/* 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),
+ /* fn bitfieldExtract[T : iu32, N : num](base: vec<N, T>, insert: vec<N, T>, offset: i32, bits: i32) -> vec<N, T> */
+ /* num overloads */ 3,
+ /* overloads */ OverloadIndex(16),
},
{
/* [11] */
- /* fn packFloat2x16(value: vec2<f16>) -> u32 */
- /* num overloads */ 1,
- /* overloads */ OverloadIndex(31),
- },
- {
- /* [12] */
- /* fn unpackFloat2x16(value: u32) -> vec2<f16> */
+ /* fn bitfieldInsert[T : iu32](base: T, insert: T, offset: i32, bits: i32) -> T */
/* num overloads */ 1,
/* overloads */ OverloadIndex(32),
},
{
+ /* [12] */
+ /* fn packFloat2x16(value: vec2<f16>) -> u32 */
+ /* num overloads */ 1,
+ /* overloads */ OverloadIndex(33),
+ },
+ {
/* [13] */
+ /* fn unpackFloat2x16(value: u32) -> vec2<f16> */
+ /* num overloads */ 1,
+ /* overloads */ OverloadIndex(34),
+ },
+ {
+ /* [14] */
/* 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> */
@@ -1503,7 +1572,7 @@
/* overloads */ OverloadIndex(0),
},
{
- /* [14] */
+ /* [15] */
/* 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 a30c0b7..21c0c7c 100644
--- a/src/tint/lang/glsl/writer/builtin_test.cc
+++ b/src/tint/lang/glsl/writer/builtin_test.cc
@@ -994,5 +994,25 @@
)");
}
+TEST_F(GlslWriterTest, InsertBits) {
+ 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::kInsertBits, 1_u, 2_u, 3_u, 4_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(3u, 32u);
+ uint v_1 = min(4u, (32u - v));
+ int v_2 = int(v);
+ uint x = bitfieldInsert(1u, 2u, 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 658f861..bdc7b21 100644
--- a/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
+++ b/src/tint/lang/glsl/writer/raise/builtin_polyfill.cc
@@ -84,6 +84,7 @@
case core::BuiltinFn::kAtomicLoad:
case core::BuiltinFn::kCountOneBits:
case core::BuiltinFn::kExtractBits:
+ case core::BuiltinFn::kInsertBits:
case core::BuiltinFn::kSelect:
case core::BuiltinFn::kStorageBarrier:
case core::BuiltinFn::kTextureBarrier:
@@ -116,6 +117,9 @@
case core::BuiltinFn::kExtractBits:
ExtractBits(call);
break;
+ case core::BuiltinFn::kInsertBits:
+ InsertBits(call);
+ break;
case core::BuiltinFn::kSelect:
Select(call);
break;
@@ -167,6 +171,19 @@
call->Destroy();
}
+ void InsertBits(core::ir::Call* call) {
+ b.InsertBefore(call, [&] {
+ auto args = call->Args();
+ auto* offset = b.Convert(ty.i32(), args[2]);
+ auto* bits = b.Convert(ty.i32(), args[3]);
+
+ b.CallWithResult<glsl::ir::BuiltinCall>(call->DetachResult(),
+ glsl::BuiltinFn::kBitfieldInsert, args[0],
+ args[1], 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 bd27adf..0906251 100644
--- a/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc
+++ b/src/tint/lang/glsl/writer/raise/builtin_polyfill_test.cc
@@ -1510,5 +1510,39 @@
EXPECT_EQ(expect, str());
}
+TEST_F(GlslWriter_BuiltinPolyfillTest, InsertBits) {
+ 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::kInsertBits, 1_u, 2_u, 3_u, 4_u));
+ b.Return(func);
+ });
+
+ auto* src = R"(
+%foo = @fragment func():void {
+ $B1: {
+ %2:u32 = insertBits 1u, 2u, 3u, 4u
+ %x:u32 = let %2
+ ret
+ }
+}
+)";
+ EXPECT_EQ(src, str());
+
+ auto* expect = R"(
+%foo = @fragment func():void {
+ $B1: {
+ %2:i32 = convert 3u
+ %3:i32 = convert 4u
+ %4:u32 = glsl.bitfieldInsert 1u, 2u, %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/gen/var/insertBits/65468b.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/insertBits/65468b.wgsl.expected.ir.glsl
index ec5b2d0..0a41efd 100644
--- a/test/tint/builtins/gen/var/insertBits/65468b.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/insertBits/65468b.wgsl.expected.ir.glsl
@@ -1,11 +1,86 @@
-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: insertBits
-********************************************************************
-* 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 insertBits_65468b() {
+ int arg_0 = 1;
+ int arg_1 = 1;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ int v_1 = arg_0;
+ int v_2 = arg_1;
+ uint v_3 = arg_3;
+ uint v_4 = min(arg_2, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ int res = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+ return res;
+}
+void main() {
+ v.tint_symbol = insertBits_65468b();
+}
+#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 insertBits_65468b() {
+ int arg_0 = 1;
+ int arg_1 = 1;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ int v_1 = arg_0;
+ int v_2 = arg_1;
+ uint v_3 = arg_3;
+ uint v_4 = min(arg_2, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ int res = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = insertBits_65468b();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ int prevent_dce;
+};
+
+layout(location = 0) flat out int vertex_main_loc0_Output;
+int insertBits_65468b() {
+ int arg_0 = 1;
+ int arg_1 = 1;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ int v = arg_0;
+ int v_1 = arg_1;
+ uint v_2 = arg_3;
+ uint v_3 = min(arg_2, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ int res = bitfieldInsert(v, v_1, v_5, int(v_4));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), 0);
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = insertBits_65468b();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_6 = vertex_main_inner();
+ gl_Position = v_6.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_6.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/gen/var/insertBits/e3e3a2.wgsl.expected.ir.glsl b/test/tint/builtins/gen/var/insertBits/e3e3a2.wgsl.expected.ir.glsl
index ec5b2d0..1066ec7 100644
--- a/test/tint/builtins/gen/var/insertBits/e3e3a2.wgsl.expected.ir.glsl
+++ b/test/tint/builtins/gen/var/insertBits/e3e3a2.wgsl.expected.ir.glsl
@@ -1,11 +1,86 @@
-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: insertBits
-********************************************************************
-* 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 insertBits_e3e3a2() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ uint v_1 = arg_0;
+ uint v_2 = arg_1;
+ uint v_3 = arg_3;
+ uint v_4 = min(arg_2, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ uint res = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+ return res;
+}
+void main() {
+ v.tint_symbol = insertBits_e3e3a2();
+}
+#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 insertBits_e3e3a2() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ uint v_1 = arg_0;
+ uint v_2 = arg_1;
+ uint v_3 = arg_3;
+ uint v_4 = min(arg_2, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ uint res = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+ return res;
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ v.tint_symbol = insertBits_e3e3a2();
+}
+#version 310 es
+
+
+struct VertexOutput {
+ vec4 pos;
+ uint prevent_dce;
+};
+
+layout(location = 0) flat out uint vertex_main_loc0_Output;
+uint insertBits_e3e3a2() {
+ uint arg_0 = 1u;
+ uint arg_1 = 1u;
+ uint arg_2 = 1u;
+ uint arg_3 = 1u;
+ uint v = arg_0;
+ uint v_1 = arg_1;
+ uint v_2 = arg_3;
+ uint v_3 = min(arg_2, 32u);
+ uint v_4 = min(v_2, (32u - v_3));
+ int v_5 = int(v_3);
+ uint res = bitfieldInsert(v, v_1, v_5, int(v_4));
+ return res;
+}
+VertexOutput vertex_main_inner() {
+ VertexOutput tint_symbol = VertexOutput(vec4(0.0f), 0u);
+ tint_symbol.pos = vec4(0.0f);
+ tint_symbol.prevent_dce = insertBits_e3e3a2();
+ return tint_symbol;
+}
+void main() {
+ VertexOutput v_6 = vertex_main_inner();
+ gl_Position = v_6.pos;
+ gl_Position[1u] = -(gl_Position.y);
+ gl_Position[2u] = ((2.0f * gl_Position.z) - gl_Position.w);
+ vertex_main_loc0_Output = v_6.prevent_dce;
+ gl_PointSize = 1.0f;
+}
diff --git a/test/tint/builtins/insertBits/scalar/i32.spvasm.expected.ir.glsl b/test/tint/builtins/insertBits/scalar/i32.spvasm.expected.ir.glsl
index ec5b2d0..139c7be 100644
--- a/test/tint/builtins/insertBits/scalar/i32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/insertBits/scalar/i32.spvasm.expected.ir.glsl
@@ -1,11 +1,19 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: insertBits
-********************************************************************
-* 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;
+ int n = 0;
+ uint offset_1 = 0u;
+ uint count = 0u;
+ int v_1 = v;
+ int v_2 = n;
+ uint v_3 = count;
+ uint v_4 = min(offset_1, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ int x_15 = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}
diff --git a/test/tint/builtins/insertBits/scalar/u32.spvasm.expected.ir.glsl b/test/tint/builtins/insertBits/scalar/u32.spvasm.expected.ir.glsl
index ec5b2d0..999e1d7 100644
--- a/test/tint/builtins/insertBits/scalar/u32.spvasm.expected.ir.glsl
+++ b/test/tint/builtins/insertBits/scalar/u32.spvasm.expected.ir.glsl
@@ -1,11 +1,19 @@
-SKIP: FAILED
+#version 310 es
-<dawn>/src/tint/lang/glsl/writer/printer/printer.cc:1423 internal compiler error: TINT_UNREACHABLE unhandled core builtin: insertBits
-********************************************************************
-* 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 n = 0u;
+ uint offset_1 = 0u;
+ uint count = 0u;
+ uint v_1 = v;
+ uint v_2 = n;
+ uint v_3 = count;
+ uint v_4 = min(offset_1, 32u);
+ uint v_5 = min(v_3, (32u - v_4));
+ int v_6 = int(v_4);
+ uint x_12 = bitfieldInsert(v_1, v_2, v_6, int(v_5));
+}
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ f_1();
+}