PitchHut
Log in / Sign up
WebGPU-WGSL-BigInt
6 views
Unlock the power of precision with BigInts in WGSL shaders.
Pitch

Explore a flexible repository that empowers your WGSL shaders with BigInt support, handling operations up to 524288 bits. Adapt the provided source codes to your needs, selecting only what you require to maintain shader efficiency without sacrificing performance. Simplify your coding experience while supporting large integers seamlessly.

Description

The WebGPU-WGSL-BigInt repository is a comprehensive toolkit designed for developers who want to work with large signed integers (BigInts) within their WGSL shaders. This innovative library enables the management of 64-bit arithmetic and supports BigInts with lengths up to 2^19 bits (equivalent to 157,826 decimal digits). With this robust functionality, developers can effortlessly implement computations involving very large integers in WebGPU shaders.

Key Features:

  • Modular Source Code: The repository offers a variety of source codes tailored to specific needs. Depending on your project requirements, you can choose lighter options supporting just 64-bit integers or opt for the complete support featuring up to 524,288-bit BigInts. This flexibility allows for streamlined code management and improved readability.
  • Addressing WGSL Limitations: WGSL has several restrictions, including the lack of function overloading and recursion, which can lead to verbose code. To mitigate these challenges, the repository presents solutions to work around these limitations effectively.

How to Use:

Just copy the content from any of the .wgsl files available in the "Source Codes" folder and paste it into the corresponding section of your WGSL shader. Including a specific .wgsl file automatically ensures support for all smaller integers as well.

Disclaimer:

Please note that due to inherent stack size limitations specific to your GPU, shaders utilizing larger BigInts may experience compilation issues in certain browsers.

Comprehensive Documentation:

The toolkit comes with thorough documentation that includes detailed constructor and operator descriptions, helping you to implement various functionalities such as:

  • Instantiating BigInts from standard integer types (i32, u32).
  • Unary Operators: Perform operations like absolute value, negation, and opposite value.
  • Logic and Bitwise Operations: Execute logical operations (AND, OR, XOR) and bitwise shifts.
  • Comparison Operations: Easily compare BigInts for equality, greater than, less than, etc.
  • Arithmetic Operations: Add, subtract, multiply, divide, and apply the Karatsuba algorithm for optimized calculations.

By leveraging the WebGPU-WGSL-BigInt repository, you can significantly enhance your graphical applications that require high-precision numerical computations, aligning with modern development practices and maximizing the potential of your shaders.