Fix an issue of spirv_by_reference

When using this qualifier for a parameter, we make it as a pointer.
However, the function TranslateStorageClass() is therefore called and
the storage class should only be set to Function when it is invoked
to translate parameter types rather than actual argument types.
This commit is contained in:
Rex Xu 2021-11-23 16:40:45 +08:00
parent 7a0b9b212c
commit fe54126c05
2 changed files with 14 additions and 12 deletions

View File

@ -1256,8 +1256,10 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
if (type.getBasicType() == glslang::EbtRayQuery)
return spv::StorageClassPrivate;
#ifndef GLSLANG_WEB
if (type.getQualifier().isSpirvByReference())
return spv::StorageClassFunction;
if (type.getQualifier().isSpirvByReference()) {
if (type.getQualifier().isParamInput() || type.getQualifier().isParamOutput())
return spv::StorageClassFunction;
}
#endif
if (type.getQualifier().isPipeInput())
return spv::StorageClassInput;

View File

@ -1,30 +1,30 @@
spv.intrinsicsSpirvLiteral.vert
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 12
// Id's are bound by 13
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main"
EntryPoint Vertex 4 "main" 9 11
Source GLSL 450
SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main"
Name 9 "vec4Out"
Name 10 "vec4In"
Name 11 "vec4In"
Decorate 9(vec4Out) Location 1
Decorate 10(vec4In) Location 0
Decorate 11(vec4In) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
8: TypePointer Output 7(fvec4)
9(vec4Out): 8(ptr) Variable Output
10: TypePointer Input 7(fvec4)
11(vec4In): 10(ptr) Variable Input
4(main): 2 Function None 3
5: Label
9(vec4Out): 8(ptr) Variable Function
10(vec4In): 8(ptr) Variable Function
11: 7(fvec4) Load 10(vec4In) None
Store 9(vec4Out) 11 Volatile
12: 7(fvec4) Load 11(vec4In) None
Store 9(vec4Out) 12 Volatile
Return
FunctionEnd