Giter VIP home page Giter VIP logo

Comments (6)

dneto0 avatar dneto0 commented on May 17, 2024

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.

dneto0 avatar dneto0 commented on May 17, 2024

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.

 avatar commented on May 17, 2024

I mean bindless textures

from shaderc.

dneto0 avatar dneto0 commented on May 17, 2024

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.

 avatar commented on May 17, 2024

I ask another question. How to bind array of 256 textures with different sizes and formats?

from shaderc.

dneto0 avatar dneto0 commented on May 17, 2024

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)

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.