readonlyspir-vopengl-es-3.1shader-storage-buffer

read-only storage buffer in OpenGL ES and Spir-V


In OpenGL ES Shading Language, the shader storage buffer object (SSBO) can be decorated with qualifier readonly or writeonly.
Section 4.9 (Memory Access Qualifiers) of OpenGL ES Shading Language version 3.1 specification:

Shader storage blocks, variables declared within shader storage blocks and variables declared as image types (the basic opaque types with “image” in their keyword), can be further qualified with one or more of the following memory qualifiers: ...(A table is listed)

So I can have something in opengl es shader like this:

layout(std430, binding = 0) readonly buffer mybuffer {
        a_struct_type myarray[];  //a_struct_type was defined before
    };

But how to specify the readonly in spir-v?
In spir-v specification, 3.18 section, Access Qualifier, it says:

Used by OpTypeImage and OpTypePipe.

Does this mean that, in spir-v, the SSBO cannot be specified as readonly? I do not think SSBO falls into type OpTypeImage or OpTypePipe.

---------------------------------------------
 Resource Type  |  Storage Class |    Type       
---------------------------------------------
  Storage Buffer|  Uniform       |
                |----------------|  OpTypeStruct
                | Storage Buffer |
----------------------------------------------

Solution

  • The appropriate decorations are unintuitively NonWritable and NonReadable.