非结构类型(标量、矢量、数组等)使用相同的操作数参数化不能是类型别名。对于非结构,两个类型的
<id>的匹配如果-和唯一-如果类型匹配.
这到底是什么意思?
#version 400
void main()
{
uint a = 4;
uint b = 5;
}使用glslang编译此着色器将在
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 1
; Bound: 12
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main"
OpSource GLSL 400
OpName %main "main"
OpName %a "a"
OpName %b "b"
%void = OpTypeVoid
%3 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%uint_4 = OpConstant %uint 4
%uint_5 = OpConstant %uint 5
%main = OpFunction %void None %3
%5 = OpLabel
%a = OpVariable %_ptr_Function_uint Function
%b = OpVariable %_ptr_Function_uint Function
OpStore %a %uint_4
OpStore %b %uint_5
OpReturn
OpFunctionEnd在这里,%uint = OpTypeInt 32 0被多次使用,%_ptr_Function_uint也被使用了两次。
这条规则在哪里适用呢?
发布于 2017-07-24 14:01:49
我的猜测是,该验证规则的措辞很不幸,并引用了以下内容(2.8。SPIR-V规范的类型和变量):
根据定义,两种不同类型的
<id>形式,两种不同的类型。声明具有相同操作码和操作数的多个聚合类型<id>是有效的。这是为了允许对具有相同结构的聚合类型的多个实例进行不同的修饰。(不需要不同的装饰;允许两种不同的聚合类型<id>具有相同的声明和装饰,并且仍然是两种不同的类型。)非聚合类型是不同的:对于同一个标量、向量或矩阵类型,声明多个类型的<id>s是无效的。也就是说,非聚合类型声明都必须有不同的操作码或操作数。(请注意,不能以影响其类型的方式修饰非聚合类型。)
但有不同之处。例如,“非聚合”(即非结构+非数组)与“非结构”。
所以,它的意思是你不能做这样的事情:OpTypeInt id=1 bits=32 sign=0 // OK OpTypeInt id=1 bits=32 sign=1 // ERROR -- redefined result id OpTypeInt id=2 bits=32 sign=0 // ERROR -- uint32 already defined as id 1 OpTypeInt id=3 bits=32 sign=1 // OK
在你的SPIR示例中,我没有看到这个规则被违反。
https://stackoverflow.com/questions/45207625
复制相似问题