Comments (4)
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
from shadergen.
The second solution does sound better. Should it be based on a switch in ShaderGen as well, to avoid breaking ShaderGen users?
from shadergen.
(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.
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)
- [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.