mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
tint: Add basic support for chromium_experimental_push_constant.
This extension adds support for the push_constant storage class such
that it can be tested with WGSL test files. The real goal is to allow
future transforms that will add push constants that the SPIRV writer
will output.
The extension:
- Adds the `chromium_experimental_push_constant` enable.
- Allows the push_constant storage class for global variables.
- Adds validation that the types are host-shareable for push_constant
variables, and that they don't contain f16 (must be 32bit types
only).
- Validates that at most one push_constant variable is statically used
per entry-point.
- Skips validation that the extension has been enabled if
kIgnoreStorageClass is used.
Tests are added:
- For parsing of var<push_constant>
- Caught a missing conversion.
- For each of the validation rules.
- For the wrapping of push constants in structs if needed by
AddSpirvBlockAttribute.
- For the layout and type rules of the storage class.
- For a shader with multiple entry-points using various push constants.
- Caught a missing reset of the previous push constant variable in
the validation check that at most one is used.
- Caught the missing wrapping in structs that had to be added to
AddSpirvBlockAttribute.
- Caught incorrect logic when adding diagnostics about the call
graph leading to the reference to push constants.
Bug: tint:1620
Change-Id: I04a5d8e5188c0dcef077f2233ba1359d1575bf51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96682
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
24d36b0227
commit
4abf28e29b
@@ -37,6 +37,9 @@ Extension ParseExtension(std::string_view str) {
|
||||
if (str == "chromium_disable_uniformity_analysis") {
|
||||
return Extension::kChromiumDisableUniformityAnalysis;
|
||||
}
|
||||
if (str == "chromium_experimental_push_constant") {
|
||||
return Extension::kChromiumExperimentalPushConstant;
|
||||
}
|
||||
return Extension::kInvalid;
|
||||
}
|
||||
|
||||
@@ -50,6 +53,8 @@ std::ostream& operator<<(std::ostream& out, Extension value) {
|
||||
return out << "chromium_experimental_dp4a";
|
||||
case Extension::kChromiumDisableUniformityAnalysis:
|
||||
return out << "chromium_disable_uniformity_analysis";
|
||||
case Extension::kChromiumExperimentalPushConstant:
|
||||
return out << "chromium_experimental_push_constant";
|
||||
}
|
||||
return out << "<unknown>";
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ enum class Extension {
|
||||
kF16,
|
||||
kChromiumExperimentalDp4A,
|
||||
kChromiumDisableUniformityAnalysis,
|
||||
kChromiumExperimentalPushConstant,
|
||||
};
|
||||
|
||||
/// @param out the std::ostream to write to
|
||||
|
||||
@@ -52,6 +52,13 @@ void ExtensionParser(::benchmark::State& state) {
|
||||
"chromiuE_disable_uniformity_analysis",
|
||||
"chromium_disable_uniTTormity_aPPalsis",
|
||||
"ddhromium_disabexxuniformity_analysis",
|
||||
"c44romium_experimental_push_constant",
|
||||
"chromium_experimental_pSSsVV_constant",
|
||||
"chrom22Rm_experimental_pushRonstant",
|
||||
"chromium_experimental_push_constant",
|
||||
"chromium_exp9rimFntal_ush_constant",
|
||||
"chrmium_experimental_push_constant",
|
||||
"cOOromium_experiVeHtal_puh_conRRtant",
|
||||
};
|
||||
for (auto _ : state) {
|
||||
for (auto& str : kStrings) {
|
||||
|
||||
@@ -45,6 +45,7 @@ static constexpr Case kValidCases[] = {
|
||||
{"f16", Extension::kF16},
|
||||
{"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A},
|
||||
{"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis},
|
||||
{"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant},
|
||||
};
|
||||
|
||||
static constexpr Case kInvalidCases[] = {
|
||||
@@ -57,6 +58,9 @@ static constexpr Case kInvalidCases[] = {
|
||||
{"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},
|
||||
};
|
||||
|
||||
using ExtensionParseTest = testing::TestWithParam<Case>;
|
||||
|
||||
@@ -43,6 +43,9 @@ StorageClass ParseStorageClass(std::string_view str) {
|
||||
if (str == "storage") {
|
||||
return StorageClass::kStorage;
|
||||
}
|
||||
if (str == "push_constant") {
|
||||
return StorageClass::kPushConstant;
|
||||
}
|
||||
return StorageClass::kInvalid;
|
||||
}
|
||||
|
||||
@@ -62,6 +65,8 @@ std::ostream& operator<<(std::ostream& out, StorageClass value) {
|
||||
return out << "uniform";
|
||||
case StorageClass::kStorage:
|
||||
return out << "storage";
|
||||
case StorageClass::kPushConstant:
|
||||
return out << "push_constant";
|
||||
case StorageClass::kHandle:
|
||||
return out << "handle";
|
||||
case StorageClass::kIn:
|
||||
|
||||
@@ -36,6 +36,7 @@ enum class StorageClass {
|
||||
kWorkgroup,
|
||||
kUniform,
|
||||
kStorage,
|
||||
kPushConstant,
|
||||
kHandle, // Tint-internal enum entry - not parsed
|
||||
kIn, // Tint-internal enum entry - not parsed
|
||||
kOut, // Tint-internal enum entry - not parsed
|
||||
@@ -55,7 +56,8 @@ StorageClass ParseStorageClass(std::string_view str);
|
||||
/// @param sc the StorageClass
|
||||
/// @see https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable
|
||||
inline bool IsHostShareable(StorageClass sc) {
|
||||
return sc == ast::StorageClass::kUniform || sc == ast::StorageClass::kStorage;
|
||||
return sc == ast::StorageClass::kUniform || sc == ast::StorageClass::kStorage ||
|
||||
sc == ast::StorageClass::kPushConstant;
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
||||
@@ -28,7 +28,8 @@ namespace tint::ast {
|
||||
/// @param sc the StorageClass
|
||||
/// @see https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable
|
||||
inline bool IsHostShareable(StorageClass sc) {
|
||||
return sc == ast::StorageClass::kUniform || sc == ast::StorageClass::kStorage;
|
||||
return sc == ast::StorageClass::kUniform || sc == ast::StorageClass::kStorage ||
|
||||
sc == ast::StorageClass::kPushConstant;
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
||||
@@ -31,12 +31,48 @@ namespace {
|
||||
|
||||
void StorageClassParser(::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",
|
||||
"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",
|
||||
};
|
||||
for (auto _ : state) {
|
||||
for (auto& str : kStrings) {
|
||||
|
||||
@@ -44,18 +44,19 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
|
||||
static constexpr Case kValidCases[] = {
|
||||
{"function", StorageClass::kFunction}, {"private", StorageClass::kPrivate},
|
||||
{"workgroup", StorageClass::kWorkgroup}, {"uniform", StorageClass::kUniform},
|
||||
{"storage", StorageClass::kStorage},
|
||||
{"storage", StorageClass::kStorage}, {"push_constant", StorageClass::kPushConstant},
|
||||
};
|
||||
|
||||
static constexpr Case kInvalidCases[] = {
|
||||
{"fccnctin", StorageClass::kInvalid}, {"ucti3", StorageClass::kInvalid},
|
||||
{"functVon", StorageClass::kInvalid}, {"priv1te", StorageClass::kInvalid},
|
||||
{"pqiJate", StorageClass::kInvalid}, {"privat7ll", StorageClass::kInvalid},
|
||||
{"workroppqHH", StorageClass::kInvalid}, {"workru", StorageClass::kInvalid},
|
||||
{"wbkgGoup", StorageClass::kInvalid}, {"unifiivm", StorageClass::kInvalid},
|
||||
{"8WWiform", StorageClass::kInvalid}, {"uxxform", StorageClass::kInvalid},
|
||||
{"sXraggg", StorageClass::kInvalid}, {"traXe", StorageClass::kInvalid},
|
||||
{"stor3ge", StorageClass::kInvalid},
|
||||
{"fccnctin", StorageClass::kInvalid}, {"ucti3", StorageClass::kInvalid},
|
||||
{"functVon", StorageClass::kInvalid}, {"priv1te", StorageClass::kInvalid},
|
||||
{"pqiJate", StorageClass::kInvalid}, {"privat7ll", StorageClass::kInvalid},
|
||||
{"workroppqHH", StorageClass::kInvalid}, {"workru", StorageClass::kInvalid},
|
||||
{"wbkgGoup", StorageClass::kInvalid}, {"unifiivm", StorageClass::kInvalid},
|
||||
{"8WWiform", StorageClass::kInvalid}, {"uxxform", StorageClass::kInvalid},
|
||||
{"sXraggg", StorageClass::kInvalid}, {"traXe", StorageClass::kInvalid},
|
||||
{"stor3ge", StorageClass::kInvalid}, {"push_constanE", StorageClass::kInvalid},
|
||||
{"push_TTPnstant", StorageClass::kInvalid}, {"puxxdh_constan", StorageClass::kInvalid},
|
||||
};
|
||||
|
||||
using StorageClassParseTest = testing::TestWithParam<Case>;
|
||||
|
||||
Reference in New Issue
Block a user