GithubHelp home page GithubHelp logo

Comments (4)

mellinoe avatar mellinoe commented on May 29, 2024

This is a problem I've known about for a while. There's basically two solutions that I've thought of, but only one is suitable as a "quick fix".

The first is the solution you mentioned: adding an attribute which describes how many vertex buffers are used for the structure. This will work fine and will match how Veldrid currently expects things to be laid out. Unfortunately, it prevents you from using the same shader multiple times with a different number of vertex buffers. All the other language backends can work with a variable number of vertex buffers, because the binding space for them is different. In Metal all kinds of buffers (vertex, uniform, etc.) use the same binding space.

The second solution is one that is more elegant, but would be a breaking change and would need some kind of adaptation in Veldrid to allow it to continue working there. Instead of assuming the vertex buffers begin at index 0, we could instead place them at the END of the binding list. So a shader with 5 uniform buffers would have buffer indices 0, 1, 2, 3, and 4 assigned to the uniform buffer resources, and the [[stage_in]] buffers could instead be assigned to whatever you want. You could use buffer index 5, or 5/6, or 5/6/7, etc. This would break how Veldrid expects things, so there would need to be some kind of "switch" that you could activate to get this new behavior.

Semi-relatedly, I would also like the GLSL 300/330 backends to start using explicit binding indices for resources, rather than relying on the OpenGL code to assign them by name upon Pipeline creation. This could probably be done without breaking Veldrid at all (since it could just continue re-assigning them anyways), but Veldrid could also be augmented to directly support those explicit binding locations if the behavior was attached to that special "switch" mentioned above.

Going with the first solution could work for now, but I'm worried that it would become obsolete once I have time to implement the second feature. Luckily, adding the first one should only be a few lines of code (recognizing the attribute and then using the count in the place you mentioned).

Sorry about the wall of text 😆. I've thought about this a decent bit so I'd like to do things the right way (at least eventually).

from shadergen.

tgjones avatar tgjones commented on May 29, 2024

The second solution does sound better. Should it be based on a switch in ShaderGen as well, to avoid breaking ShaderGen users?

from shadergen.

tgjones avatar tgjones commented on May 29, 2024

(And any ideas on what the switch should be called? If it's going to cover GLSL explicit binding indices too, I'm struggling to think of a good name.)

from shadergen.

mellinoe avatar mellinoe commented on May 29, 2024

Given that ShaderGen is still churning a lot, I think we should just make the change here without a switch. I would like to start thinking about a stable release at some point soon, though, because it's becoming increasingly important to my projects (and others' as well, I think).

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.