Comments (4)
This is already supported, but it's not apparent.
Use -fauto-bind-uniforms for both uniform buffer objects and storage buffer objects.
Example:
#version 450
buffer ABuf { uint a; } B;
void main() {
B.a = 1;
}
Compile with glslc a.comp -fauto-bind-uniforms -o a.spv
and it assigns descriptor set 0 and binding 0.
The documentation should be improved, though!
from shaderc.
The confusion is that UBO and SSBO in the original SPIR-V 1.0 are both in the "Uniform" storage class, and that naming was used for the command line option, when most people think of them as different.
from shaderc.
Hey, I'm currently using shaderc & spirv_cross from C++, using these options:
opts.SetAutoMapLocations(true);
opts.SetAutoBindUniforms(true);
opts.SetPreserveBindings(true);
opts.SetForcedVersionProfile(460, shaderc_profile_core);
opts.SetOptimizationLevel(shaderc_optimization_level_zero);
opts.SetIncluder(std::make_unique<FileIncluder>(stage, extra_info));
opts.SetGenerateDebugInfo();
opts.AddMacroDefinition("stage_" + suffix);
opts.AddMacroDefinition("MAX_TEXTURES_PER_MATERIAL", std::to_string(shader_structs::MAX_TEXTURES_PER_MATERIAL));
opts.AddMacroDefinition("MAX_LIGHTS_PER_TYPE", std::to_string(shader_structs::MAX_LIGHTS_PER_TYPE));
opts.AddMacroDefinition("SAMPLER_CUBE(set_index, name)", "layout (set = set_index) uniform samplerCube name");
opts.AddMacroDefinition("SAMPLER_CUBE_ARRAY(set_index, name)", "layout (set = set_index) uniform samplerCube name[]");
opts.AddMacroDefinition("SAMPLER_TEXTURE(set_index, name)", "layout (set = set_index) uniform sampler2D name");
opts.AddMacroDefinition("SAMPLER_TEXTURE_ARRAY(set_index, name)", "layout (set = set_index) uniform sampler2D name[]");
opts.AddMacroDefinition("IN(type, name)", "in type name");
opts.AddMacroDefinition("OUT(type, name)", "out type name");
However it seems that bindings are not preserved (the auto location binding works perfectly though) and it only takes the bindings that are currently being used, this is a problem because I have 6 different bindings and some are shared between vertex and fragment shader, this leads to binding collision between my shader modules in Vulkan so instead of having a layout with 6 bindings (5 storage buffers and 1 variable size uniform of sampled images), I have a layout with 3 bindings because I merge the bindings from all stages so I can create the layout for the descriptor set used in the pipeline. If I don't merge I get that vertex shader uses 3 bindings (0 to 2) and the same for the fragment shader (same range of binding indices as well). The libraries I'm using for shaderc are shaderc_combinedd.lib and shaderc_combined.lib from the latest Vulkan SDK (1.3.250.1).
from shaderc.
Not sure if it's a problem in my syntax, I've uploaded my shaders and headers, the main shader is basic.vts under shader folder. The rest is headers that basic.vts uses.
assets.zip
Note: this is the code that works for me, by hardcoding the binding indices in basic.vts. What I tried is removing the ", binding = BINDING" part from all uniforms and buffers but it didn't work.
from shaderc.
Related Issues (20)
- MSVC 2017 debug build fails to compile SPIRV-Tools test/opt/fold_test.cpp: requires /bigobj flag HOT 1
- work around bug in CMake 3.22.1 bug in CMP0128 policy, for compiling SPIRV-Tools tests HOT 2
- shaderc::PreprocessGlsl removes defines from the shader HOT 1
- Shader stage does matter for preprocessing
- Ninja Multi-Config generator fails - Evaluation file to be written multiple times with different content HOT 1
- Including shaderc/CMakeLists.txt as suggested in README not working HOT 4
- Linking error against spirv-tools
- Proper handling of namespace in HLSL
- Is glsl 330 actually supported ?
- Gmock not found HOT 4
- FRP this Android
- No support for source level debug info?
- SPIR_V: Generate nonsemantic shader debug information (with source) HOT 1
- shaderc not found while compiling FFMPEG HOT 1
- tests fail with updated Glslang: TestDashCapOWithDashG fails due to debug output change HOT 2
- enable Glslang tests when Shaderc tests are enabled HOT 1
- "NVVM compilation failed: 3" with mesh shaders
- Build faild when I set BUILD_SHARED_LIBS ON, Windows 10 HOT 1
- RFE: is it possible to start making github releases?🤔 HOT 3
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 shaderc.