HLSL-IR: enable fuzzing of options for IR fuzzer
After landing the following CL, we should now be able to fuzz options
without triggering asserts:
https://dawn-review.googlesource.com/c/dawn/+/216154
Bug: 380271246
Change-Id: Ia98a603b7ad8f834bf4183221dc707d1f70f1aad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/216454
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/lang/hlsl/writer/writer_fuzz.cc b/src/tint/lang/hlsl/writer/writer_fuzz.cc
index f26320f..cf44d04 100644
--- a/src/tint/lang/hlsl/writer/writer_fuzz.cc
+++ b/src/tint/lang/hlsl/writer/writer_fuzz.cc
@@ -36,41 +36,6 @@
namespace tint::hlsl::writer {
namespace {
-Options GenerateOptions(core::ir::Module& module, Options::Compiler compiler) {
- Options options;
- options.disable_robustness = false;
- options.disable_workgroup_init = false;
- options.truncate_interstage_variables = false;
- options.polyfill_reflect_vec2_f32 = false;
- options.polyfill_dot_4x8_packed = false;
- options.disable_polyfill_integer_div_mod = false;
- options.polyfill_pack_unpack_4x8 = false;
- options.interstage_locations = {};
- options.root_constant_binding_point = {};
- options.pixel_local = {};
-
- options.compiler = compiler;
- options.bindings = GenerateBindings(module);
-
- options.array_length_from_uniform.ubo_binding = {30, 0};
-
- // Add array_length_from_uniform entries for all storage buffers with runtime sized arrays.
- std::unordered_set<tint::BindingPoint> storage_bindings;
- for (auto* inst : *module.root_block) {
- auto* var = inst->As<core::ir::Var>();
- if (!var->Result(0)->Type()->UnwrapPtr()->HasFixedFootprint()) {
- if (auto bp = var->BindingPoint()) {
- if (storage_bindings.insert(bp.value()).second) {
- options.array_length_from_uniform.bindpoint_to_size_index.emplace(
- bp.value(), static_cast<uint32_t>(storage_bindings.size() - 1));
- }
- }
- }
- }
-
- return options;
-}
-
bool CanRun(const core::ir::Module& module) {
// Check for unsupported module-scope variable address spaces and types.
for (auto* inst : *module.root_block) {
@@ -89,22 +54,27 @@
return true;
}
-void IRFuzzerDXC(core::ir::Module& module) {
- // TODO(377391551): Enable fuzzing of options.
- auto options = GenerateOptions(module, Options::Compiler::kDXC);
+void IRFuzzer(core::ir::Module& module, Options options) {
if (!CanRun(module)) {
return;
}
- [[maybe_unused]] auto output = Generate(module, options);
- // TODO(42251292): Fuzz DXC with HLSL output
-}
-void IRFuzzerFXC(core::ir::Module& module) {
- // TODO(377391551): Enable fuzzing of options.
- auto options = GenerateOptions(module, Options::Compiler::kFXC);
- if (!CanRun(module)) {
- return;
+ options.bindings = GenerateBindings(module);
+ options.array_length_from_uniform.ubo_binding = {30, 0};
+ // Add array_length_from_uniform entries for all storage buffers with runtime sized arrays.
+ std::unordered_set<tint::BindingPoint> storage_bindings;
+ for (auto* inst : *module.root_block) {
+ auto* var = inst->As<core::ir::Var>();
+ if (!var->Result(0)->Type()->UnwrapPtr()->HasFixedFootprint()) {
+ if (auto bp = var->BindingPoint()) {
+ if (storage_bindings.insert(bp.value()).second) {
+ options.array_length_from_uniform.bindpoint_to_size_index.emplace(
+ bp.value(), static_cast<uint32_t>(storage_bindings.size() - 1));
+ }
+ }
+ }
}
+
[[maybe_unused]] auto output = Generate(module, options);
// TODO(42251292): Fuzz DXC with HLSL output
}
@@ -112,5 +82,4 @@
} // namespace
} // namespace tint::hlsl::writer
-TINT_IR_MODULE_FUZZER(tint::hlsl::writer::IRFuzzerDXC, tint::core::ir::Capabilities{});
-TINT_IR_MODULE_FUZZER(tint::hlsl::writer::IRFuzzerFXC, tint::core::ir::Capabilities{});
+TINT_IR_MODULE_FUZZER(tint::hlsl::writer::IRFuzzer, tint::core::ir::Capabilities{});