Giter Club home page Giter Club logo

Comments (3)

akb825 avatar akb825 commented on May 29, 2024

MSL doesn't have an AST of its own as it is a meta-language built on top of GLSL. Parsing has two main phases:

  1. The code is passed through a C++ pre-processor (boost::wave) and converted into tokens.
  2. Fragments of GLSL are extracted from the tokens to be processed for the individual shaders. This primarily consists of filtering (based on the [[stage]] tags) and handling a few specialized cases by hand.

A translation from Julia would technically be possible if you were to output the extended GLSL syntax that MSL parses, either saving to a temporary file or providing a stream (e.g. std::stringstream) and passing it to the compile() function for the target you want to use.

Is your goal for compute or graphics? MSL supports compute shaders, but within the context of a graphics pipeline for use in graphics APIs such as Vulkan, OpenGL, and Metal. This distinction is important, since compute shaders run in a graphics pipeline don't support the full feature set of pure GPGPU compute such as CUDA and OpenCL.

If your goal is compute rather than graphics, a better fit may be SPIRV-LLVM-Translator. If you can translate Julia to LLVM IR, SPIRV-LLVM-Translator should allow you to convert it to SPIR-V that can be run in OpenCL.

from modularshaderlanguage.

kskyten avatar kskyten commented on May 29, 2024

My goal is to produce shaders for graphics. GPU computing is actually fairly well supported in Julia. Perhaps it is better to use something like https://github.com/graphitemaster/glsl-parser and extend it with Julia.

from modularshaderlanguage.

akb825 avatar akb825 commented on May 29, 2024

In that case, you will probably be better off with glslang, which is the official GLSL parser. It would offer the most complete language support, and already supports parsing a different language (HLSL) into the same AST.

from modularshaderlanguage.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.