简体   繁体   English

OpenGL ES和Spir-V中的只读存储缓冲区

[英]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 . 在OpenGL ES着色语言中,可以用限定符readonlywriteonly装饰着色器存储缓冲区对象(SSBO)。
Section 4.9 (Memory Access Qualifiers) of OpenGL ES Shading Language version 3.1 specification : OpenGL ES着色语言3.1版规范的第4.9节(内存访问限定符):

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) 可以使用以下一个或多个内存限定符进一步限定着色器存储块,在着色器存储块中声明的变量以及声明为图像类型的变量(其关键字中带有“ image”的基本不透明类型):...(一个表已列出)

So I can have something in opengl es shader like this: 因此,我可以在opengl es着色器中添加以下内容:

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? 但是如何在spir-v中指定readonly
In spir-v specification , 3.18 section, Access Qualifier, it says: spir-v规范的 3.18节“访问限定符”中,它表示:

Used by OpTypeImage and OpTypePipe. 由OpTypeImage和OpTypePipe使用。

Does this mean that, in spir-v, the SSBO cannot be specified as readonly? 这是否意味着在spir-v中不能将SSBO指定为只读? I do not think SSBO falls into type OpTypeImage or OpTypePipe. 我不认为SSBO属于OpTypeImage或OpTypePipe类型。

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

适当的修饰是直觉上的NonWritableNonReadable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM