GithubHelp home page GithubHelp logo

Comments (1)

mellinoe avatar mellinoe commented on May 28, 2024

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:

  1. ShaderGen does a full syntax walk (ShaderSyntaxWalker), and whenever it discovers ANY method declaration, it adds it to the context's function list.
  2. When backends are outputting code for the functions, they generate an "ordered graph" of the function calls. This does ANOTHER syntax walk (FunctionCallGraphDiscoverer and MethodWalker) 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#).
  3. 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)

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.