Results 1 to 5 of 5

Thread: glslangValidator non-opaque uniform to SPIR-V question

  1. #1

    glslangValidator non-opaque uniform to SPIR-V question

    Hi,
    I would like to convert GLSL version 140 shaders to SPIR-V with glslangValidator. I have issues when converting shaders that have non-opaque uniforms outside of a block. glslangValidator complains with : 'non-opaque uniforms outside a block'.
    An example would be :

    Code :
    #version 140
    uniform float value;
    void main()
    {
       //stuff
    }
    where value would trigger the error.

    I would like to know if there is a way to fix this other than doing a pre-pass on the shaders to group all uniforms inside a uniform block ? Or can glslangValidator do this automatically ?

    I am using a fairly recent glslangValidator build (Overload400-PrecQual.2000 12-Apr-2017)

    Thanks for your help !

  2. #2
    Vulkan does not allow for non-opaque uniforms, as clearly stated in the KHR_vulkan_glsl pseudo-extension. All uniforms go into interface blocks of some kind.

  3. #3
    Thanks for you answer and the link. I agree that it is pretty clearly stated in this document...

    So no luck for Vulkan.

    But what about "API-agnostic" SPIR-V ? Let's say I want to use SPIRV-Cross afterwards to convert it to something else. I guess this could be done, but has not yet been implemented ?

    My question now leans more towards the SPIR-V forum... sorry about that)

    Thanks again

  4. #4
    But what about "API-agnostic" SPIR-V ?
    First, take note what I said: "Vulkan does not allow for non-opaque uniforms". SPIR-V allows you to do it; Vulkan cannot consume such data. If you compiled your GLSL to target OpenGL through SPIR-V, it probably would have worked.

    Second, have you actually looked at SPIR-V? It has API-specific functionality everywhere. The most drastic choice is that between "kernel" and non-kernel execution modes. Kernels get to do pointer arithmetic; non-kernels don't.

    SPIR-V is an interchange format, but not every consumer of SPIR-V can consume any SPIR-V.

    Let's say I want to use SPIRV-Cross afterwards to convert it to something else.
    Then you need to write your shaders so that they use the intersection of the functionality that both consuming APIs support. And even then, you'll need to #define around some things (push-constants and descriptor sets don't exist in OpenGL).

  5. #5
    Thanks a lot for these clarification Alfonse. You actually summed it all up pretty well in one sentence
    SPIR-V is an interchange format, but not every consumer of SPIR-V can consume any SPIR-V.
    I still got some homework to do in my learning of SPIR-V !

    Thanks again for you help and time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean