Fix validation failures of test cases regarding GL_EXT_spirv_intrinsics

1. The test cases of OpReadClockKHR is invalid. The return type is
   unsigned integer rather than signed integer.
2. When SPIR-V decorate or SPIR-V type is specified, we should avoid
   auto location mapping because the semantics are totally decided by
   SPIR-V tokens.
This commit is contained in:
Rex Xu 2021-11-24 17:37:52 +08:00
parent 083bdc838a
commit 6c1db7fd6c
7 changed files with 48 additions and 56 deletions

View File

@ -1,5 +1,4 @@
spv.intrinsicsSpirvDecorate.frag spv.intrinsicsSpirvDecorate.frag
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 43 // Id's are bound by 43
@ -28,19 +27,12 @@ Validation failed
Decorate 10(floatIn) Location 0 Decorate 10(floatIn) Location 0
Decorate 10(floatIn) ExplicitInterpAMD Decorate 10(floatIn) ExplicitInterpAMD
Decorate 18(vec2Out) Location 1 Decorate 18(vec2Out) Location 1
Decorate 20(gl_BaryCoordNoPerspAMD) Location 0
Decorate 20(gl_BaryCoordNoPerspAMD) BuiltIn BaryCoordNoPerspAMD Decorate 20(gl_BaryCoordNoPerspAMD) BuiltIn BaryCoordNoPerspAMD
Decorate 22(gl_BaryCoordNoPerspCentroidAMD) Location 1
Decorate 22(gl_BaryCoordNoPerspCentroidAMD) BuiltIn BaryCoordNoPerspCentroidAMD Decorate 22(gl_BaryCoordNoPerspCentroidAMD) BuiltIn BaryCoordNoPerspCentroidAMD
Decorate 25(gl_BaryCoordNoPerspSampleAMD) Location 2
Decorate 25(gl_BaryCoordNoPerspSampleAMD) BuiltIn BaryCoordNoPerspSampleAMD Decorate 25(gl_BaryCoordNoPerspSampleAMD) BuiltIn BaryCoordNoPerspSampleAMD
Decorate 28(gl_BaryCoordSmoothAMD) Location 3
Decorate 28(gl_BaryCoordSmoothAMD) BuiltIn BaryCoordSmoothAMD Decorate 28(gl_BaryCoordSmoothAMD) BuiltIn BaryCoordSmoothAMD
Decorate 31(gl_BaryCoordSmoothCentroidAMD) Location 4
Decorate 31(gl_BaryCoordSmoothCentroidAMD) BuiltIn BaryCoordSmoothCentroidAMD Decorate 31(gl_BaryCoordSmoothCentroidAMD) BuiltIn BaryCoordSmoothCentroidAMD
Decorate 34(gl_BaryCoordSmoothSampleAMD) Location 5
Decorate 34(gl_BaryCoordSmoothSampleAMD) BuiltIn BaryCoordSmoothSampleAMD Decorate 34(gl_BaryCoordSmoothSampleAMD) BuiltIn BaryCoordSmoothSampleAMD
Decorate 39(gl_BaryCoordPullModelAMD) Location 6
Decorate 39(gl_BaryCoordPullModelAMD) BuiltIn BaryCoordPullModelAMD Decorate 39(gl_BaryCoordPullModelAMD) BuiltIn BaryCoordPullModelAMD
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2

View File

@ -1,5 +1,4 @@
spv.intrinsicsSpirvExecutionMode.frag spv.intrinsicsSpirvExecutionMode.frag
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 12 // Id's are bound by 12
@ -17,7 +16,6 @@ Validation failed
Name 4 "main" Name 4 "main"
Name 8 "gl_FragStencilRef" Name 8 "gl_FragStencilRef"
Name 10 "color" Name 10 "color"
Decorate 8(gl_FragStencilRef) Location 0
Decorate 8(gl_FragStencilRef) BuiltIn FragStencilRefEXT Decorate 8(gl_FragStencilRef) BuiltIn FragStencilRefEXT
Decorate 10(color) Flat Decorate 10(color) Flat
Decorate 10(color) Location 0 Decorate 10(color) Location 0

View File

