[tint][benchmark] Emit WGSL shaders as char arrays
MSVC has a limit on string literal length, so use a `std::string`
initialized with a char initializer list instead.
Bug: 42251293
Change-Id: I832e895c45c2c965546935525d6f80638e775d08
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/200614
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
Auto-Submit: James Price <jrprice@google.com>
diff --git a/src/tint/cmd/bench/generate_benchmark_inputs.py b/src/tint/cmd/bench/generate_benchmark_inputs.py
index 76a40b6..6a598b6 100644
--- a/src/tint/cmd/bench/generate_benchmark_inputs.py
+++ b/src/tint/cmd/bench/generate_benchmark_inputs.py
@@ -65,7 +65,7 @@
struct BenchmarkInput {
const char* name = nullptr;
- const char* wgsl = nullptr;
+ const std::string wgsl;
const std::vector<uint32_t> spirv;
};
const BenchmarkInput kBenchmarkInputs[] = {''',
@@ -73,9 +73,12 @@
# Add an entry to the array for each benchmark.
for f in wgsl_files:
- # WGSL shaders are emitted as string literals.
- with open(benchmark_dir + '/' + f, 'r') as input:
- print(f' {{"{f}", R"({input.read()})"}},', file=output)
+ # WGSL shaders are emitted as char initializer lists.
+ with open(benchmark_dir + '/' + f, 'rb') as input:
+ print(f' {{"{f}", {{', file=output, end='')
+ for char in input.read():
+ print(char, file=output, end=', ')
+ print(f'}}}},', file=output)
for f in spv_files:
# SPIR-V shaders are emitted as uint32_t initializer lists.
with open(benchmark_dir + '/' + f, 'rb') as input: