Comments (6)
glslc now supports -fauto-bind-uniforms, which automatically assigns bindings to uniform variables that don't have an explicit binding.
This applies to textures, images, and samplers.
An example integration test is in https://github.com/google/shaderc/blob/master/glslc/test/option_fauto_bind_uniforms.py
That shows that the sampler gets a binding assigned to it.
Does this satisfy your need?
from shaderc.
I forgot you mentioned OpenGL. Use --target-env=opengl to target OpenGL.
Example: x.vert is:
#version 450
buffer B
{ int x; int y; } my_buf;
void main() {
int x = my_buf.x;
}
Then glslc -S -o - --target-env=opengl x.vert
produces:
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %gl_VertexID %gl_InstanceID
OpSource GLSL 450
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
OpSourceExtension "GL_GOOGLE_include_directive"
OpName %main "main"
OpName %x "x"
OpName %B "B"
OpMemberName %B 0 "x"
OpMemberName %B 1 "y"
OpName %my_buf "my_buf"
OpName %gl_VertexID "gl_VertexID"
OpName %gl_InstanceID "gl_InstanceID"
OpMemberDecorate %B 0 Offset 0
OpMemberDecorate %B 1 Offset 4
OpDecorate %B BufferBlock
OpDecorate %my_buf DescriptorSet 0
OpDecorate %gl_VertexID BuiltIn VertexId
OpDecorate %gl_InstanceID BuiltIn InstanceId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%B = OpTypeStruct %int %int
%_ptr_Uniform_B = OpTypePointer Uniform %B
%my_buf = OpVariable %_ptr_Uniform_B Uniform
%int_0 = OpConstant %int 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Input_int = OpTypePointer Input %int
%gl_VertexID = OpVariable %_ptr_Input_int Input
%gl_InstanceID = OpVariable %_ptr_Input_int Input
%main = OpFunction %void None %3
%5 = OpLabel
%x = OpVariable %_ptr_Function_int Function
%14 = OpAccessChain %_ptr_Uniform_int %my_buf %int_0
%15 = OpLoad %int %14
OpStore %x %15
OpReturn
OpFunctionEnd
You can see that my_buf has a DescriptorSet decoration, but no Binding decoration.
Is that what you mean?
from shaderc.
I mean bindless textures
from shaderc.
Yes. Sorry I was confused.
You mean support for this extension:
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_bindless_texture.txt
Shaderc depends on github.com/KhronosGroup/glslang for core compilation features for GLSL. So the functionality has to be added there. If I read glslang's test code, bindless textures are not supported. I see you already asked in that project, in KhronosGroup/glslang#497
In this case, the underlying functionality would have to be made available both in SPIR-V (what operations are used in SPIR-V), and in the target environment (does OpenGL with SPIR-V extensions support it; or does Vulkan support this). I believe there is no way in SPIR-V to produce an image object from a 64bit handle. So as describe in the glslang bug, first SPIR-V extension would need to be written to add that functionality, and a corresponding extension to the client API to enable that SPIR-V.
from shaderc.
I ask another question. How to bind array of 256 textures with different sizes and formats?
from shaderc.
I assume you mean for Vulkan? That's a Vulkan question.
The closest thing would be a texture array, but those must share a common format.
For example, see https://www.khronos.org/registry/vulkan/specs/misc/GL_KHR_vulkan_glsl.txt
or you can infer it from the Vulkan specification.
from shaderc.
Related Issues (20)
- 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
- Optimization issue when specifying --target-env
- [Documentation] gmock appears to be necessary for shaderc HOT 1
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.