Comments (3)
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:
- The code is passed through a C++ pre-processor (boost::wave) and converted into tokens.
- 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.
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.
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)
- Compatibility with GLSLify HOT 1
- error: case value not in enumerated type '```boost::wave::token_id```' HOT 1
- Project doesn't respect cmake's standard variable BUILD_SHARED_LIBS
- "flatc not installed. Using pre-generated flatbuffers." should be an error, not a warning HOT 3
- Congigure fails when MSL_SHARED=ON and SPIRV_TOOLS_BUILD_STATIC=OFF HOT 1
- error: variable 'line' set but not used HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modularshaderlanguage.