@ -1,8 +1,7 @@
spv.intrinsicsSpirvInstruction.vert spv.intrinsicsSpirvInstruction.vert
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 30 // Id's are bound by 32
Capability Shader Capability Shader
Capability Int64 Capability Int64
@ -10,50 +9,52 @@ Validation failed
Extension "SPV_AMD_shader_trinary_minmax" Extension "SPV_AMD_shader_trinary_minmax"
Extension "SPV_KHR_shader_clock" Extension "SPV_KHR_shader_clock"
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
28: ExtInstImport "SPV_AMD_shader_trinary_minmax" 30: ExtInstImport "SPV_AMD_shader_trinary_minmax"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 13 18 21 EntryPoint Vertex 4 "main" 9 15 20 23
Source GLSL 450 Source GLSL 450
SourceExtension "GL_ARB_gpu_shader_int64" SourceExtension "GL_ARB_gpu_shader_int64"
SourceExtension "GL_EXT_spirv_intrinsics" SourceExtension "GL_EXT_spirv_intrinsics"
Name 4 "main" Name 4 "main"
Name 9 "uvec2Out" Name 9 "uvec2Out"
Name 13 "i64Out" Name 15 "u64Out"
Name 18 "vec2Out" Name 20 "vec2Out"
Name 21 "vec3In" Name 23 "vec3In"
Decorate 9(uvec2Out) Location 0 Decorate 9(uvec2Out) Location 0
Decorate 13(i64Out) Location 1 Decorate 15(u64Out) Location 1
Decorate 18(vec2Out) Location 2 Decorate 20(vec2Out) Location 2
Decorate 21(vec3In) Location 0 Decorate 23(vec3In) Location 0
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 0 6: TypeInt 32 0
7: TypeVector 6(int) 2 7: TypeVector 6(int) 2
8: TypePointer Output 7(ivec2) 8: TypePointer Output 7(ivec2)
9(uvec2Out): 8(ptr) Variable Output 9(uvec2Out): 8(ptr) Variable Output
11: TypeInt 64 1 10: TypeInt 32 1
12: TypePointer Output 11(int64_t) 11: 10(int) Constant 1
13(i64Out): 12(ptr) Variable Output 13: TypeInt 64 0
15: TypeFloat 32 14: TypePointer Output 13(int64_t)
16: TypeVector 15(float) 2 15(u64Out): 14(ptr) Variable Output
17: TypePointer Output 16(fvec2) 17: TypeFloat 32
18(vec2Out): 17(ptr) Variable Output 18: TypeVector 17(float) 2
19: TypeVector 15(float) 3 19: TypePointer Output 18(fvec2)
20: TypePointer Input 19(fvec3) 20(vec2Out): 19(ptr) Variable Output
21(vec3In): 20(ptr) Variable Input 21: TypeVector 17(float) 3
22: TypePointer Input 21(fvec3)
23(vec3In): 22(ptr) Variable Input
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
10: 7(ivec2) ReadClockKHR 12: 7(ivec2) ReadClockKHR 11
Store 9(uvec2Out) 10 Store 9(uvec2Out) 12
14: 11(int64_t) ReadClockKHR 16: 13(int64_t) ReadClockKHR 11
Store 13(i64Out) 14 Store 15(u64Out) 16
22: 19(fvec3) Load 21(vec3In) 24: 21(fvec3) Load 23(vec3In)
23: 16(fvec2) VectorShuffle 22 22 0 1 25: 18(fvec2) VectorShuffle 24 24 0 1
24: 19(fvec3) Load 21(vec3In) 26: 21(fvec3) Load 23(vec3In)
25: 16(fvec2) VectorShuffle 24 24 1 2 27: 18(fvec2) VectorShuffle 26 26 1 2
26: 19(fvec3) Load 21(vec3In) 28: 21(fvec3) Load 23(vec3In)
27: 16(fvec2) VectorShuffle 26 26 2 0 29: 18(fvec2) VectorShuffle 28 28 2 0
29: 16(fvec2) ExtInst 28(SPV_AMD_shader_trinary_minmax) 1(FMin3AMD) 23 25 27 31: 18(fvec2) ExtInst 30(SPV_AMD_shader_trinary_minmax) 1(FMin3AMD) 25 27 29
Store 18(vec2Out) 29 Store 20(vec2Out) 31
Return Return
FunctionEnd FunctionEnd

View File

