google / google/shaderc

WGSL output format doesn't compile with latest Tint

Open
#1,178 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.2k
Forks
445
Avg merge
11h 6m
Merged PRs (30d)
6

Description

The WGSL output format for shaderc has been helpful for WebGPU testing.

Cloning Tint into the the third_party folder and trying to build with SHADERC_ENABLE_WGSL_OUTPUT enabled does not compile, it seems the Tint API has changed since this code was added to shaderc.

I got it working by updated the WGSL generating code in file_compiler.cc. I can submit a PR, or you can update the code, if you're interested in updating the WGSL output.
```
#if SHADERC_ENABLE_WGSL_OUTPUT == 1
std::unique_ptr program;
program = std::make_unique(tint::reader::spirv::Parse(std::vector(result.begin(), result.end())));

tint::transform::Manager transform_manager;
auto mgr_out = transform_manager.Run(program.get());
*program = std::move(mgr_out.program);

auto wgsl_writer = std::make_unique(program.get());

if (!wgsl_writer->Generate()) {
std::cout << "error: failed to convert to WGSL: "
<< wgsl_writer->error() << std::endl;
return false;
}

auto* w = static_cast(wgsl_writer.get());
auto output = w->result();
*out << output;
#endif // SHADERC_ENABLE_WGSL_OUTPUT==1

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.