tools/tint/intrinsic: Sort enum values lexicographically

Reorders the output of the CanonicalizeEntryPointIO transform, but
otherwise is a no-op.

This will help with diagnostics that print the enum values.

Bug: tint:1629
Change-Id: Iff517d88836d2a8cd42ce3cfde6363c1973df0dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105321
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2022-10-11 18:26:18 +00:00 committed by Dawn LUCI CQ
parent ae832a2c6a
commit db368f1b9c
18 changed files with 427 additions and 418 deletions

View File

@ -34,17 +34,17 @@ AddressSpace ParseAddressSpace(std::string_view str) {
if (str == "private") {
return AddressSpace::kPrivate;
}
if (str == "workgroup") {
return AddressSpace::kWorkgroup;
}
if (str == "uniform") {
return AddressSpace::kUniform;
if (str == "push_constant") {
return AddressSpace::kPushConstant;
}
if (str == "storage") {
return AddressSpace::kStorage;
}
if (str == "push_constant") {
return AddressSpace::kPushConstant;
if (str == "uniform") {
return AddressSpace::kUniform;
}
if (str == "workgroup") {
return AddressSpace::kWorkgroup;
}
return AddressSpace::kInvalid;
}
@ -53,26 +53,26 @@ std::ostream& operator<<(std::ostream& out, AddressSpace value) {
switch (value) {
case AddressSpace::kInvalid:
return out << "invalid";
case AddressSpace::kNone:
return out << "none";
case AddressSpace::kFunction:
return out << "function";
case AddressSpace::kPrivate:
return out << "private";
case AddressSpace::kWorkgroup:
return out << "workgroup";
case AddressSpace::kUniform:
return out << "uniform";
case AddressSpace::kStorage:
return out << "storage";
case AddressSpace::kPushConstant:
return out << "push_constant";
case AddressSpace::kHandle:
return out << "handle";
case AddressSpace::kIn:
return out << "in";
case AddressSpace::kNone:
return out << "none";
case AddressSpace::kOut:
return out << "out";
case AddressSpace::kPrivate:
return out << "private";
case AddressSpace::kPushConstant:
return out << "push_constant";
case AddressSpace::kStorage:
return out << "storage";
case AddressSpace::kUniform:
return out << "uniform";
case AddressSpace::kWorkgroup:
return out << "workgroup";
}
return out << "<unknown>";
}

View File

@ -30,16 +30,16 @@ namespace tint::ast {
/// Address space of a given pointer.
enum class AddressSpace {
kInvalid,
kNone, // Tint-internal enum entry - not parsed
kFunction,
kPrivate,
kWorkgroup,
kUniform,
kStorage,
kPushConstant,
kHandle, // Tint-internal enum entry - not parsed
kIn, // Tint-internal enum entry - not parsed
kNone, // Tint-internal enum entry - not parsed
kOut, // Tint-internal enum entry - not parsed
kPrivate,
kPushConstant,
kStorage,
kUniform,
kWorkgroup,
};
/// @param out the std::ostream to write to

View File

@ -31,48 +31,15 @@ namespace {
void AddressSpaceParser(::benchmark::State& state) {
std::array kStrings{
"fccnctin",
"ucti3",
"functVon",
"function",
"1unction",
"unJtqqon",
"llun77tion",
"ppqqivtHH",
"prcv",
"bivaGe",
"private",
"priviive",
"8WWivate",
"pxxvate",
"wXkgrggup",
"worXVup",
"3orkgroup",
"workgroup",
"workgroEp",
"woTTPkroup",
"ddorkroxxp",
"u44iform",
"unSSfoVVm",
"RniR22m",
"uniform",
"uFfo9m",
"uniorm",
"VOORRHrm",
"straye",
"llntrrr77ge",
"stor4g00",
"storage",
"trooe",
"zzrage",
"siioppa1",
"puXXh_constant",
"pusII9_nn55nstant",
"YusHH_coaastSSrnt",
"push_constant",
"pushonkkHan",
"jush_consgRt",
"puh_cobsant",
"fccnctin", "ucti3", "functVon", "function", "1unction",
"unJtqqon", "llun77tion", "ppqqivtHH", "prcv", "bivaGe",
"private", "priviive", "8WWivate", "pxxvate", "pXh_cggnstant",
"pX_Vonstanu", "push_consta3t", "push_constant", "push_constanE", "push_TTPnstant",
"puxxdh_constan", "s44orage", "stSSraVVe", "RtoR22e", "storage",
"sFra9e", "stoage", "VOORRHge", "unfoym", "llnnrrf77rm",
"unif4r00", "uniform", "nfoom", "zzform", "uiiippo1",
"workgrouXX", "wor55gro99nII", "wrrrkgroSSaHH", "workgroup", "kkrHoup",
"jgkrouRR", "wokroub",
};
for (auto _ : state) {
for (auto& str : kStrings) {

View File

@ -42,21 +42,24 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"function", AddressSpace::kFunction}, {"private", AddressSpace::kPrivate},
{"workgroup", AddressSpace::kWorkgroup}, {"uniform", AddressSpace::kUniform},
{"storage", AddressSpace::kStorage}, {"push_constant", AddressSpace::kPushConstant},
{"function", AddressSpace::kFunction},
{"private", AddressSpace::kPrivate},
{"push_constant", AddressSpace::kPushConstant},
{"storage", AddressSpace::kStorage},
{"uniform", AddressSpace::kUniform},
{"workgroup", AddressSpace::kWorkgroup},
};
static constexpr Case kInvalidCases[] = {
{"fccnctin", AddressSpace::kInvalid}, {"ucti3", AddressSpace::kInvalid},
{"functVon", AddressSpace::kInvalid}, {"priv1te", AddressSpace::kInvalid},
{"pqiJate", AddressSpace::kInvalid}, {"privat7ll", AddressSpace::kInvalid},
{"workroppqHH", AddressSpace::kInvalid}, {"workru", AddressSpace::kInvalid},
{"wbkgGoup", AddressSpace::kInvalid}, {"unifiivm", AddressSpace::kInvalid},
{"8WWiform", AddressSpace::kInvalid}, {"uxxform", AddressSpace::kInvalid},
{"sXraggg", AddressSpace::kInvalid}, {"traXe", AddressSpace::kInvalid},
{"stor3ge", AddressSpace::kInvalid}, {"push_constanE", AddressSpace::kInvalid},
{"push_TTPnstant", AddressSpace::kInvalid}, {"puxxdh_constan", AddressSpace::kInvalid},
{"fccnctin", AddressSpace::kInvalid}, {"ucti3", AddressSpace::kInvalid},
{"functVon", AddressSpace::kInvalid}, {"priv1te", AddressSpace::kInvalid},
{"pqiJate", AddressSpace::kInvalid}, {"privat7ll", AddressSpace::kInvalid},
{"pqqsh_pponstHnt", AddressSpace::kInvalid}, {"pus_cnstat", AddressSpace::kInvalid},
{"bus_Gonstant", AddressSpace::kInvalid}, {"storiive", AddressSpace::kInvalid},
{"8WWorage", AddressSpace::kInvalid}, {"sxxrage", AddressSpace::kInvalid},
{"uXforgg", AddressSpace::kInvalid}, {"nfoXm", AddressSpace::kInvalid},
{"unif3rm", AddressSpace::kInvalid}, {"workgroEp", AddressSpace::kInvalid},
{"woTTPkroup", AddressSpace::kInvalid}, {"ddorkroxxp", AddressSpace::kInvalid},
};
using AddressSpaceParseTest = testing::TestWithParam<Case>;

View File

@ -28,20 +28,17 @@ namespace tint::ast {
/// @param str the string to parse
/// @returns the parsed enum, or BuiltinValue::kInvalid if the string could not be parsed.
BuiltinValue ParseBuiltinValue(std::string_view str) {
if (str == "position") {
return BuiltinValue::kPosition;
}
if (str == "vertex_index") {
return BuiltinValue::kVertexIndex;
}
if (str == "instance_index") {
return BuiltinValue::kInstanceIndex;
if (str == "frag_depth") {
return BuiltinValue::kFragDepth;
}
if (str == "front_facing") {
return BuiltinValue::kFrontFacing;
}
if (str == "frag_depth") {
return BuiltinValue::kFragDepth;
if (str == "global_invocation_id") {
return BuiltinValue::kGlobalInvocationId;
}
if (str == "instance_index") {
return BuiltinValue::kInstanceIndex;
}
if (str == "local_invocation_id") {
return BuiltinValue::kLocalInvocationId;
@ -49,21 +46,24 @@ BuiltinValue ParseBuiltinValue(std::string_view str) {
if (str == "local_invocation_index") {
return BuiltinValue::kLocalInvocationIndex;
}
if (str == "global_invocation_id") {
return BuiltinValue::kGlobalInvocationId;
}
if (str == "workgroup_id") {
return BuiltinValue::kWorkgroupId;
}
if (str == "num_workgroups") {
return BuiltinValue::kNumWorkgroups;
}
if (str == "position") {
return BuiltinValue::kPosition;
}
if (str == "sample_index") {
return BuiltinValue::kSampleIndex;
}
if (str == "sample_mask") {
return BuiltinValue::kSampleMask;
}
if (str == "vertex_index") {
return BuiltinValue::kVertexIndex;
}
if (str == "workgroup_id") {
return BuiltinValue::kWorkgroupId;
}
return BuiltinValue::kInvalid;
}
@ -71,32 +71,32 @@ std::ostream& operator<<(std::ostream& out, BuiltinValue value) {
switch (value) {
case BuiltinValue::kInvalid:
return out << "invalid";
case BuiltinValue::kPosition:
return out << "position";
case BuiltinValue::kVertexIndex:
return out << "vertex_index";
case BuiltinValue::kInstanceIndex:
return out << "instance_index";
case BuiltinValue::kFrontFacing:
return out << "front_facing";
case BuiltinValue::kFragDepth:
return out << "frag_depth";
case BuiltinValue::kFrontFacing:
return out << "front_facing";
case BuiltinValue::kGlobalInvocationId:
return out << "global_invocation_id";
case BuiltinValue::kInstanceIndex:
return out << "instance_index";
case BuiltinValue::kLocalInvocationId:
return out << "local_invocation_id";
case BuiltinValue::kLocalInvocationIndex:
return out << "local_invocation_index";
case BuiltinValue::kGlobalInvocationId:
return out << "global_invocation_id";
case BuiltinValue::kWorkgroupId:
return out << "workgroup_id";
case BuiltinValue::kNumWorkgroups:
return out << "num_workgroups";
case BuiltinValue::kPointSize:
return out << "point_size";
case BuiltinValue::kPosition:
return out << "position";
case BuiltinValue::kSampleIndex:
return out << "sample_index";
case BuiltinValue::kSampleMask:
return out << "sample_mask";
case BuiltinValue::kPointSize:
return out << "point_size";
case BuiltinValue::kVertexIndex:
return out << "vertex_index";
case BuiltinValue::kWorkgroupId:
return out << "workgroup_id";
}
return out << "<unknown>";
}

View File

@ -30,19 +30,19 @@ namespace tint::ast {
/// Storage class of a given pointer.
enum class BuiltinValue {
kInvalid,
kPosition,
kVertexIndex,
kInstanceIndex,
kFrontFacing,
kFragDepth,
kFrontFacing,
kGlobalInvocationId,
kInstanceIndex,
kLocalInvocationId,
kLocalInvocationIndex,
kGlobalInvocationId,
kWorkgroupId,
kNumWorkgroups,
kPointSize, // Tint-internal enum entry - not parsed
kPosition,
kSampleIndex,
kSampleMask,
kPointSize, // Tint-internal enum entry - not parsed
kVertexIndex,
kWorkgroupId,
};
/// @param out the std::ostream to write to

View File

@ -31,90 +31,90 @@ namespace {
void BuiltinValueParser(::benchmark::State& state) {
std::array kStrings{
"pccsitin",
"oiti3",
"positVon",
"position",
"1osition",
"osJtqqon",
"llos77tion",
"vrtHHppx_index",
"vertx_icx",
"veGtex_bnde",
"vertex_index",
"vertex_inveii",
"veWWtex_ind8x",
"vxxrtMx_indx",
"isXance_indegg",
"insanc_iXVex",
"instance_in3ex",
"instance_index",
"instancE_index",
"nsTTance_PPndex",
"nstancxx_indddx",
"44ront_facing",
"fSSont_facinVV",
"fronR_Racing",
"front_facing",
"ron9_faciFg",
"front_facin",
"fVonRR_HaOing",
"fyag_epth",
"f77ag_nnellrrh",
"fra400depth",
"fragdeccth",
"flaget3",
"fVag_depth",
"frag_depth",
"fa_epooh",
"frg_ezzth",
"f11a_eppiih",
"local_invXXcation_id",
"lIIcal_i5599ocation_inn",
"HHrrcal_inSSocation_Yaa",
"local_invocation_id",
"lokkal_invocatini",
"jocal_invocRRongid",
"local_inocatbon_i",
"local_injocation_index",
"local_invocatio_index",
"locl_invocqtion_ndex",
"local_invocation_index",
"localNNinvocaton_index",
"local_invocatin_ivvdx",
"locl_invocatioQQ_index",
"globalrnvocaton_iff",
"global_invocation_jd",
"NNlbal_wwnvocation82d",
"frag1depth",
"fraJqqepth",
"fra7ll_depth",
"fonHHpp_facing",
"fron_facg",
"frGnt_fbcin",
"front_facing",
"front_facvnii",
"frWWnt_faci8g",
"fxxonM_facig",
"gXobalgginvocationid",
"goVal_uvocatioX_id",
"global_in3ocation_id",
"global_invocation_id",
"global_invocationid",
"globalrrinvocation_id",
"globaG_invocation_id",
"workgroupFFid",
"worgrupid",
"workgroup_rr",
"workgroup_id",
"workgrouid",
"DokgXoJJp_id",
"8orgrup_i",
"num_wkkr11up",
"numworkgroups",
"Ju_workgroups",
"global_invocation_iE",
"TTobal_invocationPPid",
"globdd_invocatioxx_id",
"instance44index",
"instaVVce_SSndex",
"Rnstane_ind2Rx",
"instance_index",
"inFtanceind9x",
"insance_index",
"inRRancV_OOHdex",
"local_nvocytion_id",
"llGcnnl_inv77catirrn_id",
"local_invoca4i00n_id",
"local_invocation_id",
"loool_nvocaton_id",
"local_inozztion_id",
"p11cal_invocatiiin_i",
"local_invocation_iXXdex",
"local_invnnIIati99n55index",
"localYirrHHocaationSSindex",
"local_invocation_index",
"lkkal_invHcation_idx",
"gRcal_invocatioj_inex",
"lcal_invcbtion_index",
"num_workgroujs",
"num_worgroups",
"nuq_orkgoups",
"num_workgroups",
"num_corkgroups",
"num_woOkgroups",
"num_workKK__vvttps",
"smple5inxxe8",
"s__mle_qFdex",
"saqqple_idex",
"nm_workgroNNps",
"um_workgrovps",
"nQQm_orkgroups",
"posftrn",
"pojition",
"poswNN82n",
"position",
"positon",
"porrition",
"pGsition",
"sample_inFFex",
"samleinex",
"sample_indrr",
"sample_index",
"saOpe_33nde66",
"s6oople_indttQx",
"sam66le_inex",
"samxe66masOz",
"yyample_mask",
"amplZZHask",
"sample_iex",
"DaplX_JJndex",
"8amleinde",
"saplekmak",
"samle_mask",
"saJple_mak",
"sample_mask",
"WWaple_maq4k",
"samplOO_ask",
"sYohpe_msk",
"sample_cask",
"sample_maOk",
"__attpvve_KKask",
"vrtex5inxxe8",
"v__rex_qFdex",
"veqqtex_idex",
"vertex_index",
"veOtx_33nde66",
"v6ootex_indttQx",
"ver66ex_inex",
"worzzroup6Oxd",
"workgroyyp_id",
"wokrHHZpZid",
"workgroup_id",
"wWWkgqoup44id",
"wrkgroOOp_id",
"hrkgYooup_d",
};
for (auto _ : state) {
for (auto& str : kStrings) {

View File

@ -42,57 +42,57 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"position", BuiltinValue::kPosition},
{"vertex_index", BuiltinValue::kVertexIndex},
{"instance_index", BuiltinValue::kInstanceIndex},
{"front_facing", BuiltinValue::kFrontFacing},
{"frag_depth", BuiltinValue::kFragDepth},
{"front_facing", BuiltinValue::kFrontFacing},
{"global_invocation_id", BuiltinValue::kGlobalInvocationId},
{"instance_index", BuiltinValue::kInstanceIndex},
{"local_invocation_id", BuiltinValue::kLocalInvocationId},
{"local_invocation_index", BuiltinValue::kLocalInvocationIndex},
{"global_invocation_id", BuiltinValue::kGlobalInvocationId},
{"workgroup_id", BuiltinValue::kWorkgroupId},
{"num_workgroups", BuiltinValue::kNumWorkgroups},
{"position", BuiltinValue::kPosition},
{"sample_index", BuiltinValue::kSampleIndex},
{"sample_mask", BuiltinValue::kSampleMask},
{"vertex_index", BuiltinValue::kVertexIndex},
{"workgroup_id", BuiltinValue::kWorkgroupId},
};
static constexpr Case kInvalidCases[] = {
{"pccsitin", BuiltinValue::kInvalid},
{"oiti3", BuiltinValue::kInvalid},
{"positVon", BuiltinValue::kInvalid},
{"1ertex_index", BuiltinValue::kInvalid},
{"vertex_Jnqex", BuiltinValue::kInvalid},
{"velltex_inde77", BuiltinValue::kInvalid},
{"inpptanceqHHindx", BuiltinValue::kInvalid},
{"cnsanvendex", BuiltinValue::kInvalid},
{"istancG_index", BuiltinValue::kInvalid},
{"front_facvnii", BuiltinValue::kInvalid},
{"frWWnt_faci8g", BuiltinValue::kInvalid},
{"fxxonM_facig", BuiltinValue::kInvalid},
{"fXag_detgg", BuiltinValue::kInvalid},
{"fag_XuVh", BuiltinValue::kInvalid},
{"frag_dept3", BuiltinValue::kInvalid},
{"local_Envocation_id", BuiltinValue::kInvalid},
{"localiPPvocatioTT_id", BuiltinValue::kInvalid},
{"localxxnvocationddid", BuiltinValue::kInvalid},
{"loca44_invocation_index", BuiltinValue::kInvalid},
{"local_invocSStionVVindex", BuiltinValue::kInvalid},
{"locRR_invocat22n_index", BuiltinValue::kInvalid},
{"globalFinvoction_id", BuiltinValue::kInvalid},
{"gloal_invocation_id", BuiltinValue::kInvalid},
{"RRlHOOaV_invoction_id", BuiltinValue::kInvalid},
{"workgyoup_i", BuiltinValue::kInvalid},
{"wnrrrkg77loup_Gd", BuiltinValue::kInvalid},
{"00orkgr4up_id", BuiltinValue::kInvalid},
{"numwroogrops", BuiltinValue::kInvalid},
{"nzm_wokgroups", BuiltinValue::kInvalid},
{"uippworkgro11ps", BuiltinValue::kInvalid},
{"sample_iXXdex", BuiltinValue::kInvalid},
{"5nnample_99IIdex", BuiltinValue::kInvalid},
{"samYlaaHHrrndeSS", BuiltinValue::kInvalid},
{"aHkk_mask", BuiltinValue::kInvalid},
{"jRRmpl_gsk", BuiltinValue::kInvalid},
{"smple_mbk", BuiltinValue::kInvalid},
{"fragdeccth", BuiltinValue::kInvalid},
{"flaget3", BuiltinValue::kInvalid},
{"fVag_depth", BuiltinValue::kInvalid},
{"1ront_facing", BuiltinValue::kInvalid},
{"front_fJcqng", BuiltinValue::kInvalid},
{"frllnt_facin77", BuiltinValue::kInvalid},
{"global_invoqqtionppHid", BuiltinValue::kInvalid},
{"clvbal_inocaionid", BuiltinValue::kInvalid},
{"global_Gvocation_id", BuiltinValue::kInvalid},
{"invtance_iniiex", BuiltinValue::kInvalid},
{"8nstanceWWindex", BuiltinValue::kInvalid},
{"insxxanceindex", BuiltinValue::kInvalid},
{"lXcal_invoation_igg", BuiltinValue::kInvalid},
{"Xocal_nvocatin_Vd", BuiltinValue::kInvalid},
{"local_invoca3ion_id", BuiltinValue::kInvalid},
{"local_invocation_indeE", BuiltinValue::kInvalid},
{"loTTal_invPPcatin_index", BuiltinValue::kInvalid},
{"loal_invocadxxion_index", BuiltinValue::kInvalid},
{"num_work44roups", BuiltinValue::kInvalid},
{"num_wVVrkgSSoups", BuiltinValue::kInvalid},
{"Rum_wokgrou2Rs", BuiltinValue::kInvalid},
{"oFi9ion", BuiltinValue::kInvalid},
{"postion", BuiltinValue::kInvalid},
{"ROOoHiiVn", BuiltinValue::kInvalid},
{"samply_inde", BuiltinValue::kInvalid},
{"snrrmpl77l_indGx", BuiltinValue::kInvalid},
{"00ample4index", BuiltinValue::kInvalid},
{"smoo_mask", BuiltinValue::kInvalid},
{"sampzemask", BuiltinValue::kInvalid},
{"ppaplii1_mas", BuiltinValue::kInvalid},
{"vertex_iXXdex", BuiltinValue::kInvalid},
{"5nnertex_99IIdex", BuiltinValue::kInvalid},
{"verYeaaHHrrndeSS", BuiltinValue::kInvalid},
{"workkgHo_i", BuiltinValue::kInvalid},
{"worRgoupjid", BuiltinValue::kInvalid},
{"wrkgrupbid", BuiltinValue::kInvalid},
};
using BuiltinValueParseTest = testing::TestWithParam<Case>;

View File

@ -28,18 +28,18 @@ namespace tint::ast {
/// @param str the string to parse
/// @returns the parsed enum, or Extension::kInvalid if the string could not be parsed.
Extension ParseExtension(std::string_view str) {
if (str == "f16") {
return Extension::kF16;
if (str == "chromium_disable_uniformity_analysis") {
return Extension::kChromiumDisableUniformityAnalysis;
}
if (str == "chromium_experimental_dp4a") {
return Extension::kChromiumExperimentalDp4A;
}
if (str == "chromium_disable_uniformity_analysis") {
return Extension::kChromiumDisableUniformityAnalysis;
}
if (str == "chromium_experimental_push_constant") {
return Extension::kChromiumExperimentalPushConstant;
}
if (str == "f16") {
return Extension::kF16;
}
return Extension::kInvalid;
}
@ -47,14 +47,14 @@ std::ostream& operator<<(std::ostream& out, Extension value) {
switch (value) {
case Extension::kInvalid:
return out << "invalid";
case Extension::kF16:
return out << "f16";
case Extension::kChromiumExperimentalDp4A:
return out << "chromium_experimental_dp4a";
case Extension::kChromiumDisableUniformityAnalysis:
return out << "chromium_disable_uniformity_analysis";
case Extension::kChromiumExperimentalDp4A:
return out << "chromium_experimental_dp4a";
case Extension::kChromiumExperimentalPushConstant:
return out << "chromium_experimental_push_constant";
case Extension::kF16:
return out << "f16";
}
return out << "<unknown>";
}

View File

@ -33,10 +33,10 @@ namespace tint::ast {
/// @see src/tint/intrinsics.def for extension descriptions
enum class Extension {
kInvalid,
kF16,
kChromiumExperimentalDp4A,
kChromiumDisableUniformityAnalysis,
kChromiumExperimentalDp4A,
kChromiumExperimentalPushConstant,
kF16,
};
/// @param out the std::ostream to write to

View File

@ -31,13 +31,13 @@ namespace {
void ExtensionParser(::benchmark::State& state) {
std::array kStrings{
"cc6",
"s",
"HH6",
"f16",
"116",
"qJ6",
"f17ll",
"chromium_disableuniformiccy_analysis",
"chromil3_disable_unifority_analss",
"chromium_disable_Vniformity_analysis",
"chromium_disable_uniformity_analysis",
"chromium_dis1ble_uniformity_analysis",
"chromium_qqisable_unifomity_anaJysis",
"chrollium_disable_uniformity_analysi77",
"chromippHm_experqqmetal_dp4a",
"chrmium_expecimntal_dp4",
"chrmiumGexpebimental_dp4a",
@ -45,20 +45,20 @@ void ExtensionParser(::benchmark::State& state) {
"chromium_exverimentiil_dp4a",
"chro8ium_experimenWWal_dp4a",
"chromiMm_eperimxxntal_dp4a",
"chXggmium_disable_uniformity_aalysis",
"Xhomiuu_disale_uniformity_analysis",
"chromium_3isable_uniformity_analysis",
"chromium_disable_uniformity_analysis",
"chromiuE_disable_uniformity_analysis",
"chromium_disable_uniTTormity_aPPalsis",
"ddhromium_disabexxuniformity_analysis",
"c44romium_experimental_push_constant",
"chromium_experimental_pSSsVV_constant",
"chrom22Rm_experimental_pushRonstant",
"chrXmium_experimeggtal_ush_constant",
"chromiu_experVmentalpusX_constant",
"chro3ium_experimental_push_constant",
"chromium_experimental_push_constant",
"chromium_exp9rimFntal_ush_constant",
"chrmium_experimental_push_constant",
"cOOromium_experiVeHtal_puh_conRRtant",
"chromium_experEmental_push_constant",
"chPPomiumexperimental_push_conTTtant",
"chromixxm_experimentddl_push_constnt",
"4416",
"fSVV6",
"RR2",
"f16",
"96",
"f1",
"VOR6",
};
for (auto _ : state) {
for (auto& str : kStrings) {

View File

@ -42,25 +42,25 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"f16", Extension::kF16},
{"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A},
{"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis},
{"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A},
{"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant},
{"f16", Extension::kF16},
};
static constexpr Case kInvalidCases[] = {
{"cc6", Extension::kInvalid},
{"s", Extension::kInvalid},
{"HH6", Extension::kInvalid},
{"chromium_disableuniformiccy_analysis", Extension::kInvalid},
{"chromil3_disable_unifority_analss", Extension::kInvalid},
{"chromium_disable_Vniformity_analysis", Extension::kInvalid},
{"chro1ium_experimental_dp4a", Extension::kInvalid},
{"chrJmium_experiqqetal_dp4a", Extension::kInvalid},
{"chromium_experimenll77l_dp4a", Extension::kInvalid},
{"chromiumppdisableqquniformity_aalysHHs", Extension::kInvalid},
{"chromiu_disable_unifovmitc_analyi", Extension::kInvalid},
{"chromium_diable_uGbformity_analysis", Extension::kInvalid},
{"chvomium_experimental_push_constiint", Extension::kInvalid},
{"chromiu8WWexperimental_push_constant", Extension::kInvalid},
{"chromium_experiMental_push_costanxx", Extension::kInvalid},
{"cppromium_experiHHenal_qqush_constant", Extension::kInvalid},
{"chromium_xpericental_sh_vonstant", Extension::kInvalid},
{"chromium_experimental_Gsh_cbnstant", Extension::kInvalid},
{"f1vi", Extension::kInvalid},
{"f8WW", Extension::kInvalid},
{"fxx", Extension::kInvalid},
};
using ExtensionParseTest = testing::TestWithParam<Case>;

View File

@ -28,8 +28,44 @@ namespace tint::ast {
/// @param str the string to parse
/// @returns the parsed enum, or TexelFormat::kInvalid if the string could not be parsed.
TexelFormat ParseTexelFormat(std::string_view str) {
if (str == "rgba8unorm") {
return TexelFormat::kRgba8Unorm;
if (str == "r32float") {
return TexelFormat::kR32Float;
}
if (str == "r32sint") {
return TexelFormat::kR32Sint;
}
if (str == "r32uint") {
return TexelFormat::kR32Uint;
}
if (str == "rg32float") {
return TexelFormat::kRg32Float;
}
if (str == "rg32sint") {
return TexelFormat::kRg32Sint;
}
if (str == "rg32uint") {
return TexelFormat::kRg32Uint;
}
if (str == "rgba16float") {
return TexelFormat::kRgba16Float;
}
if (str == "rgba16sint") {
return TexelFormat::kRgba16Sint;
}
if (str == "rgba16uint") {
return TexelFormat::kRgba16Uint;
}
if (str == "rgba32float") {
return TexelFormat::kRgba32Float;
}
if (str == "rgba32sint") {
return TexelFormat::kRgba32Sint;
}
if (str == "rgba32uint") {
return TexelFormat::kRgba32Uint;
}
if (str == "rgba8sint") {
return TexelFormat::kRgba8Sint;
}
if (str == "rgba8snorm") {
return TexelFormat::kRgba8Snorm;
@ -37,44 +73,8 @@ TexelFormat ParseTexelFormat(std::string_view str) {
if (str == "rgba8uint") {
return TexelFormat::kRgba8Uint;
}
if (str == "rgba8sint") {
return TexelFormat::kRgba8Sint;
}
if (str == "rgba16uint") {
return TexelFormat::kRgba16Uint;
}
if (str == "rgba16sint") {
return TexelFormat::kRgba16Sint;
}
if (str == "rgba16float") {
return TexelFormat::kRgba16Float;
}
if (str == "r32uint") {
return TexelFormat::kR32Uint;
}
if (str == "r32sint") {
return TexelFormat::kR32Sint;
}
if (str == "r32float") {
return TexelFormat::kR32Float;
}
if (str == "rg32uint") {
return TexelFormat::kRg32Uint;
}
if (str == "rg32sint") {
return TexelFormat::kRg32Sint;
}
if (str == "rg32float") {
return TexelFormat::kRg32Float;
}
if (str == "rgba32uint") {
return TexelFormat::kRgba32Uint;
}
if (str == "rgba32sint") {
return TexelFormat::kRgba32Sint;
}
if (str == "rgba32float") {
return TexelFormat::kRgba32Float;
if (str == "rgba8unorm") {
return TexelFormat::kRgba8Unorm;
}
return TexelFormat::kInvalid;
}
@ -83,38 +83,38 @@ std::ostream& operator<<(std::ostream& out, TexelFormat value) {
switch (value) {
case TexelFormat::kInvalid:
return out << "invalid";
case TexelFormat::kRgba8Unorm:
return out << "rgba8unorm";
case TexelFormat::kR32Float:
return out << "r32float";
case TexelFormat::kR32Sint:
return out << "r32sint";
case TexelFormat::kR32Uint:
return out << "r32uint";
case TexelFormat::kRg32Float:
return out << "rg32float";
case TexelFormat::kRg32Sint:
return out << "rg32sint";
case TexelFormat::kRg32Uint:
return out << "rg32uint";
case TexelFormat::kRgba16Float:
return out << "rgba16float";
case TexelFormat::kRgba16Sint:
return out << "rgba16sint";
case TexelFormat::kRgba16Uint:
return out << "rgba16uint";
case TexelFormat::kRgba32Float:
return out << "rgba32float";
case TexelFormat::kRgba32Sint:
return out << "rgba32sint";
case TexelFormat::kRgba32Uint:
return out << "rgba32uint";
case TexelFormat::kRgba8Sint:
return out << "rgba8sint";
case TexelFormat::kRgba8Snorm:
return out << "rgba8snorm";
case TexelFormat::kRgba8Uint:
return out << "rgba8uint";
case TexelFormat::kRgba8Sint:
return out << "rgba8sint";
case TexelFormat::kRgba16Uint:
return out << "rgba16uint";
case TexelFormat::kRgba16Sint:
return out << "rgba16sint";
case TexelFormat::kRgba16Float:
return out << "rgba16float";
case TexelFormat::kR32Uint:
return out << "r32uint";
case TexelFormat::kR32Sint:
return out << "r32sint";
case TexelFormat::kR32Float:
return out << "r32float";
case TexelFormat::kRg32Uint:
return out << "rg32uint";
case TexelFormat::kRg32Sint:
return out << "rg32sint";
case TexelFormat::kRg32Float:
return out << "rg32float";
case TexelFormat::kRgba32Uint:
return out << "rgba32uint";
case TexelFormat::kRgba32Sint:
return out << "rgba32sint";
case TexelFormat::kRgba32Float:
return out << "rgba32float";
case TexelFormat::kRgba8Unorm:
return out << "rgba8unorm";
}
return out << "<unknown>";
}

View File

@ -30,22 +30,22 @@ namespace tint::ast {
/// Enumerator of texel formats
enum class TexelFormat {
kInvalid,
kRgba8Unorm,
kR32Float,
kR32Sint,
kR32Uint,
kRg32Float,
kRg32Sint,
kRg32Uint,
kRgba16Float,
kRgba16Sint,
kRgba16Uint,
kRgba32Float,
kRgba32Sint,
kRgba32Uint,
kRgba8Sint,
kRgba8Snorm,
kRgba8Uint,
kRgba8Sint,
kRgba16Uint,
kRgba16Sint,
kRgba16Float,
kR32Uint,
kR32Sint,
kR32Float,
kRg32Uint,
kRg32Sint,
kRg32Float,
kRgba32Uint,
kRgba32Sint,
kRgba32Float,
kRgba8Unorm,
};
/// @param out the std::ostream to write to

View File

@ -31,29 +31,29 @@ namespace {
void TexelFormatParser(::benchmark::State& state) {
std::array kStrings{
"rgbaunccrm", "rlbanr3", "rVba8unorm", "rgba8unorm", "rgba1unorm",
"rgbJqqnorm", "rgb7ll8unorm", "rgqqappnoHHm", "rv8scor", "rgbbGsnrm",
"rgba8snorm", "rgba8vniirm", "rg8a8snoWWm", "Mgbaxxnorm", "rXa8uggnt",
"rgbXVut", "3gba8uint", "rgba8uint", "rgba8uiEt", "rgTTPauint",
"ddgbauixxt", "44gba8sint", "VVgbaSSsint", "rba8si2Rt", "rgba8sint",
"r9bFsint", "rgba8int", "rgVROOsHnt", "ryba1uint", "r77ba1nnullrrt",
"rgb4006uint", "rgba16uint", "rb1uioot", "rga1uzznt", "r11b1uppiit",
"XXgba16sint", "IIgb9916nni55t", "rYbaSSrrsiHHat", "rgba16sint", "rbkk6Hit",
"jgba1sgRR", "rgbab6si", "rgba16fljat", "rgba6float", "rbq6float",
"rgba16float", "rgba1NNloat", "rgbvv6flot", "rgbaQQ6foat", "r3ffir",
"r32uijt", "rNNwuin8", "r32uint", "r32int", "rrr2uint",
"G32uint", "r32sinFF", "32st", "r3rrint", "r32sint",
"2sint", "D3siJJt", "r38n", "r211lk", "r32floa",
"r3flJat", "r32float", "r32fcoat", "r32floOt", "r32floKK_vtt",
"rxx32ui8", "Fg3qq__n", "rg32iqqt", "rg32uint", "rg333uin6",
"rtto62u9QQt", "rg366uin", "rOx2si6zz", "rg3yysint", "rHHsint",
"rg32sint", "qWW432snt", "rg3OOsnt", "g32siYt", "g32flo",
"rg32foaF", "rg32fwat", "rg32float", "G3fKoaff", "KKgq2float",
"rg32mmlo3t", "rgba32uit", "rqba3uint", "rgbabb2uin", "rgba32uint",
"rba32iint", "qgba32uiOt", "rgba32uiTTvv", "rgFFa32sint", "rg00Q2sPnt",
"rgbaP2sint", "rgba32sint", "rgb77s2sint", "rgba32sbbRRC", "rgbXX32sint",
"rOOOba3CCqoat", "rgbu32fsLt", "rgba3Xfloat", "rgba32float", "rba32float",
"qqb3float", "rgba32fl22at",
"rcc2flot", "3flo3", "r32flVat", "r32float", "132float",
"32Jlqqat", "ll3277loat", "ppqq2snHH", "r3cv", "b2siGt",
"r32sint", "r32siivt", "8WW2sint", "rxxsint", "rXuingg",
"3uiXt", "r32u3nt", "r32uint", "E32uint", "rPTTuint",
"r32uidxx", "44g32float", "VVg32SSloat", "r32flo2Rt", "rg32float",
"r93Float", "rg32foat", "rgVROOlHat", "rg3ysin", "77grr2sllnnt",
"04g32sint", "rg32sint", "g3oont", "rg32zzt", "rgiipps1n",
"XXg32uint", "rII39955nnnt", "aagHH2uinYSS", "rg32uint", "rkk3it",
"gj3uRRn", "r3bunt", "rgba16fljat", "rgba6float", "rbq6float",
"rgba16float", "rgba1NNloat", "rgbvv6flot", "rgbaQQ6foat", "rgb6srnff",
"rgba16sijt", "NNgba16ww2t", "rgba16sint", "rgba16snt", "rgba16rrint",
"rgba1Gsint", "rgba16uFFnt", "g16uEnt", "rgb16rrint", "rgba16uint",
"gba16uit", "rXa1DuiJJt", "rgauint", "rga32klot", "rgb32float",
"rgJa32flot", "rgba32float", "rgba32fcoat", "rgba32floOt", "__gttavv2fKKoat",
"rg5a32xxnt", "__ba3sqqFt", "rgbqq2sint", "rgba32sint", "33ba32s66nt",
"rtt6a3QQooint", "r66ba3sint", "xba32zzinO6", "ryyba32uint", "rbZ32HinZ",
"rgba32uint", "rgba3u4WWnq", "rgba32uOOt", "oogba2Yin", "gba8si",
"rgba8inF", "rgba8wnt", "rgba8sint", "Gb8Kinff", "KKgqa8sint",
"rgbammsi3t", "rgba8snom", "rqba8norm", "rgbabbsnor", "rgba8snorm",
"rba8siorm", "qgba8snoOm", "rgba8snoTTvv", "rgbaFFuint", "rgQa00uiP",
"rgPa8uint", "rgba8uint", "rgssa77unt", "Cgbbb8uiRRt", "rgba8uinXX",
"CqgbaOOunorm", "rgbu8usrL", "rgba8Xnorm", "rgba8unorm", "rgba8unrm",
"ba8uqqor", "rgba8unor22",
};
for (auto _ : state) {
for (auto& str : kStrings) {

View File

@ -42,41 +42,41 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"rgba8unorm", TexelFormat::kRgba8Unorm}, {"rgba8snorm", TexelFormat::kRgba8Snorm},
{"rgba8uint", TexelFormat::kRgba8Uint}, {"rgba8sint", TexelFormat::kRgba8Sint},
{"rgba16uint", TexelFormat::kRgba16Uint}, {"rgba16sint", TexelFormat::kRgba16Sint},
{"rgba16float", TexelFormat::kRgba16Float}, {"r32uint", TexelFormat::kR32Uint},
{"r32sint", TexelFormat::kR32Sint}, {"r32float", TexelFormat::kR32Float},
{"rg32uint", TexelFormat::kRg32Uint}, {"rg32sint", TexelFormat::kRg32Sint},
{"rg32float", TexelFormat::kRg32Float}, {"rgba32uint", TexelFormat::kRgba32Uint},
{"rgba32sint", TexelFormat::kRgba32Sint}, {"rgba32float", TexelFormat::kRgba32Float},
{"r32float", TexelFormat::kR32Float}, {"r32sint", TexelFormat::kR32Sint},
{"r32uint", TexelFormat::kR32Uint}, {"rg32float", TexelFormat::kRg32Float},
{"rg32sint", TexelFormat::kRg32Sint}, {"rg32uint", TexelFormat::kRg32Uint},
{"rgba16float", TexelFormat::kRgba16Float}, {"rgba16sint", TexelFormat::kRgba16Sint},
{"rgba16uint", TexelFormat::kRgba16Uint}, {"rgba32float", TexelFormat::kRgba32Float},
{"rgba32sint", TexelFormat::kRgba32Sint}, {"rgba32uint", TexelFormat::kRgba32Uint},
{"rgba8sint", TexelFormat::kRgba8Sint}, {"rgba8snorm", TexelFormat::kRgba8Snorm},
{"rgba8uint", TexelFormat::kRgba8Uint}, {"rgba8unorm", TexelFormat::kRgba8Unorm},
};
static constexpr Case kInvalidCases[] = {
{"rgbaunccrm", TexelFormat::kInvalid}, {"rlbanr3", TexelFormat::kInvalid},
{"rVba8unorm", TexelFormat::kInvalid}, {"rgba1snorm", TexelFormat::kInvalid},
{"rgbJqqnorm", TexelFormat::kInvalid}, {"rgb7ll8snorm", TexelFormat::kInvalid},
{"rgbauippqHH", TexelFormat::kInvalid}, {"rgbaun", TexelFormat::kInvalid},
{"rba8Gint", TexelFormat::kInvalid}, {"rgvia8sint", TexelFormat::kInvalid},
{"rgba8WWint", TexelFormat::kInvalid}, {"rgbasxxMt", TexelFormat::kInvalid},
{"rXba16ungg", TexelFormat::kInvalid}, {"rba1XuVt", TexelFormat::kInvalid},
{"rgba16uin3", TexelFormat::kInvalid}, {"rgba16sinE", TexelFormat::kInvalid},
{"TTgba16sPPn", TexelFormat::kInvalid}, {"rgbad6xxint", TexelFormat::kInvalid},
{"rgba446float", TexelFormat::kInvalid}, {"SSVVba16float", TexelFormat::kInvalid},
{"rgbRR6float", TexelFormat::kInvalid}, {"rFui9t", TexelFormat::kInvalid},
{"r32int", TexelFormat::kInvalid}, {"VOORRHnt", TexelFormat::kInvalid},
{"r3siyt", TexelFormat::kInvalid}, {"lln3rrs77nt", TexelFormat::kInvalid},
{"r32s4n00", TexelFormat::kInvalid}, {"32ooat", TexelFormat::kInvalid},
{"r32fzzt", TexelFormat::kInvalid}, {"r3iippl1a", TexelFormat::kInvalid},
{"XXg32uint", TexelFormat::kInvalid}, {"rII39955nnnt", TexelFormat::kInvalid},
{"aagHH2uinYSS", TexelFormat::kInvalid}, {"rkk3it", TexelFormat::kInvalid},
{"gj3sRRn", TexelFormat::kInvalid}, {"r3bsnt", TexelFormat::kInvalid},
{"rg32flojt", TexelFormat::kInvalid}, {"r32floa", TexelFormat::kInvalid},
{"rg32lot", TexelFormat::kInvalid}, {"rgb3uit", TexelFormat::kInvalid},
{"rgjj3uint", TexelFormat::kInvalid}, {"rgb2urnff", TexelFormat::kInvalid},
{"rgba32sijt", TexelFormat::kInvalid}, {"NNgba32ww2t", TexelFormat::kInvalid},
{"rgba32snt", TexelFormat::kInvalid}, {"rgba32rrloat", TexelFormat::kInvalid},
{"rgGa32float", TexelFormat::kInvalid}, {"FFgba32float", TexelFormat::kInvalid},
{"rcc2flot", TexelFormat::kInvalid}, {"3flo3", TexelFormat::kInvalid},
{"r32flVat", TexelFormat::kInvalid}, {"r32s1nt", TexelFormat::kInvalid},
{"rq2Jint", TexelFormat::kInvalid}, {"r32sin7ll", TexelFormat::kInvalid},
{"ppqq2unHH", TexelFormat::kInvalid}, {"r3cv", TexelFormat::kInvalid},
{"b2uiGt", TexelFormat::kInvalid}, {"rgvi2float", TexelFormat::kInvalid},
{"rg328WWoat", TexelFormat::kInvalid}, {"rg32lxxMt", TexelFormat::kInvalid},
{"rgXggsnt", TexelFormat::kInvalid}, {"rgXsnu", TexelFormat::kInvalid},
{"rg32s3nt", TexelFormat::kInvalid}, {"rg3Euint", TexelFormat::kInvalid},
{"PP32TTint", TexelFormat::kInvalid}, {"xxg32ddnt", TexelFormat::kInvalid},
{"rgba446float", TexelFormat::kInvalid}, {"SSVVba16float", TexelFormat::kInvalid},
{"rgbRR6float", TexelFormat::kInvalid}, {"rga16Fint", TexelFormat::kInvalid},
{"rgb16sint", TexelFormat::kInvalid}, {"ORVHa16sint", TexelFormat::kInvalid},
{"ryba1uint", TexelFormat::kInvalid}, {"r77ba1nnullrrt", TexelFormat::kInvalid},
{"rgb4006uint", TexelFormat::kInvalid}, {"rboofloat", TexelFormat::kInvalid},
{"rgbaz2loat", TexelFormat::kInvalid}, {"ppga3ii1floa", TexelFormat::kInvalid},
{"XXgba32sint", TexelFormat::kInvalid}, {"IIgb9932nni55t", TexelFormat::kInvalid},
{"rYbaSSrrsiHHat", TexelFormat::kInvalid}, {"rbkk2Hit", TexelFormat::kInvalid},
{"jgba3ugRR", TexelFormat::kInvalid}, {"rgbab2ui", TexelFormat::kInvalid},
{"rgba8sijt", TexelFormat::kInvalid}, {"rba8sint", TexelFormat::kInvalid},
{"rba8sqt", TexelFormat::kInvalid}, {"rgba8NNnom", TexelFormat::kInvalid},
{"rga8vvorm", TexelFormat::kInvalid}, {"rgba8snorQ", TexelFormat::kInvalid},
{"rgbauirf", TexelFormat::kInvalid}, {"rgbajuint", TexelFormat::kInvalid},
{"wNNgbauin2", TexelFormat::kInvalid}, {"rgba8unrm", TexelFormat::kInvalid},
{"rgba8urrorm", TexelFormat::kInvalid}, {"rgba8Gnorm", TexelFormat::kInvalid},
};
using TexelFormatParseTest = testing::TestWithParam<Case>;

View File

@ -45,6 +45,42 @@ struct MemberInfo {
std::optional<uint32_t> location;
};
/// FXC is sensitive to field order in structures, this is used by StructMemberComparator to ensure
/// that FXC is happy with the order of emitted fields.
uint32_t BuiltinOrder(ast::BuiltinValue builtin) {
switch (builtin) {
case ast::BuiltinValue::kPosition:
return 1;
case ast::BuiltinValue::kVertexIndex:
return 2;
case ast::BuiltinValue::kInstanceIndex:
return 3;
case ast::BuiltinValue::kFrontFacing:
return 4;
case ast::BuiltinValue::kFragDepth:
return 5;
case ast::BuiltinValue::kLocalInvocationId:
return 6;
case ast::BuiltinValue::kLocalInvocationIndex:
return 7;
case ast::BuiltinValue::kGlobalInvocationId:
return 8;
case ast::BuiltinValue::kWorkgroupId:
return 9;
case ast::BuiltinValue::kNumWorkgroups:
return 10;
case ast::BuiltinValue::kSampleIndex:
return 11;
case ast::BuiltinValue::kSampleMask:
return 12;
case ast::BuiltinValue::kPointSize:
return 13;
default:
break;
}
return 0;
}
/// Comparison function used to reorder struct members such that all members with
/// location attributes appear first (ordered by location slot), followed by
/// those with builtin attributes.
@ -68,8 +104,8 @@ bool StructMemberComparator(const MemberInfo& a, const MemberInfo& b) {
// `b` has location attribute and `a` does not: `b` goes first.
return false;
}
// Both are builtins: order doesn't matter, just use enum value.
return a_blt->builtin < b_blt->builtin;
// Both are builtins: order matters for FXC.
return BuiltinOrder(a_blt->builtin) < BuiltinOrder(b_blt->builtin);
}
}

View File

@ -148,6 +148,9 @@ func (r *resolver) enum(e ast.EnumDecl) error {
names.Add(ast.Name)
}
// Sort the enum entries into lexicographic order
sort.Slice(s.Entries, func(i, j int) bool { return s.Entries[i].Name < s.Entries[j].Name })
return nil
}