@ -1,5 +1,4 @@
spv.intrinsicsSpirvType.rgen spv.intrinsicsSpirvType.rgen
Validation failed
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 8000a // Generated by (magic number): 8000a
// Id's are bound by 21 // Id's are bound by 21
@ -17,7 +16,6 @@ Validation failed
Name 4 "main" Name 4 "main"
Name 8 "rq" Name 8 "rq"
Name 11 "as" Name 11 "as"
Decorate 11(as) Location 0
Decorate 11(as) DescriptorSet 0 Decorate 11(as) DescriptorSet 0
Decorate 11(as) Binding 0 Decorate 11(as) Binding 0
2: TypeVoid 2: TypeVoid

View File

@ -4,10 +4,10 @@
#extension GL_ARB_gpu_shader_int64: enable #extension GL_ARB_gpu_shader_int64: enable
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056) spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
uvec2 clockRealtime2x32EXT(void); uvec2 clockRealtime2x32EXT(int);
spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056) spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
int64_t clockRealtimeEXT(void); uint64_t clockRealtimeEXT(int);
spirv_instruction (extensions = ["SPV_AMD_shader_trinary_minmax"], set = "SPV_AMD_shader_trinary_minmax", id = 1) spirv_instruction (extensions = ["SPV_AMD_shader_trinary_minmax"], set = "SPV_AMD_shader_trinary_minmax", id = 1)
vec2 min3(vec2 x, vec2 y, vec2 z); vec2 min3(vec2 x, vec2 y, vec2 z);
@ -15,12 +15,12 @@ vec2 min3(vec2 x, vec2 y, vec2 z);
layout(location = 0) in vec3 vec3In; layout(location = 0) in vec3 vec3In;
layout(location = 0) out uvec2 uvec2Out; layout(location = 0) out uvec2 uvec2Out;
layout(location = 1) out int64_t i64Out; layout(location = 1) out uint64_t u64Out;
layout(location = 2) out vec2 vec2Out; layout(location = 2) out vec2 vec2Out;
void main() void main()
{ {
uvec2Out = clockRealtime2x32EXT(); uvec2Out = clockRealtime2x32EXT(1);
i64Out = clockRealtimeEXT(); u64Out = clockRealtimeEXT(1);
vec2Out = min3(vec3In.xy, vec3In.yz, vec3In.zx); vec2Out = min3(vec3In.xy, vec3In.yz, vec3In.zx);
} }

View File

@ -1865,10 +1865,12 @@ public:
bool isAtomic() const { return false; } bool isAtomic() const { return false; }
bool isCoopMat() const { return false; } bool isCoopMat() const { return false; }
bool isReference() const { return false; } bool isReference() const { return false; }
bool isSpirvType() const { return false; }
#else #else
bool isAtomic() const { return basicType == EbtAtomicUint; } bool isAtomic() const { return basicType == EbtAtomicUint; }
bool isCoopMat() const { return coopmat; } bool isCoopMat() const { return coopmat; }
bool isReference() const { return getBasicType() == EbtReference; } bool isReference() const { return getBasicType() == EbtReference; }
bool isSpirvType() const { return getBasicType() == EbtSpirvType; }
#endif #endif
// return true if this type contains any subtype which satisfies the given predicate. // return true if this type contains any subtype which satisfies the given predicate.

View File

@ -845,7 +845,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
} }
// no locations added if already present, a built-in variable, a block, or an opaque // no locations added if already present, a built-in variable, a block, or an opaque
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock || if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
type.isAtomic() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) { type.isAtomic() || type.isSpirvType() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables
@ -873,8 +873,8 @@ int TDefaultIoResolverBase::resolveInOutLocation(EShLanguage stage, TVarEntryInf
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations added if already present, or a built-in variable // no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
if (type.getQualifier().hasLocation() || type.isBuiltIn()) { if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
@ -960,8 +960,8 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
if (type.getQualifier().hasLocation()) { if (type.getQualifier().hasLocation()) {
return ent.newLocation = type.getQualifier().layoutLocation; return ent.newLocation = type.getQualifier().layoutLocation;
} }
// no locations added if already present, or a built-in variable // no locations added if already present, a built-in variable, or a variable with SPIR-V decorate
if (type.isBuiltIn()) { if (type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables
@ -1042,7 +1042,8 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
} else { } else {
// no locations added if already present, a built-in variable, a block, or an opaque // no locations added if already present, a built-in variable, a block, or an opaque
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock || if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
type.isAtomic() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) { type.isAtomic() || type.isSpirvType() ||
(type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables