Comments (1)
Yes, this is something I would like to support.
The way that functions are enumerated, ordered, and processed is quite a mess at the moment. It's grown over time from the beginning when I had no clue how the Roslyn API worked or how ShaderGen should use it...
I've looked it over again and this is how it currently works:
- ShaderGen does a full syntax walk (
ShaderSyntaxWalker
), and whenever it discovers ANY method declaration, it adds it to the context's function list. - When backends are outputting code for the functions, they generate an "ordered graph" of the function calls. This does ANOTHER syntax walk (
FunctionCallGraphDiscoverer
andMethodWalker
) which puts the functions that are actually used into an ordered graph. This is because HLSL and GLSL need functions to be declared before they are called (unlike C#). - The HLSL/GLSL backend spit out the functions in reverse order from the call order. Actually, the Metal backend does this too, but I don't think it's actually necessary. I never tested, but it's not a big deal either way.
Unless I'm missing something obvious, we should be able to more-or-less remove the first step. The only thing that step needs to discover is the entry point functions for the shader set (vertex/fragment). It doesn't need to track all of the other functions in the type, because they don't actually matter unless they are called by the entry function. If they are, they will be caught by the FunctionCallGraphDiscoverer
later on. We can augment the FunctionCallGraphDiscoverer
to output the full ShaderFunctionAndBlockSyntax
information that is needed to generate the code in each backend.
Note that this definitely won't work for externally-defined functions (e.g. there's no implementation IL available for them). To allow that, we'd need to process an entirely different object model (Cecil's, probably), and only if you have the implementation handly (not a reference assembly).
from shadergen.
Related Issues (20)
- [Enhancement] Upgrade Shader.App to .Net Core 2.2
- ShaderGen.Build does not generate any shader HOT 1
- Double precision support?
- About findFXC
- embedding generated shaders as part of the compilation process.
- Converting ShaderGen to work as a Roslyn Source Generator
- [SUGGESTION] Control compatibility level for method implementations. HOT 3
- [Suggestion] Add JetBrains.Annotations HOT 4
- NuGet packages out of order
- How do you normalize? HOT 3
- I can't output some file. HOT 6
- Who can give me a basic only demo project?
- When I use ShaderGen.Build ,I con't do with ComplexCompute.cs and SimpleCompute.cs .
- [Bug] Hlsl.bytes no longer produced. HOT 3
- [Bug] Tests fail on computers without OpenGLES
- [Enhancement] Add more options to ShaderGen.App to require shader compilations
- [Enhancement] Use a C# wrapper library for GLSLangValidator
- [Enhancement] Use GLSLangValidator to validate OpenGL Shaders
- [Enhancement] Add tests for ShaderGen.App
- [Enhancement] Asynchronously compile shaders
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 shadergen.