tree: ef9e53b447616fb83d560d15d55cad1e36af9b0b [path history] [tgz]
  1. construct.cc
  2. construct.h
  3. entry_point_info.h
  4. enum_converter.cc
  5. enum_converter.h
  6. enum_converter_test.cc
  7. fail_stream.h
  8. fail_stream_test.cc
  9. function.cc
  10. function.h
  11. function_arithmetic_test.cc
  12. function_bit_test.cc
  13. function_call_test.cc
  14. function_cfg_test.cc
  15. function_composite_test.cc
  16. function_conversion_test.cc
  17. function_decl_test.cc
  18. function_glsl_std_450_test.cc
  19. function_logical_test.cc
  20. function_memory_test.cc
  21. function_misc_test.cc
  22. function_var_test.cc
  23. namer.cc
  24. namer.h
  25. namer_test.cc
  26. parser.cc
  27. parser.h
  28. parser_impl.cc
  29. parser_impl.h
  30. parser_impl_convert_member_decoration_test.cc
  31. parser_impl_convert_type_test.cc
  32. parser_impl_function_decl_test.cc
  33. parser_impl_get_decorations_test.cc
  34. parser_impl_handle_test.cc
  35. parser_impl_import_test.cc
  36. parser_impl_module_var_test.cc
  37. parser_impl_named_types_test.cc
  38. parser_impl_test.cc
  39. parser_impl_test_helper.h
  40. parser_impl_user_name_test.cc
  41. parser_test.cc
  42. README.md
  43. spirv_tools_helpers_test.cc
  44. spirv_tools_helpers_test.h
  45. usage.cc
  46. usage.h
  47. usage_test.cc
src/reader/spirv/README.md

SPIR-V Reader

This component translates SPIR-V written for Vulkan into the Tint AST.

The SPIR-V reader entry point is tint::reader::spirv::Parser, which implements the Reader interface in tint::reader::Reader.

It's usable from the Tint command line:

# Dump the Tint AST after reading SPIR-V.
tint --dump-ast --parse-only a.spv

# Translate SPIR-V into WGSL.
tint --format wgsl a.spv

Validation

The SPIR-V module must pass validation for the SPV_ENV_WEBGPU_0 target environment in SPIRV-Tools.

That set of rules is experimental and was originally intended to constraint SPIR-V modules being ingested directly by the WebGPU API. Those rules are now too restrictive, because some amount of sanitization and normalization occurs during translation from SPIR-V to WGSL. The validation rules will be relaxed at some point TBD.

Generally, validation of functionality used will remain, e.g. WebGPU currently does not support CullDistance or subgroup operations.

However, detailed rules about the form of SPIR-V can be relaxed, e.g. the requirement to use SPIR-V 1.3, and restrictive rules about statically unreachable code.

Feedback

Please file issues at https://crbug.com/tint, and put spirv-reader in the issue title.

Outstanding issues can be found by using the spirv-reader label in the Chromium project's bug tracker: https://bugs.chromium.org/p/tint/issues/list?q=label:spirv-reader